Message Boards Message Boards

6 Replies
4 Total Likes
View groups...
Share this post:

Animate a point on a function?

Posted 8 years ago


The code below don't work!

f[x_] := x^2 + 2 x - 3
p = {{a, f[a]}}
Animate[ Plot[f[x], {x, -2, 4}, Epilog -> Point[p]], {a, -2, 4}]

But, If I replace the variable p with is evaluation, the code is OK.

Animate[Plot[f[x], {x, -2, 4}, Epilog -> Point[{{a, -3 + 2 a + a^2}}]], {a, -2, 4}]

I want to use the variable in my document. How can I do it?

Thank you.

Marcel Pelletier

POSTED BY: Marcel Pelletier
6 Replies

Hi, Marcel, I posted this new code for the tangent line as a suggestion for you to post other pieces of code that you are using in the course. They may be useful for others in the Wolfram Community and the Community may suggest new solutions and useful pieces of code. Sure, it's your decision...

Hi Valeriu, Thank you for this new response! I have create animations for my course.. Your help are welcome. Marcel Pelletier

POSTED BY: Marcel Pelletier
f[x_] := 2 x^3 + 2 x - 3
p[a_] := {{a, f[a]}}
t[x_, a_] := f[a] + (x - a) f'[a]
Animate[Plot[f[x], {x, -2, 4}, PlotRange -> {{-2, 4}, {-24, 128}}, 
  Epilog -> {PointSize[Medium], Point[p[a]], Red, 
    InfiniteLine[{p[a][[1]], {0, t[0, a]}}]}], {a, -2, 4}, 
 AnimationDirection -> ForwardBackward]

You are welcome!

Hi Valeriu.

Thank you for your help. This will ameliorate my document.

Marcel Pelletier

POSTED BY: Marcel Pelletier
f[x_] := x^2 + 2 x - 3
    p[a_] := {{a, f[a]}}
    Animate[Plot[f[x], {x, -2, 4}, Epilog -> Point[p[a]]], {a, -2, 4}]

enter image description here

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract