how to find the root of transcedental equation while loop

1 回表示 (過去 30 日間)
shiv gaur
shiv gaur 2022 年 2 月 17 日
コメント済み: shiv gaur 2022 年 2 月 17 日
k0=(2*pi/0.6328)*1e6;
t2=1.5e-6;
n1=1.512;n2=1.521;n3=4.1-1i*0.211;
n4=1;
m=0;
t3=1e-9;
k1=k0*sqrt(n1^2-x^2);
k2=k0*sqrt(n2^2-x^2);
k3=k0*sqrt(n3^2-x^2);
k4=k0*sqrt(n4^2-x^2);
tol = 1e-12;
n = 1;
y=-(k2)*t2+atan(k1/1i*k2)+atan((k3/k2)*tan(atan(k4/1i*k2)-k3*t3))+m*pi;
how to calculate the root of equation i.e the vaue of x numerically by while loop
  2 件のコメント
shiv gaur
shiv gaur 2022 年 2 月 17 日
what will be root of this equation using while loop
shiv gaur
shiv gaur 2022 年 2 月 17 日
any one pl iterate the value of x is the root help

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 2 月 17 日
format long g
k0=(2*pi/0.6328)*1e6;
t2=1.5e-6;
n1=1.512;n2=1.521;n3=4.1-1i*0.211;
n4=1;
m=0;
t3=1e-9;
tol = 1e-12;
n = 1;
x = rand
x =
0.599324733046148
y = inf;
while n < 5 & abs(y) > tol
k1=k0*sqrt(n1^2-x^2);
k2=k0*sqrt(n2^2-x^2);
k3=k0*sqrt(n3^2-x^2);
k4=k0*sqrt(n4^2-x^2);
y=-(k2)*t2+atan(k1/1i*k2)+atan((k3/k2)*tan(atan(k4/1i*k2)-k3*t3))+m*pi;
[n, x, y]
n = n + 1;
end
ans =
1 + 0i 0.599324733046148 + 0i -17.6929697847717 + 7.90103155130006e-07i
ans =
2 + 0i 0.599324733046148 + 0i -17.6929697847717 + 7.90103155130006e-07i
ans =
3 + 0i 0.599324733046148 + 0i -17.6929697847717 + 7.90103155130006e-07i
ans =
4 + 0i 0.599324733046148 + 0i -17.6929697847717 + 7.90103155130006e-07i
All of the results are the same because you have not defined any way for x to change.
  5 件のコメント
shiv gaur
shiv gaur 2022 年 2 月 17 日
from muller method ans is different why is so
here is program
function kps3
T3 = 1e-9:1e-9:1e-6;
for j=1:numel(T3)
t3 = T3(j);
p0 = 0.5;
p1 = 1;
p2 = 1.5;
TOL = 10^-8;
N0 = 100; format long
h1 = p1 - p0;
h2 = p2 - p1;
DELTA1 = (f(p1,t3) - f(p0,t3))/h1;
DELTA2 = (f(p2,t3) - f(p1,t3))/h2;
d = (DELTA2 - DELTA1)/(h2 + h1);
i=3;
while i <= N0
b = DELTA2 + h2*d;
D = (b^2 - 4*f(p2,t3)*d)^(1/2);
if abs(b-D) < abs(b+D)
E = b + D;
else
E = b - D;
end
h = -2*f(p2,t3)/E;
p = p2 + h;
if abs(h) < TOL
%disp(p)
break
end
p0 = p1;
p1 = p2;
p2 = p;
h1 = p1 - p0;
h2 = p2 - p1;
DELTA1 = (f(p1,t3) - f(p0,t3))/h1;
DELTA2 = (f(p2,t3) - f(p1,t3))/h2;
d = (DELTA2 - DELTA1)/(h2 + h1);
i=i+1;
end
if i > N0
formatSpec = string('The method failed after N0 iterations,N0= %d \n');
fprintf(formatSpec,N0);
end
P(j)=real(p);
end
plot(T3,P)
end
function y=f(x, t3)
k0=(2*pi/0.6328)*1e6;
t2=1.5e-6;
n1=1.512;n2=1.521;n3=4.1-%i*0.211;
n4=1;
m=0;
m=0;
k1=k0*sqrt(n1^2-x^2);
k2=k0*sqrt(n2^2-x^2);
k3=k0*sqrt(n3^2-x^2);
k4=k0*sqrt(n4^2-x^2);
y=(k2)*t2-atan(k1/1i*k2)-atan((k3/k2)*tan(atan(k4/1i*k2)-k3*t3))+m*pi;
end
why results are so different using while loop pl sort out the problem using this while loop
shiv gaur
shiv gaur 2022 年 2 月 17 日
I think root will be same for both program use while loop or muller

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by