Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Is it possible to differentiate this equation 34 times?

Subject: Is it possible to differentiate this equation 34 times?

From: Chen

Date: 26 Mar, 2009 10:33:01

Message: 1 of 7

hi, i need to find a way to differentiate this equation 34 times at least. Before that I was using the diff() command on the 2007 version. However, after the 4th differentiation, I maxed out the number of characters that can be displayed on the screen.
P(z)=([-3.996.*(z-1).*(z+0.9985).*(z-(-0.0008 - 0.9992i)).*(z-(-0.0008 + 0.9992i))]./[1.9985.*(1.0008 + 0.9992i).*(1.0008 - 0.9992i).*(1-z.^4.*exp(0.00307*(1-z)))])

I dont need to get the differentiated form of the equation, just the probability values of each differentiated equation when z =0. Like
P(0)=
d/(dz)P(0)=
d/(dz^2)P(0)=
d/(dz^3)P(0)=
.
.
.
d/(dz^34)P(0)

Is there a way to do so? I looked through the tutorials but I don see how I can use the ode functions or polydar functions to solve it. Any help is greatly appreciated.

Subject: Is it possible to differentiate this equation 34 times?

From: Torsten Hennig

Date: 26 Mar, 2009 11:23:22

Message: 2 of 7

> hi, i need to find a way to differentiate this
> equation 34 times at least. Before that I was using
> the diff() command on the 2007 version. However,
> after the 4th differentiation, I maxed out the number
> of characters that can be displayed on the screen.
> P(z)=([-3.996.*(z-1).*(z+0.9985).*(z-(-0.0008 -
> 0.9992i)).*(z-(-0.0008 + 0.9992i))]./[1.9985.*(1.0008
> + 0.9992i).*(1.0008 -
> 0.9992i).*(1-z.^4.*exp(0.00307*(1-z)))])
>
> I dont need to get the differentiated form of the
> equation, just the probability values of each
> differentiated equation when z =0. Like
> P(0)=
> d/(dz)P(0)=
> d/(dz^2)P(0)=
> d/(dz^3)P(0)=
> .
> .
> .
> d/(dz^34)P(0)
>
> Is there a way to do so? I looked through the
> tutorials but I don see how I can use the ode
> functions or polydar functions to solve it. Any help
> is greatly appreciated.
>

http://www.mathworks.com/access/helpdesk_r13/help/toolbox/symbolic/ch22.html

Best wishes
Torsten.

Subject: Is it possible to differentiate this equation 34 times?

From: Alan Weiss

Date: 26 Mar, 2009 13:54:40

Message: 3 of 7

Chen wrote:
> hi, i need to find a way to differentiate this equation 34 times at least. Before that I was using the diff() command on the 2007 version. However, after the 4th differentiation, I maxed out the number of characters that can be displayed on the screen.
> P(z)=([-3.996.*(z-1).*(z+0.9985).*(z-(-0.0008 - 0.9992i)).*(z-(-0.0008 + 0.9992i))]./[1.9985.*(1.0008 + 0.9992i).*(1.0008 - 0.9992i).*(1-z.^4.*exp(0.00307*(1-z)))])
>
> I dont need to get the differentiated form of the equation, just the probability values of each differentiated equation when z =0. Like
> P(0)=
> d/(dz)P(0)=
> d/(dz^2)P(0)=
> d/(dz^3)P(0)=
> .
> .
> .
> d/(dz^34)P(0)
>
> Is there a way to do so? I looked through the tutorials but I don see how I can use the ode functions or polydar functions to solve it. Any help is greatly appreciated.
If you have Symbolic Math Toolbox(TM), simply write

syms z
p =(-3.996*(z-1)*(z+0.9985)*(z-(-0.0008 - 0.9992i))*(z-(-0.0008 +
0.9992i))/(1.9985*(1.0008 + 0.9992i)*(1.0008 -
0.9992i)*(1-z^4*exp(0.00307*(1-z)))));
y = diff(p,34); % be prepared to wait a while here
finalanswer = simplify(subs(y,0)) % be prepared to wait again

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: Is it possible to differentiate this equation 34 times?

From: Roger Stafford

Date: 26 Mar, 2009 14:35:03

Message: 4 of 7

"Chen " <abathesith@yahoo.com> wrote in message <gqflkt$sqk$1@fred.mathworks.com>...
> hi, i need to find a way to differentiate this equation 34 times at least. Before that I was using the diff() command on the 2007 version. However, after the 4th differentiation, I maxed out the number of characters that can be displayed on the screen.
> P(z)=([-3.996.*(z-1).*(z+0.9985).*(z-(-0.0008 - 0.9992i)).*(z-(-0.0008 + 0.9992i))]./[1.9985.*(1.0008 + 0.9992i).*(1.0008 - 0.9992i).*(1-z.^4.*exp(0.00307*(1-z)))])
>
> I dont need to get the differentiated form of the equation, just the probability values of each differentiated equation when z =0. Like
> P(0)=
> d/(dz)P(0)=
> d/(dz^2)P(0)=
> d/(dz^3)P(0)=
> .
> .
> .
> d/(dz^34)P(0)
>
> Is there a way to do so? I looked through the tutorials but I don see how I can use the ode functions or polydar functions to solve it. Any help is greatly appreciated.

  You might try to persuade the Symbolic Toolbox's 'taylor' function to expand your function about z = 0 out to the 34-th power of z. Each of its n-th coefficients gives you the n-th derivative evaluated at z = 0 divided by n factorial. This perhaps wouldn't be as much strain on its resources as obtaining full expressions for the derivatives as functions of z.

Roger Stafford

Subject: Is it possible to differentiate this equation 34 times?

From: Roger Stafford

Date: 26 Mar, 2009 14:55:03

Message: 5 of 7

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gqg3qn$shj$1@fred.mathworks.com>...
> You might try to persuade the Symbolic Toolbox's 'taylor' function to ......

  I neglected to mention that it probably would be advisable to simplify your expression for P(z) as much as possible before expanding in a Taylor series. Something like this:

 P(z) = (z-1)*(z-a)*(z^2+b*z+c)/(1-z^4*exp(d*(1-z)))

This would be somewhat less of a drain on Symbolic Toolbox resources. You can evaluate the parameters a, b, c, d and multiply P by the appropriate constant at a later stage.

Roger Stafford

Subject: Is it possible to differentiate this equation 34 times?

From: Chen

Date: 27 Mar, 2009 07:59:03

Message: 6 of 7


> If you have Symbolic Math Toolbox(TM), simply write
>
> syms z
> p =(-3.996*(z-1)*(z+0.9985)*(z-(-0.0008 - 0.9992i))*(z-(-0.0008 +
> 0.9992i))/(1.9985*(1.0008 + 0.9992i)*(1.0008 -
> 0.9992i)*(1-z^4*exp(0.00307*(1-z)))));
> y = diff(p,34); % be prepared to wait a while here
> finalanswer = simplify(subs(y,0)) % be prepared to wait again
>
> Alan Weiss
> MATLAB mathematical toolbox documentation

Hi Alan, unfortunately as Im can only access Mat Lab in the school com lab, I realise that they do not have the symbolic math toolbox. Is there way to solve the above equation using just matlab?

Subject: Is it possible to differentiate this equation 34 times?

From: Alan Weiss

Date: 27 Mar, 2009 12:18:07

Message: 7 of 7

Chen wrote:
>> If you have Symbolic Math Toolbox(TM), simply write
>>
>> syms z
>> p =(-3.996*(z-1)*(z+0.9985)*(z-(-0.0008 - 0.9992i))*(z-(-0.0008 +
>> 0.9992i))/(1.9985*(1.0008 + 0.9992i)*(1.0008 -
>> 0.9992i)*(1-z^4*exp(0.00307*(1-z)))));
>> y = diff(p,34); % be prepared to wait a while here
>> finalanswer = simplify(subs(y,0)) % be prepared to wait again
>>
>> Alan Weiss
>> MATLAB mathematical toolbox documentation
>
> Hi Alan, unfortunately as Im can only access Mat Lab in the school com lab, I realise that they do not have the symbolic math toolbox. Is there way to solve the above equation using just matlab?

I don't think you can perform this calculation reliably using just
numerical calculation. You can try using a centered differencing scheme,
but I am afraid that you will end up subtracting large numbers from each
other, losing too much numerical precision to arrive at a reliable answer.

But, if you want to give it a try:
1. choose a value of delta
2. populate a vector with the values of p(z) for z = (-35*delta,
-33*delta, ..., -delta, delta, 3*delta, ... , 35*delta)
3. compute the 34th central divided difference of the vector (the steps
are 2 delta). You can use the diff function to compute the differences.

If you don't understand what I am saying, look at any book on finite
differences or introductory numerical analysis.

Good luck,

Alan Weiss
MATLAB mathematical toolbox documentation

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us