Documentation ¶
Index ¶
- Constants
- Variables
- func BinomialCoefficient(k float64, n float64) float64
- func BinomialXEqualTo(k float64, n float64, p float64) float64
- func BinomialXLessThan(k float64, n float64, p float64) (law float64)
- func CheckExpression(function string) (err error)
- func Evaluate(function string, x float64) (value float64, err error)
- func Factorial(n float64) (o float64)
- func GatherFunctions()
- func GenerateLatex(name string, heading string, expression string) (pngPath string, file *os.File, err error)
- func Integral(args ...interface{}) (interface{}, error)
- func Plot(c chart.Chart, name string) telegram.FileReader
- func Surface(args ...interface{}) (interface{}, error)
Constants ¶
const CalcDisclaimer = "" /* 268-byte string literal not displayed */
CalcDisclaimer is the default disclaimer for commands that use mathematical expressions
const LatexHeader = `` /* 221-byte string literal not displayed */
LatexHeader contains the default header for all LaTeX outputs
Variables ¶
var BasicFunctions = map[string]govaluate.ExpressionFunction{ "sqrt": oneParamFunc(math.Sqrt), "abs": oneParamFunc(math.Abs), "rem": twoParamsFunc(math.Remainder), "gamma": oneParamFunc(math.Gamma), "fact": oneParamFunc(Factorial), "floor": oneParamFunc(math.Floor), "ceil": oneParamFunc(math.Ceil), "exp": oneParamFunc(math.Exp), "ln": oneParamFunc(math.Log), "log": oneParamFunc(math.Log10), "sin": oneParamFunc(math.Sin), "cos": oneParamFunc(math.Cos), "tan": oneParamFunc(math.Tan), "asin": oneParamFunc(math.Asin), "acos": oneParamFunc(math.Acos), "atan": oneParamFunc(math.Atan), "sinh": oneParamFunc(math.Sinh), "cosh": oneParamFunc(math.Cosh), "tanh": oneParamFunc(math.Tanh), "dsin": degreeToRadiansFunc(math.Sin), "dcos": degreeToRadiansFunc(math.Cos), "dtan": degreeToRadiansFunc(math.Tan), "dasin": degreeToRadiansFunc(math.Asin), "dacos": degreeToRadiansFunc(math.Acos), "datan": degreeToRadiansFunc(math.Atan), "dsinh": degreeToRadiansFunc(math.Sinh), "dcosh": degreeToRadiansFunc(math.Cosh), "dtanh": degreeToRadiansFunc(math.Tanh), "binomcoef": twoParamsFunc(BinomialCoefficient), "binomet": threeParamsFunc(BinomialXEqualTo), "binomlt": threeParamsFunc(BinomialXLessThan), }
var Colors = []string{"red", "green", "blue", "cyan", "magenta", "yellow", "black", "gray", "white", "darkgray", "lightgray", "brown", "lime", "olive", "orange", "pink", "purple", "teal", "violet"}
Colors defines the colors that can be used in LaTeX outputs (using the `xcolor` package)
var DataDocumentation = func() string { var functionsDescription string for name := range BasicFunctions { functionsDescription += fmt.Sprintf("`%s`, ", name) } functionsDescription = strings.TrimSuffix(functionsDescription, ", ") var processesDescription string for name := range Processes { processesDescription += fmt.Sprintf("`%s`, ", name) } processesDescription = strings.TrimSuffix(processesDescription, ", ") var constantsDescription string for name := range Constants { constantsDescription += fmt.Sprintf("`%s`, ", name) } constantsDescription = strings.TrimSuffix(constantsDescription, ", ") return fmt.Sprintf("📈 Les fonctions disponibles sont : %s.\n⚙ Les procédés mathématiques, prenants en paramètres des expressions entre guillemets, sont : %s.\nπ Les constantes disponibles sont: %s.", functionsDescription, processesDescription, constantsDescription) }()
DataDocumentation holds the documentation for the available functions and constants, to use in mathematical expressions
var Functions = map[string]govaluate.ExpressionFunction{}
var PlotColors = []color.NRGBA{
{0xcd, 0xdc, 0x39, 0xff},
{0x03, 0xa9, 0xf4, 0xff},
{0xf4, 0x43, 0x36, 0xff},
{0x8b, 0xc3, 0x4a, 0xff},
{0x00, 0xbc, 0xd4, 0xff},
{0xff, 0x98, 0x00, 0xff},
{0x9c, 0x27, 0xb0, 0xff},
{0x00, 0x96, 0x88, 0xff},
{0xe9, 0x1e, 0x63, 0xff},
{0x79, 0x55, 0x48, 0xff},
{0x4c, 0xaf, 0x50, 0xff},
{0xff, 0xc1, 0x07, 0xff},
{0x3f, 0x51, 0xb5, 0xff},
{0x21, 0x96, 0xf3, 0xff},
{0xff, 0xeb, 0x3b, 0xff},
}
PlotColors defines the colors available for charts
var Processes = map[string]govaluate.ExpressionFunction{ "integral": Integral, "surface": Surface, }
Functions ¶
func BinomialCoefficient ¶
BinomialCoefficient returns "k in n"
func BinomialXEqualTo ¶
BinomialXEqualTo returns P(X = p)
func BinomialXLessThan ¶
BinomialXLessThan returns P(X <= p)
func CheckExpression ¶
CheckExpression checks if a mathematical expression is valid (taking in account the syntax and available functions)
func GatherFunctions ¶
func GatherFunctions()
GatherFunctions lists the functions the user can use in their expressions
func GenerateLatex ¶
func GenerateLatex(name string, heading string, expression string) (pngPath string, file *os.File, err error)
GenerateLatex renders a LaTeX expression into a PNG file
func Integral ¶
func Integral(args ...interface{}) (interface{}, error)
Integral uses Simpson's rule to integrate a function See https://en.wikipedia.org/wiki/Simpson%27s_rule
Types ¶
This section is empty.