Nonlinear Equation solution of one variable ?

I'm trying to solve this modified effective permittivity non linear equation using newton raphson method, the solution does not return a pair of complex solution, could anyone help me with coding!
p=[0.23]
er1=(10000); % first relative permttivity
er2=(2.5); % second relative permttivity
Hc=(10^6);
H=[0,2.5*10^4,5.0*10^4,7.5*10^4,1*10^5,1.3*10^5,1.5.*10^5];
Pc=(0.33).*exp(-abs(H)/Hc);
c1=(1-3*Pc).*(((p)./(Pc)).^Pc).*(((1-p)./(1-Pc)).^(1-Pc)); %concnetration
% wanted solution for varaible x
f=@(x) ((p.*(x-er1)./(er1-2.*x))./(1+c1.*(x-er1)./(er1-2.*x))+((1-p).*(x-er2)./(er2-2.*x))./(1+c1.*(x-er2)./(er2-2.*x))); %Equation 4
df=@(x) ((3.*er1.*p)./(er1+2.*x+c1.*(x-er1)).^2)+(((x-er2).*(1-p))./(er1+2.*x+c1.*(x-er1))); %derivative of the above function
a=1; b=20;
x=a;
for i=1:1:100
x1=x-(f(x)/df(x));
x=x1;
end
sol=x;
fprintf('Approximate Root is %.15f',sol)
a=1;b=20;
x=a;
er(5)=0;
for i=1:1:5
x1=x-(f(x)/df(x));
x=x1;
er(i)=x1-sol;
end
plot(er)
xlabel('Number of iterations')
ylabel('Error')
title('Error Vs. Number of iterations')
i had attached the wanted equation solution in the picture attachments.

댓글 수: 3

Matt J
Matt J 2019년 10월 16일
Why not just use fzero?
Ammar Ahmed
Ammar Ahmed 2019년 10월 16일
I tried to use fzero and could not reach to solution!!
df does not appear to be the derivative of f.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2019년 10월 16일

댓글:

2019년 10월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by