zoukankan      html  css  js  c++  java
  • python转LaTeX

    !rm -rf latexify_py
    !git clone https://github.com/odashi/latexify_py -b develop
    !pip install -e latexify_py
    
    # Before running following cells, restart the runtime so that the installed
    # module is activated.
    import math
    import latexify
    
    @latexify.with_latex
    def solve(a, b, c):
        return (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)
    
    print(solve(1, 4, 3))
    print(solve)
    print()
    solve
    
    -1.0
    operatorname{solve}(a, b, c) 	riangleq frac{-b + sqrt{b^{2} - 4ac}}{2a}
    

    (operatorname{solve}(a, b, c) riangleq frac{-b + sqrt{b^{2} - 4ac}}{2a})

    @latexify.with_latex
    def sinc(x):
        if x == 0:
            return 1
        else:
            return math.sin(x) / x
    
    print(sinc)
    
    operatorname{sinc}(x) 	riangleq left{ egin{array}{ll} 1, & mathrm{if}  x=0 \ frac{sin{left({x}
    ight)}}{x}, & mathrm{otherwise} end{array} 
    ight.
    

    [operatorname{sinc}(x) riangleq left{ egin{array}{ll} 1, & mathrm{if} x=0 \ frac{sin{left({x} ight)}}{x}, & mathrm{otherwise} end{array} ight. ]

    # Elif or nested else-if are unrolled.
    @latexify.with_latex
    def fib(x):
        if x == 0:
            return 1
        elif x == 1:
            return 1
        else:
            return fib(x-1) + fib(x-2)
    
    print(fib)
    
    operatorname{fib}(x) 	riangleq left{ egin{array}{ll} 1, & mathrm{if}  x=0 \ 1, & mathrm{if}  x=1 \ operatorname{fib}left(x - 1
    ight) + operatorname{fib}left(x - 2
    ight), & mathrm{otherwise} end{array} 
    ight.
    

    [operatorname{fib}(x) riangleq left{ egin{array}{ll} 1, & mathrm{if} x=0 \ 1, & mathrm{if} x=1 \ operatorname{fib}left(x - 1 ight) + operatorname{fib}left(x - 2 ight), & mathrm{otherwise} end{array} ight. ]

  • 相关阅读:
    POLARDB与其他关系型数据库对比
    美团关于分布式ID实践方案
    CRM、DMP、CDP概念解析
    TIDB简介
    美团关于分布式ID实践方案细节
    美团在TIDB方面的实践
    设计模式之桥梁模式
    【转】Hibernate和IBatis对比
    Eclipse插件安装
    【转】揭开正则表达式的神秘面纱
  • 原文地址:https://www.cnblogs.com/douzujun/p/13392937.html
Copyright © 2011-2022 走看看