枫 - 代入方程
Maple - Substituting into equation
我在设置函数时遇到困难,我将 x1[1]
和 x2[1]
代入其中。任何帮助将不胜感激。
我的代码是:
restart;
with(LinearAlgebra);
x1[1] := -2+1606*alpha;
x2[1] := 2+400*alpha;
f := proc (alpha) options operator, arrow; (-x1[1]^2+1)^2+100*(-x1[1]^2+x2[1])^2 end proc;
f 的输出留下 x1[1]
和 x2[1]
,并没有根据需要用 -2+1600*alpha
和 2+400*alpha
替换它们。
f(0);
然后没有给出所需的 409 输出。
我可以用下面的函数 g
替换我自己的 -2+1606*alpha
和 2+400*alpha
。虽然这不是我想要的,因为我希望它采用 x1[1]
和 x2[1]
设置的任何内容,而不是手动执行。
g := proc (alpha) options operator, arrow; (1-(1606*alpha-2)^2)^2+100*(2+400*alpha-(1606*alpha-2)^2)^2 end proc
g(0);
此处g(0);
根据需要给出409。
我在下面附上了一张照片,显示了枫树输出在我的屏幕上的显示方式。
当您在表达式上应用运算符过程时,Maple 会在之前 进行评估。在表达式
f := proc (alpha) options operator, arrow; (-x1[1]^2+1)^2+100*(-x1[1]^2+x2[1])^2 end proc;
这与使用 "arrow" 表示法相同
f2 := alpha -> (-x1[1]^2+1)^2+100*(-x1[1]^2+x2[1])^2;
然后 Maple 正在寻找任何 alpha
。有none。当您随后调用 f(0)
时,将使用运算符调用中的(不存在的)alpha
对表达式求值。因此,对于任何 x
,f(x) = f(0)
。 From the help page:
The use of option arrow also disables Maple simplification rules that add any non-local names in the operator expression to the parameter list. This option has no meaning for modules.
相反,您可以使用 unapply
运算符,它 returns 是 求值 表达式的运算符。如果您将变量 expr
定义为您的函数内容,这将变得更加清晰。
expr := (-x1[1]^2+1)^2+100*(-x1[1]^2+x2[1])^2;
f := alpha -> expr;
h := unapply(expr, alpha);
h(0); # returns 409
我在设置函数时遇到困难,我将 x1[1]
和 x2[1]
代入其中。任何帮助将不胜感激。
我的代码是:
restart;
with(LinearAlgebra);
x1[1] := -2+1606*alpha;
x2[1] := 2+400*alpha;
f := proc (alpha) options operator, arrow; (-x1[1]^2+1)^2+100*(-x1[1]^2+x2[1])^2 end proc;
f 的输出留下 x1[1]
和 x2[1]
,并没有根据需要用 -2+1600*alpha
和 2+400*alpha
替换它们。
f(0);
然后没有给出所需的 409 输出。
我可以用下面的函数 g
替换我自己的 -2+1606*alpha
和 2+400*alpha
。虽然这不是我想要的,因为我希望它采用 x1[1]
和 x2[1]
设置的任何内容,而不是手动执行。
g := proc (alpha) options operator, arrow; (1-(1606*alpha-2)^2)^2+100*(2+400*alpha-(1606*alpha-2)^2)^2 end proc
g(0);
此处g(0);
根据需要给出409。
我在下面附上了一张照片,显示了枫树输出在我的屏幕上的显示方式。
当您在表达式上应用运算符过程时,Maple 会在之前 进行评估。在表达式
f := proc (alpha) options operator, arrow; (-x1[1]^2+1)^2+100*(-x1[1]^2+x2[1])^2 end proc;
这与使用 "arrow" 表示法相同
f2 := alpha -> (-x1[1]^2+1)^2+100*(-x1[1]^2+x2[1])^2;
然后 Maple 正在寻找任何 alpha
。有none。当您随后调用 f(0)
时,将使用运算符调用中的(不存在的)alpha
对表达式求值。因此,对于任何 x
,f(x) = f(0)
。 From the help page:
The use of option arrow also disables Maple simplification rules that add any non-local names in the operator expression to the parameter list. This option has no meaning for modules.
相反,您可以使用 unapply
运算符,它 returns 是 求值 表达式的运算符。如果您将变量 expr
定义为您的函数内容,这将变得更加清晰。
expr := (-x1[1]^2+1)^2+100*(-x1[1]^2+x2[1])^2;
f := alpha -> expr;
h := unapply(expr, alpha);
h(0); # returns 409