Sha256: 734cd55695c5a0bdfb615a02b4a6b0a776b81b1e67f729eac5a5c8327b93f1ac

Contents?: true

Size: 553 Bytes

Versions: 16

Compression:

Stored size: 553 Bytes

Contents

#!/usr/bin/env ruby
# Find synchrotron spectrum peak
require("gsl")

# Create Function object from the module function
F = GSL::Function.alloc { |x| GSL::Sf::synchrotron_1(x) }
# Derivative of the function
DF = GSL::Function.alloc { |x|  
  result, abserr, status = F.deriv_central(x, 1e-6)  
  result
}
# Find zero-point of the derivative in interval (0.01, 5)
peak, = DF.fsolve(0.01, 5)
printf("A peak is found at %3.2f.\n", peak)

x = GSL::Vector.linspace(0, 5, 100)
s = GSL::Sf::synchrotron_1(x)
s.graph(x, "-C -g 3 -X x -L 'Sf::synchrotron_1(x)'")

Version data entries

16 entries across 16 versions & 4 rubygems

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