How do I simplify an equation found using the symbolic solver?
이전 댓글 표시
The equation involves fractions and logarithmic functions, and no matter how many steps I specify in the simplify command, the log's and fractions are not simplified to their decimal forms. Additionally, numbers are being carried out to as many significant digits as they occupy without any scientific notation.
Is there a way to simplify the equation to solve all fractions and log functions and display everything in scientific notation? My code is below. I am trying to simplify the function h as much as possible.
Thanks in advance for assistance.
close all clear all clc
% Declare variables syms t p R p1 p2 t1 t2
% Define known constants and variables R = 8.314; % units of J/(mol-K) p1 = 2.0*101325; % conversion of atm to Pa (kg/m-s^2) p2 = 0.5*101325; % conversion of atm to Pa (kg/m-s^2) t1 = 1000; % unit of K
% Integrate both terms in entropy equation over full range of % temperature, and from p1 to p2 f = int((1/t)*(-3.74 + 30.5*(t/100)^(1/2) - 4.10*(t/100) + 0.0242*(t/100)^2),t,t1,t2); g = int(R/p,p,p1,p2);
% Set equation to zero because it is an isentropic expansion % ds = 0 h = f - g == 0;
h = simplify(h,'steps',1000)
답변 (1개)
Michael Haderlein
2015년 2월 5일
I think there's a misunderstanding: simplify does not solve anything, it just tries to simplify the equation (whatever that exactly means). E.g.
>> simplify((1-cos(x)^2),100)
ans =
sin(x)^2
Btw., simple does the same but tries harder.
You will agree that both fractions and logarithms can only be displayed with round-off errors for the very most numbers. However, as simplify is algebraic, this cannot happen. Maybe vpa is what you are looking for, but there will be round-off errors.
>> vpa('123456789',3)
ans =
1.23e8
댓글 수: 9
Michael Haderlein
2015년 2월 5일
So you want to get a value for t2?
>> solve(h)
ans =
803.75522617529050692267578222982 %<- still a symbolic variable!
>> double(solve(h))
ans =
8.037552261752906e+02 %<- double scalar - good for further numerics
Gabriel
2015년 2월 6일
Michael Haderlein
2015년 2월 6일
In my opinion, the equation you have posted is the simplest form. I mean, how do you want to simplify log(2)? Regarding the fractions, you could of course replace (4157*log(2))/250 by 16.628*log(2)/250, but is that really any better? If you want to get a better view on the structure of the equation, you might either use pretty() or this submission in the fex: http://www.mathworks.com/matlabcentral/fileexchange/11150-sexy
Torsten
2015년 2월 6일
I think the OP means how to write the solution for t2 explicitly:
t2= ...
But I doubt that this is possible.
Best wishes
Torsten.
Gabriel
2015년 2월 6일
Star Strider
2015년 2월 6일
Use the vpa function:
y = vpa((4157*log(2))/250)
produces:
y =
11.525651318350769614085038483609
Gabriel
2015년 2월 6일
Star Strider
2015년 2월 6일
My pleasure!
카테고리
도움말 센터 및 File Exchange에서 Common Operations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!