7.4 Exponential Change and Separable Differential Equations

We've already taken a first look at symbolic differential equation solvers in the context of simple IVPs of the form ${\displaystyle \left\{\begin{array}{l}\frac{dy}{dx}=f(x)\\y(0)=y_0\end{array}\right.}$. This page applies the same methods to solve some less trivial separable differential equations.

Octave / MATLAB

Mathematica

Sage


Octave / MATLAB

Exponential change

Let's feed dsolve() the differential equation that models any function whose rate of change is proportional to its value.

>> syms k y0 t y(t) >> dsolve( diff(y)==k*y, y(0)==y0 ) ans = y0*exp(k*t)

MATLAB has produced the general solution.

Separable differential equations

Here we give dsolve() the equation ${\displaystyle \frac{dy}{dx}=(1+y)e^x}$ without any side conditions.

>> syms x y(x) >> dsolve( diff(y)==(1+y)*exp(x) ) ans = C4*exp(exp(x)) - 1

MATLAB has returned a one-parameter family of solutions to the differential equation. C4 represents an arbitrary constant.

The next example shows that we don't necessarily need to solve our differential equation algebraically for $\frac{dy}{dx}$ before passing it to dsolve().

>> syms x y(x) >> dsolve( y*(x+1)*diff(y)==x*(y^2+1) ) ans = (exp(C7 + 2*x - 2*log(x + 1)) - 1)^(1/2) -(exp(C7 + 2*x - 2*log(x + 1)) - 1)^(1/2) i -i

If the differential equation above modelled a necessarily real-valued quantity $y$, then of course the non-real singular solutions $\pm i$ could be dismissed. It may appear that the interesting pair of solutions is only valid for $x>-1$. Note, however, that MATLAB's log() is a complex extension of the natural log function. This complex log is not only defined for negatives, it also outputs a constant imaginary part for negative inputs which may be cancelled by setting the imaginary part of C7 appropriately. So in fact MATLAB's solution set includes real-valued solutions on $x<-1$. Of course examining the differential equation itself quickly reveals that there can't be a real-valued solution on any interval that includes $x=-1$.


Mathematica

Exponential change

Separable differential equations

Notice that in the last example Mathematica did not produce the singular solutions $y=\pm i$.


Sage

Exponential change

Separable differential equations