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
58 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: ...
0
votes
1answer
46 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 ...
4
votes
1answer
107 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 ...
2
votes
0answers
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 ...
4
votes
2answers
108 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 ...
1
vote
1answer
53 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? ...
9
votes
4answers
696 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 ...
1
vote
2answers
141 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 ...
0
votes
0answers
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 ...
1
vote
0answers
40 views

Flatten works in output but not in Global Workspace?

I am trying Michael Trott's Sierpinski Triangle. ...
1
vote
1answer
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 ...
10
votes
1answer
175 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, ...
6
votes
1answer
71 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
54 views

Collecting the Log Problem

I have been having tremendous success with my students due to the following idea: ...
0
votes
1answer
63 views

Sum the several solution functions returned by DSolve [duplicate]

Could you please explain why this code does not work. ...
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
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 ...
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 ...
4
votes
0answers
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 ...
6
votes
0answers
70 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: ...
2
votes
2answers
129 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
50 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
49 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 ...
3
votes
0answers
79 views
2
votes
1answer
62 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: ...
2
votes
1answer
72 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
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 ...
1
vote
1answer
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? ...
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
487 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
41 views

Can't clear variables with subscripts [duplicate]

ClearAll["Global`*"] doesn't clear subscripted variables. It won't clear these variables for example. ...
2
votes
0answers
59 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: ...
4
votes
1answer
172 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 ...
5
votes
0answers
74 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 ;;; ...
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 ...
0
votes
1answer
63 views

Should I define a function or not?

I was trying to execute the following code: ...
5
votes
0answers
71 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  (...
14
votes
3answers
234 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 ...
9
votes
3answers
164 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 ...
20
votes
3answers
301 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 ...
4
votes
2answers
85 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 ...
6
votes
4answers
926 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 ...
0
votes
1answer
98 views

How to calculate the pseudo-remainder and pseudo-quotient of two multivariate polynomials

I have fixed some code, but it always gives me errors. Can anybody tell me its right code? ...
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
73 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? ...
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]];
5
votes
2answers
171 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: <...
4
votes
2answers
138 views

ReplaceRepeated as a Looping construct?

There are a lot of discussions about looping constructs (notable example here). Wolfram language guides, as usually, contain most relevant links. Looping constructs guide has the following part on ...
4
votes
1answer
190 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 ...