class Dydx::Algebra::Inverse
Attributes
operator[RW]
x[RW]
Public Class Methods
new(x, operator)
click to toggle source
# File lib/dydx/algebra/inverse.rb, line 7 def initialize(x, operator) @x, @operator = x, operator end
Public Instance Methods
differentiate(sym = :x)
click to toggle source
# File lib/dydx/algebra/inverse.rb, line 32 def differentiate(sym = :x) case operator when :+ inverse(x.differentiate(sym), :+) when :* inverse(x.differentiate(sym) * inverse(x ** 2, :*), :+) end end
Also aliased as: d
subst(hash = {})
click to toggle source
# File lib/dydx/algebra/inverse.rb, line 18 def subst(hash = {}) case operator when :+ then x.subst(hash) * -1 when :* then x.subst(hash) ** -1 end end
to_f()
click to toggle source
# File lib/dydx/algebra/inverse.rb, line 25 def to_f case operator when :+ then x.to_f * -1 when :* then x.to_f ** -1 end end
to_s()
click to toggle source
# File lib/dydx/algebra/inverse.rb, line 11 def to_s case operator when :+ then "( - #{x} )" when :* then "( 1 / #{x} )" end end