How can I plot a function in R with complex numbers?

别来无恙 提交于 2019-12-07 11:09:16

问题


I want to plot the following function in R

f(w) = 1/(1-5*e^(-iw))

where i is the square root of -1. Can R handle complex numbers in plotting?


回答1:


This should get you started (mostly by demonstrating the notation R uses for representing complex numbers and the exponential function).

f <- function(x) 1/(1-5*exp(-(0+1i)*x))
x <- seq(0, 2*pi, by=0.1)
plot(f(x))



来源:https://stackoverflow.com/questions/20109257/how-can-i-plot-a-function-in-r-with-complex-numbers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!