On 03/30/2010 08:31 AM, Jared Schlieper wrote:
Greetings,

I am in the process of converting calculus 3 assignments from
Mathematica to Sage and came upon an error I can't figure out.

Trying to find the mass of a region bounded by two functions(g1,g2)
with a given density. Below is the code,

x, y = var('x ,y')
density=e^(sqrt(x))+e^(y^2/2)
g1=e^(2*x)-1
g2=5-5*(x-1)^2
p=plot(g1,0,1)
p+=plot(g2,0,1,color='red')
show(p)
b=(g2-g1).find_root(.7,1.0,x)
a=(g2-g1).find_root(-.1,.2,x)
f=integral(density,y,g1,g2)
numerical_integral(f, a, b)

This results in a TypeError: float() argument must be a string or a
number

I have tried various changes and still the same error. My thought is
the error is due the error function that results from the first
integration. Am I missing something?


Nope, it's a bug. The problem is that Sage tries to automatically compile f into a version that is fast to evaluate, but does not handle complex numbers. You have complex numbers in f, so it fails.

Apparently f.nintegral does not try to compile f into a fast version, but uses Maxima to do the numerical integration.

Do you mind sharing your worksheets? I am teaching calc 3 this semester and next semester as well, and I'd be interested in seeing them.

Thanks,

Jason

--
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
URL: http://www.sagemath.org

To unsubscribe from this group, send email to sage-support+unsubscribegooglegroups.com or 
reply to this email with the words "REMOVE ME" as the subject.

Reply via email to