标签: power-series

Haskell中的电源系列

我正在尝试在Haskell中编写电源系列,

e^x = 1 + x + x^2/2! + x^3/3! + ...
Run Code Online (Sandbox Code Playgroud)

这样就可以了

[1,1,1/2,1/6,...]
Run Code Online (Sandbox Code Playgroud)

到目前为止我得到了:

factorial 0 = 1 
factorial n = n * factorial (n - 1)

powerSrs x = 1 : powerSrsFunc[1..] where
        powerSrsFunc ( p: xs ) = 
            p : powerSrsFunc[y | y <-xs, ( (x^y) / (factorial y) )]
Run Code Online (Sandbox Code Playgroud)

但是,据我所知,我在这里打字是错误的.我收到此错误:

tut08.hs:8:58:
    No instance for (Integral Bool)
      arising from a use of `^'
    Possible fix: add an instance declaration for (Integral Bool)
    In the first argument of …
Run Code Online (Sandbox Code Playgroud)

haskell power-series

6
推荐指数
1
解决办法
1411
查看次数

绘制幂级数 gnuplot

我想知道如何绘制幂级数(其变量是 x),但我什至不知道从哪里开始。我知道绘制无限级数可能是不可能的,但绘制前n项的总和也可以。

gnuplot function power-series

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

power-series ×2

function ×1

gnuplot ×1

haskell ×1