Using powers in calculations?

Good day,
Som insight why there are two different evaluations for “basically” the same calculus…
u=symunit;
V1 = .15*u.m^3;
p1 = 2*u.bar;
V2 = .02*u.m^3;
gma=1.4;
p2=p1*V1^gma/V2^gma
Output for this coud p2 =((2*(0.1500*[m]^3)^1.4000)/(0.0200*[m]^3)^1.4000)*[bar].
And for…
u=symunit;
V1 = .15*u.m^3;
p1 = 2*u.bar;
V2 = .02*u.m^3;
gma=1.4;
p2=p1*(V1/V2)^gma
Is this one - p2 =33.5827*[bar]
How the program is calculating powers? What's the difference between these two cases?

Answers (1)

They give the same results, just in different forms.
u=symunit;
V1 = .15*u.m^3;
p1 = 2*u.bar;
t1 = (12+273)*u.K;
V2 = .02*u.m^3;
gma=1.4;
p2=p1*V1^gma/V2^gma
p3=p1*(V1/V2)^gma
Now check:
isAlways(p2 == p3) % true
simplify(p2)
simplify(p3) % these two simplify calls give the same result
The bottle of soda sitting next to me says it contains 2 liters, 2 quarts 3.6 fluid ounces, or 67.6 fluid ounces. That's three different ways to describe the same amount of soda.

3 Comments

Thank You for Your answer. The question is insufficiently precise.
How does the program decide which of the available answer types to choose? It's logical that in this code I'm asking for “shortest” ans expression, that I could evaluate it as precisely as I could.
When askt with “powers” inside brackets – (V1^gma/V2^gma), there is a output/ans in,let my cal it a “long-expression” - p2 = ((2*(0.1500*[m]^3)^1.4000)/(0.0200*[m]^3)^1.4000)*[bar]. And when askt with “powers” outside brackets – (V1/V2)^gma, the output is in “short-expression”, with subtracted auxiliary units (m^3), leaving it in bars.
The question may seem to be too philosophical. What's the difference for a MATLAB, “powers” are in or out of the brackets?
My guess is that the symunit functionality in Symbolic Math Toolbox is unwilling to work with fractional dimensions unless you explicitly tell it to simplify the result. (cubic meters)^(1.4) is meters^(4.2) -- what does that represent?
When you divide cubic meters by cubic meters before raising the result to the 1.4 power, you're raising a unitless quantity to that power.
Yes, it’s sou.
For example (15/2)^1.4 gives ans=16.79.
(15*u.m^3/2*u.m^3)^1.4 gives (7.5000*[m]^6)^1.4000.
(15*u.m/2*u.m)^1.4 gives (7.5000*[m]^2)^1.4000.
In the last example instead of subtraction in output occurs squaring. It can be compromising in further calculus.
Seams that there is no symunit subtraction. And before making calculus user must know about this, to adjust sequence of mathematical expressions.
Thank you for Your time. And shared thoughts.

Sign in to comment.

Tags

Asked:

on 2 Sep 2020

Commented:

on 2 Sep 2020

Community Treasure Hunt

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

Start Hunting!