If I were able to "Save" the computed inverse function somewhere and then plot it, the manipulation would become faster. As I understand, Evaluate should do the job, but for some reason it does not. Why?

f[x_] := Sqrt[x]; c[x_] := x^2; g[x_] := c'[x]/f'[x];
x[gamma_, δ_, φ_, ρ_, mode_] := 
  InverseFunction[g][gamma/(1 - δ*φ*ρ)*mode];

    {Evaluate@x[gamma, δ, φ, ρ, 1], 
     Evaluate@x[gamma, δ, φ, ρ, 2]},
    {gamma, 0, 10}, 
    PlotRange -> {{0, 10}, {0, 10}}],

 {δ, 0, 1}, {φ, 0, 1}, {ρ, 0, 1}

2 Answers 2


In the Manipulate as you wrote it, the InverseFunction has to be re-calculated every time the function x is called. To avoid this, define x with Set instead of SetDelayed:

f[x_] := Sqrt[x]; c[x_] := x^2; g[x_] := c'[x]/f'[x];


Block[{gamma, δ, φ, ρ, mode},
  x[gamma_, δ_, φ_, ρ_, mode_] = 
    InverseFunction[g][gamma/(1 - δ*φ*ρ)*mode]

==> ((gamma mode)/(1 - δ ρ φ))^(2/3)/(2 2^(

 Plot[{x[gamma, δ, φ, ρ, 1], 
   x[gamma, δ, φ, ρ, 2]}, {gamma, 0, 10}, 
  PlotRange -> {{0, 10}, {0, 10}}], {δ, 0, 1}, {φ, 0,
   1}, {ρ, 0, 1}]

Then you can also leave out the Evaluate as I did above.

  • $\begingroup$ thanks for the reply. However, the Manipulate does not seem to work in your example.. $\endgroup$ Jul 21, 2013 at 1:54
  • $\begingroup$ Sorry, this was the Mathematica problem. I restarted it and it worked alright! $\endgroup$ Jul 21, 2013 at 3:38
  • $\begingroup$ Jens, IMO you need to protect against the symbols used in x having values assigned. I am going to wrap that definition in Block. $\endgroup$
    – Mr.Wizard
    Jul 21, 2013 at 5:58
  • $\begingroup$ @Mr.Wizard What specific to this situation necessitates that Block be used? $\endgroup$ Jul 21, 2013 at 6:13
  • $\begingroup$ @Mr.Wizard You're right, it's better to be safe than sorry. I could also have added the variables to the Clear statement. But using Block is more flexible because it leaves any previously assigned values for δ, φ, ρ etc. intact while at the same time preventing them from becoming part of the definition of x. $\endgroup$
    – Jens
    Jul 21, 2013 at 7:04

Evaluate needs to be the top-most expression inside Plot. As in, the code needs to look exactly like:

Plot[Evaluate[...], ...]

or else the call to Evaluate will be effectively ignored.

  • $\begingroup$ I implemented what you've suggested and Manipulate stopped working $\endgroup$ Jul 21, 2013 at 3:01
  • $\begingroup$ Perhaps you need to restart Mathematica for some reason? I'm using Manipulate[Plot[Evaluate[{x[..., 1], x[..., 2]}],...],...] without any problems. $\endgroup$ Jul 21, 2013 at 3:08
  • $\begingroup$ Indeed, restart helped! Thanks! Is that common that Mathematica needs a restart to work properly? $\endgroup$ Jul 21, 2013 at 3:39
  • $\begingroup$ It was probably working properly before, but you may have had some intermediate state (such as another definition for x) that was causing unexpected behavior. This would have been difficult to track down online, so I suggested a restart. $\endgroup$ Jul 21, 2013 at 4:17

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.