[R] Problem with integrate(function(x) x^3 / sin(x), -pi/2, pi/2)
Leonard Mada
|eo@m@d@ @end|ng |rom @yon|c@eu
Sun Jan 8 04:24:05 CET 2023
Dear List-Members,
I encounter a problem while trying to integrate the following function:
integrate(function(x) x^3 / sin(x), -pi/2, pi/2)
# Error in integrate(function(x) x^3/sin(x), -pi/2, pi/2) :
# non-finite function value
# the value should be finite:
curve(x^3 / sin(x), -pi/2, pi/2)
integrate(function(x) x^3 / sin(x), -pi/2, 0)
integrate(function(x) x^3 / sin(x), 0, pi/2)
# but this does NOT work:
integrate(function(x) x^3 / sin(x), -pi/2, pi/2, subdivisions=4096)
integrate(function(x) x^3 / sin(x), -pi/2, pi/2, subdivisions=4097)
# works:
integrate(function(x) x^3 / sin(x), -pi/2, pi/2 + 1E-10)
# Note: works directly with other packages
pracma::integral(function(x) x^3 / sin(x), -pi/2, pi/2 )
# 3.385985
I hope that integrate() gets improved in base R as well.
Sincerely,
Leonard
More information about the R-help
mailing list