Advice: Solving equations involving numerical integration

Suppose you want to solve an equation involving a function [Maple Math] , defined as a definite integral which Maple must evaluate numerically. For example, you might want to solve the equation [Maple Math] . Using calculus, it is not hard to prove that this has exactly one solution with [Maple Math] [Maple Math] . It is convenient to write the equation as [Maple Math] :

> F:= x -> Int(1/(t + exp(t)), t=0..x) + x;

[Maple Math]

We use the inert form Int rather than int , because int(1/(t+exp(t)), t=0..x) returns unevaluated. Now the following does not work:

> fsolve(F(x)=1, x = 0 .. 1);

Error, (in fsolve) should use exactly all the indeterminates

That is because of "premature evaluation": Maple first evaluates F(x) , obtaining an expression that includes the variable t , and fsolve objects to this. The usual cure for premature evaluation is to delay evaluation using quotes:

> fsolve('F(x)'=1, x = 0 .. 1);

[Maple Math]

This takes a rather long time to solve, since it requires evaluating the function [Maple Math] at many points, and each such evaluation requires another numerical integration. But another approach, based on differential equations, can be used. Note that [Maple Math] , with [Maple Math] . Now since [Maple Math] is a one-to-one function of [Maple Math] , we can just as well consider [Maple Math] as a function of [Maple Math] . It will satisfy the differential equation [Maple Math] with initial condition [Maple Math] , and what we want is [Maple Math] .

> de:= diff(x(F),F) = 1/(1/(x(F)+exp(x(F)))+1);

[Maple Math]

> soln:= dsolve({de, x(0)=0},x(F), numeric);

[Maple Math]

> soln(1);

[Maple Math]

This approach would not work in more general cases, e.g. an integral depending on a parameter whose value must be found. In those cases the solution must be found with fsolve .

See also: fsolve , dsolve/numeric

Maple Advisor Database, R. Israel 1997