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)

Respuestas (1)

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 comentarios

Gabriel
Gabriel el 5 de Feb. de 2015
Editada: Gabriel el 5 de Feb. de 2015
I should clarify- in my code I integrate two functions, combine them after integration into function h, and solve for the unknown, t2. My code is effective at this, and I am getting a solution for t2, however, I wish to view function h in a format that is easily written down, with all log functions and fraction operations carried out.
For example, here is h after my code has been run:
(4157*log(2))/250 - (41*t2)/1000 + (561*log(10))/50 - (187*log(t2))/50 - 61*10^(1/2) + (121*t2^2)/100000000 + (61*t2^(1/2))/10 + 3979/100 == 0
Simple does not help with this.
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
Yes, I want the value for t2. Thanks for the advice regarding "double".
However, my main question is, after finding t2, if I still want to view the function "h" in its simplest form (with logs and fractions solved), how do I do that?
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
I think the OP means how to write the solution for t2 explicitly:
t2= ...
But I doubt that this is possible.
Best wishes
Torsten.
Michael and Torsten-
For example, I want (4157*log(2))/250 to show as its explicitly calculated value, 11.5257.
Any ideas?
Thanks.
Use the vpa function:
y = vpa((4157*log(2))/250)
produces:
y =
11.525651318350769614085038483609
Star Strider- Perfect! Thanks all for your help.
My pleasure!

Iniciar sesión para comentar.

Productos

Preguntada:

el 5 de Feb. de 2015

Comentada:

el 6 de Feb. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by