Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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: 17,944
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" <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




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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.