[英]I struggle to find a code to estimate the second derivative of sin(x) at x=pi/4 with h^-1 in octave
I tried function handle as follow:我试过函数句柄如下:
f=@(f(x+h)-2*(f(x))+(f(x-h)))./h^2;
I got parse error:我得到解析错误:
invalid parameter list无效的参数列表
f=@(f(x+h)-2*(f(x))+(f(x-h)))./h^2;
I try to estimate the second derivative of sin(x) at x=pi/4 with h^-1 in octave.我尝试在 x=pi/4 处估计 sin(x) 的二阶导数,其中 h^-1 以八度为单位。
I couldn't find code to estimate the second derivative of sin(x) at x=pi/4 with h^-1我找不到用 h^-1 估计 x=pi/4 处 sin(x) 的二阶导数的代码
Anonymous functions are defined as:匿名函数定义为:
f= @(parameters)(function);
You forgot to add the parameters.你忘记添加参数了。 I suspect you want:我怀疑你想要:
f=@(x)((f(x+h)-2*(f(x))+(f(x-h)))./h^2);
However this will cause a second problem: you are overwriting f
.但是,这会导致第二个问题:您正在覆盖f
。 Maybe you want也许你想要
% you defined some f=@(x)...
g=@(x)((f(x+h)-2*(f(x))+(f(x-h)))./h^2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.