Group Abstract Group Abstract

Message Boards Message Boards

0
|
5K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Defining the function "qf[x_, y_, z_, is_] := x^2 + y^2 + z^2 - 5 is"?

Posted 9 years ago
POSTED BY: Stefan Reuter
4 Replies
Posted 9 years ago

Thank you all for the quick help!

POSTED BY: Stefan Reuter
Posted 9 years ago

Try this

Clear[x, y, z, is, q, f];
q = x^2 + y^2 + z^2 - 5 is;
f[x_, y_, z_, is_] := Evaluate[q];

Now let's see what f is

?f

which shows you

Global`f
f[x_,y_,z_,is_]:=-5 is+x^2+y^2+z^2

so it appears that the contents of q have been used in the definition of f.

Try using f and see what happens

f[1, 1, 1, 1]

which gives you

-2

and that seems to be the result you are expecting.

So using Evaluate was the key.

POSTED BY: Bill Simpson

... or likewise (and this probably illustrates the problem):

Clear[x, y, z, is, q, f];
q = x^2 + y^2 + z^2 - 5 is;
f[x_, y_, z_, is_] := Evaluate@q;
f[1, 1, 1, 1]
POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard