I would like to program and plot this function into R:
The code I have been using is:
js <- sapply( seq(1,50, 1), FUN <- function(x) x^{-4})
pim <- sapply(seq(1,50, 1), FUN <- function(x) 2*pi*x)
beta <- function(x) sum(js*sqrt(2)*cos(pim*x))
but while this returns the right values for each point, I am running into trouble when I try to plot it using the curve function as what I get is:
Error in curve(beta, 0, 1) :
'expr' did not evaluate to an object of length 'n'
In addition: Warning messages:
1: In pim * x :
longer object length is not a multiple of shorter object length
2: In js * sqrt(2) * cos(pim * x) :
longer object length is not a multiple of shorter object length
Could you please help me fix that problem and get a working plot? Thank you.

