Ask Your Question
0

Using numerical integration within solve or find_root

asked 2013-01-21 20:41:30 +0200

ZelenojZemlji gravatar image

Hi there,

I have a function of two variable, u and Z: F(u,Z).

I would like to know for what value of u the integral of this function is zero. Could someone please help me with the syntax to do so?

I think I want to do something like: find_root(numerical_integral(F,Z,-infinity,infinity),0,1)

U must be between 0 and 1: 0<=u<=1 F cannot be solved symbolically.

Thanks so much!

edit retag flag offensive close merge delete

Comments

1

A lambda expression might be useful here.

kcrisman gravatar imagekcrisman ( 2013-01-21 21:39:30 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-01-22 02:37:52 +0200

benjaminfjones gravatar image

Here's an example that I think does what you want. Notice in particular that numerical_integral returns a tuple (ans, err) so you need to extract the zero-th component of it before using it in find_root.

sage: F(u,z) = sin(z+u)
sage: find_root(lambda w: numerical_integral(lambda v: F(w, v),-pi/2,pi/2)[0], pi/2, 3*pi/2)
3.141592653589793
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-01-21 20:41:30 +0200

Seen: 324 times

Last updated: Jan 22 '13