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?
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It only takes a minute to sign up.Sign up to join this community
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)
 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)
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)