给定一个多项式函数f(例如,作为实数系数的列表p升序或降序),一个非负整数n和一个实数值x,返回:
f n(x)
即值˚F(˚F(˚F(... ˚F(X)...))),用于Ñ的应用˚F上X。
使用合理的精度和舍入。
将f作为系数列表的解决方案可能是最有趣的,但是如果您能够将f作为实际函数(从而将此挑战减少为琐碎的“ n次应用函数”),请随时添加非平凡的解决方案之后。
案例案例
p = [1,0,0]
或f = x^2
, n = 0
, x = 3
: f 0(3)=3
p = [1,0,0]
或f = x^2
, n = 1
, x = 3
: f 1(3)=9
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 0
, x = 2.3
: f 0(2.3)=2.3
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 1
, x = 2.3
: f 1(2.3)=-8.761
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 2
, x = 2.3
: f 2(2.3)=23.8258
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 3
, x = 2.3
: f 3(2.3)=-2.03244
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 4
, x = 2.3
: f 4(2.3)=1.08768
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 5
, x = 2.3
: f 5(2.3)=-6.38336
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 6
, x = 2.3
: f 6(2.3)=14.7565
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 7
, x = 2.3
: f 7(2.3)=-16.1645
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 8
, x = 2.3
: f 8(2.3)=59.3077
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 9
, x = 2.3
: f 9(2.3)=211.333
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 10
, x = 2.3
: f 10(2.3)=3976.08
p = [0.1,-2.3,-4]
或f = 0.1x^2-2.3x-4
, n = 11
, x = 2.3
: f 11(2.3)=1571775
p = [-0.1,2.3,4]
或f = −0.1x^2+2.3x+4
, n = 0
, x = -1.1
: f 0(-1.1)=-1.1
p = [-0.1,2.3,4]
或f = −0.1x^2+2.3x+4
, n = 1
, x = -1.1
: f 1(-1.1)=1.349
p = [-0.1,2.3,4]
或f = −0.1x^2+2.3x+4
, n = 2
, x = -1.1
: f 2(-1.1)=6.92072
p = [-0.1,2.3,4]
或f = −0.1x^2+2.3x+4
, n = 14
, x = -1.1
: f 14(-1.1)=15.6131
p = [0.02,0,0,0,-0.05]
或f = 0.02x^4-0.05
, n = 25
, x = 0.1
: f 25(0.1)=-0.0499999
p = [0.02,0,-0.01,0,-0.05]
或f = 0.02x^4-0.01x^2-0.05
, n = 100
, x = 0.1
: f 100(0.1)=-0.0500249