Initial-value problems

Maple is very good a finding analytic solutions to initial-value problems if a solution exists.

A first-order initial-value problem

Let us consider a first-order initial-value problem:

[> dsolve( {D(y)(t) = -y(t) + 3, y(0) = 1}, {y(t)} );

$y(t) = 3 - 2e^{-t}$

You will note that the first argument is a set that contains both the differential equation and the initial conditions. Recall that if y is a function, then D(y) is the derivative of the function, and D(y)(t) is that derivative evaluated at $t$.

[> dsolve( {D(y)(t) = -y(t)^2 + 3, y(0) = 1}, {y(t)} );

$y \! \left(t \right) = \sqrt{3}\, \tanh \! \left(\frac{\left(\sqrt{3}\, \mathrm{arctanh} \left(\frac{\sqrt{3}}{3}\right)+3 t \right) \sqrt{3}}{3}\right)$

If dsolve(...) cannot find a solution, it returns a null sequence. This author knows better than to put an example where Maple does not return a solution, as the maintainer of dsolve(...) has an incredible ability to constantly extend the functionality of this tool.

Higher-order initial-value problems

You can have higher-order initial-value problems, and you will recall that the second derivative of a function y may be written as either D(D(y)) or (D@@2)(y), but the second looks clenaer.

[> dsolve( {(D@@2)(y)(t) = y(t) + t*D(y)(t) + 3, y(0) = 1, D(y)(0) = 0}, {y(t)} );

$y \! \left(t \right) = 4 \,e^{\frac{t^{2}}{2}}-3 \,e^{\frac{t^{2}}{2}} e^{-\frac{t^{2}}{2}} $

If you are using the second derivative a lot, you can always assign:

[> D2 := D@@2:
   D2(y)(t);

$D^{(2)}(y)(t)$

A system of first-order initial-value problems

You can provide Maple with a system of IVPs:

[> dsolve( {D(x)(t) + D(y)(t) = y(t), D(x)(t) - D(y)(t) = x(t), y(0) = 1, x(0) = 2},
           {x(t), y(t)} );

$\left\{x \! \left(t \right) = e^{\frac{t}{2}} \left(2 \cos \! \left(\frac{t}{2}\right)+\sin \! \left(\frac{t}{2}\right)\right) ,\right.$
$\left. y \! \left(t \right) = e^{\frac{t}{2}} \left(\cos \! \left(\frac{t}{2}\right)-2 \sin \! \left(\frac{t}{2}\right)\right) \right\}$

Please note the issue with the output: if there is only one function being solved for, dsolve(...) returns an equation of that function evaluated at $t$ equated to the solution; however, if there is more than one function being solved for, a set of such equations is returned. This inconsistency may be frustrating, especially when solve( {...}, {...} ) consistently returns the solutions as an expression sequence of sets of equations.

A system of higher-order initial-value problems

You can, of course, have a system of higher order initial-value problems:

[> solns := dsolve( {
      (D@@2)(x)(t) + D(y)(t) + t = y(t), D(x)(t) + (D@@2)(y)(t) = x(t),
      y(0) = 1, x(0) = 2, D(x)(0) = 3, D(y)(0) = 4
}, {x(t), y(t)} );

$solns := \left\{x \! \left(t \right) = -\frac{\sqrt{3}\, e^{\frac{t}{2}} \sin \! \left(\frac{\sqrt{3}\, t}{2}\right)}{3}+e^{\frac{t}{2}} \cos \! \left(\frac{\sqrt{3}\, t}{2}\right)+\left(\frac{1}{2}+\frac{7 \sqrt{5}}{10}\right) e^{\frac{\left(\sqrt{5}-1\right) t}{2}}+\left(\frac{1}{2}-\frac{7 \sqrt{5}}{10}\right) e^{-\frac{\left(\sqrt{5}+1\right) t}{2}} ,\right.$ $\left.y \! \left(t \right) = \frac{\sqrt{3}\, e^{\frac{t}{2}} \sin \! \left(\frac{\sqrt{3}\, t}{2}\right)}{3}-e^{\frac{t}{2}} \cos \! \left(\frac{\sqrt{3}\, t}{2}\right)+\left(\frac{1}{2}+\frac{7 \sqrt{5}}{10}\right) e^{\frac{\left(\sqrt{5}-1\right) t}{2}}+\left(\frac{1}{2}-\frac{7 \sqrt{5}}{10}\right) e^{-\frac{\left(\sqrt{5}+1\right) t}{2}}+t +1 \right\} $

[> eval( solns, t = 0 );

${x(0) = 2, y(0) = 1}$

[> eval( map( diff, solns, t ), t = 0 );

$\left\{ \left(\frac{d}{d t}x \! \left(t \right)\right)\bigg|_{\left\{t = 0\right\}} = \left(\frac{1}{2}+\frac{7 \sqrt{5}}{10}\right) \left(\frac{\sqrt{5}}{2}-\frac{1}{2}\right)+\left(\frac{1}{2}-\frac{7 \sqrt{5}}{10}\right) \left(-\frac{\sqrt{5}}{2}-\frac{1}{2}\right) ,\right.$ $\left. \left(\frac{d}{d t}y \! \left(t \right)\right)\bigg|_{\left\{t = 0\right\}} = 1+\left(\frac{1}{2}+\frac{7 \sqrt{5}}{10}\right) \left(\frac{\sqrt{5}}{2}-\frac{1}{2}\right)+\left(\frac{1}{2}-\frac{7 \sqrt{5}}{10}\right) \left(-\frac{\sqrt{5}}{2}-\frac{1}{2}\right) \right\} $

[> simplify( eval( map( diff, solns, t ), t = 0 ) );

$\left\{ \left(\frac{d}{d t}x \left(t \right)\right)\bigg|_{\{t = 0\}} = 3,\right.$
$\left. \left(\frac{d}{d t}y \left(t \right)\right)\bigg|_{\{t = 0\}} = 4\right\} $

Note that this says: the deriviative of $x(t)$ with respect to $t$ evaluated at $t = 0$ is $3$, with a similar statement for $y(t)$, so these solutions do indeed satisfy all four initial values.