src

package
v0.0.0-...-6de9b76 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2021 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const CalcDisclaimer = "" /* 268-byte string literal not displayed */

CalcDisclaimer is the default disclaimer for commands that use mathematical expressions

View Source
const LatexHeader = `` /* 221-byte string literal not displayed */

LatexHeader contains the default header for all LaTeX outputs

Variables

View Source
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),
}
View Source
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)

View Source
var Constants = map[string]interface{}{
	"e":   math.E,
	"pi":  math.Pi,
	"phi": math.Phi,
}
View Source
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

View Source
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

View Source
var Processes = map[string]govaluate.ExpressionFunction{

	"integral": Integral,
	"surface":  Surface,
}

Functions

func BinomialCoefficient

func BinomialCoefficient(k float64, n float64) float64

BinomialCoefficient returns "k in n"

func BinomialXEqualTo

func BinomialXEqualTo(k float64, n float64, p float64) float64

BinomialXEqualTo returns P(X = p)

func BinomialXLessThan

func BinomialXLessThan(k float64, n float64, p float64) (law float64)

BinomialXLessThan returns P(X <= p)

func CheckExpression

func CheckExpression(function string) (err error)

CheckExpression checks if a mathematical expression is valid (taking in account the syntax and available functions)

func Evaluate

func Evaluate(function string, x float64) (value float64, err error)

Evaluate calculates f(x) for a certain function contained in an expression

func Factorial

func Factorial(n float64) (o float64)

Factorial is the mathematical function n! = 1 × 2 × 3 × ⋯ × n

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

func Plot

func Plot(c chart.Chart, name string) telegram.FileReader

Plot generates the image file for a chart, ready to be sent over Telegram

func Surface

func Surface(args ...interface{}) (interface{}, error)

Surface is a short-hand to calculate integral of a function while taking in account its sign

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL