Sha256: 938bbb6852e1f77eaa1a36119da5cc1fb8d14917a2893abb4afe7e1064531884

Contents?: true

Size: 365 Bytes

Versions: 16

Compression:

Stored size: 365 Bytes

Contents

#!/usr/bin/env ruby
# Ahmed's Integral
# See e.g. http://mathworld.wolfram.com/AhmedsIntegral.html
#
require("gsl")
include GSL
include Math

f = Function.alloc { |x| 
  sqrtx22 = sqrt(x*x + 2)
  atan(sqrtx22)/(sqrtx22*(x*x + 1))
}

val = f.qng(0, 1)[0]

puts("Ahmed's integral")
puts("Expect: 5pi^2/96 = #{5.0*M_PI*M_PI/96}")
puts("QNG result:        #{val}")


 

Version data entries

16 entries across 16 versions & 4 rubygems

Version Path
rb-gsl-1.16.0.4 examples/integration/ahmed.rb
rb-gsl-1.16.0.3 examples/integration/ahmed.rb
rb-gsl-1.16.0.3.rc1 examples/integration/ahmed.rb
gsl-nmatrix-1.15.3.2 examples/integration/ahmed.rb
gsl-nmatrix-1.15.3.1 examples/integration/ahmed.rb
rb-gsl-1.16.0.2 examples/integration/ahmed.rb
rb-gsl-1.16.0.1 examples/integration/ahmed.rb
rb-gsl-1.16.0 examples/integration/ahmed.rb
rb-gsl-1.15.3.2 examples/integration/ahmed.rb
rb-gsl-1.15.3.1 examples/integration/ahmed.rb
blackwinter-gsl-1.15.3.2 examples/integration/ahmed.rb
gsl-nmatrix-1.15.3.0 examples/integration/ahmed.rb
gsl-1.15.3 examples/integration/ahmed.rb
gsl-1.14.7 examples/integration/ahmed.rb
gsl-1.14.6 examples/integration/ahmed.rb
gsl-1.14.5 examples/integration/ahmed.rb