Matlab solve function: instead of a numerical value, getting an expression in terms of pi along with very large coefficients
2 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to solve a nonlinear equation with unknown variable x. For some reason, the solve function is not returning a numerical value but instead is giving an answer in the following form:
S =
1/(-(22151167999999998189964888425476653056*(7485821338025924274921417236328125*pi - 682384*pi*(643853259116881963687067249682911142222430853231504543*pi^2 + 3530320533242058359881816156536132990233490194707680000)^(1/2)))/(299808933118153986784342462217472647824840011671796397686580260608*pi^2 - 54393634679405996130076386078977333642982815218462091444297323935625))^(1/3)
Can anyone please explain why this is happening and what I can do to fix this? I am able to use the 'eval' function to evaluate the form above to get a numerical value. I am attaching the relevant part of my code where x is the unkown and all other quantities are defined/known:
syms x
sigma_a_i_new = (32*Kf*M_i)/(pi *(x^3));
sigma_m_i_new = (sqrt(3)*16*Kfs*T_m)/(pi *(x^3));
var_sigma_a_i_new = ((32*M_i)/pi)^2*( (((-3*Kf/x^4)^2)*(0.02*x)^2)+ (((1/x^3)^2)*(sd_Kf^2)) )
var_sigma_m_i_new = ((sqrt(3)*16*T_m)/pi)^2*( (((-3*Kfs/x^4)^2)*(0.02*x)^2)+ (((1/x^3)^2)*(sd_Kfs^2)) )
eqn = 4.2649== (Se^2*Sut^2 - (sigma_a_i_new*Sut^2*Se)-(sigma_m_i_new*Se^2*Sut))/(Sut^4*(sigma_a_i_new^2*sd_Se^2 + Se^2*var_sigma_a_i_new)+Se^4*(sigma_m_i_new^2*sd_Sut^2+(Sut^2*var_sigma_m_i_new)))^0.5
S = solve ( eqn, x, 'Real', true)
采纳的回答
Walter Roberson
2020-5-4
solve() is a request to find an indefinitely precise closed-form solution if one exists. solve() will only return a numeric approximation if it is unable to find an indefinitely precise closed-form solution.
If what you wanted was a numeric approximation, then use vpasolve(), or else vpa() or double() the result you got from solve()
(0.02*x)^2
Your equations cannot justify using solve(), since they involve coefficients that are only approximated. Remember that 0.02 cannot be exactly represented in finite double precision so you can only get an approximation for 0.02 . Also if you remember back to high school chemistry, when you write 0.02 you are saying you have one significant digit and that one digit represents rounding of the actual number, so 0.02 represents the set of numbers from 15/1000 inclusive to 25/1000 exclusive. When you have a value that is uncertain, you cannot justify using solve() because it is only for finding exact solutions.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!