0
|
7477 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
GROUPS:

# Why Manipulate command is not working when ploting the tangent line?

Posted 11 years ago
 Hi all,I'm trying to get an interactive output that allows me to plot both the function f and its tangent line y by changing the parameter x0. However I'm not able to obtain the plot of y. This is the code:f[x_] = x^2;y[x_] = f[x0] + f'[x0]*(x - x0);Manipulate[Plot[{y[x], f[x]}, {x, -4, 10}], {x0, 0, 6}]  And this what I get:As you see no tangent line appears.Thanks a lot!
5 Replies
Sort By:
Posted 11 years ago
 Thanks, Bruce!
Posted 11 years ago
 Notes on typing posts, including keeping code looking good, are in http://community.wolfram.com/groups/-/m/t/151347I put your code into MCode boxes and the function arguments reappeared.
Posted 11 years ago
 Your original posted code does not work as in the illustration.  The function  f  and  y  are missing their arguments.The reason it wouldn't work with  f  and  y  is that  Manipulate  localizes  x0.  This means the  x0  symbol in the definition of  y  is a different symbol than the  x0  in  Manipulate.Here's a way to get what seems intended:f[x_] = x^2;y[x_, x0_] = f[x0] + f'[x0]*(x - x0);Manipulate[Plot[{y[x, x0], f[x]}, {x, -4, 10}], {x0, 0, 6}]
Posted 11 years ago
 Thanks a lot Michael now it works!I did write the missing arguments of y and f in Mathematica but for some reason they dissapeared when copying them here.
Posted 11 years ago
 I found that if I write the whole expression of the tangent line inside the Manipulate command it works:f[x_] = x^2;Manipulate[Plot[{f[x0] + f'[x0]*(x - x0), f[x]}, {x, -4, 10}], {x0, 0, 6}] Why is that?Thanks!