0
$\begingroup$

Say I have a function

f(x,y,theta,xi) = x*y*c*theta*xi;

where c is a function of theta and xi and is predefined as

c:=theta*xi+theta^xi^2;

so f is effectively a function of x, y, theta, xi.

when I do the

Plot3D[f[x,y,0.5,0.5],{x,0,1},{y,0,1}]

Mathematica could not automatically calculate the value of c.

How do I plot a function of this sort?

That is, it contains a parameter which is a expression of the variables.

Thank you.

$\endgroup$
1
  • $\begingroup$ It's not clear how you defined f. How it is done will affect how it works. Probably, the global variable theta in the definition of c is not the same as the local parameter theta in the definition of f. $\endgroup$
    – Michael E2
    Commented Jan 30, 2016 at 18:44

1 Answer 1

2
$\begingroup$

Make c an explicit function of theta and xi

c[theta_, xi_] = theta*xi + theta^xi^2;

f[x_, y_, theta_, xi_] = x*y*c[theta, xi]*theta*xi;

Plot3D[f[x, y, 0.5, 0.5],
 {x, 0, 1}, {y, 0, 1}]

enter image description here

$\endgroup$
3
  • $\begingroup$ Hi Bob, thanks for your code. But when I run it, it gives "Tag Times in (theta\ xi)[theta_,xi_] is Protected."I understand that it is because I am passing a function to another function. $\endgroup$
    – LazyGamer
    Commented Jan 30, 2016 at 20:50
  • $\begingroup$ Could you please share your thought on how to overcome this problem- tag times is protected" in general? thanks! $\endgroup$
    – LazyGamer
    Commented Jan 30, 2016 at 20:51
  • $\begingroup$ @LazyGamer - The code as posted works. Clear all of your definitions or start with a fresh kernel. $\endgroup$
    – Bob Hanlon
    Commented Jan 31, 2016 at 0:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.