Using powers in calculations?

1 Ansicht (letzte 30 Tage)
Andrew
Andrew am 2 Sep. 2020
Kommentiert: Andrew am 2 Sep. 2020
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?

Antworten (1)

Steven Lord
Steven Lord am 2 Sep. 2020
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 Kommentare
Steven Lord
Steven Lord am 2 Sep. 2020
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.
Andrew
Andrew am 2 Sep. 2020
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by