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: How to import data without losing much precision
Replies: 5   Last Post: Dec 3, 2012 9:44 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Nasser Abbasi

Posts: 5,661
Registered: 2/7/05
Re: How to import data without losing much precision
Posted: Dec 3, 2012 9:39 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 12/3/2012 4:10 PM, Steven_Lord wrote:

> Symbolic arrays from Symbolic Math Toolbox are generally arbitrary
> precision, but make sure you don't limit yourself prior to the construction.
> For instance:
>
> t = 3^(1/3);
> x1 = sym(t);
> x2 = sym(3)^(1/3);
>
> x1 and x2 will not be exactly the same as you can see with VPA. In the case
> of x1 we took the cube root of 3 in double precision, while in the case of
> x2 we converted 3 into a symbolic expression then took the cube root
> symbolically.
>


Another way to see this is to do

x3 = sym('3^(1/3)')

now x3 and x2 are the same:

------------------------
EDU>> vpa(x3)
1.4422495703074083823216383107801

EDU>> vpa(x2)
1.4422495703074083823216383107801
--------------------------------

using '' protects the expression in question
from premature evaluation until it gets safe to the
symbolic toolbox home

--Nasser





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.