16

Bug intoduced in (8.0?) persisting through version 13.2


If we use TimeValue to look at the PV of an Annuity with initial payment:

TimeValue[ Annuity[{ 1, { p, 0 } }, 2], r ] // Apart

$p + \frac{1}{(1+r)^2} + \frac{1}{1+r}$

The initial payment p is taken to be at time 0. However if we take the Cashflow of the same Annuity and look at the PV of that Cashflow:

TimeValue[ Cashflow @ Annuity[{ 1, { p, 0 } }, 2], r ] // Apart

$\frac{1}{(1+r)^2} + \frac{1+p}{1+r}$

Suddenly p is now taken to be at time 1 instead of 0. Is this a bug?

bmf
  • 15,157
  • 2
  • 26
  • 63
asterix314
  • 1,325
  • 8
  • 19
  • 3
    Looks like a bug. Mathematica is quite clearly adding the initial payment to the first period rather than at t=0. Output Out[18] above should be Cashflow[{{0, p}, {1, 1}, {2, 1}}] – Mike Honeychurch Mar 17 '15 at 05:35
  • Yes, and it would be convenient that way to have initial payment at 0. BTW my version is 10.0.2.0. I don't know the behavior of previous versions. – asterix314 Mar 18 '15 at 02:00
  • 2
    Bug report submitted to WRI. – asterix314 Mar 25 '15 at 05:58
  • Please post code in text form, per site formatting help, rather than images of code! – murray Jan 23 '17 at 19:43
  • 5
    Looks like nobody at WRI cares to fix this rather simple bug. Sad. :) – gwr Feb 27 '17 at 12:35
  • As a workaround and in general I would always use Cashflow to make the payments and times more visible (as suggested by Mike). Then using the functionality shown here you can always construct complicated cashflows by adding and subtracting individual cashflows, e.g. cashflow = Cashflow[ Annuity[ 1, 5] ] + Cashflow[ {p} ]. – gwr Feb 27 '17 at 12:51
  • 3
    I just noticed this in version 12.3. When I went to post about it I found this earlier post. This bug will result in a wrong result in a financial calculation. Why hasn't it been fixed? – David Keith Sep 04 '21 at 23:30
  • Still persisting in v13.1 – IntroductionToProbability Oct 10 '22 at 13:21
  • 3
    It is ridiculous this bug has persisted for 7+ years now. If it is of any use, the case number was CASE:2800989 in whatever issue tracking system Wolfram Research was using back then. – asterix314 Oct 12 '22 at 06:43
  • 2
    I even scavenged out the email reply I got at the time, it said "It does appear that the Cashflow function is not behaving properly in this case and I have forwarded an incident report to our developers with the information you provided." -- So you see, there's a middle layer between the actual bug and the developpers. This stands in contrast with the Open Source model, where bug reports are directly sent to the dev team and are immediately viewable by everyone. – asterix314 Oct 12 '22 at 07:10
  • 3
    @asterix314 it is possible that the person who wrote this initially has left WRI and no one there understands the code fully to fix it without introducing new bug. May be if it is complex code. This happens all the time at large software companies. May be this is why it has not been fixed yet?. Just guessing ofcourse. – Nasser Oct 12 '22 at 08:41
  • 2
    @Nasser This happens all the time, true, but I can't believe it's the case for this one. MMA's QA is generally sound, and CashFlow is far from being the most complex function. That's why this bug doesn't make sense. – asterix314 Oct 12 '22 at 16:08

1 Answers1

6

WRI replied, finally:

We believe that the issue has been resolved in the current 13.2.1 release of Mathematica.

I don't have the newest version installed so I cannot verify. But I think we can take their word and consider the issue closed.

asterix314
  • 1,325
  • 8
  • 19
  • 4
    I can confirm that TimeValue[Annuity[{1, {p, 0}}, 2], r] // Apart and TimeValue[Cashflow@Annuity[{1, {p, 0}}, 2], r] // Apart both yield (p + 1/(1 + r)^2 + 1/(1 + r)) at v.13.2.1 – alex Apr 28 '23 at 10:10
  • What's that? 13 years later? I got an email from them 5 years after I reported a bug, telling me it had been fixed. I wonder what their mean bug-fix time is... – berniethejet Apr 28 '23 at 17:12
  • Better later than never - you are welcome :) – Gosia May 23 '23 at 18:33