The Math Forum

Search All of the Math Forum:

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

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 18,038
Registered: 12/7/04
Re: Suitable form of solution
Posted: Feb 22, 2013 4:52 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Milos Milenkovic" <> wrote in message
> As Stiven said solution is based on via VPA like in this case =>
> "Milos Milenkovic" <> wrote in message
> <kg85ib$eor$>...

>> Please, look at this solution>


>> 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

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
To contact Technical Support use the Contact Us link on

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.