diff --git a/mathbot/calculator/parser.py b/mathbot/calculator/parser.py index bd62e725..6267474d 100644 --- a/mathbot/calculator/parser.py +++ b/mathbot/calculator/parser.py @@ -704,7 +704,7 @@ def tokenizer(original_string, ttypes, source_name = '__unknown__'): ('string', r'"(?:\\.|[^\\"])*"'), ('string', r'“(?:\\.|[^\\”])*”'), ('glyph', r';\\.|;[^\\]'), - ('word', r'π|τ|∞|[a-zA-Z_][a-zA-Z0-9_]*'), + ('word', r'π|τ|∞|φ|ϕ|[a-zA-Z_][a-zA-Z0-9_]*'), # ('die_op', r'd'), ('pow_op', r'\^'), ('superscript', r'[⁰¹²³⁴⁵⁶⁷⁸⁹]+'), diff --git a/mathbot/calculator/runtime.py b/mathbot/calculator/runtime.py index 4af83230..d45b8bd4 100644 --- a/mathbot/calculator/runtime.py +++ b/mathbot/calculator/runtime.py @@ -151,6 +151,10 @@ def reduce_to_float(value): 'π': sympy.pi, 'τ': sympy.pi * 2, 'tau': sympy.pi * 2, + 'φ': sympy.S.GoldenRatio, + 'phi': sympy.S.GoldenRatio, + 'ϕ': (1 - math.sqrt(5)) / 2, + 'phiconj': (1 - math.sqrt(5)) / 2, 'true': True, 'false': False } @@ -159,8 +163,12 @@ def reduce_to_float(value): FIXED_VALUES_EXPORTABLE = { 'π': math.pi, 'τ': math.pi * 2, + 'φ': (1 + math.sqrt(5)) / 2, + 'ϕ': (1 - math.sqrt(5)) / 2, 'pi': math.pi, 'tau': math.pi * 2, + 'phi': (1 + math.sqrt(5)) / 2, + 'phiconj': (1 - math.sqrt(5)) / 2, 'true': True, 'false': False }