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

5
votes
2answers
218 views

Why SetDelayed won't work

I'm trying to do this: Riffle[list = {a, b, c, d, e, f}, tem = RandomInteger[1, Length@list-1]] {a, 0, b, 0, c, 1, d, 0, e, 0, f} But I think this method is ...
1
vote
1answer
41 views

How to use Composition when the functions have two parameter

There are some basic instructions about Composition on this site, but I'm still confused on how to use it when the functions I am composing have two parameter, such ...
5
votes
3answers
226 views

Relational operators on vectors

How do I use relational operators on vectors? {1, 2, 3} > {0, 1, 2} (*outputs {1, 2, 3} > {0, 1, 2}*) More generally, I want ...
0
votes
3answers
61 views

Plotting with NestList[]

So I want to use the NestList[] function, but i'm not sure how to achieve this for a system of equations like I have here $P_{n+1} = (rP_n +sQ_n)(1 - \frac{P_n + ...
0
votes
1answer
53 views

Solving a System of Equations syntax confusion

I have a system of two equations which I would like to solve in terms of a third unknown variable $s$. ...
1
vote
1answer
49 views

Basic Syntax Question — Variables for a function

I am looking at the following mathematica code Subscript[ff, r1_, r2_, CC_][x_, y_] := (r1 x + r2 y) (1 - (x + y)/CC) Subscript[gg, r1_, r2_, CC_][x_, y_] := x ...
1
vote
1answer
105 views

Module that prints first m positive odd integers and returns the square root of the sum of them

I am working on this problem and I feel like I've come so close. Write a module that takes as input a positive integer m, prints the first m positive odd numbers and returns the square root of the ...
1
vote
1answer
31 views

Iterating my function by $4$ using NestList — Syntax Confusion [duplicate]

I want to iterate my function $f(x) = 13xe^{-x}$ by $4$ multiple times. That is, $f, f^{4}, f^{8}, f^{12},\cdots$. Using Nestlist[f,x,4] I can get $f,f^{(2)}, f^{(3)...
3
votes
0answers
53 views

Pre-define list of variables to set them in bulk

I understand this is likely tremendously simple, but I cannot work out how to do the following: vars = {b,c} *define variables* vars = {1,2} *set them* Then I ...
1
vote
2answers
104 views

Extract all elements from a list that belong to a set or have a set element as an argument

EDIT: Added that I want to extract not only the variables from a specific set, but also functions involving variables from a specific set. Given the set ...
1
vote
1answer
53 views

Using the Nest function — Confusion on my output

I have the following code and output where the original function is $f(x,a) = a^2 - x^2$. ...
-1
votes
1answer
61 views

Syntax Error for the following code

I have the following code in mathematica ...
2
votes
1answer
50 views

Recognition Power Head for numeric value

We know: Map[Head, {a, a^2, a^3}] (* {Symbol, Power, Power} *) and Map[Head, {2, 2^2, 2^3}] all of them will be known as <...
1
vote
1answer
89 views

What explains non-working (black) variables?

I'm a bit new in Mathematica 10.3 and have had strange problem. Sometimes, variables appear in black and obviously prompt and error when used. ...
1
vote
1answer
85 views

Double arguments and place of the underscore

Could someone explain me of this bit of code below is correct: Is it possible to define a function with a second bracket, see below, i.e. f[x_][y_]? And what does ...
0
votes
1answer
83 views

what do those signs #1, #1^2, #1^3, & mean here? [duplicate]

I have read common pitfalls page and the documentation page but I still don't understand what do those signs mean here? ...
2
votes
1answer
62 views

Why do Wolfram Alpha and Mathematica give different answers? [closed]

I've just got my hands on Wolfram Mathematica and tried to see if I can figure out how to use it by myself. I've plugged in an integral $\int \frac{dx}{(1-x^2)^{2/3}}$, knowing that the result is $\...
0
votes
2answers
116 views

Referencing elements of ArrayRules

How do I call elements of ArrayRules by their indices rather than by Part[ArrayRules[list],i]? I'd like to call the element that ...
4
votes
1answer
45 views

Aliases for keys?

The syntactic sugar for alternatives in replacement rules is clean: {a|b|c-> 1, d->2} Are there any analogous shorthands for keys in associations. I want ...
0
votes
1answer
68 views

What does the syntax <<X>> mean? [duplicate]

What does the syntax; << X >> mean? Where X is a number? Cheers
3
votes
0answers
91 views
2
votes
4answers
146 views

How to obtain the gradient of a function as a function?

The Grad function allows me to get the gradient of a function like this: ...
7
votes
3answers
171 views

Morse Code Spacing

Trying to make a function to convert text into morse code and play the sound. Have it pretty much completed, but I cannot get mathematica to emit no sound so I can have a pause between the dots and ...
0
votes
0answers
25 views

I would like know why “&” came after “FrontEndToken[”New"] here [duplicate]

I am a newbie to this Mathematica world who lives in South Korea, which is not a desirable place to have people to discuss Mathematica. So I came here, even though this question may look very simple ...
3
votes
0answers
38 views

Java anonymous functions from JLink?

JLink is really great to act on Java objects and access Java static methods. I'm asking myself if there would be a way to have access to a more recent Java syntax that allows anonymous functions, ...
5
votes
5answers
220 views

Nested function with an increasing argument

If, for example, I have a nesting function like Nest[1 + x^n (#) &, 1, 3] it gives the result ...
0
votes
1answer
53 views

Compile decreases the number of returned list elements

I have: LogisticMap = Compile[{μ}, ({μ, #} &) /@ Union[Drop[NestList[μ # (1 - #) &, .2, 300], 100]]]; Then: ...
3
votes
1answer
114 views

Binary decision diagrams (BDD) syntax error

I am new here (and to Mathematica) and would like to rebuild a simple binary decision diagram that I found here https://en.wikipedia.org/wiki/Binary_decision_diagram A code has been provided as part ...
7
votes
3answers
86 views

TagSetDelayed on a function with a delayed value

I'm trying to automatically optimize cases when the user evaluates Length[returnsList[x_]] to instead use returnsLength: ...
4
votes
1answer
200 views

Why assign variables to empty curly brackets?

I am trying to read code and I see empty curly brackets. For example: abc = {} or fort[x_] := Module[{}, more stuff here ] ...
6
votes
2answers
151 views

Ignore some values at return

Is there Mathematica analogue of Python _ (underscore) or Matlab ~, a special variable, that can be used when a function returns ...
6
votes
3answers
319 views

How can I create currying functions using pure function syntax?

For example how can I write In: pureFunctionSyntax[myF] /@ {7, 3} Out: {myF[7, Log[7]], myF[3, Log[3]]}
6
votes
2answers
556 views

What does (0 &) mean in an evaluation? [closed]

My Mathematica code is this: Simplify[D[Sqrt[1 + (u')^2 + (-60 x - 20 u u')^2], u]] It returns this: ...
5
votes
3answers
606 views

Can symbols like + or * be used to denote the Plus and Times functions?

Can one do something similar to +[1, 2]? The point is that with one symbol you would be able to write expressions like ...
0
votes
2answers
66 views

Function input syntax [closed]

My functions are ...
1
vote
0answers
90 views

Meaning of Abs´? [closed]

A friend showed me the code below. r[i_] := {x[i, t], y[i, t], z[i, t]}; rji = r[i] - r[j]; solap = 2 a - Norm[rji]; FullSimplify[D[solap, t]] I'm unsure about ...
1
vote
1answer
34 views

Scan appears to work setting graph properties, but get error on property-read

This is a self-contained version of something a bit bigger - going for brevity. It is a bit synthetic, but there are applications I have in mind where the {{1,2}} will be replaced with real data, more ...
1
vote
2answers
73 views

Intersection of all sublists of a list [duplicate]

I want to get the intersection of all sublists of list in an easy way. ...
11
votes
1answer
162 views

The equivalent of dplyr mutate with Dataset

In R, there is a package "dplyr" that works on data.frame objects, which is one of the origins of the Mathematica Dataset construct. One of the things dplyr can do is "mutate" the columns of a data....
1
vote
1answer
81 views

Can I map a function over a sequence of arguments without making the arguments into a list first?

I would like to set evenFunction[f_][a_, b_, c_, ...] = f[Abs[a], Abs[b], Abs[c], ...] I have come up with two ways to do this so far. Use pure functions <...
5
votes
2answers
287 views

f /@ # & /@ # & /@ # & /@ # & /@ # & /@ # & /@ # & /@ matrix

How can one write f /@ # & /@ # & /@ # & /@ # & /@ # & /@ # & /@ # & /@ matrix in one line with arbitrary level and without using ...
0
votes
0answers
46 views

Solving Integral -syntax or interpretation problems

WA interpreter achievement not well this entry from Mathematica, steps need to see the full resolution input WA ...
0
votes
1answer
144 views

Convert code from C++ to Mathematica [closed]

I need to know how to convert the following code in C++ to Mathematica. ...
1
vote
4answers
122 views

Build a truncated tower with numbers from 1 to 9 without repeating

consider the image subject to the following conditions appearing in my code, I find not the appropriate numbers ...
4
votes
2answers
118 views

Sorting and keeping the main format of list numbers [duplicate]

I have a list with these elements: list={1/2 (1 + Sqrt[5]), 1, 1, 1/2 (1 - Sqrt[5]), 0}; I want to sort them with ...
4
votes
0answers
94 views

Why does FromDigits transpose its argument (sometimes)?

a = {{1, 2}, {3, 4}, {5, 6}} ; FromDigits /@ Transpose@ a == FromDigits @ a (* True *) The only "strange" syntax I've found in the docs is But it doesn't ...
0
votes
1answer
38 views

Possibly syntax errors? [duplicate]

trying to graph, however graph is blank when i enter it. Please help! ...
0
votes
1answer
404 views

Syntax::sntxf: “…” cannot be followed by “…\MatrixForm” [closed]

I'm trying to create a $3\times 1$ matrix named Pauli but I really don't understand what's the problem of the following code? ...
0
votes
1answer
90 views

How to store value of result in an array for a calculation inside the loop [closed]

Note: In my code I used j (ranging from 3 to 7) but I want j to be general I tried this ...
4
votes
0answers
104 views

“\:”; flagged as syntax error

While answering question 94032, I noticed that Mathematica 10.2 flagged "\:" <> IntegerString[62378, 16, 4] with a red bracket, apparently indicating a ...