Solving for a single unknown (non-linear equation)

조회 수: 17 (최근 30일)
Anthony
Anthony 2012년 3월 12일
I apologize for my naivety, I am new to MatLab. I have this very long equation typed out and the unknown I need to solve for is "P"
6.2==1.414*(1-(0.548+0.71*(3.83/49.5)^4)*(1-(1-(P/194166))))*sqrt(P/1.184)*(((0.9975-0.00653*(10^6/(70900*49.5*((1.184*P)/(1-(6/49.5)^4))^0.5))^0.5)*0.018241)+(3*((0.9975-0.00653*(10^6/(70900*49.5*((1.184*P)/(1-(4/49.5)^4))^0.5))^0.5)*0.008107))+((0.9975-0.00653*(10^6/(70900*49.5*((1.184*P)/(1-(3/49.5)^4))^0.5))^0.5)*0.00456)+((0.9975-0.00653*(10^6/(70900*49.5*((1.184*P)/(1-(2/49.5)^4))^0.5))^0.5)*0.002027))
very messy, but it should be typed out correctly. The hard part has been done..
How can I get MatLab to solve P for me? I've tried
solve('that equation', P)
But it gives me an error, saying P is an unknown variable. Any help would be appreciated. I'm sure this is easy, I just have no idea what the command is to solve an equation. Or what must be done to any variables you plan on using (like P, here)
Thank you!

답변 (4개)

G A
G A 2012년 3월 12일
syms P
solve('6.2=1.414*(1-(0.548+0.71*(3.83/49.5)^4)*(1-(1- (P/194166))))*sqrt(P/1.184)*(((0.9975-0.00653*(10^6/(70900*49.5*((1.184*P)/(1-(6/49.5)^4))^0.5))^0.5)*0.018241)+(3*((0.9975-0.00653*(10^6/(70900*49.5*((1.184*P)/(1-(4/49.5)^4))^0.5))^0.5)*0.008107))+((0.9975-0.00653*(10^6/(70900*49.5*((1.184*P)/(1-(3/49.5)^4))^0.5))^0.5)*0.00456)+((0.9975-0.00653*(10^6/(70900*49.5*((1.184*P)/(1-(2/49.5)^4))^0.5))^0.5)*0.002027))',P)
ans =
408270.34774603219832835714795887
290297.52311957774144902012949622
290318.2813236540219441455483253
10023.461083668597932042362965426
408256.9318415621052355263787515
10037.722237649978451175667443743
10030.586416547686816457207201435 + 7.1305756978312245604932980434246*i
10030.586416547686816457207201435 - 7.1305756978312245604932980434246*i
290307.90584288889227473668488892 + 10.379101358088288664349740315312*i
290307.90584288889227473668488892 - 10.379101358088288664349740315312*i
408263.63817095856098494380133019 - 6.7079520439268252489438119583435*i
408263.63817095856098494380133019 + 6.7079520439268252489438119583435*i
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 3월 13일
G A, when I plot the equations, I show no sign of double roots near 10000 or 290000 or 408250 -- only single roots.
G A
G A 2012년 3월 13일
Walter, I have just demonstrated to Anthony that function solve() works giving some result - no matter is solution meaningless or not. However, your are right. I have not checked equation graphically or algebraically as you have done.

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


Walter Roberson
Walter Roberson 2012년 3월 13일
Anthony, your equation is numerically fairly meaningless. You are creating polynomials of at least degree 16 because of the ^4 expressions. The roots (especially the transition between real and complex) of such polynomials are usually quite sensitive to the exact coefficients of the polynomials. You do not, however, have meaningful exact coefficients: you use a mix of floating point values varying from 1 significant place to 5 significant places. Logically you are getting major round-off in that calculation, so the high-degree polynomials that result are near meaningless except as examples of a wide range of coefficient values that are within the round-off of the figures you give.
In some places in your equation, you use sqrt(), but in other places you use ^0.5 . The two are not equivalent in algebra. In algebra, it is not known whether the 0.5 is the representation of 1/2 or of 5/10 or of 10/20 and so on -- interpretations that can affect the sign of the result and can affect which complex root is chosen. Using floating point values as a power causes problems for algebraic solutions, especially when negative values are being taken to the power (which can happen incidentally due to a rewriting of the expression to make it easier to calculate.)
  댓글 수: 1
Bjorn Gustavsson
Bjorn Gustavsson 2012년 3월 13일
In addition to that: 1.414...
...might be a very short version of sqrt(2)...

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


Honglei Chen
Honglei Chen 2012년 3월 12일
Move 6.2 to the right side of the equation and then use fzero.
doc fzero
for example, to solve x+1 = 2
fzero(@(x)x-1,0)

Anthony
Anthony 2012년 3월 12일
Now I'm getting the error
Function value at starting guess must be finite and real.
I'm guessing this has something to do with my equation then? Thanks for the help.
  댓글 수: 4
Anthony
Anthony 2012년 3월 12일
it's a pressure, so the answer can not be negative... which means the equation is most likely messed up somewhere. hmm...
thanks.
Honglei Chen
Honglei Chen 2012년 3월 12일
Try change the initial guess. I'm using 0 for the initial guess but you can use a different number so it is not easy to fall into negative P region.

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

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by