Sha256: 0d49cfb96b975d59db202f2a967e13b9e04d11cc1c982e02500a81b900d25f7d

Contents?: true

Size: 708 Bytes

Versions: 6

Compression:

Stored size: 708 Bytes

Contents

#!/usr/bin/env ruby
require("gsl")
include Math

# Expected: x0 ~ 0.57983, x1 ~ 2.54621
func = GSL::MultiRoot::Function.alloc(2) { |x, f|
  x0 = x[0]
  x1 = x[1]
  f[0] = -2.0*x0*x0 + 3.0*x0*x1 + 4.0*sin(x1) - 6.0
  f[1] = 3.0*x0*x0 - 2.0*x0*x1*x1 + 3.0*cos(x0) + 4.0
}

p func.solve([1.0, 2.0].to_gv, 1000, 1e-7, "hybrids")
p func.solve([1.0, 2.0].to_gv, 1000, "broyden")
p func.solve([1.0, 2.0], "hybrid")
p func.solve([1.0, 2.0], 2000, "hybrid")
p func.solve([1.0, 2.0])

#fsolver = GSL::MultiRoot::FSolver.alloc("dallocton", 2)
fsolver = GSL::MultiRoot::FSolver.alloc("broyden", 2)

x = GSL::Vector.alloc([1.0, 2.0])
fsolver.set(func, x)

p ans = fsolver.solve()
#ans = MultiRoot::FSolver.solve(fsolver)

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
gsl-2.1.0.3 examples/multiroot/fsolver3.rb
gsl-2.1.0.2 examples/multiroot/fsolver3.rb
gsl-2.1.0.1 examples/multiroot/fsolver3.rb
gsl-2.1.0 examples/multiroot/fsolver3.rb
gsl-1.16.0.6 examples/multiroot/fsolver3.rb
rb-gsl-1.16.0.5 examples/multiroot/fsolver3.rb