MATLAB Answers

From where is this exp in syms calculus?

1 view (last 30 days)
Andrew
Andrew on 2 Sep 2020
Edited: Andrew on 3 Sep 2020
syms V1 V2 p1 p2 n
eqv=p1*V1^n==p2*V2^n;
solve(eqv,V2)
Warning: Solutions are parameterized by the symbols: l. To include parameters
and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
> In sym/solve>warnIfParams (line 475)
In sym/solve (line 357)
Warning: Solutions are only valid under certain conditions. To include
parameters and conditions in the solution, specify the 'ReturnConditions' value
as 'true'.
> In sym/solve>warnIfParams (line 478)
In sym/solve (line 357)
ans =
exp(-(l*6.2832i)/n)*((V1^n*p1)/p2)^(1/n)
true ans ((V1^n*p1)/p2)^(1/n).

  0 Comments

Sign in to comment.

Accepted Answer

James Tursa
James Tursa on 2 Sep 2020
Edited: James Tursa on 3 Sep 2020
The solution space has multiple values, not just one. The solver has parameterized the solution space for you. There are multiple complex roots possible. E.g., a simpler example:
>> syms Y X n
>> eqv = Y==X^n;
>> solve(eqv,X)
Warning: Solutions are parameterized by the symbols: l. To include parameters and conditions in the
solution, specify the 'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 475)
In solve (line 357)
Warning: Solutions are valid under the following conditions: 0 <= real(n)*(pi - imag(log(Y)/n) +
2*l*pi*real(1/n)) & 0 < real(n) & 0 < real(n)*(pi + imag(log(Y)/n) - 2*l*pi*real(1/n)) & in(l,
'integer') | real(n)*(pi - imag(log(Y)/n) + 2*l*pi*real(1/n)) <= 0 & real(n) < 0 & real(n)*(pi +
imag(log(Y)/n) - 2*l*pi*real(1/n)) < 0 & in(l, 'integer'). To include parameters and conditions in the
solution, specify the 'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 482)
In solve (line 357)
ans =
Y^(1/n)*exp(-(pi*l*2i)/n)
The obvious solution by inspection is X = Y^(1/n). That happens to be the solution for the parameter choice l=0, but there are other solutions for other values of l also. Essentially it includes the n'th roots of 1 as a multipler in this case (the exp stuff).
E.g., to get rid of those complex n'th roots of 1:
>> solve(eqv,X,'Real',true)
Warning: Solutions are valid under the following conditions: 0 < Y. To include parameters and
conditions in the solution, specify the 'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 482)
In solve (line 357)
ans =
Y^(1/n)
And thus your code could be:
>> syms V1 V2 p1 p2 n
>> eqv = p1*V1^n==p2*V2^n;
>> solve(eqv,V2,'Real',true)
Warning: Solutions are valid under the following conditions: 0 < (V1^n*p1)/p2 &
in(((V1^n*p1)/p2)^(1/n), 'real'). To include parameters and conditions in the solution, specify the
'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 482)
In solve (line 357)
ans =
((V1^n*p1)/p2)^(1/n)

  1 Comment

Andrew
Andrew on 3 Sep 2020
This parametrization occurs when syms are used to solve equations that have exponential expressions. In solve function stating ‘Real’ excludes integers, confirming that simulated variables will be only real numbers?
For me, MATLAB is a new stuff/tool… So no offense if the additional question is completely incorrect. Built-in symunit, or “symbolic tool box” is making me confused…
u=symunit;
p1=1*u.bar;
t1=(35+273)*u.K;
p2=40*u.bar;
V1=.8*u.m^3;
n=1.3;
V2=(V1^n*p1/p2)^(1/n)
t2=(p2*V2)/(p1*V1/t1)
p11=1;%*u.bar;
t11=(35+273);%*u.K;
p22=40;%*u.bar;
V11=.8;%*u.m^3;
n=1.3;
V22=(V11^n*p11/p22)^(1/n) %*u.m^3;
t22=(p22*V22)/(p11*V11/t11) %*u.K;
When calculating with units and calculus/equations have exponents ans becomes complicated. Is there som posibiliti to make this calculus with units, but keeping “normal/expected” form of ans?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!