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

2
votes
0answers
37 views

Multiple Constrained Sum

I need to perform a multiple summation, that obeys some conditions. This arises in the study of a statistical physics model. q=Exp[-β]. I would like to ask if ...
5
votes
1answer
103 views

Why is Reap result nested?

A minimal (toy) example for my question: i= 1; Reap[Do[Sow[i = (i + 1)^2], {4}]] (* {Null, {{4, 25, 676, 458329}}} *) I presume the entire result is a ...
7
votes
1answer
130 views

What kind of creature is h[c] for definition h[c_][x_] := (* function of x and c *)

To implement "Hero's Method" for approximating $\sqrt{c}$, one iterates the function (x + c/x)/2 for a given number c (e.g., ...
2
votes
4answers
196 views

How can I make a summary of all the commands of Mathematica?

I would like to have a simple way to get summary information about all the many commands built into Mathematica. How could I do this? Is there a site I may refer to?
0
votes
0answers
48 views

memory aid frequently used commands [closed]

I am looking for links to a summarized list of most used commands of Mathematica or a reference manual with examples that only includes commands and syntax. I would also like a list of keyboard ...
3
votes
0answers
59 views

Syntax error in debug mode

Bug introduced in 9.0 or earlier and persisting through 10.2.0 It appears that in debug mode, the \[Piecewise] symbol gives syntax error. Is it a bug? Are there ...
9
votes
5answers
4k views

Notation of partial derivative

I want to write partial derivatives of functions with many arguments. Why is it that when I type f[x,y] ctrl+6 (0,1) it turns out to be bad syntax? The output of ...
1
vote
1answer
47 views

Display a triangle that rotates at certain rate when space bar is held down?

This question is a follow up on: Open a pop up window that runs a calculation in loop until it is closed? How can I open a pop up to show a picture of a triangle that rotates by ...
3
votes
1answer
36 views

Open a pop up window that runs a calculation in loop until it is closed?

How should I construct a code which opens a pop up window, displays a constantly updating image in it and is terminated once the pop up is closed? The constant updating would be an infinite loop of ...
12
votes
1answer
183 views

ToExpression processing errors

Is their a way to get a more comprehensive return value when running ToExpression? For example when I run ...
2
votes
1answer
37 views

How to use MakeExpression in terminal?

This is in continuation to the question in Infix form of PutAppend ( >>> ) does not work with variable. I was trying to use ...
1
vote
1answer
92 views

Summation over list elements

As we know, one of the simplest way to do a summation (with special intervals) over list elements is using Sum[list[[i]], {i, 3, 8, 2 }] (*with steps of 2*) for ...
13
votes
5answers
728 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 ...
11
votes
1answer
585 views

When to use @@@ vs. /@ [duplicate]

So much thanks to Szabolcs in improving sequence.. for complete explanation. I am so glad to read all explanation which fundamentally remove the problem. But in number 4 of its explanation pointed to ...
32
votes
4answers
15k views

Is there a syntax for single-line comments for notebooks?

I'm aware that I can use (* ... *) to comment out stuff in a notebook. Many languages have a syntax for single-line comments, such as ...
13
votes
2answers
807 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: ...
7
votes
2answers
251 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. ...
21
votes
3answers
852 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 ...
5
votes
3answers
229 views

How to imitate list comprehensions for constant arrays?

In Python, ['a'] * 10 generates ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'] and ...
6
votes
2answers
782 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: ...
1
vote
0answers
100 views

How can I solve the 2D Laplace equation with Neumann boundary conditions? [closed]

I would like to solve the following boundary value problem for $u(x,y)$: PDE $\quad \quad \frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} = 0$ Domain $\quad \quad 0 \le x \le ...
1
vote
2answers
93 views

How to define a sequence of piecewise functions and then plot them altogether?

The following is the piecewise functions I want to define ${f_k(x)} = \left\{ {\begin{array}{*{20}{c}} {\frac{{j - 1}}{{{2^k}}}}&{\frac{{j - 1}}{{{2^k}}} \le f(x) \le \frac{j}{{{2^k}}}}\\ ...
19
votes
0answers
326 views

A documented syntax of FileNames doesn't work?

Documentation discrepancy present through 10.2 According to the documentation for FileNames under Details: However when I attempt to use this syntax I get an ...
19
votes
0answers
187 views

New AssociationThread forms in 10.2?

Is this another case of "documented" but "not implemented" ? or at least it is not explained clearly as I cannot make it work: Two new forms appears in the new 10.2 doc. of ...
3
votes
0answers
46 views

String option names for Cells

They seem to be correctly interpreted. I'm asking because of some minor reasons and a major one: NotebookWrite a Cell with WholeCellGroupOpener option I don't know any official confirmation so let ...
2
votes
2answers
65 views

Simplify set-theoretic expressions [duplicate]

As I can get set-theoretic simplifications of expressions and corresponding Venn diagram for example ...
1
vote
0answers
41 views

Mathematica Workflow [duplicate]

What methods/tools/tips have you found that dramatically improved your Mathematica workflow? I have a love/hate relationship with Mathematica. It is useful no doubt, but defies my intuition at every ...
47
votes
1answer
1k views

Incompatible Changes since Mathematica Version 7?

There is documentation of the incompatible changes made to Mathematica with each major release: Incompatible Changes since Mathematica Version 1 Unfortunately that documentation simply stopped ...
0
votes
1answer
89 views

How to enter piecewise functions into Mathematica [closed]

I'm trying to enter a piecewise function (named eq30) into Mathematica. However, it seems not to work. The expression I entered is ...
2
votes
2answers
295 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 ...
21
votes
1answer
525 views

Shorter syntax for Fold and FoldList?

I find it tedious to write out the following: a = {1, 2, 3, 4}; Fold[f, First @ a, Rest @ a] f[f[f[1, 2], 3], 4] It ...
17
votes
3answers
1k 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 ...
0
votes
1answer
50 views

A question about the syntax [closed]

I have $3$ elementary questions to ask and I thank you in advance. Question N°1. What is the right syntax for $$y\equiv0\pmod {2}$$ in the code below? ...
5
votes
2answers
160 views

How to Write Partition with Infix?

The documentation says that using Infix ~, the following input f[e1,e2,e3,...] can be rewritten as ...
7
votes
0answers
149 views

What is a good way to code long, complex, compilable algorithms?

The functional paradigm of the Wolfram Language used in Mathematica is all around wonderful. For intense numerics, Mathematica comes with the ability to Compile ...
2
votes
2answers
85 views

Using Table with arbitrary number of variables [duplicate]

Let $P=\{p_1,...p_n\}$. I would like a way to implent Table[Expression,{$p_1$,lim},{$p_2$,lim},...,{$p_n$,lim}] where n and lim are parameters defined by the user. Any ideas?
6
votes
1answer
80 views

What is the role of _ in this expression?

I'm fairly familiar with basic Mathematica, but some of its more advanced syntax (especially certain special characters) eludes me. In the Scope section in the documentation of ...
1
vote
1answer
52 views

How to set the values into some variables from different lists [duplicate]

I have a list of Values and a list of variables. I want to set the Values into Variables. Assume the following code: ...
4
votes
1answer
65 views

How to define an expression which is differently evaluated in calculations and printed

Let's say, we have a list: values = {1.2, 0.04, 0.9}; Is it possible to replace 0.04 by some expression, which displays as ...
0
votes
1answer
83 views

Can't get a plot from piecewise parametric function [closed]

I can't seem get a 3D plot from r[t]. Any suggestions? ...
1
vote
1answer
78 views

How to make a StreamPlot with three variables and two expressions

I'm trying to make a StreamPlot in Mathematica with three variables. I already have two variables, x and y, that make an ellipse via StreamPlot[{-y,x}] but I ...
1
vote
2answers
73 views

What is the meaning of Range[10] /. {x_ /; PrimeQ[x] -> x^2}? [closed]

I'm currently doing a unit at university that touched briefly on Mathematica, but the final exam will feature multiple choice questions from Mathematica (along with excel and matlab). This leads to ...
0
votes
1answer
38 views

Testing Conditions in For Loops

I am attempting to create a set of coefficients that satisfy a set of conditions using the Do function and If statements. I did this successfully with a basic set of conditions: ...
2
votes
1answer
66 views

Failure in the use of FullSimplify

My question is about an apparent failure of the function "FullSimplify" to simplify an easy algebraic expression. This is the expression that I ask Mathematica to evaluate: ...
2
votes
1answer
103 views

Mathematica and special functions

How is it possible that Mathematica doesn't recognize it's own definitions of special functions ? I tried as input: ...
-2
votes
1answer
64 views

Sign of a symbolic expression as a function of parameter values

I need to know the sign of the following expression for p[t] = z/(1-a), as a function of the parameters {a, b, c, z}: ...
1
vote
1answer
87 views

How to evaluate sum with different coefficient in each term?

I would like to know if there is a syntax that allows me to enter a sum that has coefficients that vary for every term? I have no interest in evaluating them numerically, but rather to keep them as ...
1
vote
2answers
87 views

Matrix with infinity on main diagonal

The question is trivial, however, there might be unexpected solutions. What would be nice way to create a square matrix with $\infty$ on main diagonal, and some arbitrary constant everywhere else? My ...
2
votes
3answers
806 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. ...