I have a set of differential equations of the form:
x1dot = x3;
x2dot = x2;
x3dot = x1;
x4dot = x2 + integral(x1,t,tend)
I have the boundary condition for x1
, x2
at tstart
and x3
, x4
at tend
. Without the integral term it's a straight forward implementation using BVP4C
.
I am wondering if it is possible to have the previous solution for the states from the BVP solver which can be used for the integral.
One possibility is using ode45
and fsolve
in combination for the boundary value problem, where I can have the previous solution, but this approach is not as fast as the BVP setup.
I also feel that there may be some difficulty in convergence when I use the previous solution, x1
, for the integral.
Is there a better/quicker or easier way to solve this problem?
Set
x5 = integral(x1,t,tend)
then
x5dot = -x1 with x5(tend) = 0
Since x5dot + x3dot = 0
, it follows that x5 + x3 = C = const
. Therefore you can use the substitution x5 → C - x3
.
The constant C
is simply C = x3(tend) + x5(tend) = x3(tend)
(because x5(tend) = 0
).