lib/dydx/algebra/operator/parts/general.rb in dydx-0.0.7 vs lib/dydx/algebra/operator/parts/general.rb in dydx-0.0.8
- old
+ new
@@ -21,13 +21,13 @@
case operator
when :+ then _(2) * self
when :* then self ^ _(2)
when :^ then super(x)
end
- elsif operator == :+ && inverse?(x, :+)
+ elsif operator == :+ && inverse?(:+, x)
e0
- elsif operator == :* && inverse?(x, :*)
+ elsif operator == :* && inverse?(:*, x)
e1
elsif [:+, :*].include?(operator) && x.send("#{to_str(operator)}?")
if combinable?(x.f, operator)
send(operator, x.f).send(operator, x.g)
elsif combinable?(x.g, operator)
@@ -41,23 +41,15 @@
elsif combinable?(x.x.g, operator)
send(operator, inverse(x.x.g, operator)).send(operator, inverse(x.x.f, operator))
else
super(x)
end
- elsif [:*].include?(operator) && x.subtrahend?
+ elsif [:*].include?(operator) && x.inverse?(:+)
inverse(::Algebra::Formula.new(self, x.x, operator.to_sym), :+)
else
super(x)
end
end
- end
-
- def to_str(operator)
- {
- addition: :+,
- multiplication: :*,
- exponentiation: :^
- }.key(operator)
end
end
end
end
end