0
$\begingroup$

Consider the equations

$$\int_0^L \mathbf W(\mathbf u, s) \, \mathrm ds = \mathbf 0$$

where $0 \leq s \leq L$ and $\mathbf u$ is a vector of constants.

Numerically, what is the best way to determine $\mathbf u$ that satisfy the equations?

$\endgroup$
1
  • 2
    $\begingroup$ I think this isn't what's usually called an integral equation: en.wikipedia.org/wiki/Integral_equation, it's just a regular equation that happens to involve an integral. In other words, define the function $f(u) = \text{l.h.s.}$, and just apply a regular multidimensional root finder to $f(u)=0$. $\endgroup$
    – Kirill
    Oct 8, 2016 at 1:22

1 Answer 1

2
$\begingroup$

Like what @Kirill says, write a script that defines $f(u)$ to be a function that approximates the integral. Thus all that you need to is solve $f(u)=0$ which can use standard root finding tools like Newton's method.

You're best choice for this is probably Julia. Using the built in quadgk function for Gauss-Kronrad quadrature, you can define the f function via:

f(u) = quadgk((x)->W(u,x),0,L)[1]

(the [1] is because quadgk returns a tuple where the first part is the integral and the second part is the error estimate, so this function ignores the error estimate and just returns the integral approximation). Note that (x)->W(u,x) is using what's known as a closure: it makes an anonymous function g(x) = W(u,x) where it sticks in the value of u, allowing you to easily integrate among the x. Since Julia v0.5 compiles the anonymous functions as generic functions, this will be very fast.

Then you just have to solve the root finding problem. I particularly like the library NLSolve. Since this function is not in place, we would use the command

using NLsolve
nlsolve(not_in_place(f),initial_u)

where initial_x is a guess for the final value of u. This will use finite differencing. We can many times make it faster and more accurate by enabling auto-differentiation:

nlsolve(not_in_place(f),initial_u,autodiff = true)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.