# Revision history [back]

(suggestion: edit your question to include clarifying information rather than put it in an answer)

It seems homomorphisms for fraction fields are a bit underdeveloped. However, for polynomials things work fine and since numerator and denominator allow you to take apart a fraction field element, you can just assemble the result you want yourself.

sage: RR = PolynomialRing(RR,'s')
sage: conv = lambda f: RR(f.numerator())/RR(f.denominator())
sage: [conv(c) for c in LL]
[0.533227478329869/(s + 1.08766810903621),
0.0780427896513687/(s + 2.96794729592164),
0.0137297320187619/(s + 5.57596354241057)]
sage: [inverse_laplace(conv(c),s,u) for c in LL]
[54528517/102261266*e^(-13571505/12477616*u),
3364341/43108928*e^(-163049898/54936925*u),
6233434/454009881*e^(-9174183/1645309*u)]


That last answer looks very fishy, though: you're inputting something with floats and you're getting back rational numbers. That can't be trustworthy. Something in the code has replaced floats by rationals that are close to it (that's what maxima does more often). But it means you don't know how to interpret those rational numbers.

Much more useful is

sage: var('a,b,s,u')
(a, b, s, u)
sage: inverse_laplace(a/(s+b),s,u)
a*e^(-b*u)


which shows you what the transform actually does on expressions of the form that you have.

Depending on what you want to do next, it could be that

def ilt(f):
if f.numerator().degree() > 0 or f.denominator().degree() >1 or f.denominator().leading_coefficient() != 1:
raise ValueError
return f.numerator()*exp(-f.denominator().constant_coefficient()*s)

sage: [ilt(f) for f in LL]
[0.5332274783298694?*e^(-1.087668109036214?*s),
0.07804278965136865?*e^(-2.967947295921641?*s),
0.01372973201876195?*e^(-5.575963542410567?*s)]


gives a more useful result. (Be careful: you do end up with an element in SR and elements of Qbar usually don't play nice with that. So you might STILL want to convert the relevant numbers to actual floats)

(suggestion: edit your question to include clarifying information rather than put it in an answer)

It seems homomorphisms for fraction fields are a bit underdeveloped. However, for polynomials things work fine and since numerator and denominator allow you to take apart a fraction field element, you can just assemble the result you want yourself.

sage: RR RRs = PolynomialRing(RR,'s')
sage: conv = lambda f: RR(f.numerator())/RR(f.denominator())
RRs(f.numerator())/RRs(f.denominator())
sage: [conv(c) for c in LL]
[0.533227478329869/(s + 1.08766810903621),
0.0780427896513687/(s + 2.96794729592164),
0.0137297320187619/(s + 5.57596354241057)]
sage: [inverse_laplace(conv(c),s,u) for c in LL]
[54528517/102261266*e^(-13571505/12477616*u),
3364341/43108928*e^(-163049898/54936925*u),
6233434/454009881*e^(-9174183/1645309*u)]


That last answer looks very fishy, though: you're inputting something with floats and you're getting back rational numbers. That can't be trustworthy. Something in the code has replaced floats by rationals that are close to it (that's what maxima does more often). But it means you don't know how to interpret those rational numbers.

Much more useful is

sage: var('a,b,s,u')
(a, b, s, u)
sage: inverse_laplace(a/(s+b),s,u)
a*e^(-b*u)


which shows you what the transform actually does on expressions of the form that you have.

Depending on what you want to do next, it could be that

def ilt(f):
if f.numerator().degree() > 0 or f.denominator().degree() >1 or f.denominator().leading_coefficient() != 1:
raise ValueError
return f.numerator()*exp(-f.denominator().constant_coefficient()*s)

sage: [ilt(f) for f in LL]
[0.5332274783298694?*e^(-1.087668109036214?*s),
0.07804278965136865?*e^(-2.967947295921641?*s),
0.01372973201876195?*e^(-5.575963542410567?*s)]


gives a more useful result. (Be careful: you do end up with an element in SR and elements of Qbar usually don't play nice with that. So you might STILL want to convert the relevant numbers to actual floats)