3
$\begingroup$

I have a function:

C = 0.0625 + 0.0008*X - 0.0232*Y - 0.0157*Z + 0.0059*X^2 + 0.0112*Y^2 + 0.0160*Z^2 - 
    0.0063*X*Y - 0.0243*X*Z + 0.0211*Y*Z

This equation has 4 variables, X, Y, Z, C. Normally, I would change X, Y, Z to get a C. Now I wanted to get a feel how a 3D plot of X, Y, Z would look given a value for C. Thus X, Y, Z are unknown in this case. I tried a few examples with Wolfram|Alpha:

C equal to 0

C equal to 1

C equal to 2

...

As you can see the function changes. My question is: How can I make this interactive? So a slider for C and a plot of the corresponding figure?

Normally I would try this in python or matlab, but I haven't got the faintest idea how to start, but since Wolfram|Alpha is able to plot this, I guess it should be possible.

I think this is especially difficult, since there are 3 unknowns and 1 function, nevertheless Wolfram|Alpha is able to do it.

$\endgroup$
7
$\begingroup$

Try this:

    Solve[c == 
   0.0625 + 0.0008*X - 0.0232*Y - 0.0157*Z + 0.0059*X^2 + 
    0.0112*Y^2 + 0.0160*Z^2 - 0.0063*X*Y - 0.0243*X*Z + 0.0211*Y*Z // 
  Rationalize, Z]

(*   {{Z -> 1/320 (157 + 243 X - 
      211 Y - \[Sqrt](-375351 + 6400000 c + 71182 X + 21289 X^2 + 
         82226 Y - 62226 X Y - 27159 Y^2))}, {Z -> 
   1/320 (157 + 243 X - 
      211 Y + \[Sqrt](-375351 + 6400000 c + 71182 X + 21289 X^2 + 
         82226 Y - 62226 X Y - 27159 Y^2))}}   *)

Then this:

    Manipulate[
 Plot3D[{1/
    320 (157 + 243 X - 
      211 Y - \[Sqrt](-375351 + 6400000 c + 71182 X + 21289 X^2 + 
         82226 Y - 62226 X Y - 27159 Y^2)),
   1/320 (157 + 243 X - 
      211 Y + \[Sqrt](-375351 + 6400000 c + 71182 X + 21289 X^2 + 
         82226 Y - 62226 X Y - 27159 Y^2))

   }, {X, -10, 10}, {Y, -10, 10}, PlotStyle -> {Blue, Orange}], {c, 0,
   2}]

This should appear on the screen. enter image description here

Take care that capital C is reserved, use the small one. Have fun.

$\endgroup$
  • $\begingroup$ Awesome! 2 additional questions, what does the rationalize do ? And how do I add axis labels ? Thx ! $\endgroup$ – Olivier_s_j Oct 10 '14 at 14:36
  • 1
    $\begingroup$ @Ojtwist Rationalize substitutes rational numbers instead of the decimal ones. It is not necessary, but Mma works faster in that case and the expressions look less awful. For the second question check please Menu/Help/AxisLabels $\endgroup$ – Alexei Boulbitch Oct 10 '14 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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