I’m using Mathematica for some conceptually simple algebra, that will ultimately land in Excel or a compiled language.
$Assumptions = Element[{r0,r1,t0,t1,disc0}, Reals] && (t1>t0) && (disc0>0)
(* Also, typically, r0 ≈ r1 && r0 ≈ 0 && r1 ≈ 0 *)
r[t_] = ((t1-t)r0+(t-t0)r1) / (t1-t0) (* Linear interpolation *)
disc[t_] = disc0 Exp[-Integrate[r[tt], {tt, 0, t}]]
ans = Integrate[disc[t], {t,t0,t1}]
ans // FullSimplify
It works, in that it produces an answer. But the answer has multiple divisions by (r0 - r1), or, worse, by its Sqrt, As said in the first comment in the code, r0 ≈ r1 && r0 ≈ 0 && r1 ≈ 0. Hence dividing by (r0 - r1) is numerically unwise. Please, is there a means of instructing Mathematica of the approximate equalities, so as to discourage division by things near zero?
Perhaps relevant: $Version = “9.0 for Mac OS X x86 (64-bit) (January 24, 2013)”.
Thank you.

:=rather than=. – A.G. Apr 23 '21 at 21:49Integratecommand to be executed at definition-time (i.e., only once), not at function-call time (i.e., at every call). – Roman Apr 24 '21 at 17:26=in defining functions? – A.G. Apr 24 '21 at 17:41a=5anda[x_]=5. – Roman Apr 24 '21 at 17:58