尝试对两个产品求和时出错,其中一个产品是 1x2 矩阵

Error when trying to sum two products, where one product is a 1x2 matrix

我在这里发布的第一个问题是,我正在为周一的期末考试编写一些代码,但出于某种原因,我不断收到以下错误。任何帮助将不胜感激。谢谢!;

The following imagine shows the error in my code, I had switched to 1D math and still can't seem to find the issue

在 Maple 中,全局名称 D 有一个预先分配的值。它是微分算子。例如,

f := t -> sec(t):

D(f);

      t -> sec(t)*tan(t)

全局名称 D 也受到 保护,即。您不能为其分配其他值。

一般来说,在您的代码中将名称 D 用作虚拟变量并不是一个好主意(因为默认情况下已经为它分配了一个系统过程)。你的例子是一个(不幸的)奇怪的例子,可能会随之而来。

D * Vector([-3,1]);
  Error, (in LinearAlgebra:-Multiply) invalid arguments

您有几个选择:

1) 请改用其他名称,例如 DD.

2) 如果您的 Maple 版本是最新的,那么您可以将它(一次)声明为顶级使用的本地名称。例如,

restart;

local D;

               D

D * Vector([-3,1]);

             [-3 D]
             [    ]
             [ D  ]

如果您声明局部 D 供顶级使用,那么您仍然可以通过其全局名称 :-D 使用微分运算符。例如

restart;
local D:

f := t -> sec(t):

D(f);     # does nothing, since this is the local D

             D(f)

:-D(f);

       t -> sec(t)*tan(t)

如果这一切听起来令人困惑,您最好使用其他名称。

只有少数具有预先指定值或用途的短符号,例如。 Pi, I, D.

您可能还想查看主题 initialconstants and trydeclaringlocal 的帮助页面。