Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [core-language]

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

0
votes
1answer
100 views

How can I translate some JavaScript code into Mathematica code? [on hold]

I am a programmer and would like to understand another field outside of the procedural thinking of if-else and for. I would ...
9
votes
1answer
155 views

Around usage results

Why is Around[10, 1]^2 +- 20 and Around[10, 1] Around[10, 1] giving 100 +- 14 ? Just curious I would suspect them to ...
0
votes
1answer
45 views

Deriving a list of time differences from a column in a dataset and appending the list as a new column

I know it's a beginner question, but I've struggled with it for some time now and can't find a solution. I have a dataset consisting of timestamps, where I've managed to compute the time differences ...
10
votes
4answers
521 views

What is the accessibility of a package's `Private` context variables?

I've been reading up on how Mathematica handles contexts, $Context, $ContextPath, and a few of the tutorials they have on ...
2
votes
1answer
62 views

How to trace value assigned to local variable(variables in Module)?

Bug introduced in v10.1 or earlier and persists through v11.3 CASE:4240757 Here is my code: ...
1
vote
0answers
83 views

Design completion idea for Position [closed]

This is not exactly a question but rather a suggestion for a design which I think would greatly improve Mathematica. Before I put this to Wolfram Research I would like to see what other people think ...
1
vote
2answers
102 views

Computation with arrays of numbers

My code is m = RandomVariate[NormalDistribution[], 100]; c = 0.1; f1 = RandomVariate[NormalDistribution[], 100]; F = Sqrt[c]*m + Sqrt[1 - c]*f1; I would like to ...
0
votes
2answers
28 views

My function for computing a partial derivative generates an error message [closed]

Apologies, I'm still new at Mathematica. I have defined the function ...
1
vote
2answers
58 views

Using a Do-loop to find divisors mod 13 [closed]

I want to check sum of divisors of i mod 13 fori = 1 to i = 20. I tried writing a Do-Print ...
10
votes
1answer
117 views

Why does Success[…][key] work and Failure[…][key] doesn't work?

I'm trying to figure out what is a quick way to add error reporting to my user defined functions. I was experimenting with Success and ...
5
votes
2answers
84 views

Converting prefix to infix

Is there a way in Mathematica to convert prefix to infix notation (where precedence order is preserved)? For example, how would I convert S[a, S[b, c]] to ...
3
votes
1answer
48 views

Is using Length more efficient than using === as stopping criterion?

I am using NestWhileList[ f[#, elems]&, pairs, Length[#1]<Length[#2]&, 2, Infinity, -1 ] to generate all suitable subsets from ...
1
vote
2answers
87 views

Change the output for `Times`function

When I have an input like: 1/2*k The output is: How to change the output of Timesfunction to see this result: Another ...
1
vote
1answer
62 views

Defining iterative algorithms [closed]

Assume the iterative algorithm of interest to be as follows: ...
3
votes
2answers
67 views

Iconize behaves in a confusing manner

When I evaluate Iconize[Range[10], "range10"], it returns an icon labled "range10", which if evaluated returns ...
12
votes
2answers
119 views

Bad Float Counts? (Length[xs] != Total@Counts[xs])

In Mma 11.3, tallying floats with Counts seems to fail. (Tally works fine, and rounding fixes the problem.) Is this behavior ...
1
vote
1answer
37 views

using strings from a header row as “pointers”

Suppose I have a list like: data={{"product","amount","price"},{"A",1,100},{"A",3,100},{"B",5,200}} I could use a Map to calculate over each row the "amount" * "...
0
votes
0answers
60 views

Implementing a function that exhibits linearity

I am trying to define a function $\mathbb{E}_t$ such that $\mathbb{E}_{t}[f[x_{s}]] = f[x_{s}]$ if s<=t, and $\mathbb{E}_{t}[f[x_{s}]] = \mathbb{E}_{t}[f[x_{s}]]$ if s>t. $\mathbb{E}_{t}$ is ...
0
votes
0answers
87 views

Is there a direct way of adding two random step size lists

As shown in the figure, I have three lists a,b and c. I want to see whether a + b +C0= c(here C0 is a constant). Since list a and b have varing step size (...
6
votes
2answers
147 views

Flat attribute : example I don't understand

I am just beginning to learn about attributes of function in mathematica. I saw the example "Flat". But there is something I don't get : ...
2
votes
1answer
63 views

Inspecting Mathematica object

I'm using ProofObject for my question, but it applies to other objects too. FindEquationalProof returns ...
1
vote
0answers
62 views

Is there packages can help read, analyze or understand MMA codes? [closed]

Sometimes, I think that it's difficult to learn high level codes, or even when looking back on some long lines of codes I myself had written, espectially when lots of pure-functions was used, so I'm ...
5
votes
3answers
315 views
6
votes
1answer
62 views

unexpected result from augmented assignment to association

Is the last of these results expected? If so, how? ...
1
vote
0answers
40 views

raise error on type mismatch

Is there a best practice for raising an error on a type mismatch? For compiled functions I'm guessing the answer is the use of GeneralUtilities`WithMessageHandler. ...
3
votes
1answer
49 views

Module - Symbols out of scope of lexical scoping

The Problem Consider the following code (1): In[1]:= x = 2; Module[{x, y}, y[x_] = x; y[1] ] Out[2]= 2 I expected the answer ...
7
votes
2answers
429 views

Can we make a faster Boole implementation?

I just learned about Mr. Wizard's very efficient code here. ...
1
vote
3answers
99 views

Unable to implement bisection method using recursion [duplicate]

I have tried to implement a bisection method for finding roots using SetAttributes[BisectionItt, HoldAll] and then ...
0
votes
0answers
54 views

How can I better formulate a conditional statement?

To solve optimization problems I have seen this: Is there a more elegant way to do this with alternative conditional expressions? Is there something equivelant to ...
4
votes
1answer
50 views

Is it possible to write an expression A such that Evaluate[Evaluate[A]] is different from Evaluate[A]?

Mathematica is cool for all sorts of "magic tricks", but I'm trying to get an idea on how the core term-rewriting system works. Is it possible to make a term such that the output of its evaluation can ...
17
votes
1answer
272 views

Distinguishing Wolfram Language and Mathematica, the software

Which features are part of Mathematica, the software, and which features are Wolfram Language? I would say there has to be a line discriminating the two somewhere. One could say that Mathematica, in ...
14
votes
3answers
204 views

What is the difference between Set and SetDelayed when evaluating the RHS leaves it unchanged?

I thought there was no difference between f[a_] = 2 + a; and f[a_] := 2 + a; because the resulting ...
3
votes
1answer
106 views

Why did Set work instead of SetDelayed?

I started with the following expression a[t_] := -Pi Sin(Pi/2*t) where initial velocity is 2 Pi and initial distance is 1. ...
4
votes
1answer
57 views

How can I evaluate only the (bound) variables in an expression?

Given an arbitrary expression, how can I have Mathematica only evaluate the (bound) symbols, i.e. replace them by their respective values, but not do any further simplification/evaluation of the ...
0
votes
1answer
34 views

FunctionExpand vs FullSimplify

The documentation (v.11.3) says: "FunctionExpand is automatically called by FullSimplify." Why then does ...
1
vote
1answer
42 views

undesirable/buggy change in behavior of Limit in Mma 11.2?

The behavior of Limit changed in Mma 11.2, and I think it is in some ways undesirable or possibly buggy. Consider ...
1
vote
1answer
78 views

What resources can I use to become familiar with high level syntax?

I was reading a question about dropping higher order terms and realized that I have a serous gap in knowledge when it comes to the finer points of mathematica computational programming. Are there any ...
1
vote
0answers
47 views

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

Spelunking the Export function, I stumbled upon the following definition: ...
11
votes
1answer
120 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, ...
7
votes
1answer
101 views

advantages of ApplySides?

Version 11.3 introduces ApplySides for situations where I usually use Map. What is an example where ...
3
votes
0answers
146 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 ...
6
votes
1answer
125 views

Is (x|y|…)∈set the same as x∈set&&y∈set&&…?

I've sometimes seen that this operator is used to specify that each of given variables is in some set, e.g. Reals. Like ...
11
votes
2answers
116 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
73 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
160 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
39 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
174 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
50 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
46 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 ...