First time here? Check out the FAQ!

Ask Your Question
0

Using numerical integration within solve or find_root

asked 12 years ago

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!

Preview: (hide)

Comments

1

A lambda expression might be useful here.

kcrisman gravatar imagekcrisman ( 12 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 12 years ago

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
Preview: (hide)
link

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: 12 years ago

Seen: 427 times

Last updated: Jan 22 '13