# Tagged Questions

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.

100 views

### Dot when used in a pattern becomes Times… Why?

In[1] := Hold[a.b] // FullForm Out[1] := Hold[Dot[a,b]] So far so good. ...
5k 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, ...
23 views

### Incorporating Built-In Function Options/Parameters into Shorthand [duplicate]

Shorthand syntax provides an alternate way to apply functions and, in many cases, improves readability. A simple example would be ...
203 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 ...
469 views

### Conditional range in a parametric plot

I have a program that needs to be done like this: ParametricPlot[ equation, If[x < 1, {x, 0, t}, {x, t, 2}]] But Mathematica didn't seem to recognize the ...
69 views

### Pathological behaviour when evaluating a sum

When I declare the function $f$ as follows: f[n_] := Sum[x/Sum[Sqrt[y], {y, 1, x}], {x, 1, n}]/n the input ...
204 views

### Making nice code: choosing one of several procedures

Happy new year mathematica gurus of stack exchange! As I see it one of the major obstacles in getting decent at programming mathematica is that, not only do you need to learn how certain commands ...
115 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: ...
196 views

### Is it possible to use infix notation ~ for functions with one argument or more than 2 arguments?

According to a Mathematica textbook, we can write N[x,n] by using infix notation as x ~ N ~ n. How about other functions with ...
374 views

### Changing Default Color for Titles, Sections, Subsections, etc., and Items (bullet color) [duplicate]

I'm new to Mathematica 9, and I assume there must be an easy fix for my problem, but I have not been able to find any yet. Essentially, I want the default color for the text of all of my titles, ...
239 views

### What are the min and max arguments to EdgeDetect?

What are the min and max arguments to EdgeDetect, for all methods and specifically "Sobel"? How do I find the limits or ranges ...
309 views

### Limit won't compute

Does anyone know why the limit: ...
369 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²] ...
407 views

### Treat all variables as local in a module [duplicate]

In most languages, any variable defined inside a function is considered local. ...
146 views

### Why does the iterator index in Table not work here?

I type the following command line Table[D[#1,varx[[i]]] &,{i,3}] where varx is a vector of dummy variables ...
474 views

### import a list of replacement rules

I have a text file with a set of replacement rules, of the form x^3y^2 -> 4, xy^2 -> 2, ... for example. I'm having some issues trying to figure out ...
79 views

### Decapitating “explicit” and “implicit” heads

This is a follow up to this question. So far, I named "explicit" heads to those that appear explicitly in the expression. For example, f[x] has an explicit head. I ...
2k views

### Difference between @ and @@

I am confused by the commands @ and @@. From the documentation, I learnt that @@ is the ...
271 views

### Syntax error for optional pattern, but only in debugger

This expression (explained here by Leonid) evaluates fine unless Evaluation->Debugger is enabled: h[x : (_Integer) : 1] := x Syntax::sntxf: "x:" cannot be ...
44 views

### Matching Root[…] objects with patterns, unexpected hidden argument

I needed to write patterns that could distinguish between arbitrary-function and polynomial forms of Root objects, for example, ...
148 views

### Defining an operator

Let s be a positive integer and let DifferenceDelta be this function with step = 1. Define <...
94 views

### Plot producing many error messages when given complicated function

I'm new to Mathematica and am running in to all sorts of silly difficulties with coding in it. I'm trying to calculate a function f[x, k], normalise it with another ...
272 views

### Where did I go wrong with my implementation of finding a plane tangent to a surface?

I am working on finding the plane tangent to a paraboloid at a given point. My code: ...
131 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? ...
366 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 ...
199 views

### Shortcut for Range[]?

I use Range a lot. Is there any syntactic shortcut for it, or do you always have to spell it out?
122 views

### Passing f[x][[1]] to FindRoot [duplicate]

FindRoot seems to fail for most examples of the form f[x_?NumericQ] := {x - 3 , x^3}; FindRoot[f[x][[1]], {x, 3}] ...
95 views

### Syntax for FrontEndSelectionSetStyle

I know FrontEndSelectionSetStyle is undocumented, but its name suggests it does what I need. What is its syntax? I have already tried several variations of the ...
103 views

### Is it possible to use a mathematical expression as function name?

This might seem as a silly question, but is it feasible to use a mathematical expression as the name of a function? For example, I'm studying the cross section of Compton scattering and there is a ...
121 views

### Help with writing a polynomial series [duplicate]

I want to write and evaluate an expression something like Sum[x[i] Product[y[j], {j(!=i), 1, n}], {i, 1, n}] but with correct syntax, where n is a any number (...
100 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 gently-...
193 views

### Levels and slots

I am struggling with levels and #, if I understand this I think I will be able to grasp the entire concept. ...
326 views

### Manipulate, Import external table, save as CDF, mail presentation

For my work I do data analysis. Most of these analysis are done on big databases with milions of records. I would like to make a manipulate (or animate) using a external dataset and create a CDF ...
271 views

### HoldForm[Operator ##] on some list

Recently in response to this question Mr.Wizard suggested an unusual way to summing numbers. This doesn't seem to be documented. ...
5k views

### Guidelines on giving readable names to variables [closed]

I know that one cannot use underscore to a variable name, like degree_of_The_First_Polynomial. But for a long variable name, it ...
152 views

### The /. syntax in numerical methods [duplicate]

I have an analytical approximation method for solving an ODE and want to compare this to an NDSolve solution, but the syntax is confusing me. To get the solution from NDSolve, I define the ODE as eqn ...
1k views

### How is + as an infix operator associated with Plus?

How is + associated with Plus? Suppose I want to define a head FooBar and have it ...
427 views

### Can someone explain this code for joining two lists by the first element of each sublist?

Background (which may be skipped, unless context is needed) I've recently begun learning Mathematica (and only up to chapter 3 of Wellin), but wanted to write some code to get a better feel for ...
115 views

### Assign variables from list inside With or Module

I have found that it is possible to assign variables from lists, as follows. r = {1, 2, 3}; {a, b, c} = r; b 2 However, ...
205 views

### Constraint syntax compaction

Is there a more compact way to represent these constraints: NMaximize[{a+b+c,a <= 5 && b <= 5 && c <= 5...
298 views

### Infix form of PutAppend ( >>> ) does not work with variable

I'm new to Mathematica, so I suspect this question involves either a misunderstanding involving variables or the usage of >>>. On a webMathematica page (...
345 views

### Writing a function that returns a (usable) function

I am trying to create a function that returns Arnold's Cat Map of size n iterated k times. I can get something out of the Function command, but I can't figure out ...
987 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 ...
79 views

### Why do two codes give different output?

I have tried the following to get the eigenvalues of several matrices of the type: ...
82 views

### Constructing an Array from typed expression

I want to produce an array from expressions given by test[one][1] = 3; . . test[one][5] = 7; etc. Normally would use ...
119 views

### How to make InverseFunction work on function defined with restriction on arguments

This example works to define InverseFunction on the first argument of a function ...
272 views

### Overlapping pure functions

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

### Split dataset based on the first column [duplicate]

I have a dataset which I want to split based on the first column. The data looks like this ...
Suppose I have a function say $f=x^2$. What I would like is a list (or even better, a list with a grid) which resembles {{1,1},{2,4},{3,9}, ...}. Ideally one should ...