roots for nonlinear equation

2 visualizaciones (últimos 30 días)
Ammar Ahmed
Ammar Ahmed el 10 de Jun. de 2019
Editada: Walter Roberson el 10 de Jun. de 2019
I'm trying to solve and finding the roots for equation 2 as in the picture in such way it will give the same result if i intend to solve equation 3 ,
EQN.bmp
i tried to use fsolve command and fzero command but not reach to solution
Any suggestion commands
coding
function fval=eqns(ere)
P=(0.27);
er1=(1+1.8*10^14*1i);
er2=(2.5+2.5*10^-3*1i);
fval=((P).*((ere-er1)./(er1-2.*ere)))+((1-P).*((ere-er2)./(er2-2.*ere)));
end

Respuestas (2)

Matt J
Matt J el 10 de Jun. de 2019
Editada: Matt J el 10 de Jun. de 2019
You need to pose the problem in terms of real numbers only,
[ere,fval]=fsolve(@eqns,[1,1]);
ere=complex(ere(1),ere(2))
fval,
function fval=eqns(ere)
P=(0.27);
ere=complex(ere(1),ere(2)); %<---added
er1=(1+1.8*10^14*1i);
er2=(2.5+2.5*10^-3*1i);
fval=((P).*((ere-er1)./(er1-2.*ere)))+((1-P).*((ere-er2)./(er2-2.*ere)));
fval=[real(fval),imag(fval)]; %<---added
end
With the initial guess [1,1], the result solves the equations quite well
ere =
1.9685 + 0.0020i
fval =
1.0e-08 *
-0.1270 0.5217
  2 comentarios
Matt J
Matt J el 10 de Jun. de 2019
Ammar Ahmed's comment moved here
thanks for replying, i already got this solution but it's not what I want .
as i mentioned in the picture uploaded the Equation 2 and 3 should have the same roots
using Fsolve or Fzero Does not give up the Same roots.
Equation 2 Must have at least two roots one of them is the same root of Equation 3 the trivial equatio.
many thanks
Catalytic
Catalytic el 10 de Jun. de 2019
Editada: Catalytic el 10 de Jun. de 2019
I don't think either fsolve or you Equation 3 could ever give you numbers you can trust in double floating point arithmetic. There is not enough precision in double floats to evaluate the imaginary part of,
(3*p-1)*ere1+(2-3*p)*ere2
for the values that you've shown. The values 1.8e14 and 2.5e-3 are too far apart.
Maybe have a look at vpasolve().

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 10 de Jun. de 2019
Editada: Walter Roberson el 10 de Jun. de 2019
There is nothing to solve for. You have specific inputs for p, er1, er2, and equation 3 has only those on the right hand side. Therefore the left hand side, ere, is completely defined as a specific numeric value.
Now take that numeric value for ere and substitute it and the p, er1, er2 into equation 2. The equation will either be satisfied or else it will not be.
Might I suggest that the real problem is to find the p value that works? If so then the solution is p = 1
With p = 0.27 then if you wanted to find one of er1 or er2 given the other, then the solution is er1 == er2

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by