Solving for a single unknown (non-linear equation)
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
0 commentaires
Réponses (4)
G A
le 12 Mar 2012
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 commentaires
Walter Roberson
le 13 Mar 2012
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
le 13 Mar 2012
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
le 13 Mar 2012
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 commentaire
Bjorn Gustavsson
le 13 Mar 2012
In addition to that: 1.414...
...might be a very short version of sqrt(2)...
Honglei Chen
le 12 Mar 2012
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)
0 commentaires
Anthony
le 12 Mar 2012
4 commentaires
Honglei Chen
le 12 Mar 2012
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.
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!