0

I'm having some troubles with the Dynamic command in Mathematica, the next code shows an interactive graphic of the function f(x) = 1 - x^2. The graphic's title also shows the current area under the curve (definite integral) which is modified using the slider.

 Manipulate[Show[Plot[1 - x^2, {x, 0, 1}, PlotLabel -> Integrate[1 - x^2, {x, 0, Limite - 0.000000000001}]],   
 Plot[-x^2 + 1, {x, 0, Limite}, PlotRange -> {0, 1}, Filling -> Axis] ], {Limite, 0.000000000001, 1}, LocalizeVariables -> False]

I would like to show the current area using this command:

Integrate[1 - x^2, {x, 0, Dynamic[Limite]}]

but the result is not what i expected. Mathematica evaluates this like 0.529 - (0.529)^3 / 3 which is correct but i don't understand why it displays an expression instead of a single number. The //FullSimplify and//N commands just don't solve the problem.

Is there a better way to obtain the result?

Am I using the Dynamic command correctly?

Thanks!

Gotenks
  • 3
  • 1
  • The code with `Manipulate` shows a number on my system. – b.gatessucks Jun 20 '12 at 07:31
  • Works for me with mma 8.0.1 and win7. – Ajasja Jun 20 '12 at 07:54
  • It works, the problem is the difference between the graphic´s title format (0.6667 for example) and the Integrate[1 - x^2, {x, 0, Dynamic[Limite]}] format (0.529 - (0.529)^3 / 3) – Gotenks Jun 20 '12 at 08:02
  • Works for me too (Mathematica 7.0.1, Windows 7). Though at `Limited` equal to its minimum value (`0.000000000001`) it does show an expression. I have tried with `ReleaseHold` - but it seem not to have an effect. There is some fantastic "magic" begin the dynamic frontend. Beautifully documented but quite a science in itself. – Ole Thomsen Buus Jun 20 '12 at 08:02

1 Answers1

1

With your example the Integrate command is performed once with a symbolic upper limit. When the value of that upper limit changes the integral is not recomputed. You will get your desired result if you move the Dynamic[] wrapper from the iterator specification and wrap it around the Integrate command, which will cause the integral to be recomputed whenever Limite changes.

Dynamic[Integrate[1 - x^2, {x, 0, Limite}]]
ragfield
  • 2,486
  • 13
  • 15