[Python] How to force Sympy to simplify expressions that contain logarithms inside an...

Discussão em 'Python' iniciado por Stack, Fevereiro 1, 2025.

  1. Stack

    Stack Membro Participativo

    Consider the following MWE:

    import sympy as sp
    a,b = sp.symbols("a b", positive=True, real=True)
    t = sp.symbols("t", real=True)
    s = sp.symbols("s")
    T = 1/(1+s*a)/(1+s*b)
    y = sp.inverse_laplace_transform(T,s,t)
    tmax = sp.solve(sp.diff(y,t),t)[0]
    ymax = y.subs(t,tmax)
    display(ymax.simplify())


    This code gives the following output: [​IMG]

    How can I force Sympy to simplify this expression? Both the fraction and the sum can be decomposed easily, leaving a term in the form of exp(log(x)), which can be simplified to x.

    Edit: Here is one example how the simplification of one exp() term could look like (the first one in this case): [​IMG]

    Continue reading...

Compartilhe esta Página