Class: Exp
Overview
Implements the exp operation in SymCalc
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Equation
#*, #**, #+, #-, #/, #coerce, #derivative, #eval, #inspect, #simplify, #sub, #to_s
Constructor Details
#initialize(power) ⇒ Exp
Returns a new instance of Exp.
588
589
590
|
# File 'lib/symcalc.rb', line 588
def initialize power
@power = to_equation(power)
end
|
Instance Attribute Details
#power ⇒ Object
Returns the value of attribute power.
586
587
588
|
# File 'lib/symcalc.rb', line 586
def power
@power
end
|
Instance Method Details
#==(eq) ⇒ Object
604
605
606
607
608
609
610
|
# File 'lib/symcalc.rb', line 604
def == eq
if eq.is_a? Exp
return eq.power == @power
else
return false
end
end
|
#__derivative__(variable: nil) ⇒ Object
600
601
602
|
# File 'lib/symcalc.rb', line 600
def __derivative__ variable: nil
return Exp.new(@power) * @power.derivative(variable: variable)
end
|
#__eval__(var_hash) ⇒ Object
596
597
598
|
# File 'lib/symcalc.rb', line 596
def __eval__ var_hash
return Math::E ** (@power.eval(var_hash))
end
|
#__get_m_elements__(var_hash) ⇒ Object
622
623
624
625
626
627
628
629
|
# File 'lib/symcalc.rb', line 622
def __get_m_elements__ var_hash
if var_hash.keys.include? "exp"
var_hash["exp"] += @power
else
var_hash["exp"] = @power
end
return var_hash
end
|
#__simplify__ ⇒ Object
612
613
614
615
616
617
618
619
620
|
# File 'lib/symcalc.rb', line 612
def __simplify__
if @power.is_a? Ln
return @power.eq
elsif @power.is_a?(Log) && @power.base == BasicVars::E
return @power.eq
else
return self
end
end
|
#__sub__(original, replacement) ⇒ Object
635
636
637
638
|
# File 'lib/symcalc.rb', line 635
def __sub__ original, replacement
return to_equation(replacement) if self == to_equation(original)
return Exp.new(@power.__sub__(original, replacement))
end
|
#all_variables ⇒ Object
631
632
633
|
# File 'lib/symcalc.rb', line 631
def all_variables
return @power.all_variables
end
|
#display ⇒ Object
592
593
594
|
# File 'lib/symcalc.rb', line 592
def display
return "exp(#{@power.display})"
end
|