Exun.Fun (exun v0.5.2)

Function management. @base and @compound are the definitions of external functions.

Link to this section Summary

Functions

base is a map that holds functions names and a tupla For example

Compounds is a map that holds synthetic definitions. Function revert_compounds is able to look in an ast and identify this list, substituting the values. For now, the definitions are

returns true if ast contains variable vc

Finds and exec a function call. Search in base and compounds, if cannot find any returns a symbolic fcall.

returns true if ast is a polynomial element on v

Looks in compounds for a match of ast and return it. Thw first wins.

Link to this section Functions

base is a map that holds functions names and a tupla For example:

"ln(F)" => {&:math.log/1, "F'x/F", "x*ln(F)-$(x/F),x"}
  • ln(F) : means function name is 'ln' and can receive Functions as argument
  • &:math.log/1 : Is the Elixir numeric function for ln
  • F'x/F : is the symbolic derivative of ln, deriv(F,x)/F
  • x*ln(F)-$(x/F),x : is the symbolic integral for ln

For now the definitions are

    "ln(F)" => {&:math.log/1, "F'x/F", "x*ln(F)-$(x/F),x", "exp"},
    "exp(F)" => {&:math.exp/1, "F'x*exp(F)", nil, "ln"},
    "sin(F)" => {&:math.sin/1, "F'x*cos(F)", nil, "asin"},
    "cos(F)" => {&:math.cos/1, "-F'x*sin(F)", nil, "acos"},
    "tan(F)" => {&:math.tan/1, "F'x/cos(F)^2", nil, "atan"},
    "acos(F)" => {&:math.acos/1, "-F'x/(1-F^2)^0.5", nil, "cos"},
    "asin(F)" => {&:math.asin/1, "F'x/(1-F^2)^0.5", nil, "sin"},
    "atan(F)" => {&:math.atan/1, "F'x/(1+F^2)", nil, "tan"},
    "sinh(F)" => {&:math.sinh/1, "F'x*cosh(F)", nil, "asinh"},
    "cosh(F)" => {&:math.cosh/1, "F'x*sinh(F)", nil, "acosh"},
    "tanh(F)" => {&:math.tanh/1, "F'x/cosh(F)^2", nil, "atanh"},
    "asinh(F)" => {&:math.asinh/1, "F'x/(F^2+1)^0.5", nil, "sinh"},
    "acosh(F)" => {&:math.acosh/1, "F'x/(F^2-1)^0.5", nil, "cosh"},
    "atanh(F)" => {&:math.atanh/1, "F'x/(1-F^2)", nil, "tanh"}

Compounds is a map that holds synthetic definitions. Function revert_compounds is able to look in an ast and identify this list, substituting the values. For now, the definitions are:

"sqrt(F)" => "F^0.5",
"tan(F)" => "sin(F)/cos(F)"
Link to this function

contains(ast, vc)

returns true if ast contains variable vc

Link to this function

fcall(name, args)

Finds and exec a function call. Search in base and compounds, if cannot find any returns a symbolic fcall.

Link to this function

is_poly(ast, v)

returns true if ast is a polynomial element on v

Link to this function

revert_compounds(ast)

Looks in compounds for a match of ast and return it. Thw first wins.