fsolve (nonlinear) equation solver with given one equation.

How could I solve the equation, using fsolve? Currently, I do have p4, p1, r4, r1, a1, and a4 values, but I am trying to find p2/p1.
It does not have to be fsolve. Any methods it can solve is fine.

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 3월 6일
You can use fzero.
Since you already know the values of p1, p4, r1, r4, a1, and a4, you can use solve the equation for the value of p2 to get . For example,
% dummy values
p1 = 1;
p4 = 2;
r1 = 1;
r4 = 2;
a1 = 1;
a4 = 1;
fun = @(p2) p2/p4*(1 -((r4-1)*a1/a4*(p2/p1-1))./(2*r1*(2*r1+(r1+1)*(p2/p1-1))).^.5).^(-2.*r4./(r4-1))-1;
result = fzero(fun, 10)/p1;

댓글 수: 4

Why there is -1 at the end? ((-2.*r4./(r4-1))-1) because I do not see any -1 in my original equation.
To use fsolve, we need to convert the function in the form f(x) = 0. Therefore,
1) Multiply both side with p1.
2) Divide both side by p4.
3) Subtract 1 from both side.
You will get the equation as mentioned in this answer.
For example, if my p4 = 29.82, p1 = 6.78, r1=r4=1.4, a1=a4=96.13, what would be p2?
Also, in result, result = fzero(fun, 10)/p1, what does 10 represent?
Would it be okay to use any value for that?
Thank you for your answer.
Ameer Hamza
Ameer Hamza 2020년 3월 6일
편집: Ameer Hamza 2020년 3월 6일
Here, p2 = fzero(fun, 10) and therefore result = p2/p1.
10 is the initial estimate of the value of p1. It is used as a starting point by the solving algorithm. You can use any value, but you will get a better solution if it is near the actual solution. You can use your knowledge about the problem to give a rough estimate of its optimal value.

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

카테고리

도움말 센터File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

질문:

2020년 3월 6일

편집:

2020년 3월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by