Class: Fractals::Newton
- Inherits:
-
Fractal
- Object
- Renderers::Base
- Fractal
- Fractals::Newton
- Defined in:
- lib/fractals.rb
Overview
The Newton fractal.
Instance Attribute Summary
Attributes inherited from Fractal
Attributes inherited from Renderers::Base
#algorithm, #bailout, #height, #last_iteration, #magnification, #max_iterations, #set_color, #theme, #width
Instance Method Summary collapse
-
#initialize(c = Complex(0.0, 0.0)) ⇒ Newton
constructor
A new instance of Newton.
Methods inherited from Fractal
Methods inherited from Renderers::Base
acts_as_renderer, #in_set?, #render, #renderer=, #where_is?
Constructor Details
#initialize(c = Complex(0.0, 0.0)) ⇒ Newton
Returns a new instance of Newton.
92 93 94 95 96 97 98 |
# File 'lib/fractals.rb', line 92 def initialize(c=Complex(0.0, 0.0)) super(c, {:a => 1, :pz => lambda { |z| z**3 - 1 }}) do |args| dx_pz = derivative(0.0001) { |x| args[:pz].call(x) } args[:z] = args[:z] - args[:a] * (args[:pz].call(args[:z]) / (dx_pz.call(args[:z]))) end end |