Nonlinear Equation solution of one variable ?
Show older comments
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
Matt J
on 16 Oct 2019
Why not just use fzero?
Ammar Ahmed
on 16 Oct 2019
Walter Roberson
on 17 Oct 2019
df does not appear to be the derivative of f.
Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!