Tagged Questions

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

17 views

Is there a way to do ParallelMapIndexed?

I need the know the index of the items I'm mapping my function at, is there a way to achieve this when using all the kernels?
80 views

What has changed in pattern matching functions with the Orderless attribute?

In making an attempt to answer this question, we ran into a version-dependent pattern-matching issue. An extended discussion in the comments transpired, and some inconsistencies arose. Consider the ...
603 views

What are the requirements for a well behaved indexed variable? Subscript, ToExpression, Downvalue?

On writing this answer I needed to call a function, (NonlinearModelFit) with an unknown number of parameters. We have learned that we should not use ...
156 views

How can I assign many values each to a different variable? [duplicate]

How can I assign many values each to a different variable? For example, I want to set $a = f(1),\,b = f(2),\,c = f(3),\,\dots,\,z = f(26)$ (generally more variables than these). How can I do this ...
735 views

Capital Letters that are built-in symbols

I'm trying to search for an answer to "What is the complete list of single capital letters that represent built-in Mathematica commands, symbols, or uses?" For example: C, D, E, I, N, O Is this ...
52 views

Why does Transpose not work after I wrap a list with NumberForm? [duplicate]

This code works fine. ...
55k 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 ...
64 views

Counting flops to compare to operations

I know there is a Timing approach, but I am wondering if there is a Mathematica command that will count the number of flops (floating point operations). For example, if I do: ...
47 views

Problem storing $x_j$ terms in variable x

This works: Table[Subscript[x, j], {j, 1, 10}] But this doesn't: x = Table[Subscript[x, j], {j, 1, 10}] Giving this ...
110 views

Why do I get the Null when I evaluate Print[x] // InputForm? [duplicate]

When I execute: Print[x]//InputForm I get a Null at the last line of the result. This is an example shown in the ...
68 views

Confusing alternative definition of a function [duplicate]

I saw a function defined something like the following: f[n_Integer][r, θ] = Sin[n r π/L] Cos[n r L π θ/4] My question is, why did my professor define the ...
112 views

time complexity of MemberQ

I was rather surprised that the operator form of MemberQ takes a form as its argument. I looked for the operator form thinking that repeated testing for elementhood in a given "set" is a common need ...
54 views

Evaluation of Element?

What is the Mathematica reasoning behind the result of the first two elements on the second row of the following table? ...
194 views

How to check and reset the boolean value of many options one times?

I defined a function which owns many options. In addtion, these options have a common characteristic. Namely, only accepting boolean value True or ...
146 views

Defining a variable with comma (or any other separator) in its name?

How can I define Mathematica variable/function with comma in it? For example, defineL00,1 as a variable? I plan to use L00,1 ...
24 views

Get List of All Atomic Expressions [duplicate]

Cases[Names["System*"],x_:> If[StringTake[x, 1] == "\$", Nothing, If[AtomQ@ToExpression[x], ToExpression[x], Nothing]]] This still gives me a list of atoms ...
2k views

Scan vs. Map vs. Apply

I cannot understand the difference between Apply, Scan, and Map. I have tried to play with ...
40 views

Flatten works in output but not in Global Workspace?

I am trying Michael Trott's Sierpinski Triangle. ...
55 views

Subscripted variables give errors in Module expression [closed]

I have following problem. I want the R not to calculate before the integration but substitute later as a function of z. My Mathematica codes look like: Codes like big, (sorry) but most of them ...
88 views

Which symbol gets DownValues or OwnValues when using SetDelayed?

I have been looking at various usages of Pattern objects. Here's a number of ways to define the same thing: mod[x_] := {x} ...
176 views

Core functions or operations that every aspiring Mathematica programmer should know? [duplicate]

I am aware that there are common yet very powerful operations like Map, Thread, Apply, ...
72 views

Custom operator form for system functions?

There are some functions for which an operator form would make sense but isn't implemented. For example, I'd like to make this work: RandomSample[3] @ Range[10] ...
55 views

Collecting the Log Problem

I have been having tremendous success with my students due to the following idea: ...
65 views

Sum the several solution functions returned by DSolve [duplicate]

Could you please explain why this code does not work. ...
146 views

Free symbols in an expression

I am starting to learn the basic MMA grammar these days. I hope I do not ask too much stupid questions. Here is one of them: Getting free symbols in an expression can be done by following codes: <...
71 views

Mod[k, 2] == 0 versus EvenQ[k] [duplicate]

I'm having some trouble with Mod[k, 2] == 0 versus EvenQ[k] They are sometimes yielding different results when given the ...
126 views

Learning the Wolfram Language ‘from the bottom up’ [duplicate]

I'm a armchair programming-language theorist, and I know … quite a few programming languages, some to extensive depths. (Hell, I've built more than my fair share.) Most of the information I've found ...
41 views

How do I Define a Module Which Displays Some Graphics and Returns Some Data?

I want to bundle some actions of a task in a module to call it a few times. The task shall display some Graphics and it shall return some data (as a list). But I can't do that (it would have been ...
65 views

Pairing values with their indexes for MapThread

Several operations require you to map over a list of values and to know the index of each value as you process it. To accomplish this, my current somewhat ugly solution uses MapThread: ...
71 views

Why Unevaluated doesn't work on unheld side of Rule/RuleDelayed?

Unevaluated is a function that I never truly understand, and here's one of the cases confusing me: ...
220 views

How to Override the Head of a Symbol

I was wondering if it is possible to override the head of symbols/operators. As a motivating example if I run: Then Ket will be returned. But lets say I want Bob to be returned instead of Ket. Is ...
131 views

ImageData reverses the order of the row of an Image [duplicate]

Could someone convince me what is the utility of doing a function like ImageData that reverses the order of rows in an image? Why was it coded like this? Why does ...
50 views

How to deal with repeating usage of same attributes

I am producing in my notebookfile many plots with the following example code: ...
50 views

Solve a backward-forward equation with a loop

I want to solve this recursive equation X[t+1] = 0.8 X[t] + 0.04 P[t+1] + 119.6; P[t_] := 0.4 X[t] + 0.8 P[t + 1]; P[t_] := S[t] X[t] - g[t]; and with these ...
79 views

Get list value without displaying it on screen [duplicate]

Having this code: ...
72 views

Scoping problem with NDSolve [closed]

I'm trying to solve a more complex problem , however , this simple problem can represent well : ...
261 views

Version inconsistency with optional arguments: what if the default value doesn't match the pattern?

I just came across some weird behaviour. Take this function definition: ClearAll[f] f[vs_List : All] := "match" The default value of ...
2k views

How to completely delete the head of a function expression

Is there any way to completely remove the head of an expression function? For example, how would I remove the head Cos from ...
137 views

Mystery with ValueQ

Consider the following ClearAll[jd]; ValueQ[jd] We expect False and get it. Now consider ...
82 views

why does ReadString[“fname”,term] open a persistent stream, and how to close it?

Bug introduced in 10.0 and fixed in 10.3.0 Create a file temp.txt with the following content: test1 ;;; test2 ;;; test3 ;;; ...
311 views

Resolving my Entity* Crisis

In the Wolfram Language I can usually guess a function's name, operation or idiomatic application but I don't have such a sense for various Entities ... ... instead, I seem to keep needing to ...
142 views

Unexpected behavior from Indexed (threading and messages)

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

Why does using replacement rules give a different result than setting the variable? [duplicate]

These two methods should give the same result, but one terminates when the result is unchanged (to machine precision) while the other continues for the full 100 allowed cycles. Why? ...
235 views

Defer, Hold, Unevaluated, Inactivate — which one when?

What are some guidelines on which function to select from among the superficially similar functions Defer, Hold, ...
4k views

++ is dangerous for C programmers

I noticed this fact, that may be misleading for programmers used to C language. In Mathematica, if you have a function f[] and an array v, and you write ...
492 views

How can one manually change the rule ordering

I have a function which has some general behaviour, but that should act on some specific kinds of objects in some other way. I know that Mathematica is supposed to automatically order the rules so ...
42 views

Can't clear variables with subscripts [duplicate]

ClearAll["Global*"] doesn't clear subscripted variables. It won't clear these variables for example. ...
2k views

Is Mathematica comparable to C++ for creating standalone applications?

At my university, I have a yearly essay. I'm allowed to use any technology for implementing it. I've been coding it in C++ with Qt. I thought of about Wolfram Mathematica because I have some ...