Maple 2023plot() 函数对于复合函数的工作非常奇怪。我是不是做错了什么?

问题描述 投票:0回答:1

我正在尝试制作一个在 1 和 0 之间振荡的周期函数。我制作了一个在间隔内按照我需要的方式振荡的函数 <0,7), when i tried to make it periodical i wrote a modified modulo function (which accounts for modulo not being continuous) but when i make a composite function it is not plotting correctly.

有人见过类似的东西吗?

Maple 2023 plot(modulo(t)) vs plot(modulo)

当我使用绘图(函数)时,函数显示正确,但我无法更改图形比例。 (如果我改变它,它就会破坏图表) 当我使用plot(function(t))时,它无法正常工作并且仅显示一些基本的线性函数。 当我使用带有某些参数的绘图时,它也不起作用。

Maple 2023 代码:

sigmoid := t -> 1/(1 + exp(-t));
weekend_function := t -> piecewise(0 <= t and t < 2.5, 0, 2.5 <= t and t < 3.5, sigmoid(12*t - 36), 3.5 <= t and t < 4.5, 1 - sigmoid(12*t - 48), 4.5 <= t, 0);
modulo := t -> (floor(t) mod 7) + t - floor(t);
fun := t -> weekend_function(modulo(t));
plot(modulo);
plot(fun);
math numerical-methods maple
1个回答
0
投票

当您在 Maple 中调用过程并向其传递参数时,这些参数会在过程开始对它们起作用之前进行“评估”。对传递的参数的评估是“预先”完成的。这是Maple正常的评价模型。 例如,您构建了这个过程:

modulo := t -> (floor(t) mod 7) + t - floor(t):

现在,让我们用参数来称呼它 
t

modulo(t);

      t

是的,结果就是
t

。发生这种情况是因为这个结果,当

t
只是一个未分配的名称时:
floor(t) mod 7;

    floor(t)

所以,如果你打电话来,

plot( modulo(t) );

然后 
plot

命令将仅接收

t
作为其参数,这是评估
modulo(t)
的结果。
当你打电话时,

plot( modulo )

您正在调用 
plot

命令的所谓运算符形式调用序列,在这种情况下,

modulo
本身仅使用实际的数字参数进行调用(即,不仅仅是名称,
t
)。
您可以通过多种方式修复您的方法。

方法 1) 使用单右勾(又名“不值引号”)来延迟对传递给

plot

的第一个参数的求值。

这些工作,

plot('modulo'(t)); plot('fun'(t));

方法 2)以不同的方式定义您的 
modulo

过程,以便它返回自己的调用(

未评估
),如果您仅使用 t 等名称或非数字名称来调用它。
modulo2 := proc(t)
  if not type(t,numeric) then
    return 'procname'(args);
  else
    (floor(t) mod 7) + t - floor(t);
  end if;
end proc:

现在,看,这不仅仅是返回 
t

modulo2(t);

    modulo2(t)

现在这些工作了,

plot(modulo2(t)); fun2 := t -> weekend_function(modulo2(t)): plot(fun2(t))

© www.soinside.com 2019 - 2024. All rights reserved.