Questions on correct (or improved) formulation of Mathematica code to achieve particular results. Use this tag (not "symbol") for questions about all those odd @@ /@ # & and ~ characters.

learn more… | top users | synonyms

8
votes
5answers
573 views

can the color in MeshStyle be specified by a ColorFunction, such as “SunsetColors” for example. If so, what is the correct syntax?

This is an example given in Help: Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, MeshStyle -> Gray] Could this be changed to something like ...
8
votes
2answers
231 views

Cases[data,Colon[key,_]] vs. Cases[data,key:_] toward XPath, XQuery

Exploring methods to index and search tree-structured key:value pairs via named-entity index (key paths) as opposed to Position-based indexing. Using Rule as ...
8
votes
1answer
340 views

Setting the DifferenceOrder Option

I've been playing around with Method in NDSolve[...] and can't quite seem to figure out how to force ...
8
votes
1answer
105 views

Does the syntax coloring I see indicate a real problem?

I need a behaviour provided by: x = 2; Block[{x = HoldForm[x]}, x] x FrontEnd marks ...
8
votes
1answer
442 views

What is the difference between prefix/postfix notations and map?

I am new to Mathematica and just experimenting with the different programming constructs. I have been looking at Map and how to evaluate a function for a list of ...
8
votes
1answer
151 views

Different behaviours of Default Argument

I don't really understand the behaviour of Default Argument. If I execute this command in Mathematica: In: {f[a], f[a + b]} /. f[x_ + y_.] -> p[x, y] ...
8
votes
1answer
110 views

Head of a MatrixForm expression?

An example in http://www-zeuthen.desy.de/theory/capp2005/Course/hahn/mathematica.pdf amounts to the following ...
7
votes
3answers
1k views

Using D to find a symbolic derivative

I need to do the following: Define a function Take the derivative of this function and have a look at the symoblic representation Substitute in some values With the bonus that I want to use the ...
7
votes
2answers
204 views

Internal Representation of ?name and ??name

Code FullForm[Hold[?name]] Syntax::bktmcp: Expression "Hold[?name]]" has no closing "]". Syntax::sntxi: Incomplete expression; more input is needed . Question ...
7
votes
3answers
307 views

Why can't D[] be used in place here? [duplicate]

Possible Duplicate: General::ivar is not a valid variable when plotting - what actually causes this and how to avoid it? Beginner question: Why can't I use ...
7
votes
2answers
265 views

What's the purpose of the Unique function?

As the title says: What's the purpose of Unique? I understand that it generates some unique symbol, but when and for what is it to be used? Are there applications ...
7
votes
3answers
339 views

how to read in a file in the same directory?

Now I am writing a small package. I have written several files and put them in the same directory. And some files need to read in or include another file in the same directory. But when I simply write ...
7
votes
3answers
445 views

Difference between @ and @@

I am confused by the commands @ and @@. From the documentation, I learnt that @@ is the ...
7
votes
2answers
171 views

“A number in base b” and pure functions: why doesn't b^^# & work?

Why do the following not work (in Mathematica 7)? 2^^ # & /@ {1000, 1101} and 2^^ # & @ 1101 This does work: ...
7
votes
1answer
189 views

How can I specify a numerical order for variables?

I need to specify that a variable is less than another, and greater than yet another, in a Mathematica program, because I will later apply a test to them that will determine what functional form to ...
7
votes
3answers
470 views

What is the right way to construct DynamicModule

When I'm creating DynamicModules for CDF purposes I'm usualy basing on my experience with that, particular goal and content rather than on deep insight. I want to ...
6
votes
5answers
288 views

Is it possible to insert arguments into functions when they're used like Function@ or //Function?

Is it possible to insert arguments into functions when they're used like Function@ or //Function? Sometimes I need to do this, but then I have to return to the standard function usage: Function[] ...
6
votes
3answers
250 views

Where did I go wrong with my implementation of the trapezoidal rule?

One method for doing quadrature, called the trapezoidal rule, improves accuracy by connecting the points on the curve corresponding to the points of subdivision with line segments, forming trapezoidal ...
6
votes
4answers
169 views

How to select only NotebookObjects that are referring to ordinary notebooks? (not palettes etc.)

There is of course function Notebooks[] But, unfortunatelly it hasn't got useful options in this context. My question is how to pick ...
6
votes
3answers
249 views

Finding the square root of a squared number?

Taking the square root of the square of a number Variable set to a real value I'm wondering why these examples a = -4.3; Sqrt@a² Sqrt@(a^2) Sqrt[a^2] Sqrt[a²] ...
6
votes
2answers
858 views

How to reverse the direction of the y axes

I have a similar question to this one. Unfortunately, the answers there didn't help me. I would like to plot a simple function with the normal Plot function. ...
6
votes
1answer
626 views

Coding mistake? [closed]

I have just started using Mathematica with v9.0. I am trying to follow a computation from a book on Fourier series with the function $f(x)=x$ on the interval $-\pi < x < \pi$. Here is the code ...
6
votes
1answer
145 views

How can I define a ⊕ operator?

What is wrong with the following code? CirclePlus := SparseArray[Band[{1, 1}] -> {##}] & a_ ⊕ b_ := CirclePlus[a, b] SetDelayed::write: Tag Function in ...
6
votes
1answer
106 views

Why can Format be used on the left side?

I am learning Mathematica in random order by reading its documentation. This approach is what I like most when learning new things. Consider the following 2 cases. Syntax A: ...
6
votes
1answer
103 views

A question about two ways to use Default

Usually we define a function with default values by the syntax x_:default, but there is another technique to do this by registering a global default value with ...
6
votes
1answer
76 views

Why only up to two \[Prime] superscripts are interpreted as derivatives?

I noticed that only up to two \[Prime] superscripts are interpreted as derivatives. Is there a reason for this restriction? Is it documented? ...
6
votes
2answers
325 views
6
votes
1answer
121 views

Extract what symbol is set by SetDelayed, Set, TagSet, UpSet, SetAttributes, etc

One of the recent features of the Mathematica Plugin for IntelliJ IDEA (www.mathematicaplugin.halirutan.de) is a Structure View which let's you see information about several definitions that are done ...
6
votes
1answer
88 views

Where does Documentation Center introduce the basics?

While helping a user who mistakenly thought that log rather than Log was the correct built-in function name, I included a ...
6
votes
1answer
140 views

Problem overloading D[] using UpValues

First I define an entry of UpValues overloading D[] for expressions with head ftest: ...
6
votes
0answers
108 views

Design considerations behind `O` (a.k.a. BigOh, a.k.a. Landau Order)

This works without any warnings: O[Log[x]]. This raises a warning: O[x^2]. I have a few questions around this: Why is it a ...
5
votes
4answers
288 views

Multiple colors in Graphics[] environment

There are other questions on the site that are similar to this one, but the answers provided didn't help me. I want to draw disks of different radii. Each radius is the absolute value of a variable, ...
5
votes
3answers
272 views

Syntax for prefix mode with multiple arguments using @ shorthand

Is it possible to use the @ symbol with multiple arguments? The Prefix command suggested not. If so, why?
5
votes
3answers
871 views

Matrix Multiplication in context of row and column vectors

I've been looking at some matrices in Mathematica and I've noticed something very weird: They're extremely temperamental when it comes to dot products! For example, if I have the following, ...
5
votes
2answers
224 views

Overlapping pure functions

Let say I need and option for Plot: RegionFunction -> (-6 < #2 < 6 &) But I also want those ...
5
votes
2answers
227 views

Splicing a list of arguments into a function with Sequence

Not sure if this has been asked, but I have a fairly simple operation that I don't know the syntax for. Say I have an array with some values, and a function f that accepts an arbitrary number of ...
5
votes
3answers
584 views

Keep function range as a variable

Plot[2*x^2 - x + 2, {x, -1, 1}] plots a function of x from -1 to 1. As far as I can see, I cannot "save" this range in a variable: ...
5
votes
2answers
143 views

Syntax highlighting conflict

I'm trying to syntax highlight this expression: x=$\sqrt{\pi }$//N and from various sources I've learned that x (the assigned symbol) belongs to context Global while the Pi and N belongs to System. So ...
5
votes
2answers
377 views

Multiply each element of an array by another array?

I would like to multiply an array by each element of another array, and am having a lot of trouble finding a built-in or automated method of doing. Here is an example of what I'd like to achieve: ...
5
votes
2answers
486 views

Evaluating an If condition to yield True/False

I would like to decide whether an option passed to my custom function has the value Automatic or something else. This is my attempt: ...
5
votes
1answer
222 views

What does ` symbol in ClearAll[“Global`*”] mean?

I have found an example for clearing all symbol definition by: ClearAll["Global`*"] But what does the symbol ` mean? It isn't the apostrophe ', yet it is not ...
5
votes
2answers
798 views

Constructing a Summation with a Variable Number of Inner Sums

I have a question regarding multiple sums. And my second index depends on the first index. Here it is: $$ \sum_{d=1}^{P}e^{-d}\sum_{\substack{1\leq k_{1}\leq Q \\ 1\leq k_{2}\leq Q \\... ...
5
votes
1answer
212 views

Why does the Front End group backslashes into pairs?

What is \\ for? Help finds nothing on it. An odd number of backslashes greater than one are grouped by two and the last one is displayed with a different color. ...
5
votes
1answer
150 views

Treat all variables as local in a module [duplicate]

In most languages, any variable defined inside a function is considered local. ...
5
votes
1answer
198 views

How to convert an image to a compressed string representation equivalent to one copied to clipboard by `CopyToClipboard[image]`?

In my recent question I asked How to embed an image into a string? The suggested solution was ...
5
votes
4answers
144 views

Defining a function with parameters as variables

I have an expression V = (a[1] + a[2])b[1]. How would I define a function of a[1], a[2] and ...
4
votes
4answers
4k views

Mapping multiple parameters of a function to specific values

I am a little bit confused by the documentation for Apply (@@). I want to define a list of parameters, for instance: ...
4
votes
3answers
187 views

Is it possible to make the Button execute two or more actions?

According to the help: Button[label,action] Is it possible to make the button execute two actions?
4
votes
2answers
353 views

List reversion inspired by Python

In python, if you wish to reverse a list, here is the trick: range(10)[::-1] => [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] Note: ...