How this calculation works
Solve a small nonlinear first-order system with affine conditions at both endpoints using cubic collocation and residual-driven mesh refinement.
y′=f(x,y), B_a y(a)+B_b y(b)=c. On each panel enforce the fourth-order cubic collocation equation and control normalized differential residuals between nodes.A worked example
The system y1′=y2, y2′=2y1³ with y1(0)=1 and y1(1)=1/2 has the exact solution y1=1/(1+x), y2=-1/(1+x)². At x=1/2 these are 2/3 and -4/9.
Good to know
1–3 real states, polynomial RHS degree≤3 in x/states, exactly n affine endpoint conditions, 5–40 initial mesh nodes and max100 refined nodes. Cubic fourth-order collocation, analytic Jacobian and damped Newton with residual-driven refinement. Return one converged branch from user guess, residuals and termination; no uniqueness/completeness claim, singular endpoint terms or unknown free parameters.
Reference: SciPy solve_bvp collocation and residual control (opens in a new tab) ↗
Convert the problem to a first-order system
Write one polynomial expression for each state derivative, using x and state names y1 through yn. A second-order equation becomes a two-state system by assigning the second state to the first derivative. The calculator accepts one through three real states and polynomial degree at most three, which makes analytic state Jacobians available without finite-difference perturbations.
Supply exactly as many affine endpoint conditions as there are states. Use a1 through an for left endpoint values and b1 through bn for right endpoint values. Two conditions on the same endpoint are allowed algebraically but may define an initial-value problem rather than a genuinely two-point model. Having the correct number of conditions is necessary, yet it does not establish independence, solvability or uniqueness.
Compare this with the Boundary value differential equation calculator with finite differences. Existing boundary solver is linear y″+p(x)y′+q(x)y=f(x) with fixed endpoints and expressly excludes nonlinear equations. Solve a nonlinear first-order system with coupled endpoint residuals using collocation and an initial solution guess.
Understand the role of the initial guess
The initial mesh and state guesses initialize a nonlinear equation solve. They are not additional boundary conditions and they do not alter the differential equation. A good guess captures the approximate scale and branch of the desired solution, making the Newton iteration more likely to converge to that branch with reasonable mesh refinement.
Nonlinear boundary problems can have several solutions, one solution or no solution. Different initial guesses can converge to different branches. Returning one converged branch therefore does not establish that all solutions were found. If the iteration fails, the mathematical problem may still have a solution; the chosen initialization, conditioning or mesh limit may be the obstacle. The termination message must preserve that distinction.
How cubic collocation is assembled
On each mesh interval, a cubic polynomial links the two endpoint states and their derivatives. Its midpoint is computed consistently from those endpoint values and derivative estimates. Enforcing the differential equation at the midpoint leads to a Simpson-like collocation residual involving the left, middle and right derivative evaluations. All panels and endpoint conditions form one coupled nonlinear system.
Damped Newton iteration uses the analytic Jacobian of that system and reduces the step when a full update does not improve the residual measure. After the nonlinear solve, evaluate differential residuals away from the collocation points and refine panels whose normalized defects are too large. Checking only the equations used to build the polynomial can miss approximation error between those points, even when the discrete algebraic solve is excellent.
Verify a manufactured nonlinear solution
The default first state is y1=1/(1+x), whose derivative is -1/(1+x)². Taking that derivative as y2 satisfies the first equation exactly. Differentiating y2 gives 2/(1+x)³, which equals 2*y1³ and satisfies the second equation. The endpoint values of y1 are one and one half, matching both supplied boundary conditions.
At the midpoint, the exact states are two thirds and minus four ninths. The first-state derivative is also minus four ninths, while the second-state derivative is sixteen twenty-sevenths. These independent values test the returned continuous solution, derivative evaluation and sign conventions. A mesh-node-only test would be weaker because interpolation and residual errors can be largest between the nodes selected by the solver.
Read residuals rather than just plotted smoothness
The boundary residual measures how accurately the affine endpoint equations are met. The differential residual compares the derivative of the returned piecewise polynomial with f evaluated on that polynomial. Its normalization by a scale such as one plus the derivative magnitude prevents large derivative units from dominating every comparison. A small boundary residual alone does not establish that the interior ODE is well approximated.
The static figure shows the exact manufactured profile, mesh nodes and a separate residual concept. A smooth-looking line is expected from cubic interpolation, including after an inaccurate solve. Consult the residual estimates, node count and termination status before using numerical values downstream. The requested residual tolerance is a computational acceptance target, not a theorem bounding global solution error for every nonlinear boundary problem.
Interpret refinement and failure statuses
Begin with five through forty mesh nodes; the refined mesh may contain at most one hundred. Local refinement concentrates work where the differential defect is largest. A singular Newton matrix can indicate nonunique linearized behavior or poor initialization, while exhausting the node budget means that the requested accuracy was not resolved under the current resource limit. Neither status is an automatic proof that the original boundary problem is infeasible.
The implementation excludes singular endpoint terms and unknown free parameters. Polynomial input can still lead to blow-up, unstable branches or nearly dependent boundary equations. Check units and state scales, and provide a more informative guess before simply tightening tolerance. A failed computation should retain enough diagnostics to distinguish nonlinear iteration failure from a successful discrete solve that still needs more mesh resolution.
Choose collocation for a boundary problem
Boundary conditions at separated endpoints constrain the entire trajectory simultaneously. A shooting method instead guesses missing initial data and repeatedly solves an initial-value problem; it can be highly sensitive when trajectories amplify small starting errors. Collocation attacks a coupled mesh problem directly, which is useful for many such cases but does not remove nonlinear branch ambiguity.
Use an initial-value solver when all state values are given at the initial endpoint and forward integration is the intended task. Use this page when endpoint conditions and a continuous branch approximation are central. Save the equations, interval, endpoint conditions, initial guess and termination diagnostics together. Without the guess and branch context, two numerically valid outputs for the same nonlinear model may look contradictory when they actually represent different solutions.
A few questions, answered
Does convergence prove uniqueness?
No. The solver returns one branch reached from the supplied initial guess.
Why are there n boundary conditions?
A system of n first-order states requires n scalar endpoint constraints in this fixed-parameter formulation.
Is a tiny boundary residual enough?
No. Interior differential residuals must also be checked.
What does the node cap mean?
The requested residual target was not resolved within the allowed refined mesh size.