这是曲线之间的面积。
过了一天,我发现了如何在 LaTeX (Miktex) 中做到这一点:
\documentclass[10pt]{article}
\usepackage{pstricks-add}
\begin{document}
\begin{pspicture}(-3.5,-0.5)(4,7)
\begin{psclip}{
\psplot[linestyle=none,algebraic,plotpoints=2000]{-3}{3}{x^2+1}%
\psline[linestyle=none,algebraic,plotpoints=2000](-1,1)(-1,2)(2,5)(2,1)
}%
\psframe*[linecolor=cyan,fillstyle=solid](-1,1)(2,5)
\end{psclip}
\psplot[algebraic,plotpoints=2000,yMaxValue=5.6]{-2.3}{2.3}{x^2+1}
\psplot[algebraic,plotpoints=2000]{-3.5}{2.5}{x+3}
\psaxes{->}(0,0)(-3.5,-.9)(4,6.5)
\uput[-90](3.9,-.2){$x$}
\uput[-135](-.2,6.7){$y$}
\end{pspicture}
\end{document}
奇怪的是,下面的代码不起作用:
\documentclass[10pt]{article}
\usepackage{pstricks-add}
\begin{document}
\begin{pspicture}(-3.5,-0.5)(4,7)
\begin{psclip}{
\psplot[linestyle=none,algebraic,plotpoints=2000]{-1.2}{2.2}{x^2+1}%
\psplot[linestyle=none,algebraic,plotpoints=2000]{-1.2}{2.2}{x+3}
}%
\psframe*[linecolor=cyan,fillstyle=solid](-1,1)(2,5)
\end{psclip}
\psplot[algebraic,plotpoints=2000,yMaxValue=5.6%,linecolor=cyan
]{-2.3}{2.3}{x^2+1}
\psplot[algebraic,plotpoints=2000]{-3.5}{2.5}{x+3}
\psaxes{->}(0,0)(-3.5,-.9)(4,6.5)
\uput[-90](3.9,-.2){$x$}
\uput[-135](-.2,6.7){$y$}
\end{pspicture}
\end{document}
看起来问题出在像 f(x)= ax + b 这样的函数上。
我对么?
答案1
psclip
将内部使用的曲线包裹起来\pscustom
,并确保括一个空格。为此,我交换了线性函数的起点/终点x+3
:
\documentclass{article}
\usepackage{pstricks-add}
\begin{document}
\begin{pspicture}(-3.5,-0.5)(4,7)
\begin{psclip}{
\pscustom[linestyle=none,algebraic,plotpoints=2000]{
\psplot{-1.2}{2.2}{x^2+1}%
\psplot{2.2}{-1.2}{x+3}
}
}%
\psframe*[linecolor=cyan,fillstyle=solid](-1,1)(2,5)
\end{psclip}
\psplot[algebraic,plotpoints=2000,yMaxValue=5.6%,linecolor=cyan
]{-2.3}{2.3}{x^2+1}
\psplot[algebraic,plotpoints=2000]{-3.5}{2.5}{x+3}
\psaxes{->}(0,0)(-3.5,-.9)(4,6.5)
\uput[-90](3.9,-.2){$x$}
\uput[-135](-.2,6.7){$y$}
\end{pspicture}
\end{document}