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. ]

  • 相关阅读:
    Kubernetes实战模拟三(wordpress健康检查和服务质量QoS)
    Kubernetes实战模拟二(wordpress高可用)
    Kubernetes实战模拟一(wordpress基础版)
    Rook部署测试Ceph和wordpress实战应用
    kettle作业转换的执行
    BUU BURP COURSE 1
    BUU SQL COURSE 1
    BUU CODE REVIEW 1
    查看FGC
    Pod大量为Evicted被驱逐状态
  • 原文地址:https://www.cnblogs.com/douzujun/p/13392937.html
Copyright © 2011-2022 走看看