Advice: Solving equations involving numerical integration

Suppose you want to solve an equation involving a function F(x) , defined as a definite integral which Maple must evaluate numerically. For example, you might want to solve the equation Int(1/(t+exp(t)),t = 0 .. x) = 1-x . Using calculus, it is not hard to prove that this has exactly one solution with 0 < x `` < 1 . It is convenient to write the equation as F(x) = 1 :

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

F := proc (x) options operator, arrow; Int(1/(t+exp...

We use the inert form Int rather than int , because int(1/(t+exp(t)), t=0..x) returns unevaluated. Now we can solve the equation numerically:

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


This takes a rather long time to solve, since it requires evaluating the function F(x) at many points, and each such evaluation requires another numerical integration. But another approach, based on differential equations, can be used. Note that dF/dx = 1/(x+exp(x))+1 , with F(0) = 0 . Now since F is a one-to-one function of x , we can just as well consider x as a function of F . It will satisfy the differential equation dx/dF = 1/(1/(x+exp(x))+1) with initial condition x(0) = 0 , and what we want is x(1) .

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

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

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

soln := proc (rkf45_x) local i, rkf45_s, outpoint, ...

> soln(1);

[F = 1, x(F) = .6122555623019387]

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