#First, correct your code
H <- 0.7;
t <- 1;
s <- seq(0,t,0.1);
x <- 1-t/s;
library(gsl)
Gauss2F1 <- function(H,x){
a <- H-1/2;
b <- 1/2-H;
c <- H+1/2;
# if(x>=0 & x<1){
# hyperg_2F1(a,b,c,x)
# }else{
hyperg_2F1(c-a,b,c,1-1/(1-x))/(1-x)^b
# }
}
#Here
#F <- Gauss2F1(a,b,c,x)
#and here
#integrate(F,lower=0,upper=1,H=0.7)
integrate(Gauss2F1,lower=0,upper=1,H=0.7)
Error in integrate(Gauss2F1, lower = 0, upper = 1, H = 0.7) :
non-finite function value
#Then note that
Gauss2F1(H,x)
[1] Inf 1.143016 1.083553 1.056065 1.039444 1.028055 1.019653
1.013143 1.007920 1.003618
[11] 1.000000
#whereupon you find your second problem.
#Joe
Xuse Chuse <chuse22@gmail.com>
Sent by: r-help-bounces@r-project.org
06/17/2014 08:32 AM
To
r-help <r-help@r-project.org>,
cc
Subject
[R] hypergeometric integral
Dear all,
I am trying to make a numerical integral of a Hypergeometrical function
2F1
but it is not working. I dont know how to pass the arguments to my
function. Thank you beforehand.
Chuse.
Here is my code:
H <- 0.7;
t <- 1;
s <- seq(0,t,0.1);
x <- 1-t/s;
library(gsl)
Gauss2F1 <- function(H,x){
a <- H-1/2;
b <- 1/2-H;
c <- H+1/2;
# if(x>=0 & x<1){
# hyperg_2F1(a,b,c,x)
# }else{
hyperg_2F1(c-a,b,c,1-1/(1-x))/(1-x)^b
# }
}
F <- Gauss2F1(a,b,c,x)
integrate(F,lower=-1,upper=1,H=0.7)
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]