沿 y 轴着色有界区域

Shade Bounded Region along y-axis

我画了一条线,但想沿着 y 轴给 2 和 4 之间的区域加上阴影以说明曲线下的区域,但不知道该怎么做,谁能帮忙?这是代码,比较简单

>y:=(2*x);

>plot(y,x=0..3);

我很难理解您所指的区域。

是这个吗?

restart;

y := 2*x:

plots:-display(
  plot(2*x, x=0..3),
  plots:-inequal([Y>=y, Y>=2, Y<=4], x=0..3, Y=0..6,
                 'nolines', 'color'="Burgundy")
);

当然你可以省略曲线(线)y=2*x by 删除上面对 plot 的调用。

如果您有其他想法,那么您应该能够相应地调整对 plots:-inequal 的调用。

还有其他方法可以完成这些事情,例如调用 plot 及其 filled 选项。也可以使用plottools:-reflect,或者使用plot的参数化调用顺序,翻转xy轴。

我认为您可能希望避免必须 "solve for x",以获得对应于 y=2y=4x 值(即使在这个示例中y=2*x 你可以在脑海中做到这一点。

这些是我认为您会发现使用 plots:-inequal 最简单的原因。

[编辑:关于 8 个矩形的后续评论]

首先,一个略有不同的例子,希望更清楚。

restart;

x:=arcsin(y/6):

P := plots:-display(
  plot(x, y=2..5),
  plots:-inequal([X<=x], y=2..5, X=0..1.2,
                 'nolines', 'color'=pink)
):

plots:-display(
  plot(2, color=black, linestyle=dot),
  plot(5, color=black, linestyle=dot),
  plot([x, y, y=0..6]),
  plottools:-transform((x,y)->[y,x])(P),
  view=[0..1.2,0..6],
  labels=["x","y"],
  size=[500,300]
);

可以使用 Student:-Calculus1 包中的 RiemannSum 命令可视化下和的上限(使用矩形)。 (或者您可以使用 seq 命令并通过角的公式构建它们 - 但这看起来像是很多笨拙的簿记。)

您当然可以删除下面传递给 plots:-display 命令的任何部分。

restart;

with(Student:-Calculus1):

x:=arcsin(y/6):

P:=RiemannSum(x, y=2..5, method = upper, output = plot,
              partition=8,
              boxoptions=[filled=[color=pink,transparency=.5]],
              caption=""):

rP:=plottools:-transform((x,y)->[y,x])(P):

plots:-display(
  plot(2, color=black, linestyle=dot),
  plot(5, color=black, linestyle=dot),
  plot([x, y, y=0..6]),
  rP,
  view=[0..1.2,0..6],
  labels=["x","y"],
  size=[500,300]
);

或者,

restart;

with(Student:-Calculus1):

x:=arcsin(y/6):

P:=RiemannSum(x, y=2..5, method = lower, output = plot,
              partition=8,
              boxoptions=[filled=[color=pink,transparency=.5]],
              caption=""):

rP:=plottools:-transform((x,y)->[y,x])(P):

plots:-display(
  plot(2, color=black, linestyle=dot),
  plot(5, color=black, linestyle=dot),
  plot([x, y, y=0..6]),
  rP,
  view=[0..1.2,0..6],
  labels=["x","y"],
  size=[500,300]
);

如果您想要曲线和 x 轴之间的区域,那么所有这些示例都会稍微简单一些。