Skip to main content
Tweeted twitter.com/#!/StackMma/status/303312659556732928
deleted 2 characters in body
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

I am new to Mathematica and was experimenting with a simply problem of plotting a tangent to a curve and being able to move the point at which the tangent is drawn using Manipulate. When I run the following, the cell flickers a lot and it also seems to consume a lot of CPU  ? Is there a way to avoid this  ?

Manipulate[
  Module[{f, x, y, dx, dy},
    dx = dy = 1;
    f[x_] := x^2;
    tangent[x_, y_] := {{x - dx, y - f'[x] dy}, {x + dx, y + f'[x] dy}};
    g = Graphics[Line @ tangent[x0, f[x0]], PlotRange -> {{-5, 5}, {-5, 5}}];
    p = Plot[f[x], {x, -5, 5}];
    Show[p, g]],
  {{x0, 2}, -4, 4}]

I am new to Mathematica and was experimenting with a simply problem of plotting a tangent to a curve and being able to move the point at which the tangent is drawn using Manipulate. When I run the following, the cell flickers a lot and it also seems to consume a lot of CPU  ? Is there a way to avoid this  ?

Manipulate[
  Module[{f, x, y, dx, dy},
    dx = dy = 1;
    f[x_] := x^2;
    tangent[x_, y_] := {{x - dx, y - f'[x] dy}, {x + dx, y + f'[x] dy}};
    g = Graphics[Line @ tangent[x0, f[x0]], PlotRange -> {{-5, 5}, {-5, 5}}];
    p = Plot[f[x], {x, -5, 5}];
    Show[p, g]],
  {{x0, 2}, -4, 4}]

I am new to Mathematica and was experimenting with a simply problem of plotting a tangent to a curve and being able to move the point at which the tangent is drawn using Manipulate. When I run the following, the cell flickers a lot and it also seems to consume a lot of CPU? Is there a way to avoid this?

Manipulate[
  Module[{f, x, y, dx, dy},
    dx = dy = 1;
    f[x_] := x^2;
    tangent[x_, y_] := {{x - dx, y - f'[x] dy}, {x + dx, y + f'[x] dy}};
    g = Graphics[Line @ tangent[x0, f[x0]], PlotRange -> {{-5, 5}, {-5, 5}}];
    p = Plot[f[x], {x, -5, 5}];
    Show[p, g]],
  {{x0, 2}, -4, 4}]
Improved formatting
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

I am new to mathematicaMathematica and was experimenting with a simply problem of plotting a tangent to a curve and being able to move the point at which the tangent is drawn using manipulateManipulate. When iI run the following, the cell flickers a lot and it also seems to consume a lot of CPU ? Is there a way to avoid this ?

Manipulate[
  Module[{f, x, y, dx, dy},
dx=dy=1;    dx = dy = 1;
    f[x_] :=x^2;= x^2;
    tangent[x_, y_] := {{x - dx, y - f'[x] dy}, {x+dxx + dx,y+f'[x] y + f'[x] dy}};
    g = Graphics[Line @ tangent[x0, f[x0]], PlotRange -> {{-5, 5}, {-5, 5}}];
    p = Plot[f[x], {x, -5, 5}];
    Show[p,g]
] g]],
  {{x0, 2}, -4, 4}
 ]

Thanks David.

I am new to mathematica and was experimenting with a simply problem of plotting a tangent to a curve and being able to move the point at which the tangent is drawn using manipulate. When i run the following the cell flickers a lot and it also seems to consume a lot of CPU ? Is there a way to avoid this ?

Manipulate[
Module[{f,x,y,dx,dy},
dx=dy=1;
f[x_]:=x^2;
tangent[x_,y_]:= {{x-dx,y-f'[x] dy},{x+dx,y+f'[x] dy}};
g = Graphics[Line @ tangent[x0,f[x0]],PlotRange->{{-5,5},{-5,5}}];
p = Plot[f[x],{x,-5,5}];
Show[p,g]
],
{{x0,2},-4,4}
 ]

Thanks David.

I am new to Mathematica and was experimenting with a simply problem of plotting a tangent to a curve and being able to move the point at which the tangent is drawn using Manipulate. When I run the following, the cell flickers a lot and it also seems to consume a lot of CPU ? Is there a way to avoid this ?

Manipulate[
  Module[{f, x, y, dx, dy},
    dx = dy = 1;
    f[x_] := x^2;
    tangent[x_, y_] := {{x - dx, y - f'[x] dy}, {x + dx, y + f'[x] dy}};
    g = Graphics[Line @ tangent[x0, f[x0]], PlotRange -> {{-5, 5}, {-5, 5}}];
    p = Plot[f[x], {x, -5, 5}];
    Show[p, g]],
  {{x0, 2}, -4, 4}]
Source Link
David McHarg
  • 1.7k
  • 1
  • 15
  • 29

Manipulate flickering and consuming lots of CPU

I am new to mathematica and was experimenting with a simply problem of plotting a tangent to a curve and being able to move the point at which the tangent is drawn using manipulate. When i run the following the cell flickers a lot and it also seems to consume a lot of CPU ? Is there a way to avoid this ?

Manipulate[
Module[{f,x,y,dx,dy},
dx=dy=1;
f[x_]:=x^2;
tangent[x_,y_]:= {{x-dx,y-f'[x] dy},{x+dx,y+f'[x] dy}};
g = Graphics[Line @ tangent[x0,f[x0]],PlotRange->{{-5,5},{-5,5}}];
p = Plot[f[x],{x,-5,5}];
Show[p,g]
],
{{x0,2},-4,4}
]

Thanks David.