→ anki-sin-cos/
This commit is contained in:
parent
350891a6fa
commit
8ee526f85b
2 changed files with 1 additions and 1 deletions
30
anki-sin-cos/anki-sin-cos-table.py
Executable file
30
anki-sin-cos/anki-sin-cos-table.py
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python3
|
||||
from collections import OrderedDict
|
||||
from functools import reduce
|
||||
|
||||
from sympy import latex, simplify
|
||||
from sympy import pi, sin, cos, tan
|
||||
|
||||
|
||||
def anki_latex(e):
|
||||
"""Format SymPy expression as Anki LaTeX"""
|
||||
return "[$$]" + latex(e) + "[/$$]"
|
||||
|
||||
|
||||
def as_csv(*values):
|
||||
return reduce(lambda a, b: a + ";" + b, values)
|
||||
|
||||
|
||||
def deduplicate(iterable):
|
||||
return list(OrderedDict.fromkeys(iterable))
|
||||
|
||||
|
||||
xs = sorted(deduplicate(map(simplify,
|
||||
[i * pi / 4 for i in range(-16, 16)]
|
||||
+ [i * pi / 6 for i in range(-24, 24)])))
|
||||
|
||||
for x in xs:
|
||||
for f in [sin, cos, tan]:
|
||||
front = "What is " + anki_latex(f(x, evaluate=False)) + "?"
|
||||
back = anki_latex(f(x))
|
||||
print(as_csv(front, back))
|
Loading…
Add table
Add a link
Reference in a new issue