Exun.Fun (exun v0.4.4)

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

For convenience, creates ast {{:m,:mult},[a,b^-1]}

For convenience, creates ast {:elev,a,b}

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

For convenience, creates ast {{:m,:mult},[a,b]}

Replace arguments on ast as specified. Not intended for external use, mus be public for now

For convenience, creates ast {{:m,:mult},[a,-b]}

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

For convenience, creates ast {{:m,:suma},[a,b]}

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"},
"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 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

For convenience, creates ast {{:m,:mult},[a,b^-1]}

For convenience, creates ast {:elev,a,b}

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

For convenience, creates ast {{:m,:mult},[a,b]}

Link to this function

replace_args_internal(ast, args, vari)

Replace arguments on ast as specified. Not intended for external use, mus be public for now

For convenience, creates ast {{:m,:mult},[a,-b]}

Link to this function

revert_compounds(ast)

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

For convenience, creates ast {{:m,:suma},[a,b]}