Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: Suitable form of solution
Posted:
Feb 22, 2013 4:52 PM


"Milos Milenkovic" <m.milenkovic@mathworks.com> wrote in message news:kg8kib$5pb$1@newscl01ah.mathworks.com... > As Stiven said solution is based on via VPA like in this case => > http://www.mathworks.com/matlabcentral/newsreader/view_thread/263694 > > "Milos Milenkovic" <m.milenkovic@mathworks.com> wrote in message > <kg85ib$eor$1@newscl01ah.mathworks.com>... >> Please, look at this solution>
*snip*
>> Why this has to be in fractional form and by what command specify the >> solution of an equation in form of decimal numbers, or integer ..
Because Symbolic Math Toolbox prefers to keep the results of computations exact, not approximating them by decimal, until or unless you tell it to approximate using the DOUBLE function (to return the double precision approximation) or the VPA function (to return the approximation to a certain number of decimal places) on the result.
two = sym(2); three = sym(3); twothirds = two/three % fraction twothirdsD = double(twothirds) % double approximation twothirdsV = vpa(twothirds, 75) % approximation to 75 decimal places
4  (twothirdsD+twothirdsD+twothirdsD+twothirdsD+twothirdsD+twothirdsD) % not exactly 0 4  (twothirds+twothirds+twothirds+twothirds+twothirds+twothirds) % exactly 0
Note that DOUBLE will not work if your symbolic expression contains a variable that doesn't have a value, like (2/3)*t if t is not a variable. In that case use VPA.
*more snip*
 Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com



