Questions on the basic structure of the Mathematica language (Wolfram language) including atomic data types, syntax etc

learn more… | top users | synonyms

264
votes
25answers
35k views

What are the most common pitfalls awaiting new users?

As you may already know, Mathematica is a wonderful piece of software. However, it has a few characteristics that tend to confuse new (and sometimes not-so-new) users. That can be clearly seen from ...
13
votes
1answer
340 views

Why is an Identity function needed?

Today I came across the function Identity[x] in Mathematica (documentation). The example given in the documentation uses it in ...
0
votes
1answer
127 views

Help with functions in Mathematica

I'd like to make a function that has many parts. Doing this in something such as Java, which I am familiar with, would be simple. In Mathematica I have these "pieces", which I want to put into a ...
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?
1
vote
0answers
19 views

How to ValueQ a symbol, constructing the symbol name from strings? [duplicate]

In a function I'm writing, I need to check whether a particular symbol has been assigned a value (any value) in a particular context. This would work: ...
41
votes
4answers
669 views

What's the difference between Inactive and HoldForm?

In version 10, Mathematica not only added Inactive / Activate but also highlighted this change in the "New in 10" page (in Core ...
9
votes
2answers
215 views

Pattern and Orderless function

I'm a Mathematica beginner. I am exploring the use of patterns and (only for fun) am trying to implement a permutations function. My (dirty) code is: ...
3
votes
2answers
223 views

Issue with Set function

Tables often come with column headers. Indexing the columns with the header is a natural thing to do. Although a proper dictionary is the usual solution in such a case, I find it often practical and ...
0
votes
1answer
39 views

Could I use Select with condition on any column other than First (Last)? [closed]

I often deal with huge tables of various functions of randomly generated values for my research. Sometimes there's need to only keep rows which satisfy a specific condition. This is easy with ...
2
votes
1answer
59 views
1
vote
0answers
72 views

What's in a Name? [closed]

StringReplacePart["StringReplacePart","At",{14,17}] ... Surely you can't be serious? ... Naming Matters: I think what and how we call things is underestimated ...
1
vote
1answer
69 views

DownValues when using Set and SetDelayed

It is known from several questions asked in SE that one of the basic differences between Set and SetDelayed is that the former ...
89
votes
3answers
4k views

How to make use of Associations?

I have been curious about it for long. Now that Mathematica 10 arrives, I think it's time to ask the question: How the new Association data structure would be used ...
25
votes
2answers
566 views

Why is Query so much slower than Part?

Time for another of these(1),(2) as yet another new-in-10 function appears to have poor performance compared to older alternatives. This time: Query appears to be ...
23
votes
1answer
341 views

Performance regression for Fold?

Bug introduced in 8.0 and persisting through 10.2.0 or later I noticed an over 10x performance drop on Mathematica v9.0.1 (as Oleksandr R. commented, also v8) compared with v7.01 for this code: ...
7
votes
2answers
102 views

Cannot Block Plus

It is customary to use the following idiom to partially evaluate something inside a held expression: ...
0
votes
1answer
36 views

The FindRoot output only with numbers [duplicate]

I have this code in Mathematica: FindRoot[{Sin[x - y + 2] - x == 0, Sin[2 x - z] - 8 z == 0, Sin[z + y + z] - 2 x == 0}, {{x, 0}, {y, 0}, {z, 0}}] where it's ...
0
votes
1answer
69 views

solving quadratic and linear congruences with different modulus

We are able to solve the quadratic congruences $C^2 + Q^4 - 2\equiv mod 3072$ and $C - Q^2 - 2046\equiv mod 3072$ by entering ...
0
votes
2answers
50 views

How to make Mathematica to assemble components we already have like a regular input

Suppose we have the following list: {5, 3} I want to add the -> to the end of the first element in the list in Mathematica ...
1
vote
1answer
68 views

How should I enter indexed terms? For example, constants $n_k$ for $k\in\{1,\,\ldots,\,N\}$

How should I enter $\quad \quad \sum^{N}_{k=0}{f(n_k)}$ into Mathematica? More generally, how should I work with the indices? Take the following as an example. I know how the ...
4
votes
1answer
50 views

Boundedness of an expression

First post on this part of the stackexchange network, I was just wondering if Mathematica allows one to quickly see if an expression is always within a certain range given values for the parameters it ...
1
vote
1answer
80 views

A question on using Cases [closed]

I am working on Wagon's FindRoots2D section. Clear[f]; f[x_, y_] := x - y^2 Cos[y]; g[x_, y_] := -y + x Sin[x]; fcnVec[{x_, y_}] := {f[x, y], g[x, y]}; I am ...
0
votes
2answers
37 views

Equality of expressions containing complex numbers [closed]

I am using Mathematica to test the equivalence of symbolic expressions. I run into what appears to be a bug when I test the equivalence of expressions involving an imaginary number taken to a complex ...
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 ...
3
votes
1answer
43 views

Order of evaluation of Exp and Normal on result from Series

This may be more math related than Mathematica related, but I thought this might be of interest to the group. I'm trying to work with some Taylor Series approximations of functions that are ...
6
votes
1answer
67 views

Is $ModuleNumber working properly on my machine?

In the documentation ref/$ModuleNumber, I read: Every Wolfram System session starts with $ModuleNumber set to 1. Yet, when I quit Mathematica 10.1 (OS X 10.10.4), restart it, open a new notebook ...
14
votes
1answer
233 views

What's wrong with Simplify and FullSimplify?

I have a quite complex list of equations and inequalities I combine to a boundary condition for my cost function. After investigation of two days I found the bug (I really name it a bug!). One of my ...
3
votes
3answers
141 views

How I can count multiplications in an experssion?

Next task to complete: Count *-symbol in such expression as a + s^2*b - c/y + o^3 + n*m*u (in this case count of ...
21
votes
1answer
524 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 ...
2
votes
2answers
115 views

What is wrong with my use of Flatten? [duplicate]

Why does Flatten[f[g[a, f[b]], f[c, d]]] result in f[g[a, f[b]], c, d] I expected the answer to be ...
10
votes
3answers
186 views

How do I make a string literal without having to escape backslashes?

I'd like to say something like: foo = @"\abc\def\ghi" instead of foo = "\\abc\\def\\ghi" How do I do this? This would ...
0
votes
1answer
67 views

Draw a number of rectangles from list of coordinates [closed]

I'm new to Mathematica and this is also my first post here. Now for the question: I try to let Mathematica draw a number of rectangles from lists of coordinates. Unfortunately it only works when I ...
20
votes
1answer
363 views

Why some built-in functions are slow

I just wonder why some built-in functions are slower compared to some other ways using more than one built-in functions for doing same job. consider this example: ...
9
votes
4answers
234 views

How to Thread with custom functions? Thread vs Map?

This function finds n given the nth prime: findPrime[n_] := If[PrimeQ[n], i = 1; While[Prime[i] < n, i = i + 1]; i, False]; This works: ...
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 ...
4
votes
1answer
144 views

What is the relationship between Thread and MapThread

I hope this is not a silly question, since there are plenty of questions on Thread and MapThread. However, I still cannot quite ...
16
votes
1answer
181 views

A bug in the overloading of MemberQ and FreeQ for Association?

Bug introduced in 10.0.0 and fixed in 10.1.0. While answering Pattern match for nested Association I came across behavior of MemberQ and ...
4
votes
0answers
85 views

Unexpected behavior from Indexed

I was going to include Indexed in this answer, thinking that it operated much as a List-only ...
12
votes
1answer
163 views

Is there a way to control which special forms Normal converts?

Normal documentation reads: Normal[expr] converts expr to a normal expression, from a variety of special forms. But is there a way to control which special ...
3
votes
3answers
163 views

How to assign symbols to functions

Several functions work with symbols in MMA: Take for example Part: l1=l2=Range[4]; l1[[3]] (*3*) l2[[4]] (*4*) I want to make ...
2
votes
3answers
84 views

Perform For-loop and show output which meets a certain criterion

I am new to Mathematica and I have a For loop like so: For[i = 0, i < 15, i++, PowerMod[i, -1, 15]] Currently it doesn't output anything. The calculation I am ...
2
votes
1answer
72 views

Can I use Switch with an inequality? [closed]

I'd like to have something like: Switch[x, 10, a = 3; b = 7, >10, a = 5; c = 6, _, a = 7; d = 12, b = 1]; I can't seem to get this to work.
20
votes
2answers
1k views

Scan vs. Map vs. Apply

I cannot understand the difference between Apply, Scan, and Map. I have tried to play with ...
3
votes
0answers
160 views

Minimalistic code challenge on Apollonian gaskets

I've been recently fascinated by the beauty, symmetry and mathematical richness of the Apollonian gaskets. So I felt myself challenged to see if it was possible to generate one in Mathematica with ...
0
votes
0answers
45 views

Treating expressions as symbols [duplicate]

I'm trying to do something like this: test = {x, y}; With[{test[[1]] = 3}, x/y] However, the following error is printed: With::lvset: "Local variable ...
0
votes
2answers
41 views

Using Nest on a function that takes a function as one of its arguments [closed]

I have a function, nS[f_, xk_], which takes as arguments a function f and a vector xk. It ...
5
votes
0answers
156 views

Built-in symbols which are more close to the root/core of Wolfram Language

Seeing the vast scope of science covered by the Wolfram Language (WL) and the large amount of built-in symbols (functions), I am curious to know which built-in symbols are more close to the root of ...
0
votes
1answer
88 views

Solving a vector equation [duplicate]

I want a simple and intuitive way of solving for $t$ given that $\mathbf{i},\, \mathbf{j},\, \mathbf{k}$ are the unit vectors in $\mathbf{R}^3$. $$ 5 = (2 \mathbf{i} - 3 \mathbf{k} + (\mathbf{i} - ...