On Sun, 8 Jan 2023 05:24:05 +0200
Leonard Mada via R-help wrote:
> pracma::integral(function(x) x^3 / sin(x), -pi/2, pi/2 )
> # 3.385985
Note that at least one implementation used by pracma::integral has the
same problem:
pracma::integral(function(x) x^3/sin(x), -pi/2, pi/2, no_intervals=7)
# [
`subdivisions` is the maximum number of subintervals. Looking here
https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/src/appl/integrate.c#L1275
I'm not surprised that changing `subdivisions` has no effect on the
outcome. The integration method from {pracma} might work,
You're dividing 0 by 0, giving you NaN, perhaps you should try
function(x) ifelse(x == 0, 0, x^3/sin(x))
On Sat, Jan 7, 2023, 22:24 Leonard Mada via R-help
wrote:
> Dear List-Members,
>
> I encounter a problem while trying to integrate the following function:
>
> integrate(function(x) x^3 / sin
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)
int
4 matches
Mail list logo