Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.9K Views
|
6 Replies
|
1 Total Like
View groups...
Share
Share this post:

[?] Minimize a very complicated expression?

Attachments:
POSTED BY: Robert Poenaru
6 Replies

So, let's say that I have two functions which depends on two variables, say x and y and the function also has two real parameters a and b. Then you also have a term Q which is a linear combination of the previous functions, and this expression still depends on x and y, with the parameters a and b.

Now you have a final term which is some constant plus the term Q, and this will depend only on x, with a fixed known y.

How would you express such a thing in mathema

POSTED BY: Robert Poenaru

Your description is kind of 'general', i'm not sure what the issue might be. What is the difference between a variable and a parameter? You can use:

f[a_,b_,x_,y_] := …
POSTED BY: Sander Huisman

The expression for:

chi2[a_, b_]

Does not contain a or b…

Simplified example:

f = a^2;
xy[a_] := f
xy[2]

will return a^2, not 4. Because you are using SetDelayed := not Set =

POSTED BY: Sander Huisman

Hello Sander, Thank you for the reply. I modified the := to =. I can get numerical results in chi2.

In[49]:= chi2[1, 2]

Out[49]= 277.249 - 7.44202*10^-16 I

Why should be a problem if in chi2 there is no a and b? The terms a and b are "encoded" in the terms "en[x]" from its expression.

POSTED BY: Robert Poenaru

SetDelayed first 'fills in' a and b with the values you give them in the function, and then evaluates the rhs expression. That is the characteristic of :=, you want first evaluate, then fill in, that is done using =

POSTED BY: Sander Huisman

Compare:

ClearAll[f,xy,a];
f=a^2;
xy[a_]:=f;
xy[2]

ClearAll[f,xy,a];
f=a^2;
xy[a_]=f;
xy[2]

f has a 'encoded' in it. The first and second function definition give different results…

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard