Re: What does & mean?

• To: mathgroup at smc.vnet.net
• Subject: [mg107080] Re: What does & mean?
• From: David Bailey <dave at removedbailey.co.uk>
• Date: Tue, 2 Feb 2010 03:28:25 -0500 (EST)
• References: <hk6d22\$m61\$1@smc.vnet.net>

```Michael Knudsen wrote:
> Hi,
>
> I have recently bought Mathematica, and I have a really tough time
> getting started. I'm reading the various documents found under
> "Complete Documentation" at the Mathematica homepage, but it doesn't
> feel like the right place to start.
>
> For example, I'm now trying to solve some simple differential
> equations, and the documentation provides the following example:
>
> A = {{4, -6}, {1,-1}};
>
> X[t_] = {x[t], y[t]};
> system = MapThread[#1 == #2 &, {X'[t], A.X[t]}];
>
> sol = DSolve[system, {x,y}, t]
>
> However, there is no explanation of how & works here (and it isn't in
> order to understand basic constructs like this? This particular
> example is really nasty, since & is generally ignored by search
> engines.
>
> Thanks,
> Michael Knudsen
>
The construction #1 == #2 & is what is known as a 'pure function'. This
function takes its first argument (#1) and compares it with its second
(#2). You can only really understand expressions like that if you know
the precedences of the various operators, but if you click the mouse
somewhere inside the expression and press  Ctrl-. you will see the
selection expand each time you press Ctrl-. This will work with any
expression and lets you study its structure.

This is probably not the best place to start learning Mathematica! Have
you tried the 'quick tour' option when you load Mathematica?

The example you quote is solving a matrix differential equation. Unless
that is what you want, I'd start with some of the examples in the help
system (press F1) under DSolve, e.g.

DSolve[y'[x] + y[x] == a Sin[x], y[x], x]

Note also, that you can cut and paste examples from the help system into