我试图在R中集成一个复杂的对数函数,但我不知道如何定义它。
当我写的时候说x*i我得到的我没有定义......但它是对面1的平方根,不是吗? 如果我说写5i我没有问题,但5*i给出了错误。
我定义了一些数字x和y。 通常,以下代码会给我一个错误
fun <- function(x + y*i){1/(x + y*i)} integrate(fun,5+0i,10+0i)以下代码有效
lower = 5 upper = 10 z <- complex(real = x, imaginary = y) fun <- function(z){1/z} integrate(fun,lower,upper)但是如何计算轮廓积分? 这是双重积分,真的,我不知道如何在这里实现它。
更重要的是,我想采取右手限制(即lim Y - > 0+),涉及复数对数,等于(1),其中Y减小到0而X是固定的。 在这里,我没有错误地定义我的复杂函数和变量。
I am trying to integrate an complex logarithm function in R, but I am not sure how to define it.
Also when I write say x*i I get i is not defined ... but it is square root of opposite 1, isn't it? If I write say 5i I get no problem but 5*i gives error.
I define with some numbers x and y. In general, following code gives me an error
fun <- function(x + y*i){1/(x + y*i)} integrate(fun,5+0i,10+0i)Following code works
lower = 5 upper = 10 z <- complex(real = x, imaginary = y) fun <- function(z){1/z} integrate(fun,lower,upper)But how do calculate contour integrals? This is double integral, really, and I have no idea how to implement it here.
More importantly, I want to take a right hand limit (i.e. lim Y -> 0+) involving a complex logarithm, equal to (1), where Y decreases to 0 while X is fixed. Here, I could not define my complex function and variable without error.
最满意答案
复杂的集成是沿着路径的集成。 您可以按弧长参数化路径,即使用实际间隔。 (结果实际上取决于路径。)
人们可以期望能够沿着-2-1i和2-1i之间的直线计算1/z的积分,如下所示(注意使用1i而不是i )。
f <- function(s) { z <- s-1i 1/z } integrate( f, -2, 2 ) # Fails但integrate仅适用于实数。 您需要分别计算实部和虚部。
integrate( function(s) Re(f(s)), -2, 2 )$value + 1i * integrate( function(s) Im(f(s)), -2, 2 )$value # [1] 0+2.214297iComplex integration is integration along a path. You can parametrize the path, by arc length, i.e., using a real interval. (The result can actually depend on the path.)
One would expect to be able to compute the integral of 1/z along a straight line between -2-1i and 2-1i as follows (note the use of 1i rather than i).
f <- function(s) { z <- s-1i 1/z } integrate( f, -2, 2 ) # FailsBut integrate only works with real numbers. You need to compute separately the real and imaginary parts.
integrate( function(s) Re(f(s)), -2, 2 )$value + 1i * integrate( function(s) Im(f(s)), -2, 2 )$value # [1] 0+2.214297i更多推荐
发布评论