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

learn more… | top users | synonyms

14
votes
5answers
376 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
28 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
47 views

Pattern Matching and overloading NonCommutativeMultiply

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
67 views

Problems with QueueingNetworkProcess [on hold]

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
164 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 ...
2
votes
0answers
25 views

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

Create a file temp.txt with the following content: test1 ;;; test2 ;;; test3 ;;; Treating the semicolon sequence as ...
6
votes
1answer
320 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
59 views

Should I define a function or not?

I was trying to execute the following code: ...
5
votes
0answers
62 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
214 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 ...
7
votes
3answers
130 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 ...
15
votes
3answers
201 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
83 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
915 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
94 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
37 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
2answers
66 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
52 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
156 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
130 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 ...
0
votes
2answers
109 views

Using 0 < x < 10 as a condition in an equation

How do I write 0 < x < 10 on the right side in the equation. If #1 + #2 is bigger than 0 and smaller than 10. And is it possible to require -10 < x < 10 with the additional condition x != ...
3
votes
1answer
97 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 ...
7
votes
1answer
81 views

Strange behavior of UpSetDelayed together with MakeBoxes

In order to answer this question, I just stumbled into the world of UpValues. Though I managed to find a solution for the problem, I'm confused by my own code now ...
3
votes
0answers
59 views

How to get “BasicFunctions” from WolframLanguageData with implicit entity

I am trying to get a list of the functions that have property "FunctionalityAreas" -> "BasicFunctions". The following does not work: ...
4
votes
1answer
165 views

Why assign variables to empty curly brackets?

I am trying to read code and I see empty curly brackets. For example: abc = {} or ...
6
votes
0answers
49 views

KeyIntersection fails (?) when an association is empty

I think I found a bug in KeyIntersection (Mma 10.2). To illustrate, input the following: ...
4
votes
1answer
163 views

Using Mathematica's Position Function

I have a list a = {-1, 2/3, -2 - 4 I, -2 + 7 I, 2 I} and when I use the Position[a, I] it returns ...
8
votes
1answer
89 views

Understanding Part and Span operating on expressions with heads that are not List [duplicate]

I hope this is not a duplicate. I do not understand how does the Part and Span functions work on this expression: ...
0
votes
2answers
38 views

How to use With on previously defined expressions [duplicate]

The command With[{x = 1}, x] outputs 1. The command t = x; With[{x = 1}, t] outputs ...
2
votes
1answer
40 views

How to label outputs from Print [closed]

I have problem with Print in Mathematica. The data that I get from it, is not labelled so that I can use it elsewhere, therefore I have got to label them manually. ...
10
votes
1answer
508 views

Difficulty understanding difference between == and ===

After doing this: ...
14
votes
0answers
156 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, ...
1
vote
2answers
89 views

Row-wise matrix multiplication

I have a matrix $A=\{a_{ij}\}$ of dimensions $n$ rows by $m$ columns, and I would like to multiply each row of the matrix by a constant $b_i$, $i=1,\ldots,n$, and store the result in the same ...
2
votes
1answer
56 views

Out[] is returning percent sign % instead of expression 10.3 [closed]

Has anyone else had this problem, is it a setting, or a bug in 10.3? In[1]:= 2; %+2 Out[2]= %1+2
6
votes
2answers
249 views

Wolfram Language symbols by their Ranks

I'd like to get the top 50, the bottom 50 and an ordered list of all Wolfram Language symbols based on their "Ranks". With ...
0
votes
0answers
53 views

Weird variable report

All, What does this mean when it shows up in your notebook? ?f f Global` CreateUUID["Info-"] False False False ?x x Global` CreateUUID["Info-"] False False False What has happened? ...
0
votes
0answers
32 views

elementwise operation with vector and matrix (“broadcasting”) [duplicate]

In languages supporting broadcasting, one can easily do elementwise comparison of a vector and a matrix. What is the recommended approach in Mma? For example, suppose I want to do a ...
0
votes
1answer
74 views

Formulate an equation to find a fixed point [closed]

I have the following equation: Subscript[x, n + 1] = Subscript[x, n]^2 + c with Subscript[x, 0] = 0. This equation is restricted ...
5
votes
5answers
483 views

Defining indefinitely many functions

Is it possible to define a class of indefinitely many functions f1, f2, f3, ... such that ...
4
votes
1answer
60 views

Manipulate: how to hide manipulator

Suppose one creates a simple Manipulate in a notebook, with a single numerical control and no changing of the default appearance. Then there is a small + in the upper right, for accessing the ...
1
vote
1answer
43 views

should Variance of EmpiricalDistribution include Bessel correction? (it doesn't)

I was rather surprised by this: ...
0
votes
0answers
35 views

when to use `Select` vs `Cases` [duplicate]

Given a list lst and a Boolean function f, are there any interesting differences in the following? ...
6
votes
2answers
272 views

What evaluation mechanism is behind Mathematica support for multiple definitions of a function? What is the benefit of this?

I am studying the question What are the most common pitfalls awaiting new users? Up to now, I have fulfilled some of the parts but yet don't understand which this problem is related to? Consider the ...
18
votes
3answers
408 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 ...
0
votes
1answer
47 views

SortBy second item in each list item [closed]

I have: mydata = {{1, "NEBRASKA", 2.7`}, {2, "NORTH DAKOTA", 3.`}, {3, "UTAH", 3.6`}, {3, "VERMONT", 3.6`}, {5, "HAWAII", 3.7`}} Now, I can do: ...
0
votes
1answer
63 views

How to put a levelspec in operator form? [closed]

All variable argument functions need Function wrapped around them in operator form, but is there any other way to achieve this: ...
8
votes
3answers
101 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 ...
2
votes
0answers
36 views

Unexpected behavior from Return called in a Block [duplicate]

I like to write functions that dispose of failure cases early, before they do the main calculation, but I don't like to write cascading If statements. Here is a toy ...
14
votes
1answer
407 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 ...
1
vote
0answers
20 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: ...