Exun.Fun (exun v0.5.0)
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()
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"},
"sin(F)" => {&:math.sin/1, "F'x*cos(F)", nil},
"cos(F)" => {&:math.cos/1, "-F'x*sin(F)", nil},
"tan(F)" => {&:math.tan/1, "F'x/cos(F)^2", nil},
"acos(F)" => {&:math.acos/1, "-F'x/(1-F^2)^0.5", nil},
"asin(F)" => {&:math.asin/1, "F'x/(1-F^2)^0.5", nil},
"atan(F)" => {&:math.atan/1, "F'x/(1+F^2)", nil},
"sinh(F)" => {&:math.sinh/1, "F'x*cosh(F)", nil},
"cosh(F)" => {&:math.cosh/1, "F'x*sinh(F)", nil},
"tanh(F)" => {&:math.tanh/1, "F'x/cosh(F)^2", nil},
"asinh(F)" => {&:math.asinh/1, "F'x/(F^2+1)^0.5", nil},
"acosh(F)" => {&:math.acosh/1, "F'x/(F^2-1)^0.5", nil},
"atanh(F)" => {&:math.atanh/1, "F'x/(1-F^2)", nil}
compounds()
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)"
contains(ast, vc)
returns true if ast contains variable vc
fcall(name, args)
Finds and exec a function call. Search in base and compounds, if cannot find any returns a symbolic fcall.
finv(name)
is_poly(ast, v)
returns true if ast is a polynomial element on v
revert_compounds(ast)
Looks in compounds for a match of ast and return it. Thw first wins.