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:
How to find out multiple roots for an exponential equation.

Subject: How to find out multiple roots for an exponential equation.

From: Chen

Date: 21 Mar, 2009 08:37:01

Message: 1 of 11

HI, I have a problem in trying to find out multiple roots for an exponential equation. I managed to find some help on the web, but the roots I got are not the ans Im looking for.

Basically, I need to to find the roots for this equation

z^4*[exp^0.00307(1-z)]=1

For Mod z is less or equal 1.

I created the m. file below;

function f = example1( z, oldroots)
 
f = 1-z^3*exp(0.00307-0.00307*z);
 
if ~isempty( oldroots ) ,
f = f / polyval( poly ( oldroots ), z );
end

Then I used this m. file which I found;

function x = findallzeros( fhandle, xguess, maxroots)
%
% x = findallzeros( fhandle, xguess, maxroots)
% ==================================
%
% attemps to find multiple roots of a function.
%
% fhandle = function handle, prefix by @
% xguess = a scalar value used as initial guess
% ( = 0 if not supplied )
% maxroots = the number of roots needed
% ( = 1 if not supplied )

% (c) 2005 by Tomas Co
% @ Michigan Technological University

    x = [ ] ;
    
    if nargin==1
        xguess =0;
        maxroots = 1;
    end
    
    if nargin==2
        maxroots = 1;
    end

    nroots = 0;
    
    while nroots<maxroots
        if abs(feval(fhandle,xguess,[ ]))<=1e-16,
            xroot=xguess;
        else
            [xroot,val,flag] = fzero(fhandle,xguess,[ ],x);
            if flag <= 0
                return
            end
        end
        x=[x,xroot];
        nroots=nroots+1;
        xguess=xguess+0.1;
    end

However, the roots i get are most 1, or numbers with ten to the power of 3/4

Since !z!<1, the roots I managed to get are not Usable.

This equation is from the generating function for queuing model, M/D/c/k. Where C=4 and K=30.

From there, I still need to find out how to do differentiation for the later equations. But would like to know If anyone can help me with this problem first.
ANy help would be greatly appreciated.

Subject: How to find out multiple roots for an exponential equation.

From: Bruno Luong

Date: 21 Mar, 2009 08:57:01

Message: 2 of 11

"Chen " <abathesith@yahoo.com> wrote in message <gq28vd$7t$1@fred.mathworks.com>...
> HI, I have a problem in trying to find out multiple roots for an exponential equation. I managed to find some help on the web, but the roots I got are not the ans Im looking for.
>
> Basically, I need to to find the roots for this equation
>
> z^4*[exp^0.00307(1-z)]=1
>
> For Mod z is less or equal 1.
>

Wait a minute, I believe you are looking for complex root (otherwise only z is the real root)? IIRC, fzero is a method to find roots of real value function.

You migh need to rewrite separately the real and imag part of the function and look for the roots of function from R^2 to R^2.

Bruno

Subject: How to find out multiple roots for an exponential equation.

From: Bruno Luong

Date: 21 Mar, 2009 09:07:01

Message: 3 of 11

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gq2a4t$g7o$1@fred.mathworks.com>...

Sorry should read:

otherwise only z=0 is the real root

Bruno

Subject: How to find out multiple roots for an exponential equation.

From: John D'Errico

Date: 21 Mar, 2009 11:19:01

Message: 4 of 11

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gq2anl$oao$1@fred.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gq2a4t$g7o$1@fred.mathworks.com>...
>
> Sorry should read:
>
> otherwise only z=0 is the real root
>
> Bruno

I'd immediately look to z = 1 as the real root.

fun = @(z) z.^4.*exp(0.00307*(1-z)) - 1;
ezplot(fun,[0,1])

But yes, this is a 2-d problem if the OP wishes to
solve it in the complex plane. It is not a problem
for a 1-d solver like fzero. But, a simple fixed
point iterative scheme appears to work.

format long g
z = j;
delta = inf;
while abs(delta) > 1e-15
  R = roots([1 0 0 0 -1./exp(0.00307*(1-z))]);
  [junk,ind] = min(abs(z - R));
  delta = z - R(ind);
  z = R(ind);
end
z

z =
      -0.000766321589335123 + 0.999231912902329i

fun(z)
ans =
       5.32907051820075e-15 - 1.37737043992558e-15i

Start the iteration out anywhere near z = -1,
and we get another real root.

z = -1;
delta = inf;
while abs(delta) > 1e-15
  R = roots([1 0 0 0 -1./exp(0.00307*(1-z))]);
  [junk,ind] = min(abs(z - R));
  delta = z - R(ind);
  z = R(ind);
end
z
z =
        -0.998467352013704

fun(z)
ans =
     0


z = -j;
>> delta = inf;
while abs(delta) > 1e-15
  R = roots([1 0 0 0 -1./exp(0.00307*(1-z))]);
  [junk,ind] = min(abs(z - R));
  delta = z - R(ind);
  z = R(ind);
end
z
z =
      -0.000766321589335123 - 0.999231912902329i

HTH,
John

Subject: How to find out multiple roots for an exponential equation.

From: Chen

Date: 21 Mar, 2009 14:56:01

Message: 5 of 11

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gq2if5$j7l$1@fred.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gq2anl$oao$1@fred.mathworks.com>...
> > "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gq2a4t$g7o$1@fred.mathworks.com>...
> >
> > Sorry should read:
> >
> > otherwise only z=0 is the real root
> >
> > Bruno
>
> I'd immediately look to z = 1 as the real root.
>
> fun = @(z) z.^4.*exp(0.00307*(1-z)) - 1;
> ezplot(fun,[0,1])
>
> But yes, this is a 2-d problem if the OP wishes to
> solve it in the complex plane. It is not a problem
> for a 1-d solver like fzero. But, a simple fixed
> point iterative scheme appears to work.
>
> format long g
> z = j;
> delta = inf;
> while abs(delta) > 1e-15
> R = roots([1 0 0 0 -1./exp(0.00307*(1-z))]);
> [junk,ind] = min(abs(z - R));
> delta = z - R(ind);
> z = R(ind);
> end
> z
>
> z =
> -0.000766321589335123 + 0.999231912902329i
>
> fun(z)
> ans =
> 5.32907051820075e-15 - 1.37737043992558e-15i
>
> Start the iteration out anywhere near z = -1,
> and we get another real root.
>
> z = -1;
> delta = inf;
> while abs(delta) > 1e-15
> R = roots([1 0 0 0 -1./exp(0.00307*(1-z))]);
> [junk,ind] = min(abs(z - R));
> delta = z - R(ind);
> z = R(ind);
> end
> z
> z =
> -0.998467352013704
>
> fun(z)
> ans =
> 0
>
>
> z = -j;
> >> delta = inf;
> while abs(delta) > 1e-15
> R = roots([1 0 0 0 -1./exp(0.00307*(1-z))]);
> [junk,ind] = min(abs(z - R));
> delta = z - R(ind);
> z = R(ind);
> end
> z
> z =
> -0.000766321589335123 - 0.999231912902329i
>
> HTH,
> John

Hi John. actually, Bruno is right. That was one detail I missed out myself when I tried solving this, cause its for a project and I am not really familiar with the theory myself cause it was given to me to just implement with no time to understand.

Im not familiar with the workings of Matlab so I was using fzero and the above file I found to solve it. However, is it possible to find the roots of this equation without simple fixed point iterative scheme using matlab?

For this project, I need to find the roots of the z when c=1,2,3. Then use them into another equation. But I will try looking for complex roots functions in matlab fiirst. Thanks alot.

Subject: How to find out multiple roots for an exponential equation.

From: John D'Errico

Date: 21 Mar, 2009 15:36:01

Message: 6 of 11

"Chen " <abathesith@yahoo.com> wrote in message <gq2v61$2tq$1@fred.mathworks.com>...

> Hi John. actually, Bruno is right. That was one detail I missed out myself when I tried solving this, cause its for a project and I am not really familiar with the theory myself cause it was given to me to just implement with no time to understand.

How is Bruno correct that z = 0 is a root?
This is your function as stated:

z^4*[exp^0.00307(1-z)]=1

However, you also asked about

z^3*exp(0.00307(1-z)) = 1

In this case, there is only one real root with
magnitude less than 1. See for yourself.

fun = @(z) z.^3.*exp(0.00307*(1-z)) - 1;
ezplot(fun,[-1,1])

Which problem do you wish to solve?

When z = 0, the left hand side is zero, exactly
so. It is not 1. On what planet is zero a root
of either expression?

When z = 1, the left hand side is exactly 1 in
either case.

However, I also showed how to find the second,
negative root, at least for the problem you
stated.
 
> Im not familiar with the workings of Matlab so I was using fzero and the above file I found to solve it. However, is it possible to find the roots of this equation without simple fixed point iterative scheme using matlab?

Next, it is not even true that there is ONLY
ONE real root, at least if you will raise z^4
as in your first post.

There are TWO real roots, as I showed, and I
showed you how to find them simply. Fzero
cannot find ALL roots of a function. It can
only find one at a time, based on an interval
or a starting value.

If you define your problem clearly, then we
can help you to solve it.


> For this project, I need to find the roots of the z when c=1,2,3. Then use them into another equation. But I will try looking for complex roots functions in matlab fiirst. Thanks alot.

There are no complex roots functions in matlab,
at least besides roots itself.

John

Subject: How to find out multiple roots for an exponential equation.

From: Chen

Date: 21 Mar, 2009 15:36:01

Message: 7 of 11

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gq2if5$j7l$1@fred.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gq2anl$oao$1@fred.mathworks.com>...
> > "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gq2a4t$g7o$1@fred.mathworks.com>...
> >
> > Sorry should read:
> >
> > otherwise only z=0 is the real root
> >
> > Bruno
>
> I'd immediately look to z = 1 as the real root.
>
> fun = @(z) z.^4.*exp(0.00307*(1-z)) - 1;
> ezplot(fun,[0,1])
>
> But yes, this is a 2-d problem if the OP wishes to
> solve it in the complex plane. It is not a problem
> for a 1-d solver like fzero. But, a simple fixed
> point iterative scheme appears to work.
>
> format long g
> z = j;
> delta = inf;
> while abs(delta) > 1e-15
> R = roots([1 0 0 0 -1./exp(0.00307*(1-z))]);
> [junk,ind] = min(abs(z - R));
> delta = z - R(ind);
> z = R(ind);
> end
> z
>
> z =
> -0.000766321589335123 + 0.999231912902329i
>
> fun(z)
> ans =
> 5.32907051820075e-15 - 1.37737043992558e-15i
>
> Start the iteration out anywhere near z = -1,
> and we get another real root.
>
> z = -1;
> delta = inf;
> while abs(delta) > 1e-15
> R = roots([1 0 0 0 -1./exp(0.00307*(1-z))]);
> [junk,ind] = min(abs(z - R));
> delta = z - R(ind);
> z = R(ind);
> end
> z
> z =
> -0.998467352013704
>
> fun(z)
> ans =
> 0
>
>
> z = -j;
> >> delta = inf;
> while abs(delta) > 1e-15
> R = roots([1 0 0 0 -1./exp(0.00307*(1-z))]);
> [junk,ind] = min(abs(z - R));
> delta = z - R(ind);
> z = R(ind);
> end
> z
> z =
> -0.000766321589335123 - 0.999231912902329i
>
> HTH,
> John

Hi John. actually, Bruno is right. That was one detail I missed out myself when I tried solving this, cause its for a project and I am not really familiar with the theory myself cause it was given to me to just implement with no time to understand.

Im not familiar with the workings of Matlab so I was using fzero and the above file I found to solve it. However, is it possible to find the roots of this equation without simple fixed point iterative scheme using matlab?

For this project, I need to find the roots of the z when c=1,2,3. Then use them into another equation. But I will try looking for complex roots functions in matlab fiirst. Thanks alot.

Subject: How to find out multiple roots for an exponential equation.

From: Matt Fig

Date: 21 Mar, 2009 16:12:01

Message: 8 of 11

You could try using a numerical Newton's method.

f = @(z) z.^4.*exp(0.00307*(1-z))-1
rt = newtzero(f,1+i,[],5e-16);
rt = rt(abs(rt)<=1)
rt =
         -0.998467352013704
      -0.000766321589335465 - 0.999231912902327i
      -0.000766321589335465 + 0.999231912902327i
                          1



f = @(z) z.^3.*exp(0.00307*(1-z))-1
rt = newtzero(f,1+i,[],5e-16);
rt = rt(abs(rt)<=1)
rt =
           -0.4999976509975 - 0.8642552061869i
           -0.4999976509975 + 0.8642552061869i
                          1



f = @(z) z.^2.*exp(0.00307*(1-z))-1
newtzero(f,1+i)
ans =

        -0.996939391275836
                         1


Where newtzero is on the FEX.

Subject: How to find out multiple roots for an exponential equation.

From: Chen

Date: 21 Mar, 2009 17:05:05

Message: 9 of 11

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gq31h1$1jv$1@fred.mathworks.com>...
> "Chen " <abathesith@yahoo.com> wrote in message <gq2v61$2tq$1@fred.mathworks.com>...
>

> > For this project, I need to find the roots of the z when c=1,2,3. Then use them into another equation. But I will try looking for complex roots functions in matlab fiirst. Thanks alot.
>
> There are no complex roots functions in matlab,
> at least besides roots itself.
>
> John

Hi John, Thanks a lot for your quick reply. You saved me a lot of time. However, when I said Bruno was right, I meant that he was right to say that z is a complex root and not z=0 is a root. Small misunderstanding there... very sorry about it.

However, I followed your syntax to the tee( copy and paste) and some how I got a different value for fun(z) tho my value of z is the same as yours. I don know whats the reason, so was wondering if it was due to the difference in versions. I did manual calculations and realized that my values are wrong.

I really appreciate your help tho, been working on this and learning how to use mathlab together for 2 days without any results. THANK YOU!!!

Subject: How to find out multiple roots for an exponential equation.

From: Chen

Date: 21 Mar, 2009 17:25:03

Message: 10 of 11

"Matt Fig" <spamanon@yahoo.com> wrote in message <gq33kh$d51$1@fred.mathworks.com>...
> You could try using a numerical Newton's method.
>
> Hi Matt, I found the newtzero file and will test the values I get on my later equations to see how it goes... thanks a lot!!.

Subject: How to find out multiple roots for an exponential equation.

From: Chen

Date: 21 Mar, 2009 17:40:05

Message: 11 of 11

"Matt Fig" <spamanon@yahoo.com> wrote in message <gq33kh$d51$1@fred.mathworks.com>...
> You could try using a numerical Newton's method.
>
> Hi Matt, I found the newtzero file and will test the values I get on my later equations to see how it goes... thanks a lot!!.

Tags for this Thread

No tags are associated with 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