lib/dydx/algebra/formula.rb in dydx-0.0.9 vs lib/dydx/algebra/formula.rb in dydx-0.1.0

- old
+ new

@@ -1,10 +1,10 @@ module Dydx module Algebra class Formula include Helper - attr_accessor :f, :g, :operator + attr_accessor :f, :operator, :g def initialize(f, g, operator) @f, @g, @operator = f, g, operator end @@ -14,10 +14,12 @@ f.d(sym) + g.d(sym) when :* (f.d(sym) * g) + (f * g.d(sym)) when :^ # TODO: - if f == sym + if g.is_num? + f.d(sym) * g * (f ^ (g - 1) ) + elsif f == sym g * (f ^ (g - 1)) elsif f == e g.d(sym) * self else self * (g * log(f)).d(sym)