Not calculated when using Subs function

조회 수: 11 (최근 30일)
Deokjae Jeong
Deokjae Jeong 2016년 9월 15일
댓글: Deokjae Jeong 2016년 9월 17일
When using Subs function,the output of v is (14*2^(2/5)*3^(3/5)*15^(3/5)*25^(2/5))/75, which is 8.7615770046893.
Why the output is not simply 8.761577004689 ?
syms px py w v a
v=(w*(a/px)^a*((1-a)/py)^(1-a))
a=0.4
px=3
py=5
w=70
v=subs(v)

답변 (2개)

John D'Errico
John D'Errico 2016년 9월 15일
Because that is not the exact number.
simplify(v)
ans =
(14*3^(1/5)*10^(2/5))/5
I'm sure you can see that as soon as you decide to write it in decimal form, no matter what, you cannot write it exactly. And since this is the symbolic TB you are talking about, what do you expect?
vpa(v)
ans =
8.7615770046893145084508459712354
  댓글 수: 3
John D'Errico
John D'Errico 2016년 9월 16일
vpa will give you a decimal (but still in symbolic form) approximation to the number, yes. So will double, with fewer digits as a double precision number.
Deokjae Jeong
Deokjae Jeong 2016년 9월 17일
Thank you so much :)

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2016년 9월 15일
(14*2^(2/5)*3^(3/5)*15^(3/5)*25^(2/5))/75 is not 8.7615770046893 . The expression is only approximately 8.7615770046893 . A better approximation would be 8.761577004689314508450845971235390274526747228228561126229132624459900445322460260513472705827961752 and it can be shown that the result is irrational (and thus non-terminating). Another way of writing the expression is (14/75)*50^(2/5)*45^(3/5) which you can see involves fifth roots.
The purpose of the symbolic toolbox is to calculate exact solutions whenever possible. The decimal value you list is not an exact solution, only a decimal approximation of it.
If you want the decimal approximation, use vpa() or double()
  댓글 수: 1
Deokjae Jeong
Deokjae Jeong 2016년 9월 15일
Thank you so much :) So using VPA function is the solution !!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by