ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 27 Oct 2019 07:42:11 +0100Excluding a common factor in a sumhttps://ask.sagemath.org/question/26628/excluding-a-common-factor-in-a-sum/I'm trying to figure out how to simplify this expression in Sage:
y = tau1*exp(-t/tau1)/(tau1 - tau2) - tau1*exp(-t/tau2)/(tau1-tau2)
When I try *factor(y)* or *simplify(y)*, I get this:
-tau1*(e^(t/tau1) - e^(t/tau2))*e^(-t/tau1 - t/tau2)/(tau1 - tau2)
However, the result I would like to see is this:
tau1/(tau1 - tau2)*(exp(-t/tau1) - exp(-t/tau2))
which seems like the simplest form to me. I've not been able to get this result with the various simplify commands or with assumptions (BTW, all variables are real, and tau1 & tau2 > 0).
In this case the simplest form is obvious, of course, but it would be a great help to be able to get this right for larger expressions.
Thu, 23 Apr 2015 11:29:25 +0200https://ask.sagemath.org/question/26628/excluding-a-common-factor-in-a-sum/Answer by Emmanuel Charpentier for <p>I'm trying to figure out how to simplify this expression in Sage: </p>
<pre><code>y = tau1*exp(-t/tau1)/(tau1 - tau2) - tau1*exp(-t/tau2)/(tau1-tau2)
</code></pre>
<p>When I try <em>factor(y)</em> or <em>simplify(y)</em>, I get this:</p>
<pre><code>-tau1*(e^(t/tau1) - e^(t/tau2))*e^(-t/tau1 - t/tau2)/(tau1 - tau2)
</code></pre>
<p>However, the result I would like to see is this:</p>
<pre><code> tau1/(tau1 - tau2)*(exp(-t/tau1) - exp(-t/tau2))
</code></pre>
<p>which seems like the simplest form to me. I've not been able to get this result with the various simplify commands or with assumptions (BTW, all variables are real, and tau1 & tau2 > 0).</p>
<p>In this case the simplest form is obvious, of course, but it would be a great help to be able to get this right for larger expressions.</p>
https://ask.sagemath.org/question/26628/excluding-a-common-factor-in-a-sum/?answer=48515#post-id-48515Try:
sage: var("t, tau, tau_1, tau_2")
(t, tau, tau_1, tau_2)
sage: f = tau_1*exp(-t/tau_1)/(tau_1 - tau_2) - tau_1*exp(-t/tau_2)/(tau_1-tau_2)
....:
sage: f.collect_common_factors()
tau_1*(e^(-t/tau_1) - e^(-t/tau_2))/(tau_1 - tau_2)
(i. e. $\frac{\tau_{1} {\left(e^{\left(-\frac{t}{\tau_{1}}\right)} - e^{\left(-\frac{t}{\tau_{2}}\right)}\right)}}{\tau_{1} - \tau_{2}}$), which, IMHO, is what you seek.Sun, 27 Oct 2019 07:42:11 +0100https://ask.sagemath.org/question/26628/excluding-a-common-factor-in-a-sum/?answer=48515#post-id-48515