Shant Ch wrote: > > Hi, > > I want to find a value of n1. I used the following code but I am getting > the > error - > > > Error in as.vector(x, mode) : > cannot coerce type 'closure' to vector of type 'any' > > > n=10 > a_g<-(1/(n*(n-1)))*((pi/3)*(n+1)+(2*sqrt(3)*(n-2))-4*n+6) > > a_s<-function(n1) > { > t1=(n1-1)/2; > (t1*(gamma(t1)/gamma(n1/2))^2)/2-1-a_g > } > xm<-solve(a_s) >
Have you looked in the documentation for solve? Have you done ?solve You will see that solve is for solving systems of linear equations. First you should graph your function to get some idea where the zero (if there is one) is. For example curve(a_s,from=1.1,to=10) and then start narrowing down the range curve(a_s,from=1.3,to=2) and finally use uniroot to find a zero: ?uniroot uniroot(a_s,c(1.3,2)) I hope this wasn't homework. /Berend -- View this message in context: http://r.789695.n4.nabble.com/Solving-equations-involving-gamma-functions-tp2553058p2553240.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.