I found that the error occurs only if I take r = float. In the case if
r = int I can get an expression but I can't convert in using .n()
The term I get without .n() is

step4: definition of the velocity dispersion
100000

                              inf
                             /
                             [                    2
        1.85669614564486E+10 I    (((10628820000 x  + 17218688400 x
                             ]
                             /
                              1
 + 6973568802) log(100 x + 81) + 17218688400 x + 10460353203)
               2                                  1062882 log(81) +
1594323
/(20000000000 x  + 32400000000 x + 13122000000) -
-------------------------)
                                                           2000000
   2                            3
/(x  (1.234567901234568 x + 1.0) ) dx


and with .n() I get the following error

Traceback (most recent call last):
  File "friction.py", line 25, in <module>
    print sig2(1).n()
  File "/home/florian/sage/sage-3.4/local/lib/python2.5/site-packages/
sage/calculus/calculus.py", line 1512, in numerical_approx
    approx = self._complex_mpfr_field_(ComplexField(prec))
  File "/home/florian/sage/sage-3.4/local/lib/python2.5/site-packages/
sage/calculus/calculus.py", line 5710, in _complex_mpfr_field_
    return self._convert(field)
  File "/home/florian/sage/sage-3.4/local/lib/python2.5/site-packages/
sage/calculus/calculus.py", line 5637, in _convert
    return typ(g)
  File "/home/florian/sage/sage-3.4/local/lib/python2.5/site-packages/
sage/rings/complex_field.py", line 255, in __call__
    return Parent.__call__(self, x)
  File "parent.pyx", line 283, in
sage.structure.parent.Parent.__call__ (sage/structure/parent.c:3653)
  File "coerce_maps.pyx", line 81, in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/
structure/coerce_maps.c:2793)
  File "coerce_maps.pyx", line 76, in
sage.structure.coerce_maps._call_ (sage/structure/coerce_maps.c:2700)
  File "/home/florian/sage/sage-3.4/local/lib/python2.5/site-packages/
sage/rings/complex_field.py", line 279, in _element_constructor_
    return x._complex_mpfr_field_( self )
  File "/home/florian/sage/sage-3.4/local/lib/python2.5/site-packages/
sage/calculus/calculus.py", line 5710, in _complex_mpfr_field_
    return self._convert(field)
  File "/home/florian/sage/sage-3.4/local/lib/python2.5/site-packages/
sage/calculus/calculus.py", line 5631, in _convert
    fops = [typ(op) for op in self._operands]
  File "/home/florian/sage/sage-3.4/local/lib/python2.5/site-packages/
sage/rings/complex_field.py", line 255, in __call__
    return Parent.__call__(self, x)
  File "parent.pyx", line 283, in
sage.structure.parent.Parent.__call__ (sage/structure/parent.c:3653)
  File "coerce_maps.pyx", line 81, in
sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/
structure/coerce_maps.c:2793)
  File "coerce_maps.pyx", line 76, in
sage.structure.coerce_maps._call_ (sage/structure/coerce_maps.c:2700)
  File "/home/florian/sage/sage-3.4/local/lib/python2.5/site-packages/
sage/rings/complex_field.py", line 279, in _element_constructor_
    return x._complex_mpfr_field_( self )
  File "/home/florian/sage/sage-3.4/local/lib/python2.5/site-packages/
sage/calculus/calculus.py", line 1746, in _complex_mpfr_field_
    raise TypeError
TypeError

But in principle I would like to use floats for r and therefore the
problem stated in my first thread is still valid
thank you very much for any advice
with best regards
florian
... who becomes more and more frustrated using sage...
p.s. I evaluated the integral using a for loop and this works very
well see below

def sig2(r):
    grav_const = 4.3e-06
    pi = 3.14159265358979323846

    if r == 0:
       return 0

    max_int = 100
    step = max_int/1000.;

    sigma2 = 0.;
    mass_r = mass(r);
    volume_old = (4./3.)*pi*r**3;

    sys.setrecursionlimit(100000)
    print sys.getrecursionlimit()

    for i in range(0,1000):
       radius = r + i*step
       volume_new = (4./3.)*pi*radius**3
       mass_r = mass_r + (volume_new-volume_old)*rho(radius)
       sigma2 = sigma2 + mass_r*rho(radius)/(radius**2)
       volume_old = volume_new

    return step*grav_const*sigma2/rho(r)




--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to