Class: Exp

Inherits:
Equation show all
Defined in:
lib/symcalc.rb

Overview

Implements the exp operation in SymCalc

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Equation

#*, #**, #+, #-, #/, #coerce, #derivative, #eval, #inspect, #simplify, #to_s

Constructor Details

#initialize(power) ⇒ Exp

Returns a new instance of Exp.



553
554
555
# File 'lib/symcalc.rb', line 553

def initialize power
	@power = to_equation(power)
end

Instance Attribute Details

#powerObject

Returns the value of attribute power.



551
552
553
# File 'lib/symcalc.rb', line 551

def power
  @power
end

Instance Method Details

#==(eq) ⇒ Object



569
570
571
572
573
574
575
# File 'lib/symcalc.rb', line 569

def == eq
	if eq.is_a? Exp
		return eq.power == @power
	else
		return false
	end
end

#__derivative__(variable: nil) ⇒ Object



565
566
567
# File 'lib/symcalc.rb', line 565

def __derivative__ variable: nil
	return Exp.new(@power) * @power.derivative(variable: variable)
end

#__eval__(var_hash) ⇒ Object



561
562
563
# File 'lib/symcalc.rb', line 561

def __eval__ var_hash
	return Math::E ** (@power.eval(var_hash))
end

#__get_m_elements__(var_hash) ⇒ Object



587
588
589
590
591
592
593
594
# File 'lib/symcalc.rb', line 587

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



577
578
579
580
581
582
583
584
585
# File 'lib/symcalc.rb', line 577

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

#all_variablesObject



596
597
598
# File 'lib/symcalc.rb', line 596

def all_variables
	return @power.all_variables
end

#displayObject



557
558
559
# File 'lib/symcalc.rb', line 557

def display
	return "exp(#{@power.display})"
end