Solve a differential equation when the right-hand side of the equation is a non-parametric curve

curvesordinary differential equations

I just asked another question (see here: How to calculate the shape of a curve given y coordinates and slope?) and was advised by the user who answered my question to ask a new question. I would appreciate any help on this topic. As in the previous thread, I apologise in advance if I'm not using the proper terminology, but I'm learning.

Although my problem is stated in the linked thread, I'll re-state it here with the details that required me to open a new thread.

My Question:

I would like to figure out the shape of a curve given the information in the following graph:

enter image description here

On the y axis, I'm showing the slope of the curve whose shape I'm trying to find. On the x axis, I'm showing the y-coordinate of the curve corresponding to that slope. I am missing information about the x-coordinates of my curve. The different dots are different measurements I have made in an experiment.

First, I fit a non-parametric curve to my data (in this case, a loess regression curve):

enter image description here

This gives me a non-parametric description of the relationship between dy/dx of the curve whose shape I'm trying to find out, and its y coordinates.

In this case, I can intuitively understand that my mystery curve will have a sigmoidal shape because at low and high values of y, the slope is small, and at intermediate values of y, the slope is high.

I just learnt, in the previous question, that my problem involves solving a differential equation. However, there are times when I don't have an equation describing the relationship between dx/dy and y (as in the previous question that I asked), but instead I have a non-parametric curve like a loess (local regression) curve or a spline.

How could I solve this problem?

Many thanks in advance!

Best Answer

FIRST MEHOD :

Fit a polynomial equation with the data. The curve looks like a parabola. $$y'=\frac{dy}{dx}\simeq ax^2+bx+c$$ Usual linear regression leads to $\begin{cases} a\simeq -0.096 \\ b\simeq 1.91 \\ c\simeq 1.26 \end{cases}$

enter image description here

Note that the data is not accurate because it comes from a numerical scan of the graph given by Ender instead of a numerical table.

Of course a better fit should be obtained with a polynomial equation of higher degree. But this is of no interest with such a data of bad accuracy.

Integrating Eq.$(1)$ leads to the approximate solution of the differential equation : $$y=\frac{a}{3}x^3+\frac{b}{2}x^2+cx+C$$ No boundary condition is specified in the question. As a consequence the integration constant $C$ cannot be determined.

However we need a numerical value for $C$ in order to proceed to further numerical calculus. Supposing that the condition is $y(x_1)=0$ the constant would be $C=-(\frac{a}{3}x_1^3+\frac{b}{2}x_1^2+cx_1)\simeq -0.258$

Of course, if another boundary condition is specified, one have to compute the corresponding value of $C$ and change it in the next numerical calculus.

The result of the first method is represented in the next figure :

enter image description here

This result and the approximate equation $y=\frac{a}{3}x^3+\frac{b}{2}x^2+cx+C$ are valid on the range of $x$ determined by the original data, about $0<x<20$. Outside this range one cannot guaranty the correctness.

SECOND METHOD :

Numerical integration of the data $(x_1,y'_1),\:...\:, (x_k,y'_k),\:...\:, (x_{20},y'_{20})$

With the same assumption $y(x_1)=0$ than in the first method, again one would have to add a convenient constant if the boundary condition was different.

$$y_1=0\quad;\quad y_k=y_{k-1}+\frac12\left(y'_{k-1}+y'_k\right)(x_k-x_{k-1})\qquad [\:2\leq k\leq 20\:]$$

enter image description here

The results of both methods are very close. The curves are almost indistinguishable : drawn in red for the first method and blue for the second.

Related Question