[ Content | Sidebar ]

Archives for mathematica

x + x = 2x

This post is the second in a series. The first is here. Recap: I promised a tour of some interesting features of the Mathematica programming language (which I’ll call mma). The first post was by way of introduction. The plan for this post is to introduce just enough notation to define some functions in mma, [...]

The unknown functional language

Functional languages are experiencing something of a renaissance, or so I gather from reading reddit and the blogs. I have been known to dabble in lisp, erlang, and haskell. Each is beautiful language in its own way. But when I actually want to get something done, not just play, I turn to either python or [...]

Euler 100

Euler Project problems can be addictive. This one gave me fits.

If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the probability of taking two blue discs, P(BB) = (15/21)×(14/20) = 1/2.
The next such arrangement, [...]

Euler 183

I have not worked a Euler Project problem in some time. Here’s problem 183:

Let N be a positive integer and let N be split into k equal parts, r = N/k, so that N = r + r + … + r.
Let P be the product of these parts, P = r × [...]

generating random permutations

I want to consider the simulation of dealing a deck of cards. The deck is simply the list of integers D = [1,2,...,52]. Dealing the cards amounts to generating a random permutation of D.
Here’s how I would do it in java.
public class Shuffle {
private static java.util.Random rand = new java.util.Random();
[...]