# 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.

2answers
417 views

### How can I compare the previous value and the current value implemented during NestWhileList?

I am trying to write a part of my code. I am using NestWhileList. However, I couldn't find out the right syntax for testing. It should compare previous result and current result and continue if it is ...
1answer
271 views

### Syntax error: newline character interpreted as multiplication

I'm getting this error in Wolfram Workbench, and I don't know where it comes from: "Syntax error: newline character interpreted as multiplication" This error happens around an If[] function, in a ...
1answer
1k views

### Problem with Fourier coefficients

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 ...
1answer
737 views

...
1answer
859 views

### Using Transpose with a list as the second argument

I'm having difficulty understanding the Transpose function. I know what the transpose of a matrix is, not a problem, and I see that applying the ...
0answers
208 views

### Syntax colouring when using Symbolize

I need to use symbols with suffixes in order to make my code readable in relation to the Eurocodes. To do this I use Symbolize from the ...
1answer
200 views

### Remove failed Solve[] attempts

I can't figure how to replace a failed evaluation with a null value. I am very new to Mathematica. I have an equation that are being processed using the Solve[] ...
1answer
116 views

### Force ellipsis to print an end of an expression

For pedantic reasons I want to display an infinite sum of fractions in fractional form (i.e. as 1/x not as x^(-1)) with an ellipsis at the end of the expression. I have tried a number of ways and ...
1answer
137 views

### Working of Date[]

Date[] returns the current date of local system, Date[1] returns {2012, 11, 15, 17, 41, 0.3161629}, ...
1answer
253 views

### Difference between Map[f[#] + g[#] &, {a, b, c}] and Map[f[x]+g[x]&, {a, b, c}]

Map[f[#] + g[#] &, {a, b, c}] vs Map[f[x]+g[x]&, {a, b, c}] My question is: why is the output different? ...
3answers
199 views

### Why can't I use Sequence to perform a Select like task? [duplicate]

Suppose I wanted to write down a list of $p^2$, for $p$ a prime between $1$ and $20$. I would expect Table[If[PrimeQ[k], k^2, Sequence[]], {k, 1, 20}] to work. ...
1answer
165 views

### Problem overloading D[] using UpValues

First I define an entry of UpValues overloading D[] for expressions with head ftest: ...
1answer
252 views

### How to generalize a formula?

This is a piece of my code: ...
1answer
139 views

### Setting a binary operator Flat

I defined a binary operator in as the first statement in a new Mathematica notebook. {x1_, y1_} ⊕ {x2_, y2_} := Module[{}, Print["do anything"];] where the code ...
2answers
378 views

### local variable naming & symbolic argument

I'm stuck here with my variable assignment in this scenario ...
3answers
781 views

### Parentheses in pure functions: # & vs. ( # &)

I've been using Mathematica for years, and over time I have developed the habit of using: Select[data, (# == 1 &)] instead of ...
3answers
9k views

### How do I identify the source of a “Tag times protected” error?

I have some code that looks like Table[ a = 1; b = {2, 3} c = i;, {i, 2} ] which gives an error: Set::write: Tag Times in c {2,3} is ...
5answers
2k views

### Superscript prime symbol

x\[Prime] looks like $x_{'}$, ugly right? Is there a way to make a symbol with prime to look like $x'$? That's what I'm trying right now: ...
3answers
604 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 ...
2answers
263 views

### How to insert an expression in a Mathematica program?

I need to insert a very large expression in a Mathematica program. So I first Put[large expression,"file"] and then use Block[{}, Get["file"];...] to ...
2answers
999 views

### Several functions in one RegionPlot with different grayscale

I try to plot the following, but something seems to be wrong in my code and I can't figure out how to fix it: ...
1answer
564 views

### Why is Euler's number an uppercase “E” and not a lowercase “e”?

Why is Euler's number an uppercase "E" and not a lowercase "e"? Isn't Euler's Number normally expressed with a lowercase "e"?
3answers
202 views

### How do I interpret the following syntax?

I have been given some code with the following line PeriodicExtension[g_, x_] := If[Abs[x] < Pi, g[x], PeriodicExtension[g, x - 2 Sign[x] Pi]] I do not ...
1answer
201 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 ...
1answer
294 views

### Upon opening my notebook, I must evaluate cell for code to work properly

I am new to Mathematica. Once I evaluate the cell containing the code, my Manipulate works as desired; however, if I open the file and do not evaluate the cell, the Manipulate goes haywire. Can ...
1answer
2k views

### What is the difference between Set and SetDelayed?

I have a problem with defining a function and most of time I get confused by Set or = and ...
2answers
986 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: ...
2answers
1k views

### Code Readability and Object-Oriented Code

The basic problem I have been running into is making readable code, where in other languages I am more familiar with I might have been using class or struct like objects. For example, you can imagine ...
2answers
553 views

### Extracting parts of nested lists of rules using a syntax similar to JsonPath or Xpath

Given an example data set: ...
2answers
269 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 ...
3answers
2k views

### Why does Mathematica use [[ ]] notation for array indexing?

I am confused by why Mathematica uses [[3]] to get the 3rd element, or [[i,j] to get the i,j-th element of a 2D array. This ...
3answers
287 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?
1answer
216 views

### Can I use Table without the appropriate bounds?

I´d like to use the Table command without defining n, so that I can have a list of n ...
3answers
1k views

### Output of plots from within Do[ ] Command

I am wondering why the following does not plot the way it's written and exactly how does the Do[] function operate? I think I could be using it incorrectly. ...
5answers
411 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[] ...
6answers
925 views

### Calling Table with custom iterator

I often find myself in situations where I, for example, need to build a table for some expression, but want to set the number of points rather then the step size, so the code ends up looking like this ...
6answers
1k 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 ...
4answers
622 views

### Using the result of Solve in subsequent calculations

I'd like to know how to use the results of Solve in later calculations. Here's what I'm doing now: This is my expression ...
1answer
1k views

### Indices and variable definitions in Mathematica

Does anyone know how I can do this in Mathematica? Just an example.. Defining indices and variables (defined over indices), "mapping" variables and indices: ...
2answers
1k views

### How can one define an infix operator with an arbitrary unicode character?

You can setup "UsefulFunction[a, b]" to use custom infix notation "a [LeftRightArrow] b" as follows: ...
1answer
778 views

### Prefix operator with low precedence

The question is simple, but I will elaborate on the background as well for those interested in the idea: How to define a new operator with specified precedence value? Background Mathematica was ...
1answer
224 views

### What is an alternative to using backticks in separating namespaces from function names?

What is an alternative to the backtick () in separating the namespace from the function name? Can the function be called without using this symbol? I think in ...
2answers
196 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: <...
3answers
2k 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 ...
3answers
621 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?
4answers
8k 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: ...
2answers
283 views

### Finding the position of a specific value in a list

Is it possible to easily find the position of a specific value in a list? For example, if the list is {{x1,y1},{x2,y2},...,{xn,yn}} I would like to know the ...
1answer
801 views

### What does the slash-colon symbol do?

I came across a bit of code that uses the syntax /: and I don't know what it does. I can't find its documentation, or maybe I'm just not looking properly. The code ...
2answers
107 views

### Functions in a different context are replaced with infix forms of their namesake in System

So, in an attempt to help out Fabian with his question, I did what I often do, and created a new symbol in the Pillsy` package that I could play with. Since it was ...
2answers
1k 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 \\... \\...\\1\...