Hi
On Jun 5, 2017, at 4:33 AM, Moshe Kelner <MOSHEKE at cellcom.co.il> wrote: Hi , I'm asking for a way to compute the integral of:
function(x) {x*(log(x)+b)*((log(x)+b)^(a-1)-b^(a-1))/(a-1)*(b^(a-1)}
Problems here ----------------^^^-----and if(a==1)-----^^^---paren--^
||| ||| |
Annotation only useful with monospaced font. Not likely to be useful to Moshe if he will be using HTML for posting.
When a and b are between 1 to 10 and X is the integral parameter between 0 to 1 '
How are you planning to handle a value of log(0)? Or for that matter division by 0 if a==1 R does do limiting integrations (if that is the correct term for lim(integrate(func, lower=0, ...)) with the value of func(0) undefined. You may need to set the lower limit of integration to be a small positive number. R also has difficulties with fractional powers of negative numbers:
(-.2)^(1.1-1)
[1] NaN
Did you perhaps intend `a` to be in the set: 2:9 ?
If I set:
my_f <- function(x, a=1.1, b=1.1) # will error out with those defaults
{x*(log(x)+b)*((log(x)+b)^(a-1)-b^(a-1))/(a-1)*(b^(a-1))}
integrate(my_f, lower=0.1,upper=.9, a=2, b=2) #call with integer `a` and `b`
-0.5063435 with absolute error < 4.6e-09
integrate(my_f, lower=0.01,upper=.9, a=2, b=2)
-0.4829606 with absolute error < 3.5e-05
integrate(my_f, lower=0.001,upper=.9, a=2, b=2)
-0.4813907 with absolute error < 4.8e-05
Moshe
excised meaningless confidentiality message
Thank You. http://www.cellcom.co.il [[alternative HTML version deleted]]
Do read the Posting Guide which advises not to use HTML.
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
David Winsemius Alameda, CA, USA