Mapytex/mapytex/calculus/__init__.py

52 lines
1.0 KiB
Python

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2017 lafrite <lafrite@Poivre>
#
# Distributed under terms of the MIT license.
"""
Make calculus as a student
==========================
Expression is the classe wich handle all calculus. It can randomly generate or import calculus, simplify them and explain them as a student would do.
>>> render.set_render("txt")
>>> e = Expression.from_str("2x + 6 - 3x")
>>> print(e)
2x + 6 - 3x
>>> f = e.simplify()
>>> print(f)
- x + 6
>>> for s in f.explain():
... print(s)
2x + 6 - 3x
2x - 3x + 6
(2 - 3) * x + 6
- x + 6
Create random Expression
========================
>>> e = random.expression("{a} / {b} + {c} / {d}")
>>> print(e) # doctest: +SKIP
- 3 / - 10 + 3 / 5
"""
from .API import render, Expression
#from decimal import getcontext
from . import random
#getcontext().prec = 2
__all__ = ["render", "Expression", "random"]
# -----------------------------
# Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
# cursor: 16 del