Пример #1
0
 def to_latex(self, jupyter_display=False, outer=False):
     cont = latex_ratio(self.value)
     if cont and jupyter_display:
         display(Math(cont))
         display(Markdown("<details><pre>$" + cont + "$</pre></details>"))
     else:
         return cont
Пример #2
0
 def to_latex(self, jupyter_display=False, outer=False):
     if self.exponent == 0:
         cont = "1"
     elif self.exponent == 1:
         cont = self.base.to_latex()
     elif self.base.ask("trig_fn"):
         cont = r"\text{" + self.base.ask("trig_fn") + "}^{" + str(self.exponent) + "}" + self.base.argument.to_latex()
     elif self.exponent < 0:
         cont = r"\frac{1}{" + Power(self.base, abs(self.exponent)).to_latex() + "}"
     # ToDo: wortels ipv breuken afhankelijk van flag?
     else:
         cont = self.base.to_latex() + "^{" + latex_ratio(self.exponent) + "}" 
     if cont and jupyter_display:
         display(Math(cont))
         display(Markdown("<details><pre>$" + cont + "$</pre></details>"))
     else:
         return cont   
Пример #3
0
    def to_latex(self, jupyter_display=False):
        if self.exponent == 0:
            cont = "1"
        elif self.exponent == 1:
            cont = self.base.to_latex()
        elif hasattr(self.base, "trig_fn"):
            cont = r"\text{" + self.base.trig_fn + "}^{" + str(self.exponent) + "}" + self.base.argument.to_latex()
        elif self.exponent < 0:
            cont = r"\frac{1}{" + Power(self.base, abs(self.exponent)).to_latex() + "}"
        else:
            cont = self.base.to_latex() + "^{" + latex_ratio(self.exponent) + "}"

        if cont and jupyter_display:
            display(Math(cont))
            display(Markdown("<details><pre>$" + cont + "$</pre></details>"))
            return None
        else:
            return cont