Changeset 7634:fb4045978e5b


Ignore:
Timestamp:
12/13/07 10:38:31 (5 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Message:

Fix trac #1489 -- bug doing symbolic computations with certain small numbers -- reported by Matthias Hillenbrand.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/calculus/calculus.py

    r7618 r7634  
    196196    5 
    197197 
     198Simplifying expressions involving scientific notation: 
     199    sage: k = var('k') 
     200    sage: a0 = 2e-6; a1 = 12 
     201    sage: c = a1 + a0*k; c 
     202    2.000000000000000e-6*k + 12 
     203    sage: sqrt(c) 
     204    sqrt(2.000000000000000e-6*k + 12) 
     205    sage: sqrt(c^3) 
     206    (2.000000000000000e-6*k + 12)^(3/2) 
     207 
    198208The symbolic Calculus package uses its own copy of Maxima for 
    199209simplification, etc., which is separate from the default system-wide 
     
    235245                            PolynomialRing, ComplexField, 
    236246                            algdep, Integer, RealNumber) 
     247 
     248from sage.rings.real_mpfr import create_RealNumber 
    237249 
    238250from sage.structure.element import RingElement, is_Element 
     
    59825994        s = s.replace('=','==') 
    59835995 
    5984     #replace all instances of scientific notation 
     5996    #replace all instances of Maxima's scientific notation 
    59855997    #with regular notation 
    59865998    search = sci_not.search(s) 
    59875999    while not search is None: 
    59886000        (start, end) = search.span() 
    5989         s = s.replace(s[start:end], str(RR(s[start:end]))) 
     6001        r = create_RealNumber(s[start:end]).str(no_sci=2, truncate=True) 
     6002        s = s.replace(s[start:end], r) 
    59906003        search = sci_not.search(s) 
    59916004       
Note: See TracChangeset for help on using the changeset viewer.