Re: What does & mean?
- To: mathgroup at smc.vnet.net
- Subject: [mg107064] Re: [mg107050] What does & mean?
- From: "David Park" <djmpark at comcast.net>
- Date: Tue, 2 Feb 2010 03:25:31 -0500 (EST)
- References: <20738936.1265024588004.JavaMail.root@n11>
It's difficult to just use Mathematica off the shelf for advanced problems. There is a somewhat steep learning curve. The example presupposes a fair amount of Mathematica knowledge. The Documentation Center itself can be intimidating. The places to start might be: 1) First Steps with Mathematica (at the bottom of the main page). 2) Core Language: Language Overview, Expressions, Rules & Patterns, Lists, Variables & Functions and Functional Programming. 3) Then what seems useful. The '&' character is used to terminate a pure function. You can learn about pure functions under Function in the Core/Functional Programming section. (How would one know to look up Function? I don't know.) Pure functions are a method for defining some action that might have only temporary use. (In your example it sets up an equation between the two sides. MapThread is another Functional programming construct. It is very worthwhile learning how to use Functional programming. It is really great and Mathematica is generally more efficient with functional programming than with procedural programming.) Here is a little example of solving an equation 'by hand' using pure functions. (Just copy and paste it into a notebook.) '#' stands for the argument, in this case a side of the equation, and we Map ('/@' ) the pure functions onto each side of the equations. Print["Equation to Solve for y"] step1 = a (x + y) == b Print["Divide both sides by a"] step2 = #/a & /@ step1 Print["Subtract x from both sides"] # - x & /@ step2 The best way to learn may be to type the Doc Center examples into your own notebook and evaluate, and to try a few modifications. Then once you are familiar with the core constructs, try to 'fly solo' by working some SIMPLE problems you know about from some NON-Mathematica book. David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: Michael Knudsen [mailto:micknudsen at gmail.com] 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 the MapThread documentation either). Where should one start reading in order to understand basic constructs like this? This particular example is really nasty, since & is generally ignored by search engines. Thanks, Michael Knudsen