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 commentaires

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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by