Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

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

1
vote
0answers
34 views

What use is empty binding list in `Block[{},…]`? [duplicate]

Spelunking the Export function, I stumbled upon the following definition: ...
11
votes
1answer
63 views

stable sort for association?

Should I be able to use the "list of functions" approach to getting a stable sort of an association? In 11.1 I see, ...
0
votes
1answer
25 views

How to Update a Finite-Width Cellular Automaton

How does one instruct CellularAutomaton to wrap at the edges? (I want a 2d finite-width CA, so it evolves on a torus.) I cannot tell from the docs if this is ...
7
votes
1answer
94 views

advantages of ApplySides?

Version 11.3 introduces ApplySides for situations where I usually use Map. What is an example where ...
3
votes
0answers
103 views

How to achieve with Mathematica the effect a closure has in other languages?

Motivation I want to write an auxiliary function (brief auxf) for testing the output of another function that evaluates its body repeatedly using ...
10
votes
2answers
97 views

Can a Symbol have more than one OwnValue?

The DownValues, UpValues, and OwnValues functions are all plural. In general, a Symbol may ...
4
votes
1answer
67 views

SetDelayed not working as expected

According to the manual, "A variable defined with SetDelayed is evaluated every time it is used". The code below suggests otherwise. ...
12
votes
1answer
135 views

Check if symbol is in core language

How can I check if a symbol is pre-defined by Mathematica, in a way that's backwards compatible with old versions? i.e. I would like some CoreLanguageQ[x_Symbol] ...
1
vote
0answers
31 views

Convenient value assignments in OOP

It is possible to implement OOP in Mathematica using something like obj=c[<|a->1,b->2|>] and it's convenient to extract value from the object by ...
0
votes
0answers
33 views

How can I extract the numerical value from the result of FindRoot [duplicate]

I've to use previous values of FindRoot to implement my program (recursively), but the type of the output from FindRoot is not a number. How can I extract the ...
4
votes
3answers
172 views

Keep only rules that replace integers with other integers

Let's say I have a list of replacement rules: List1 = {2 -> 3, b -> 5.5, 6.57 -> 2, 3 -> 4.5, 1 -> -1, 0.03 -> 0.5, 9 -> a} The desired ...
0
votes
2answers
47 views

Numerical integration with a fixed sampling size, skipping points [closed]

I have a large number of data points to integrate over numerically. I would like to sample only some of the points and use a rather large step size just to reduce computation time. Say the data ...
0
votes
2answers
40 views

NIntegrating in $n$ dimensions?

I need to make a function that takes a function $f$ and a natural number $n$ and returns the integration from -inf to inf in all the $n$ dimensions of $f(x_1,\cdots,x_n)$. With Integrate I would do ...
1
vote
1answer
41 views

any possible meaning to a “terminal” slash (/)? [closed]

I've been directed to the web page http://functions.wolfram.com/07.31.16.0001.01 The first statement in the formula is ...
-4
votes
1answer
56 views

how can i convert my matlab conde into mathematica or atleast convert the bisection program? [duplicate]

(Convert matlab code into mathematica code) (I'm fairly new to mathematica) (bisect function matlab code:) ...
0
votes
1answer
58 views

SplitBy and mod 2 [closed]

I wish to group semiprimes into groups with same parity. Mathematica does this well with SplitBy[ Select[ Range@ 100, PrimeOmega@# == 2 &], Mod[#, 2] &] ...
0
votes
1answer
100 views

Why 1 is not recognized as real? [closed]

I'm not understanding smth simple. Why is 1 not recognized as a real number in the second line?
3
votes
2answers
108 views

Writing a bisection root finder

I'm trying to make a simple function that will calculate roots of equations by using bisection method. My code isn't working right. Can anyone take a look and help me? Here is the code: ...
9
votes
1answer
325 views

What does the ToList function do, and where did it go?

I am trying to revive some code from 2015 (version 10?) which uses the function ToList. I can not find it defined in any notebook on my system (in fact, it only ...
-3
votes
3answers
183 views
11
votes
2answers
1k views

Can't understand one paragraph in Power Programming with Mathematica

In the chapter 7 of the Power Programming with Mathematica, there is a paragraph discussing the behavior of Set- functions: (page 205. (pdf version p. 224)) ...
1
vote
0answers
33 views

Is Construct introduced to replace Function application? Should it be treated as such an alternative?

I noticed that v.11.3 got released the other day; it was exciting so I went through the Summary of New Features in 11.3 to catch a glimpse of what's new and see if there is something I should keep in ...
0
votes
1answer
79 views

Why is Null printing?

I am making a function that will evaluate several other functions, using the same inputs, in my program and give me the results. I am using Print to do this (see ...
2
votes
1answer
81 views

Can the pattern “_.” be used in head?

The standard usage of the pattern _. seems usually used in the parameter, for example, f_[a_,n_.]. I wonder if such pattern can ...
0
votes
0answers
32 views

Conditional access to entities in Wolfram knowledge base

I am trying to get the name of stars that are in a range of distances from the Sun. The Input I have tried is: ...
1
vote
2answers
34 views

How can I get a variable to be recognized as an array when computing expectation for multivariate distributions

The following expression works correctly: Expectation[ x^4, {x, y, z} \[Distributed] MultinormalDistribution[{0, 0, 0}, IdentityMatrix[3]]] But when I ...
7
votes
1answer
54 views

Abort but keep what was already calculated

This is a very general question I have about aborting a running computation but keeping what was already generated. Let's say that I perform a numerical optimization over a list of parameters. ...
1
vote
0answers
47 views

Is there a MaxPosition function? [duplicate]

The Max and Min functions return values, but I would like to have the position(s). Is there a standard function that does this? ...
1
vote
0answers
45 views

Why is Part designed to sometimes wrap the original head around the parts it extracts? [duplicate]

For me, the natural meaning of the function Part is "get the sub-expression at appointing position." It is quite unlike Take, <...
7
votes
3answers
276 views

Testing equality of graphics

Is there a way to reliably test the equality of two plots? Consider this: plot1 = Plot[Sin[x], {x, 0, 2Pi}]; plot2 = Plot[Sin[x], {x, 0, 2Pi}]; You'd think ...
3
votes
3answers
114 views

aggregate records across dates

Each record in a dataset includes a country name, a year, and observations (e.g., GDP) for that country in that year. I would like to generate a new dataset with one record per country (so I would ...
10
votes
1answer
252 views

Why use pure functions?

I've now read the official documentation of wolfram on (anonymous) pure functions, and the part about (anonymous) pure functions in the book "mathematica programming intro". I believe I understand ...
3
votes
2answers
92 views

What exactly do single brackets represent syntactically?

I'm trying to deepen my understanding of the mathematica language after having messed around with it for a long time. I'm reading the book "mathematica programming Intro". Unfortunately, I don't ...
7
votes
0answers
88 views

Mathematica lexer: Numbers

This is a follow-up question to Mathematica lexer: Symbols and UTF-8 and this it is about numbers. In Mathematica, we have a large number of ways to input numbers. They can contain a notation for the ...
1
vote
2answers
29 views

Evaluating a 2D function successively with each pair of values in a list of pairs [closed]

I have a table of parameter pairs a and b {{a1, b1}, {a2, b2}, ...} and I would like to ...
1
vote
0answers
49 views

Is this expected behavior for With? Should it be replaced by Block? [duplicate]

Evaluating the following piece of code, returns-as expected-3: g[a_] = a; With[{a = 1}, 2 + g[a] ] Why does the following ...
1
vote
0answers
41 views

ClearAll works on all variables except “h”? [closed]

I have a seemingly very strange problem. I have first defined a function $h$ as follows: h[x_]:=x^2 And I also defined some other variables. Then however, I ...
0
votes
0answers
41 views

Symbols in Mathematica (#, & etc) [duplicate]

I am constantly finding a lot of examples of usage of symbols # & etc in the code. But I could not find any information what they actually mean and how to ...
11
votes
0answers
110 views

Mathematica lexer: Symbols and UTF-8

Did you ever wonder why here on our site, there is a highlighting difference between f[argX_] := 1; and f[argα_] := 1; ...
5
votes
1answer
82 views

Is Depth[x, Heads->True] historical?

I randomly found that Depth has a boolean option called Heads: ...
1
vote
1answer
51 views

Functions defined with numbers

If I have defined functions as "A1", "A2" ecc. then I have many function as A+number, can I define a For cycle to call these functions (they have all the same kind of arguments) once? Something like ...
5
votes
2answers
58 views

OwnValues for Set and SetDelayed

I am unclear about the OwnValues for Set and SetDelayed. ...
6
votes
4answers
144 views

Function for adding a head to an expression

The gist of this question is to find a function that takes a list of functions and a list of arguments and wraps each argument with the corresponding function e.g. ...
1
vote
2answers
98 views

Inconsistent arithmetic of TimeSeries with non-equally spaced data?

Consider the following non-equally spaced TimeSeries: ...
1
vote
0answers
84 views

Why does With return a temporary symbol? [duplicate]

Why does With[{x0 = 1, y0 = 2}, f[x_] = a + b x /. First[ Solve[{y0 == a + b x0, b == 0.1}, {a, b}]]] evaluate to ...
5
votes
2answers
221 views

Passing a list to a function as a sequence of variables

I have the set l = {{x1, x2}, {y1, y2}}; and I am trying to get my function f to evaluate ...
1
vote
1answer
74 views

Iterator order breaks Table

Evaluating the following Table expression ...
5
votes
1answer
87 views

How to save a context into an expression?

BeginPackage["foo`"]; bar; Begin["`Private`"]; bar[] := bar[ $Context, $ContextPath]; End[]; EndPackage[]; So I'd like to have all information ...
0
votes
0answers
24 views

Parsing Module[…] creates additional Temporary symbols

Why this happens? ?? x$ Hold[Module[{x}, x]] ?? x$
13
votes
2answers
359 views

Why is listable not an attribute of the Set function?

The following is a list of attributes for the Set function: Attributes[Set] ...