octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #51748] vpa producing strange results


From: Luis Mendo
Subject: [Octave-bug-tracker] [bug #51748] vpa producing strange results
Date: Mon, 14 Aug 2017 05:59:27 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36

URL:
  <http://savannah.gnu.org/bugs/?51748>

                 Summary: vpa producing strange results
                 Project: GNU Octave
            Submitted by: lmendo
            Submitted on: Mon 14 Aug 2017 09:59:26 AM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Inaccurate Result
                  Status: None
             Assigned to: None
         Originator Name: Luis Mendo
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 4.2.1
        Operating System: Any

    _______________________________________________________

Details:

Running these statements in Octave


vpa('5^2',30)
vpa('sqrt(5)^4',30)
vpa('.5',30)
vpa('(5^.5)^4',30)


produces the following results, the fourth of which is not correct:


ans = (sym) 25.0000000000000000000000000000
ans = (sym) 25.0000000000000000000000000000
ans = (sym) 0.500000000000000000000000000000
ans = (sym) 25.0000000000000035527136788005


This is strange, specially considering that .5 is represented exactly as a
float (see third statement).

For reference, SymPy produces the correct result:


from sympy import *
print(N(sqrt(5)**4, 30))
print(N(5**2, 30))


gives


25.0000000000000000000000000000
25.0000000000000000000000000000





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?51748>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]