Message Boards Message Boards

Avoid problems with Dynamic Updating?

Posted 7 years ago

Hello everyone,

I am learning the Wolfram Mathematica language doing some simple programs but i got stuck. I was writing code that show a parametric curve and its derivate, with a tangent vector for each one and the module of vector velocity. The problem is that when i enable dynamic updating the yellow dot on the icon of Wolfram in the application bar starts blinking red and the module of the vector change even if the vector is still. It's the first time i get this errors, and i don't know why. If someone could help me, i left the code here, i hope it's well written. Thank you.

     Module[
 {f, g},

 Manipulate[

  f[x_] := x Cos[x];
  g[x_] := x Sin[x];

  plot1 = Graphics[
    {
     {Blue, Arrow[{{0, 0}, {f[n], g[n]}}]},
     {Orange, Arrow[{{0, 0}, {f'[n], g'[n]}}]},
     {Red, Arrow[{{f[n], g[n]}, {f'[n] + f[n], g[n] + g'[n]}}]},
     {Purple, Arrow[{{f'[n], g'[n]}, {f'[n] + f''[n], g'[n] + g''[n]}}]}
     }];

  plot2 = ParametricPlot[
    {
     {f[x], g[x]},
     {f'[x], g'[x]}
     },
    {x, 0, 2 Pi}
    ]; 

  Show[{
    plot1,
    plot2
    },
   Axes -> {True, True}, PlotRange -> {{-5, 9}, {-7, 9}}
   ],
  {n, 0, 2 Pi}, Delimiter,
  Dynamic@
   Style["T =" <>  ToString[NumberForm[N[Sqrt[(f'[x])^2 + (g'[x])^2]], 3]], 
    FontFamily -> "Arial", FontSize -> Medium, FontColor -> Col]
  ]
 ]

Col is not given, moreover the outer Module is not needed, also the equations can be pulled outside the manipulate:

f[x_] := x Cos[x]
g[x_] := x Sin[x]
Manipulate[
 plot1 = Graphics[{{Blue, Arrow[{{0, 0}, {f[n], g[n]}}]}, {Orange, 
     Arrow[{{0, 0}, {f'[n], g'[n]}}]}, {Red, 
     Arrow[{{f[n], g[n]}, {f'[n] + f[n], g[n] + g'[n]}}]}, {Purple, 
     Arrow[{{f'[n], g'[n]}, {f'[n] + f''[n], g'[n] + g''[n]}}]}}];
 plot2 = ParametricPlot[{{f[x], g[x]}, {f'[x], g'[x]}}, {x, 0, 
    2 Pi}];
 Show[{plot1, plot2}, Axes -> {True, True}, 
  PlotRange -> {{-5, 9}, {-7, 9}}], {n, 0, 2 Pi}, Delimiter, 
 Dynamic@Style[
   "T =" <> ToString[NumberForm[N[Sqrt[(f'[x])^2 + (g'[x])^2]], 3]], 
   FontFamily -> "Arial", FontSize -> Medium, FontColor -> Red]]
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract