Displaying 1 result from an estimated 1 matches for "p2sq".
Did you mean:
p2s2
2011 Jan 10
2
Integration in R
...would like to request your help and comments.
I have the function:
p2<-function(x){0.5*(3*x^2-1)}
# I found the square of p2 by using some pencil and paper.
# The result is inside myfunc below
myfunc<- function(x) {0.25*(9*x^4+6*x^2+1)}
# Below I made R to find the square of p2
p2sq<-function(x) {p2(x) * p2(x)}
# Now I am trying to integrate both two function at the same interval. #Both functions should denote the square of p2
integrate(p2sq,-1,+1)
# returns 0.4 with absolute error < 4.4e-15
integrate(myfunc,-1,+1)
# returns 2.4 with absolute error < 2.7e-1...