Skip to main content
added 167 characters in body
Source Link
Nasser
  • 150.4k
  • 12
  • 161
  • 374

TrackedSymbols is not needed if one just localizes all variables in Modules (which is what one should do in the first place). Many like to use global variables all over the place and this causes such problems.

Manipulate[

 Module[{x, y, dx, dy, g, p},

  dx = dy = 1;
  g = Graphics[Line@tangent[x, x0, dx, dy, f],PlotRange -> {{-5, 5}, {-5, 5}}];
  p = Plot[f[x], {x, -5, 5}];
  Show[p, g]
 ],

 {{x0, 2}, -4, 4},

 Initialization :>
  {
   tangent[var_Symbol, x0_, dx_, dy_, f_]:= Module[{der = D[f, var] /. var -> x0},
     {{x0 - dx, f[x0] - der dy}, {x0 + dx, f[x0] + der dy}}
   ];

   f[x_] := x^2;
   }
 ]
Manipulate[

 Module[{x, y, dx, dy, g, p},

  dx = dy = 1;
  g = Graphics[Line@tangent[x, x0, dx, dy, f],PlotRange -> {{-5, 5}, {-5, 5}}];
  p = Plot[f[x], {x, -5, 5}];
  Show[p, g]
 ],

 {{x0, 2}, -4, 4},

 Initialization :>
  {
   tangent[var_Symbol, x0_, dx_, dy_, f_]:= Module[{der = D[f, var] /. var -> x0},
     {{x0 - dx, f[x0] - der dy}, {x0 + dx, f[x0] + der dy}}
   ];

   f[x_] := x^2;
   }
 ]

TrackedSymbols is not needed if one just localizes all variables in Modules (which is what one should do in the first place). Many like to use global variables all over the place and this causes such problems.

Manipulate[

 Module[{x, y, dx, dy, g, p},

  dx = dy = 1;
  g = Graphics[Line@tangent[x, x0, dx, dy, f],PlotRange -> {{-5, 5}, {-5, 5}}];
  p = Plot[f[x], {x, -5, 5}];
  Show[p, g]
 ],

 {{x0, 2}, -4, 4},

 Initialization :>
  {
   tangent[var_Symbol, x0_, dx_, dy_, f_]:= Module[{der = D[f, var] /. var -> x0},
     {{x0 - dx, f[x0] - der dy}, {x0 + dx, f[x0] + der dy}}
   ];

   f[x_] := x^2;
   }
 ]
Source Link
Nasser
  • 150.4k
  • 12
  • 161
  • 374

Manipulate[

 Module[{x, y, dx, dy, g, p},

  dx = dy = 1;
  g = Graphics[Line@tangent[x, x0, dx, dy, f],PlotRange -> {{-5, 5}, {-5, 5}}];
  p = Plot[f[x], {x, -5, 5}];
  Show[p, g]
 ],

 {{x0, 2}, -4, 4},

 Initialization :>
  {
   tangent[var_Symbol, x0_, dx_, dy_, f_]:= Module[{der = D[f, var] /. var -> x0},
     {{x0 - dx, f[x0] - der dy}, {x0 + dx, f[x0] + der dy}}
   ];

   f[x_] := x^2;
   }
 ]