Skip to content

Special Command Documentation

Thomas Xin edited this page Oct 23, 2021 · 5 revisions

Math

~math utilises the SymPy library running in concurrent subprocesses to perform calculations. It supports almost all SymPy features, NumPy features, as well as several custom additions, making it an incredibly powerful command. By default it has a timeout limit of 24 seconds at which point subprocesses are automatically restarted, in order to protect the bot against malicious uses of the command. The numerical inputs of many other commands optionally accept any equation that may be evaluated to a real number via this command.

Examples

~math 1+1

1+1 = 2
  • Evaluates operations in the typical BODMAS order.

~math (4 + 101) * 3.2 ^ 9 / 0.3

(4 + 101) * 3.2 ^ 9 / 0.3 = 12314530.2310912
962072674304
────────────
   78125
  • "deg" is a hardcoded variable that is always equal to π/180 (since SymPy uses radians as the default angle unit)

~math tan(75deg) * 6

tan(75deg) * 6 = 22.392304845413263761164678049035234201656831522862283768334841876711598101452800222486877120543491454053756848492440218179819671
6∙√3 + 12
  • This wraps the sympy.limit function, allowing easy evaluation of limits as well as substitutions.

~math lim(sin(x) / tan(x), x=0)

lim(sin(x) / tan(x), x=0) = 1
  • Normally this function is called "integrate" in SymPy, "intg" is simply an alias specific to Miza.

~math intg(8/x - 9^x)

intg(8/x - 9^x) = -0.45511961331341869680712008286805350030631802862760587236315103164764054159689687332363589041904357414485064160234702996333541748*9.0**x + 8.0*log(x)
   x
- 9  + log(43046721)∙log(x)
───────────────────────────
          2∙log(3)
  • A space after a function will cause it to operate on as much of the rest of the equation as possible.

~math series cot(x)

series cot(x) = 1/x - 0.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333*x - 0.022222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222*x**3 - 0.0021164021164021164021164021164021164021164021164021164021164021164021164021164021164021164021164021164021164021164021164021164021*x**5 + O(x**6)
         3      5
1   x   x    2∙x     ⎛ 6⎞
─ - ─ - ── - ──── + O⎝x ⎠
x   3   45   945
  • SymPy is unable to find very large prime factors; Miza uses an implementation of ECM/SIQS, compiled using -O3 in order to perform factorization of numbers 2^64 or higher.

~math factorize 926624075136003096545328250804711150013986785341302199487213356671

factorize 926624075136003096545328250804711150013986785341302199487213356671 = [682147664994066786270370071898073, 1358392211375615758890099570491927]
  • Able to use all SymPy plotting functions, automatically uploading them to Discord as message attachments.

~math plot atan(x)

plot_atan

  • Able to use NumPy arrays, which will default to using Sympy's Symbol as their data type. Most NumPy array functions are supported, including multi-dimensional matrix operations.

~math array([0.9, 0.8], [0.1, 0.2]) @ array([0.9, 0.8], [0.1, 0.2]) @ array([0.9, 0.8], [0.1, 0.2])

array([0.9,0.8],[0.1,0.2])@array([0.9,0.8],[0.1,0.2])@array([0.9,0.8],[0.1,0.2]) = [[889/1000, 111/125], [111/1000, 14/125]]
⎡889   111⎤
⎢────  ───⎥
⎢1000  125⎥
⎢         ⎥
⎢111    14⎥
⎢────  ───⎥
⎣1000  125⎦

~math std([6.26,6.23,6.34,6.26,6.24,6.32,6.26,6.30,6.35,6.28])

std([6.26,6.23,6.34,6.26,6.24,6.32,6.26,6.30,6.35,6.28]) = 0.039547439866570377023096004599049311060101564575088264603038624524976335121731679426234333322105190006337321094292526744914871829
√391
────
500 
  • Some additional custom functions:

~math random(1, 6) # randomiser

random(1, 6) = 6

~math brainfuck(--[------+<]-----.[----+<]-----.+++.+++[--+++<]-.) # brainfuck interpreter

brainfuck(--[------+<]-----.[----+<]-----.+++.+++[--+++<]-.) = bruh

~math predict_next([2, 10, 30, 68, 130]) # number sequence analyser

predict_next([2, 10, 30, 68, 130]) = 222

~math ncr(20, 4) # combinatoric math

ncr(20, 4) = 4845

~math normcdf(0.015) # features replicated from MATLAB (not actually used as a backend)

normcdf(0.015) = 0.5059839098085622313559945968065538999733772181397131831462237785234884185900457339812876872297739877112041169683752824377648909
            ⎛3∙√2⎞
1 - 0.5∙erfc⎜────⎟
            ⎝400 ⎠

~math plot_array([5, 9, 12, -1, 3]) # direct support for Matplotlib

plot_array

  • This command is open to suggestions for more custom additions or integrations!

Reminder

~reminder is a powerful command that can be used to schedule messages in an embed at a certain point in the future.

Examples

remind_3s

remind_7h1m50s

remind_5m55s

remind_99999

remind_3pm

announce_miza

remind_when

remind_as

remind_every