Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 691
user6291 Avatar asked Nov 20 '13 23:11

user6291


1 Answers

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), asp = 1)

enter image description here

like image 173
Josh O'Brien Avatar answered Sep 20 '22 18:09

Josh O'Brien