Custom print on jupyter laptop

I am looking for an alternative to MathCad for simple calculations, but I wanted the expressions to look like I used a pen and paper and make reading easier for people who don't know programming. I tried Sweave, Knitr, but I was unhappy with this. I recently found a Jupyter laptop with SymPy, and it's still not as easy as MathCad for me, but I will try. With Jupyter, I'm having trouble printing formulas: I want to automatically print both sides of the equation .

What I want:

enter image description here

What I get:

enter image description here

What i tried

ccode does not return latex, and it always boringly prints "assign_to" enter image description here

+4
source share
3

, .

class Equation(object):    
    def __init__(self, left, right, mode='latex'):        
        self.mode = mode
        self.left = left
        self.right = right

        self._eq = sym.Eq(left, right)
        self._latex = sym.latex(self._eq)

    def __repr__(self):
        if self.mode == 'latex':
            return self._latex.__repr__()
        elif self.mode == 'sympy':
            return self._eq.__repr__()

    def __str__(self):
        if self.mode == 'latex':
            return self._latex
        elif self.mode == 'sympy':
            return self.eq.__str__()

    def eq(self):
        return self._eq

    def latex(self):
        return self._latex

    @property
    def mode(self):
        return self._mode

    @mode.setter
    def mode(self, val):
        self._mode = val

    @property
    def left(self):
        return self._left
    @left.setter
    def left(self, val):
        self._left = sym

    @property
    def right(self):
        return self._right

    @right.setter
    def right(self, val):
        self._right = val
# end of class 

enter image description here

+4

sympy.Eq, . = Python, Python R_r Sympy (c_1 + (c_2*x/G) + c_3*V)*G.

, Python , . "", R_r.

R_r Eq(R_r, (c_1 + (c_2*x/G) + c_3*V)*G).

. http://docs.sympy.org/latest/tutorial/gotchas.html http://nedbatchelder.com/text/names.html.

+2
0
source

Source: https://habr.com/ru/post/1652287/


All Articles