Transcendental equation with fsolve

6 views (last 30 days)
Daniel Lagarto
Daniel Lagarto on 27 Mar 2015
Commented: Daniel Lagarto on 29 Mar 2015
I have the following trascendental equation :
(k2+k3)*sin((k2+k3)*L/2)-(k2-k3)*sin((k2-k3)*L/2)
If k2=sqrt(2*m*(E-Vi1))/hb and k3=sqrt(2*m*(E+Vi2))/hb it would be
((sqrt(2*m*(E-Vi1))/hb)+(sqrt(2*m*(E+Vi2))/hb))*sin(((sqrt(2*m*(E-Vi1))/hb)+(sqrt(2*m*(E+Vi2))/hb))*L/2)-((sqrt(2*m*(E-Vi1))/hb)-(sqrt(2*m*(E+Vi2))/hb))*sin(((sqrt(2*m*(E-Vi1))/hb)-(sqrt(2*m*(E+Vi2))/hb))*L/2)=0;
How can i find the zeros of this equation (all the function is only function of E, the rest are parameters?
Should i give numeric values to Vi1 Vi2 m hb etc or could i do it as a simbylic computation?
How could i do it in eah case?

Answers (2)

Star Strider
Star Strider on 27 Mar 2015
Edited: Star Strider on 27 Mar 2015
Finding zeros works best if you plot your function first to find out approximately where the zeros are. If you know they are approximately periodic, you can estimate the period to provide initial estimates to fzero. Then, use a for loop to loop through the starting estimates.
Note that ‘k2’ and ‘k3’ take the square root, so there will be two roots (even though sqrt will only return the positive one, or if complex, the one with the positive imaginary part), and depending on the values of ‘E’, and ‘Vi1’ and ‘Vi2’, they could be complex. Consider what root you want, and how you want to deal with complex arguments, since fzero throws an error for complex results of the function supplied to it.
Anonymous function will pick up your constants from the workspace, so your functions only need to be functions of ‘E’.
Use these for your equations:
k2 = @(E) sqrt(2*m*(E-Vi1))/hb;
k3 = @(E) sqrt(2*m*(E+Vi2))/hb;
Eqn = @(E) (k2(E)+k3(E)).*sin((k2(E)+k3(E))*L/2)-(k2(E)-k3(E)).*sin((k2(E)-k3(E))*L/2);
You can then loop through your initial estimates:
Est = [ ... ];
for k1 = 1:length(Est)
Ezero(k1) = fzero(Eqn, Est(k1));
end
I don’t have your constants, so I can’t run this with realistic values or offer you further insights.
  2 Comments
Daniel Lagarto
Daniel Lagarto on 27 Mar 2015
Thank you very much. My constants are
hb=(6.62*10^-34)/(2*pi);
m=9.1*10^-31;
L=10^-10;
But i´d like to calculate the Ezero for different values of Vi1 Vi2 so that´s the reason i´d like to know if it´s possible to find the zeros in a symbolic way as a function of Vi1 Vi2.
If it isn´t possible Vi1 and Vi2 are free parameters so I can try with different values of them
Star Strider
Star Strider on 27 Mar 2015
My pleasure.
There are no real values for your function when Vi1>E or Vi2>E. I don’t know anything about the function you are using (I don’t recognise it).
What range of values for ‘Vi1’ and ‘Vi2’ are you interested in? I would use the contour function with one contour set at zero to get a plot with respect to varying both simultaneously. I have never attempted that with a periodic function though, so I have no idea if it would work as it would with other functions.

Sign in to comment.


Roger Stafford
Roger Stafford on 28 Mar 2015
Edited: Roger Stafford on 28 Mar 2015
In a problem such as yours, Daniel, it is always helpful to redefine your variables so as to simplify the expressions, and if possible manipulate those expressions in such a way as to simplify them further. In your case I would substitute
x = k2*L/2
y = k3*L/2
and multiply the expression by L/2, obtaining
(x+y)*sin(x+y)-(x-y)*sin(x-y) = 0
or equivalently
y*sin(x)*cos(y)+x*sin(y)*cos(x) = 0
(This could be converted to the even simpler tan(x)/x+tan(y)/y = 0 if further insight is needed.)
Instead of solving for E you can solve this for x such that y^2-x^2 = K where
K = L^2/2/hb^2*m*(Vi2+Vi1)
Doing this boils down your problem to one involving only the one variable parameter, K.
Then following Star's advice, make a plot of
f(x) = y*sin(x)*cos(y)+x*sin(y)*cos(x)
where y = sqrt(x^2+K) to find all its zeros approximately, followed by 'fzero' with these as estimates to make them more accurate.
Only after you have found the desired roots for x do you need to convert back to the corresponding values of E = 2*hb^2/m/L^2*x^2+Vi1.
By the way, in the context in which you have use the word in your title, it should be spelled 'transcendental'.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!