# How to find a numerical solution for a differential equation with constraints?

I want first to apologize for my poor english level ^^ Let me present my issue.

I want resolve numerically (I use Python) for x in [0;1] the following differential equation : $$dy/dx = a(y - y^2)$$ with a being a positive constant.

However, i don't have any initial condition but a constraint which is $$\displaystyle \int_{0}^{1} y(x) \, \mathrm{d}x = y_{0}$$, with 0 < y0 < 1 a constant. The problem is that I don't know how to add such a constraint.

What I tried to do is to find find a value for $$y(0)$$ that respects the constraint. However, I think there might be other solution, with other values for $$y(0)$$, that might also respect the constraint : there isn't necessarily the uniqueness of the solution.

Is there any known methods to resolve such equations without initial conditions but with such a constraint ? If you have any links that could be useful, I would take it with pleasure.

First hint: This side is "mathematica.stackexchange.com" (not python ;-) )

Second hint: Try to introduce a new function z[x]=Integrate[y[u],{u,0,x}] from which followws z'[x]==y[x]. Your constraint now becomes z[1]== y0 !

Mathematica evaluates

DSolveValue[{z''[x] == a (z'[x] - z'[x]^2), z[1] == y0}, z, x]
(*Function[{x}, (a y0 - Log[E^a + E^C[1]] + Log[E^(a x) + E^C[1]])/a]*)


Integration parameter C[1] has to be adapted to a second boundary condition. Hope it helps.

• (+1) for helping some “Python guy” learn some symbolic computation with WL. Dec 19, 2020 at 15:19