roots for nonlinear equation

조회 수: 2 (최근 30일)
Ammar Ahmed
Ammar Ahmed 2019년 6월 10일
편집: Walter Roberson 2019년 6월 10일
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

답변 (2개)

Matt J
Matt J 2019년 6월 10일
편집: Matt J 2019년 6월 10일
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
Matt J
Matt J 2019년 6월 10일
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 2019년 6월 10일
편집: Catalytic 2019년 6월 10일
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().

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2019년 6월 10일
편집: Walter Roberson 2019년 6월 10일
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

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by