我知道在复杂的平面上只有线积分,所以我感兴趣的界面如下所示:
i =整合fxab精度计算沿直线的积分从 a 到 b 函数 f on point X 。 i , x , a , b 都是复合双倍或更好 Num a =>复杂的a 类型。
请......:)
你可以自己做这样的事情。假设你有一个函数 realIntegrate 类型为(Double - > Double) - > (Double,Double) - > Double ,接受一个函数和一个包含下限和上限的元组,并将结果返回一定的精度。例如,您可以使用数字工具定义 realIntegrate f(lo,hi)= quadRomberg defQuad(lo,hi)f 。
然后,我们可以按照如下方式创建你想要的函数 - 我现在忽略了精度(而且我不明白你的 x 参数是用于什么的! ):
integrate ::(Complex Double - > Complex Double) - >复合双 - >复合双 - > Complex Double integrate fab = r:+ i其中r = realIntegrate realF(0,1)i = realIntegrate imagF(0,1) realF t = realPart(f t)) - 或realF = realPart。 F 。插值 imagF t = imagPart(f(interpolate t)) interpolate t = a +(t:+ 0)*(b - a) pre>因此,我们表示从 a 到 b 作为通过线性插值从0到1的实际区间的函数,沿着该路径取值 f ,分别对实部和虚部进行积分(我不虽然),并将它们重新组合成最终答案。
我没有测试过这段代码,因为我没有numeric-工具安装,但至少它typechecks: - )
I am aware that on complex plane there's only line integrals, so the interface I am interested in is something like this:
i = integrate f x a b precisionto calculate integral along straight line from a to b of function f on point x. i, x, a, b are all of Complex Double or better Num a => Complex a type.
Please... :)
解决方案You can make something like this yourself. Suppose you have a function realIntegrate of type (Double -> Double) -> (Double,Double) -> Double, taking a function and a tuple containing the lower and upper bounds, returning the result to some fixed precision. You could define realIntegrate f (lo,hi) = quadRomberg defQuad (lo,hi) f using numeric-tools, for example.
Then we can make your desired function as follows - I'm ignoring the precision for now (and I don't understand what your x parameter is for!):
integrate :: (Complex Double -> Complex Double) -> Complex Double -> Complex Double -> Complex Double integrate f a b = r :+ i where r = realIntegrate realF (0,1) i = realIntegrate imagF (0,1) realF t = realPart (f (interpolate t)) -- or realF = realPart . f . interpolate imagF t = imagPart (f (interpolate t)) interpolate t = a + (t :+ 0) * (b - a)So we express the path from a to b as a function on the real interval from 0 to 1 by linear interpolation, take the value of f along that path, integrate the real and imaginary parts separately (I don't know if this can give numerically badly behaving results, though) and reassemble them into the final answer.
I haven't tested this code as I don't have numeric-tools installed, but at least it typechecks :-)
更多推荐
是否有用于集成复杂函数的Haskell库?
发布评论