在 Mathematica 中的给定点评估系统
我
f1[x_, y_] := x^2 - 10 x + y^2 + 8;
f2[x_, y_] := x*y^2 + x - 10 y + 8;
f[x_, y_] := {f1[x, y], f2[x, y]} ;
x0 = {0, 0};
想在 x0
中评估 f[x_, y_]
,所以 f[0, 0]
我正在这样做,但没有工作,正确的做法是什么?
MatrixForm[f[{x0}]]
我得到 f[{{0, 0}}]
但想要 {8, 8}
I have
f1[x_, y_] := x^2 - 10 x + y^2 + 8;
f2[x_, y_] := x*y^2 + x - 10 y + 8;
f[x_, y_] := {f1[x, y], f2[x, y]} ;
x0 = {0, 0};
I want to evaluate f[x_, y_]
in x0
, so f[0, 0]
I am doing this but does not work, what is the correct way?
MatrixForm[f[{x0}]]
I get f[{{0, 0}}]
but want {8, 8}
instead
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
出了什么问题?当您计算
f[{x0}]
时,它等于f[{{0,0}}]
,它与f< 的定义模式不匹配/代码>。
f@@x0
,它是Apply[ 的简写f,x0]
,替换 x0 的头部(其内部等于List[0,0]
,因此它的头部是List
),与f
。然后,您将得到与f
的参数模式匹配的f[0,0]
。然后你会得到正确的结果。What went wrong? When you evaluate
f[{x0}]
this equalsf[{{0,0}}]
, which doesn't match the defined pattern forf
.f@@x0
, which is shorthand forApply[f,x0]
, replaces the head of x0 (which internally equalsList[0,0]
, hence its head isList
), withf
. You then getf[0,0]
which matches the argument pattern off
. You then get the correct result.