I am doing numerical analysis where we work with differential equations but I have never had any classes on differential equations. It seems you can get by in an introductory numerical analysis course with just knowing what a differential equation is an how the initial value problem solving process works. So I know a few process for solving them numerically but I have never learned how to solve them mathematically.

Anyway, I would like to know how to 'create' differential equation for testing my numerical approximation algorithms against, but as I have never learned how to deal with them mathematically I don't know the process for creating them. Can someone show me a step by step process for creating simple differential equations?

If I have $y = 5x^2 +c$, $c$ being some constant

I can make a differential equation of the form -

$\frac{dy}{dx} = 10x$

But I want to have differential equations where the $\frac{dy}{dx}$ is dependent on not just $x$, but on $x$ and $y$.

What is the process for doing this?


To clarify, I am looking to create simple equations of the form $\frac{dy}{dx} = f(x,y)$, $y(0) = y_0$ with solutions $y$ that are also relatively simple. This is so I can then write out the first few iterations of RK methods by hand to see how it all works.

  • $\begingroup$ if $\frac{dy}{dx}$ is independent of both $x$ and $y$ then is a constant, say $c$ and the solution for that differential equation is $y(x)=cx+y(0)$ $\endgroup$
    – J L
    Nov 10, 2012 at 18:00

4 Answers 4


Consider the family of curves $\gamma_C$ given by an equation of the form $$F(x,y)=C\ ,\qquad(1)$$ where the function $$F:\ {\mathbb R}^2\to {\mathbb R}\,\quad (x,y)\to F(x,y)$$ is explicitly given; e.g. $F(x,y):=x^2+y^2$. "Locally" such a $\gamma_C$ is the graph of a function $x\mapsto y(x)$. It follows that the function $$x\mapsto\phi(x):=F\bigl(x, y(x)\bigr)$$ is identically equal to $C$. Therefore by the chain rule $$\phi'(x)=F_{.1}\bigl(x,y(x)\bigr)\cdot 1+ F_{.2}\bigl(x,y(x)\bigr)\cdot y'(x)\equiv0\ ,$$ where $F_{.1}$ denotes the partial derivative of $F$ with respect to the first entry, and similarly for $F_{.2}$. Solving the last equation for $y'(x)$ gives $$y'(x)\equiv -{F_{.1}\bigl(x,y(x)\bigr)\over F_{.2}\bigl(x,y(x)\bigr)}\ .$$ But this is saying that the function $x\mapsto y(x)$ satisfies the differential equation $$y'=-{F_x(x,y)\over F_y(x,y)}\ .\qquad(2)$$ Here the right side ($=: f(x,y)$) is a known (resp., easily computable) function of $x$ and $y$ which is independent of $C$. Therefore the equation $(2)$ can be considered as the differential equation characterizing the family of curves $\gamma_C$ defined by $(1)$.

Consider the following example: The set $\gamma_C$ of points $(x,y)$ whose distances to the "foci" $(\pm1,0)$ have given product $C>0$ is called a Cassini curve. The equation of this curve is given by $$F(x,y):=\bigl((x-1)^2+y^2\bigr)\bigl((x+1)^2+y^2\bigr)=C^2\ .$$ When $C=1$ this curve is called a lemniscate. In order to obtain the differential equation of the family of curves $\gamma_C$ we compute $$F_x=2(x-1)\bigl((x+1)^2+y^2\bigr)+2(x+1)\bigl((x-1)^2+y^2\bigr)=\ldots$$ and $$F_y=2y\bigl((x+1)^2+y^2\bigr)+2y\bigl((x-1)^2+y^2\bigr)=\ldots\quad.$$ After doing the calculations (and maybe some simplification) we can put down the differential equation $$y'=-{F_x(x,y)\over F_y(x,y)}=:f(x,y)\ ,$$ where now $f(x,y)$ is a certain definite expression in $x$ and $y$ not containing the parameter $C$.

Note that the above explanations do not take into account "singular points" or points where the tangent of the considered curve $\gamma_C$ is vertical.

  • $\begingroup$ Cheers for the detailed answer. However I'm not to sure what's going on in the differentiation part. I can't see how you got two $F$'s once you differentiated $\gamma$..What is actually happening in that differentiation, is it the chain rule? Would you be able to show me how to use to create a differential equation with a very simple example that uses actual functions? $\endgroup$
    – sonicboom
    Nov 10, 2012 at 20:45
  • $\begingroup$ @sonicboom: See my edit. $\endgroup$ Nov 10, 2012 at 21:36

I'm not entirely sure what you mean, but it sounds like you want to know how to differentiate implicitly. For instance, differentiating $x^{2}+y^{2}=25$ implicitly to get $\frac{dy}{dx}$ as a function of $x$ and $y$:

$$2x+2y\frac{dy}{dx}=0\implies \frac{dy}{dx}=-\frac{x}{y}$$

The process for doing this is by differentiating each term with respect to $x$ using the chain rule, for instance if we had $x^{2}+9xy^2+y^{4}=0$, then:



$$2x+y^{2}+2xy\frac{dy}{dx}+4y^{3}\frac{dy}{dx}=0 \implies (2xy+4y^{3})\frac{dy}{dx}=-2x-y^{2} \\ \therefore \frac{dy}{dx}=\frac{-2x-y^{2}}{2xy+4y^{3}}$$

I hope this answers your question?

  • $\begingroup$ I think that might be what I'm looking for..would you mind doing a simpler one? The solution $y$ to your $\frac{dy}{dx}$ seems pretty heavy when I put the equation into wolfram alpha. I've edited my original post to explain it better. $\endgroup$
    – sonicboom
    Nov 10, 2012 at 18:25

Here is an example of "making" a differential equation you may be interested in solving using numerical methods.

$$y = e^{-x^2}$$

$$y' = -2x e^{-x^2}$$

$$y' = -2x \left(e^{-x^2}\right)$$

$$y' = -2x \left(y\right)$$

$$y' = -2xy$$

The bottom equation would be a typical first order ODE that you would want to solve using something like Euler's Method or a Runge Kutta.

If you noticed it was actually quite easy to set this up. I took the derivative of something I knew and then found the original function in the derivative. Then I just replace that with a $y$ and pretend that I don't know the answer for $y$.


Usually the process to create differential equations from simple equations is by taking derivative of a variable based on the other ones, but speaking of how in the real world differential equations are created is like this:

Consider a society in which the rate of change of population to time (dp/dt) equals square of population (this is just an example in which "rate of change" depends on another variable), so we have :

dp/dt = p^2

This is now a first order non linear differential equation and you have a real world problem here exhibited in its mathematical form.

So solving this differential equation gives you all possible functions which show the amount of population at any given time: i.e, P= f(t)

Now using simple integration we get to this solution:

p = 1/(c - t)

In which c is all possible constants that yeild to our unique differential equation.

I hope you have now a clear idea of where differential equations come from.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .