21/02/17 22:02:29.25 /6KwdMZR.net
>>33
無思考の数値積分で出してみました。
f0 <- function(x) ifelse(x<=1,1,-1)
f0=Vectorize(f0)
f1 <- function(x) integrate(f0,0,x)$value ; f1=Vectorize(f1)
f2 <- function(x) integrate(f1,0,x)$value ; f2=Vectorize(f2)
f3 <- function(x) integrate(f2,0,x)$value ; f3=Vectorize(f3)
# (1)
fractions(f3(1))
fractions(f3(2))
# (2)
fractions(integrate(f2,1,2)$value)
# (3)
fractions(integrate(function(x) f0(x)*f1(x),0,2)$value)
> # (1)
> fractions(f3(1))
[1] 1/6
> fractions(f3(2))
[1] 1
> # (2)
> fractions(integrate(f2,1,2)$value)
[1] 5/6
> # (3)
> fractions(integrate(function(x) f0(x)*f1(x),0,2)$value)
[1] 0