How can I now obtain numerical values of $y$ from already obtained numerical values of $\frac{dy}{dx}$?

69 Views Asked by At

I have numerically solved a differential equation and obtained numerical values of $\frac{dy}{dx}$ at different points of the domain space. How can I now obtain numerical values of $y$ from these values of $\frac{dy}{dx}$?

It is not possible to obtain $y$ directly from the differential equation. Finding $\frac{dy}{dx}$ itself required computation of an elliptic integral.

I don't want a computer algorithm; I want to write it myself. Just tell me the process to do it.

3

There are 3 best solutions below

4
On

Hint.

If you have $f'(x_i)$ for a set of points $\{x_i|\; i=0,1,2,\cdots n\}$ and the value $f(x_0)$ you can estimate the value of the function at the same points using $f(x_i)=f(x_{i-1})+f'(x_i)(x_i-x_{i-1})$.

The approximation is good if the intervals $x_i-x_{i-1}$ are small. Possibly, interpolation methods can be used as suggested here.

1
On

You can do a centered integration with $f(x_i)=f(x_{i-1})+(x_i-x_{i-1})(f'(x_i)+f'(x_{i-1}))/2$

2
On

$$\frac{dy}{dx}=g(y)$$ If I well understand your problem, your data set is : $$(g_1\:,\:y_1)\:,\:(g_2\:,\:y_2)\:,\:...\:,\:(g_i\:,\:y_i)\:,\:\:,\:...\:,\:(g_n\:,\:y_n)$$ and you want to obtain $x_1\:,\:x_2\:,\:...\:,\:x_i\:,\:...\:,\:x_n$

What you need is the numerical integration of $$\frac{dx}{dy}=\frac{1}{g(y)}\quad\to\quad x=\int\frac{dy}{g(y)}+\text{constant}$$ $$x_{i+1}\simeq x_i+\frac12\left(\frac{1}{g_{i+1}}+\frac{1}{g_{i}}\right)(y_{i+1}-y_{i})\quad\text{ from }\quad i=1\quad\text{ to }\quad i=n-1.$$ You have to set a first value $x_1$ because the low bound of any definite integral must be defined. If not, an arbitrary constant must be added to the integral. This first point cannot come from the data set. It has to be derived from the wording of the problem and modeling. If not, for example, set $x_1=0$ , compute all the $x_i$ and afterwards, if necessary, translate the whole in adding a convenient constant to make it consistent with the wording of the problem.

IN ADDITION:

if your data set is : $$(g_1\:,\:x_1)\:,\:(g_2\:,\:x_2)\:,\:...\:,\:(g_i\:,\:x_i)\:,\:\:,\:...\:,\:(g_n\:,\:x_n)$$ and you want to obtain $y_1\:,\:y_2\:,\:...\:,\:y_i\:,\:...\:,\:y_n$

The principle is the same.

$$y_{i+1}\simeq y_i+\frac12\left(g_{i+1}+g_{i}\right)(x_{i+1}-x_{i})\quad\text{ from }\quad i=1\quad\text{ to }\quad i=n-1.$$ You have to set a first value $y_1$ because the low bound of any definite integral must be defined. If not, an arbitrary constant must be added to the integral. This first point cannot come from the data set. It has to be derived from the wording of the problem and modeling. If not, for example, set $y_1=0$ , compute all the $y_i$ and afterwards, if necessary, translate the whole in adding a convenient constant to make it consistent with the wording of the problem.