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 Comments

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.

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Asked:

on 16 Oct 2019

Commented:

on 17 Oct 2019

Community Treasure Hunt

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

Start Hunting!