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

learn more… | top users | synonyms

1
vote
1answer
54 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 ...
11
votes
1answer
84 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} ...
10
votes
1answer
168 views
6
votes
1answer
67 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] ...
3
votes
1answer
51 views

Collecting the Log Problem

I have been having tremendous success with my students due to the following idea: ...
0
votes
1answer
63 views
3
votes
2answers
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: ...
3
votes
1answer
66 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 ...
4
votes
0answers
125 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 ...
1
vote
2answers
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 ...
2
votes
1answer
59 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: ...
6
votes
0answers
65 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: ...
5
votes
1answer
217 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 ...
2
votes
2answers
124 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 ...
1
vote
1answer
49 views

How to deal with repeating usage of same attributes

I am producing in my notebookfile many plots with the following example code: ...
1
vote
1answer
45 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 ...
2
votes
1answer
69 views

Scoping problem with NDSolve [closed]

I'm trying to solve a more complex problem , however , this simple problem can represent well : ...
19
votes
1answer
258 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 ...
12
votes
5answers
1k 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 ...
7
votes
1answer
135 views

Mystery with ValueQ

Consider the following ClearAll[jd]; ValueQ[jd] We expect False and get it. Now consider ...
5
votes
0answers
67 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 ;;; ...
20
votes
3answers
272 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 ...
6
votes
1answer
140 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 ...
1
vote
1answer
76 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? ...
18
votes
1answer
219 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, ...
32
votes
1answer
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 ...
18
votes
5answers
480 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 ...
0
votes
1answer
38 views

Can't clear variables with subscripts [duplicate]

ClearAll["Global`*"] doesn't clear subscripted variables. It won't clear these variables for example. ...
36
votes
2answers
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 ...
2
votes
0answers
58 views

Pattern Matching and overloading NonCommutativeMultiply [duplicate]

My goal right now is to implement some rules like linearity etc for noncommuting operators (arbitrary matrices etc). This is partly an exercise for me to understand MMA better so giving me a package ...
2
votes
1answer
78 views

Problems with QueueingNetworkProcess [closed]

I have a two stage queueing network and want to vary the number of servers at the second node. The input data and the Manipulate command is below: ...
308
votes
26answers
50k 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 ...
4
votes
1answer
170 views

Goal optimization: finding the best combination of capacitors and resistors resulting in given properties

I want to edit @MarcoB answers (because the code he gave doesn't answer the question appropriately)->(the function that need to be optimised is not implemented as asked) But it seems like I am having ...
0
votes
1answer
98 views
6
votes
1answer
324 views

Battery charge simulation not clipping properly as it iterates

My code for simulating a batterylevel-state throughout a year in 15min-steps doesn't work. There is a certain list-inputs which simulates the charge state and the batterylevel-state, additionally ...
8
votes
3answers
102 views

Indexed and array-valued interpolations

Bug introduced in 10.1 or earlier and persisting through 10.3.0 or later Using Indexed on an InterpolatingFunction leads to ...
0
votes
1answer
61 views
14
votes
3answers
229 views

ReplaceAll with Associations instead of Rules

I have just noticed that x /. <|x -> 123|> evaluates to 123 In other words, the association seems to behave as a ...
55
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 ...
5
votes
0answers
70 views

How does Plus work on machine precision Real arguments?

I thought Kahan's summation method would make a nice example for students to use to think about round-off error [W. Kahan, Pracniques: Further Remarks on Reducing Truncation Errors, Commun. ACM 8  ...
8
votes
3answers
160 views

DSolve—different solutions for same set of equations using different symbols?

I happen to find that DSolve can give different solutions, even a different number of solutions, for a set of differential equations just by making a change in the ...
5
votes
2answers
163 views

Why this upvalue doesn't escape from Sum?

Probably a hard question, but I decide to cry out loud :). This is actually another problem I encountered when answering this question. Consider the following transform rule stored as an upvalue: ...
6
votes
4answers
925 views

How can I avoid using a For-loop in my code?

I am trying to avoid using For because I heard that For is not cool in functional programming. Below is a problem that the first ...
4
votes
2answers
84 views

How can I extract something from an expression and assign it without changing the expression?

I am researching how to extract a certain value from an expression by using a pattern mechanism without actually changing the original expression. The paragraph above could be very ambiguous, so here ...
109
votes
3answers
6k 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 ...
1
vote
1answer
72 views

How can I define operators that have the behavior I want? [closed]

I need to define some operators with properties like idempotence and distribution over union and intersection so that Mathematica can symbolically simplify expressions. How do I define such operators? ...
3
votes
1answer
38 views

How can I perform arithmetic on a list integers and some other exact numbers and get decimal numbers in the result?

I want to do a simple calculation with a list with Pi and 10^-6 and get a list of decimal numbers as the result. ...
1
vote
1answer
154 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 ...
0
votes
1answer
60 views

Can anyone tell me what f[[1,1,2]] is doing? [closed]

equ = DSolve[y'[x] == x + y[x], y[x], x]; y[x] /. equ; f = equ[[1, 1, 2]];