# module NumRu::GPhys::Derivative in derivative.rb

## Index

- module NumRu::GPhys::Derivative
  - threepoint_O2nd_deriv
    - First derivative (2nd Order difference use three point.)
  - cderiv
    - First derivative (using center difference method)

# module NumRu::GPhys::Derivative

Module functions of Derivative Operater for GPhys.

`threepoint_O2nd_deriv(gp, dim_or_dimname, bc=NumRu::Derivative::LINEAR_EXT))`

  Derivate `z` respect to `dim` th dimension with 2nd Order difference. return an NArray which result of the difference z divided difference `x` (in other wards,

      (s**2*z_{i+1} + (t**2 - s**2)*f_{i} - t**2*f_{i-1}) / (s*t*(s + t)):
      now s represents (x_{i} - x_{i-1}) ,t represents (x_{i+1} - x_{i})
      and _{i} represents the suffix of {i} th element in the ((<dim>)) th
      dimension of array. ).

  ARGUMENTS

  - z (NArray): a NArray which you want to derivative.
  - x (NArray): a NArray represents the dimension which derivative respect to. z.rank must be 1.
  - dim (Numeric): a Numeric represents the dimention which derivative respect to. you can give number count backward (dim<0), but z.rank ¡Üdim must be > 0.
  - bc (Numeric) : a Numeric which represent boundary condition. now only LINEAR_EXT(=1) supported. LINEAR_EXT load b_expand_linear_ext which extend boundary with lenear value.

  RETURN VALUE

  - O2nd_deriv_data (NArray): (s**2*z_{i+1} + (t**2 - s**2)*f_{i} - t**2*f_{i-1}) / (s*t*(s + t))
`cderiv(gp, dim_or_dimname, bc=NumRu::Derivative::LINEAR_EXT)`

  Derivate `gp` respect to `dim` th or `dimname` dimension with center difference. return a GPhys which result of the difference gp divided difference axis. ( in other wards, (z_{i+1} - z_{i-1}) / (x_{i+1} - x_{i-1}): now x is axis array which you wants to respects to, _{i} represents the suffix of {i} th element in the dim th dimension of array. ).

  ARGUMENTS

  - gp (GPhys): a GPhys which you want to derivative.
  - dim_or_dimname (Numeric or String): a Numeric or String represents the dimension which derivate respect to. you can give number count backward (dim<0), but z.rank ¡Üdim must be > 0.
  - bc (Numeric) : a Numeric which represent boundary condition. now only NumRu::Derivative::LINEAR_EXT(=1) supported. LINEAR_EXT load NumRu::Derivative::b_expand_linear_ext which extend boundary with linear value.

  RETURN VALUE

  - a GPhys