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 个评论

Why not just use fzero?
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 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by