Numeric solution of a transcendental equation
Show older comments
I need to solve a transcendental equation which would give me a complex result.
I use the function fzero but it requires real and finite starting point and zero of the function.
I define the function for which I want to find the complex zero
function beta1 = trial0(beta, eps1, eps2, epsm,k0,h)
S1 = sqrt(power(beta,2)-(eps1*power(k0,2)));
S2 = sqrt(power(beta,2)-(epsm*power(k0,2)));
S3 = sqrt(power(beta,2)-(eps2*power(k0,2)));
beta1 = tanh(S2*h)*((eps1*eps2*power(S2,2))+(power(epsm,2)*S1*S3)) + (S2*((eps1*S3)+(eps2*S1))*epsm);
end
And in the main program I pass the parameters and call fzero.
eps1 = 1.5471;
eps2 = 1.5431;
eps1m = -9.894 ;
epsm2 = 1.0458;
epsm = eps1m + i*eps2m;
lambda = 633;
k0 = (2*pi)/lambda;
h = 50;
beta0 = fzero(@(beta) trial0(beta, eps1, eps2, epsm,k0,h),0.02)
but since epsm is complex, it doesn't work. How can I solve the equation for various h if epsm is complex? Any help is very much appreciated
Silvia
Answers (1)
Matt Fig
on 14 Apr 2011
Please format your code using the {} Code button so that it is readable.
Using the modified version of your function below (modified to accept array arguments):
function beta1 = trial0(beta, eps1, eps2, epsm,k0,h)
S1 = sqrt(power(beta,2)-(eps1.*power(k0,2)));
S2 = sqrt(power(beta,2)-(epsm.*power(k0,2)));
S3 = sqrt(power(beta,2)-(eps2.*power(k0,2)));
beta1 = tanh(S2.*h).*((eps1.*eps2.*power(S2,2))+(power(epsm,2).*S1.*S3)) + (S2.*((eps1.*S3)+(eps2.*S1)).*epsm);
.
eps1 = 1.5471;
eps2 = 1.5431;
eps1m = -9.894 ;
eps2m = 1.0458;
epsm = eps1m + i*eps2m;
lambda = 633;
k0 = (2*pi)/lambda;
h = 50;
rt = newtzero(@(beta) trial0(beta, eps1, eps2, epsm,k0,h))
rt =
-0.0145022535285521 - 0.000368185024608621i
0.0145022535285521 + 0.000368185024608621i
Categories
Find more on Solver Outputs and Iterative Display in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!