Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Suitable form of solution
Replies: 6   Last Post: Feb 22, 2013 4:52 PM

 Messages: [ Previous | Next ]
 Steven Lord Posts: 17,945 Registered: 12/7/04
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 =>
>
> "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
http://www.mathworks.com

Date Subject Author
2/22/13 Milos Milenkovic
2/22/13 Milos Milenkovic
2/22/13 Steven Lord
2/22/13 Milos Milenkovic
2/22/13 Milos Milenkovic
2/22/13 Milos Milenkovic
2/22/13 Steven Lord