Mathematica Mathematica question - Beginner.

AI Thread Summary
The discussion revolves around issues encountered while plotting a function and its derivative in Mathematica. The user defines a function y and its derivative z, but faces errors when attempting to plot z alongside y. The main problem identified is that the derivative function z is not correctly defined for plotting, as it does not take the necessary parameters. Clarifications are made regarding the proper way to define the derivative using D[y[x, A], x] to ensure it is meaningful. After some trial and error, a solution is reached, confirming that the correct definition of z allows for successful plotting of the derivative. The conversation highlights the importance of correctly defining functions and their parameters in Mathematica to avoid errors during plotting.
plinius
Messages
4
Reaction score
0
Hi,
when I run those commands in mathematica:
y[x_,A_]:=Sin[x]+A+5
Plot[{y[x,5],y[x,6]},{x,0,5}]
z[x_]:=D[y,x]

Everything seems to go well.
But when I trie to plot the derivative:

Plot[{y[x,5],z[x]},{x,0,5}]

I allways have these errors:
Plot::plnrz[x] is not a machine-size real number at x= 2.0833333333333333`*^-7
...

What am I doing wrong ?
I allready tried to change the arguments of z[] to z[x,4], z[x,A] etc...
There's nothing about plotting derivatives on the quick tutorial.
Any help is really appreciated.
I uploaded my mathematica file here http://s47.yousendit.com/d.aspx?id=0LG6F35A7OTY2SVEC7L1T6GXA

Thanks in advance
 
Physics news on Phys.org
You take the derivative of y but y has no meaning as y is just an empty variable, y[x,a] does have meaning however, also why is z[x_] a function? if you do D[y[x,a],x] you are taking the derivative of y[x,a] with respect to x, correct, I believe its the 3'rd parameter to have it take the n'th derivative? I will be at work in an hour or so and can check it out, as I'm pretty new to Mathematica myself and don't have a copy here to check myself.
 
mewmew said:
You take the derivative of y but y has no meaning as y is just an empty variable, y[x,a] does have meaning however, also why is z[x_] a function? if you do D[y[x,a],x] you are taking the derivative of y[x,a] with respect to x, correct, I believe its the 3'rd parameter to have it take the n'th derivative? I will be at work in an hour or so and can check it out, as I'm pretty new to Mathematica myself and don't have a copy here to check myself.
I'm afraid it's not correct. I've just tried what you said and it didn't worked either :confused:
 
z[n_] = D[y[x, 10], {x, n}]; is saying you want a function of the nth derivative of y[x,10] with respect to x. Plot[{z[2]}, {x, 0, 5}] is a plot of the 2nd derivative of x from 0 to 5.
 
Thanks a lot.

Now it works indeed!
 

Similar threads

Replies
4
Views
2K
Replies
1
Views
2K
Replies
5
Views
2K
Replies
4
Views
3K
Replies
3
Views
2K
Replies
2
Views
2K
Replies
2
Views
3K
Back
Top