Author Archives: stern

IRR and NPV in Mathematica, the modern way

Back in 2010 I posted an explanation of how to compute net present values and internal rates of return in Mathematica. It worked but it was a little verbose. Considering that Mathematica can do things like optical character recognition with a single command, it seemed a shame that it couldn’t do these basic financial functions.

Wolfram has fixed this, and computing IRR and NPV in Mathematica is now much more civilized.

Using the same sample cash-flow as last time (but reformatting the date to list-format, as Mathematica’s Cashflow[] function demands for some reason),

testFlow = {{{2001, 1, 1}, -1}, {{2002, 1, 1}, .3}, {{2005, 1, 1}, .4}, {{2005, 1, 10}, .5}};

TimeValue[Cashflow[testFlow], .05, {2001, 1, 1}]

returns an NPV of .0256519, just as it should. And

FindRoot[TimeValue[Cashflow[testFlow], r, {2001, 1, 1}] == 0, {r, .05}]

gives us the IRR, in this case .0584316.

Mathematica clearly performs a compilation the first time my NPV is run, and while the native NPV and IRR computations are quicker than mine the first time one of them is run by about a factor of 50, the second time one of them is run (whether on the same data or not) my code is quicker than theirs by about 30%. Mine is also ecumenical about date formats, but in practice I find myself using their code anyway, as it is so concise.

New Sled Dogs have reached the U.S. A few pairs, anyway.

The mad Norwegians who own the rights to the Sled Dogs design and name re-entered the U.S. market this year. They (or their Hungarian partners, it’s all sort of opaque to me) made only a few units available and most sizes sold out quickly. When I pre-ordered a pair months later, it was only order ID 45, suggesting that perhaps only a few dozen pairs of skates had made the initial run.

My skates arrived this week. Perhaps too late for this season, but the lining around the heels of my old SD250s had been worn to nothing and I needed a new pair. The color of the F5s is striking but the overall design is very similar to that of the 250s, and the bases are identical. The new logo is forgettable, but they’re cheaply silkscreened onto the boots and will probably wear off in use anyway.

Sled Dog F5

I retrieved my 250s and K9s for comparison; I haven’t used the K9s in many years and had forgotten how heavy they were. As I recall them, the K9s were nearly impossible to control, best for when you want to spin down a slope at reckless angles.

A video of the unboxing, below

The Wolfram Language is Here?

Stephen Wolfram released a formal introduction to The Wolfram Language two days ago but I am watching it only now.

 

 

The demonstration answers a question I had had since first hearing about this language — How is it different from Mathematica? The answer seems to be that this is the Mathematica programming language, IDE, and APIs, but conceptually separated from the Mathematica environment and given its own name. Thus, those of use who used to say we “programmed in Mathematica” will now say we “program in the Wolfram Language,” and the code we create in Mathematica can also be run in other environments (in web browsers, on embedded devices, etc.).

It’s nice to hear Wolfram credit this as a learning language; many people regard Mathematica as complex and obscure, but the reality is that for anybody who can handle leaving the world of imperative and object-oriented programming, it is extremely easy to learn, and to use and it’s extremely flexible. Separating the language from Mathematica may encourage novices to try it.

Wolfram doesn’t announce a release date in the video but I suspect it will be simultaneous with the release of Mathematica 10, which may be very soon.