作业帮 > 数学 > 作业

mathematica作图问题:如何画出一个函数和它的垂直渐近线,要求垂直渐近线用虚线表示?以y=1/(x-2)给出程

来源:学生作业帮 编辑:拍题作业网作业帮 分类:数学作业 时间:2024/04/27 18:29:02
mathematica作图问题:如何画出一个函数和它的垂直渐近线,要求垂直渐近线用虚线表示?以y=1/(x-2)给出程
画两个图,一个用虚线,一个用实线,再放一块儿.
Show[Plot[1/(x - 2),{x,0,4},PlotStyle -> Dashing[Tiny]],
Plot[1/(x - 2),{x,0,2,4}]]
再问: 如果函数是2x/(x-1)^2,垂直渐近线是x=1,怎么弄?最好把程序和图片都放上,我好学习学习!另外,像凸函数的示意图是怎么画的?
再答: 不知什么原因,mathematica会自动画出1/(x - 2),Tan[x],1/Sin[x]等简单函数的垂直x轴的渐近线,但1/(x - 2)^2,Tan[x]^2,1/Sin[x]^2就不行了。依目前的了解,只能算出渐近线方程,再把渐近线和原函数图像画一块儿。例如你所说的2x/(x-1)^2:Show[Graphics[{Dashed, Line[{{1, 0}, {1, 40}}]}], Plot[2 x/(x - 1)^2, {x, 0, 4}], AspectRatio -> .6, Axes -> True]。 对于凸函数示意图,代码如下,顺便画上了渐近线: f[x_] := x + 1/x; g[x_] := x; x1 = .5; x2 = 4; x = 2.3; Show[ Plot[f[x], {x, 0, 6}], Plot[g[x], {x, 0, 6}, PlotStyle -> Dashing[Tiny]], Graphics[{ Point[{x1, f[x1]}], Line[{{x1, f[x1]}, {x1, 0}}], Text["x1", {x1, -.4}, BaseStyle -> {15}], Point[{x2, f[x2]}], Line[{{x2, f[x2]}, {x2, 0}}], Text["x2", {x2, -.4}, BaseStyle -> {15}], Point[{x, (f[x2] - f[x1])/(x2 - x1)*(x - x1) + f[x1]}], Point[{x, f[x]}], Line[{{x, (f[x2] - f[x1])/(x2 - x1)*(x - x1) + f[x1]}, {x, 0}}], Text["x", {x, -.4}, BaseStyle -> {15}], Line[{{x1, f[x1]}, {x2, f[x2]}}], Text["A1", {x1, f[x1] + .5}, BaseStyle -> {15}], Text["A2", {x2, f[x2] + .5}, BaseStyle -> {15}], Text["A", {x + .2, f[x] - .5}, BaseStyle -> {15}], Text["B", {x, (f[x2] - f[x1])/(x2 - x1)*(x - x1) + f[x1] + .5}, BaseStyle -> {15}], Text["y1", {x1 - .2, f[x1]/2}, BaseStyle -> {15}], Text["y2", {x2 + .2, f[x2]/2}, BaseStyle -> {15}] }], AxesOrigin -> {0, 0}, Ticks -> None, AxesLabel -> {x, y}, LabelStyle -> {15}, AxesStyle -> Arrowheads[.03], PlotRange -> All ]