package dual

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module DualSource

Dual numbers. This module provides arithmetic operations on dual numbers represented as double-precision floating-point numbers (type float).

Sourcetype t = {
  1. re : float;
  2. dre : float;
}

The type of dual numbers. re is the value and dre the derivative.

Sourceval dual : ?y:float -> float -> t

Create a dual number. By default dre is set to 1.

Sourceval print_dual : t -> unit

Pretty print dual number.

Sourceval equal : t -> t -> bool

Check equality between two dual numbers.

Sourceval add : t -> t -> t

Addition.

Sourceval sub : t -> t -> t

Subtraction.

Sourceval neg : t -> t

Unary negation.

Sourceval mul : t -> t -> t

Multiplication.

Sourceval div : t -> t -> t

Division

Sourceval pow : t -> float -> t

Power function. pow d1 d2 returns d1 to the d2 power.

Sourceval sqrt : t -> t

Square root.

Sourceval exp : t -> t

Exponentiation. exp d returns e to the d power.

Sourceval log : t -> t

Natural logarithm (in base e).

Sourceval sin : t -> t

Sine function.

Sourceval cos : t -> t

Cosine function.

Sourceval tan : t -> t

Tangent function.

Sourceval asin : t -> t

Inverse sine function.

Sourceval acos : t -> t

Inverse cosine function.

Sourceval atan : t -> t

Inverse tangent function.

Sourceval sinh : t -> t

Hyperbolic sine function.

Sourceval cosh : t -> t

Hyperbolic cosine function.

Sourceval tanh : t -> t

Hyperbolic tangent function.

Sourceval root : (t -> t) -> t -> t

root f x0 returns the root of f with starting value x0 via Newton's method.

OCaml

Innovation. Community. Security.