答案1
这不是尝试使用 LaTeX 解决二阶微分方程(尽管可以做到)。解析地解决微分方程并绘制解要容易得多。
\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}
{\addplot[color=blue,no marks,smooth] {ysol(x,1,#1)};}
\end{axis}
\begin{axis}[ymin=-5,ymax=5,domain=-2:4,width=0.45\textwidth,xshift=.5\textwidth,
title={$y'(0)=1$ and $y(0)$ varies.}]
\pgfplotsinvokeforeach{-3,-2,-1,0,1,2,3}
{\addplot[color=blue,no marks,smooth] {ysol(x,#1,1)};}
\end{axis}
\end{tikzpicture}
\caption{Solutions of $y''+3y'+2y=0$.}
\label{fig:sols}
\end{figure}
\end{document}