From: Amisha Shah on
Dear Community,

I have one equation and one unknown but the unknown is imbedded in an integral.

For example:

x +5 = x^2 + integral (x*y2)dy (boundary from 0,1)

I would like to solve for x using lsqnonlin but unsure how to incorporate the integral into it.

Please help!

Thanks!

Amisha
From: Walter Roberson on
Amisha Shah wrote:

> I have one equation and one unknown but the unknown is imbedded in an
> integral.

> For example:
>
> x +5 = x^2 + integral (x*y2)dy (boundary from 0,1)

> I would like to solve for x using lsqnonlin but unsure how to
> incorporate the integral into it.

For something like that you can get exact answers using the symbolic
solver, if you have the symbolic toolkit.

In Maple notation it would be

> solve(x+5=x^2+int(x*y^2,y=0..1),x);

1/3-1/3*46^(1/2), 1/3+1/3*46^(1/2)

This does, of course, depend upon the expression being integrated being
fourth degree or less in x .
From: Roger Stafford on
"Amisha Shah" <ads(a)alum.wustl.edu> wrote in message <htsbk8$hk$1(a)fred.mathworks.com>...
> Dear Community,
>
> I have one equation and one unknown but the unknown is imbedded in an integral.
>
> For example:
>
> x +5 = x^2 + integral (x*y2)dy (boundary from 0,1)
>
> I would like to solve for x using lsqnonlin but unsure how to incorporate the integral into it.
>
> Please help!
>
> Thanks!
>
> Amisha

For the particular example you give, an x can be factored from the integral leaving a function of y whose integral you can easily solve by calculus. This leaves you a quadratic equation which you can also solve by hand.

However in general if you have an equation of the form

f(x) + int(g(x,y))dy = 0

you could define a function which accepts x and computes the left side of this equation by way of one of the integration functions and use this function's handle in a call to fzero or fsolve. You should be sure and write the function in such a manner that it can accept multiple values of x in a vector, which of course means multiple calls on the integration routine.

Roger Stafford