# Graphing slope fields with multiple solutions (with different initial slopes, and different initial values)

Can anybody help me to draw these figures in Latex? Sorry I'm new in Latex, so I really don't know how to do it. And is it possible to do it, where you can actually see the slope field (I know you really can't in the picture)? And how would I do, if I only wan't the x-axis and y-axis to be shown, and not the whole rectangle, as they have done in the picture? Hope somebody can help a new person in Latex!

• Welcome! This has been achieved in this answer. – user194703 Mar 16 '20 at 16:55
• I see. Thanks. But what if I also want the explaining text in the slope field. Like y(0)=-3 etc, with a line to the particular solution that satisfy that condition? And the dot? Is that possible? – Jasmin Hansen Mar 16 '20 at 17:04

This is not an attempt to solve a second order differential equation with LaTeX (even though it can be done). It is much easier to solve the differential equation analytically and to plot the solutions.

\documentclass[fleqn]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
The equation
$y''+3y'+2y=0$
has the solution
$y(x)=a\,\mathrm{e}^{-x}+b\,\mathrm{e}^{-2x}\;,$
where $a$ and $b$ are fixed by the boundary conditions. Demanding that
$y(0)=u\quad\text{and}\quad y'(0)=v$
the solution becomes (cf.\ Figure~\ref{fig:sols})
$y(x)=(2\,u+v)\,\exp(-x)+(-u-v)\,\exp(-2*x)\;.$

\begin{figure}[h]
\centering
\begin{tikzpicture}[declare function={%
ysol(\x,\u,\v)=(2*\u+\v)*exp(-\x)+(-\u-\v)*exp(-2*\x);}]
\begin{axis}[ymin=-3,ymax=3,domain=-1:5,width=0.45\textwidth,
title={$y(0)=1$ and $y'(0)$ varies.}]
\pgfplotsinvokeforeach{-6,-4,-2,0,2,4,6}
title={$y'(0)=1$ and $y(0)$ varies.}]
\caption{Solutions of $y''+3y'+2y=0$.}