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