Class: CAS::Acos
Overview
Representation for the ‘arccos(x)` function. It is implemented as a `CAS::Op`. It is the inverse of the `cos(x)` function
Instance Attribute Summary
Attributes inherited from Op
Class Method Summary collapse
Instance Method Summary collapse
-
#call(f) ⇒ Object
Call resolves the operation tree in a ‘Numeric` (if `Fixnum`) or `Float` (depends upon promotions).
- #diff(v) ⇒ Object
-
#simplify ⇒ Object
Simplification callback.
-
#to_code ⇒ Object
Convert expression to code (internal, for ‘CAS::Op#to_proc` method).
-
#to_s ⇒ Object
Convert expression to string.
Methods inherited from Op
#!=, #*, #**, #+, #-, #-@, #/, #==, #args, #as_proc, #depend?, #dot_graph, #equal, #greater, #greater_equal, #initialize, #inspect, #limit, numeric_to_const, simplify_dict, #simplify_dictionary, #smaller, #smaller_equal, #subs, #to_c_lib
Constructor Details
This class inherits a constructor from CAS::Op
Class Method Details
Instance Method Details
#call(f) ⇒ Object
Call resolves the operation tree in a ‘Numeric` (if `Fixnum`) or `Float` (depends upon promotions). As input, it requires an hash with `CAS::Variable` or `CAS::Variable#name` as keys, and a `Numeric` as a value
* **argument**: `Hash` with feed dictionary
* **returns**: `Numeric`
298 299 300 301 |
# File 'lib/functions/fnc-trig.rb', line 298 def call(f) CAS::Help.assert(f, Hash) return Math::acos(@x.call(f)) end |
#diff(v) ⇒ Object
283 284 285 286 287 288 289 |
# File 'lib/functions/fnc-trig.rb', line 283 def diff(v) if @x.depend? v return CAS.invert(@x.diff(v)/CAS.sqrt(CAS::One - CAS.pow(@x, CAS::Two))) else return CAS::Zero end end |
#simplify ⇒ Object
Simplification callback. It simplify the subgraph of each node until all possible simplification are performed (thus the execution time is not deterministic).
* **returns**: `CAS::Op` simplified version
315 316 317 318 319 |
# File 'lib/functions/fnc-trig.rb', line 315 def simplify super return @x.x if @x.is_a? CAS::Cos return self.simplify_dictionary end |
#to_code ⇒ Object
Convert expression to code (internal, for ‘CAS::Op#to_proc` method)
* **returns**: `String` that represent Ruby code to be parsed in `CAS::Op#to_proc`
331 332 333 |
# File 'lib/functions/fnc-trig.rb', line 331 def to_code "Math::acos(#{@x.to_code})" end |
#to_s ⇒ Object
Convert expression to string
* **returns**: `String` to print on screen
306 307 308 |
# File 'lib/functions/fnc-trig.rb', line 306 def to_s "acos(#{@x})" end |