Questions tagged [core-language]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
68 views

Domain of `Sqrt[x]^2`

I'm just starting to work with Mathematica and this is simplified version of the problem I have: seems that Sqrt[x]^2 simplifies to just ...
1
vote
2answers
24 views

Assign numerical values to symbolic variables in a vector inside a do loop

I have vector k = {k1, k2, k3, k4, k5, k6}. I would like to assign numerical values to the elements of k in each step of a <...
3
votes
0answers
52 views

Calling custom function from C++

I'm programming a project where I use multivariate symbolic polynomials. At some point I need to perform a PolynomialMod over a prime modulus, but the library GiNaC which I use works only over the ...
0
votes
1answer
37 views

is the behavior of WriteString surprising?

WriteString["temp.txt","this string"] returns Null but creates an open stream which is reused if you again ...
1
vote
1answer
61 views

How to clear all variables? [closed]

I have noticed that the old trick of using: ClearAll["Global`*"] does not appear to work anymore. It does not clear the values of any of my variables. I assume ...
3
votes
1answer
74 views

Understanding how List head works

I am trying to understand how Wolfram Language is actually meant to work and here is something that I fail to understand. Apply[f, expr] replaces the head of expr by f. So how come I get different ...
1
vote
1answer
42 views

How do I get my function to output only true case for conditions on its arguments

I am quite new to Mathematica and have an issue regarding which statement. cut[x_, y_] := which[x>y, doFunctionX[], y>x, doFunctionY[]] cut/@{X,Y}] I wish ...
3
votes
1answer
47 views

unexpected `False` for `SymmetricMatrixQ`

Why does the following evaluate to False? ...
9
votes
2answers
370 views

Using vtx[] instead of vtx

There're two ways to generate a random tree as 1 and 2 below. Both work fine here. So what's the reason to use vtx[] instead of ...
0
votes
0answers
56 views

I need a starter kit for Differential Geometry

In Modern Cosmology, the Geodesic Equation is described as:$$\frac {d^2x'^2}{dt}+\left[ \left( \{\frac{\partial x}{\partial x'}\}^{-1} \right)^l_i \frac{\partial^2 x^i}{\partial x'^j \partial x'^k} \...
-1
votes
1answer
56 views

What is the problem in this program? [closed]

The output is showing running only. For[m = 0, m < 0.05, m++, For[a = 5, a < 20, a + 1, a1 = a*(a/2); x[m] = a1 ]; ];
26
votes
2answers
519 views

Using the Wolfram Language in a Commercial Product

Background I am currently consulting with a client that is using Mathematica to prototype a number of proprietary algorithms. Many man-hours of work have gone into the development of these algorithms ...
6
votes
3answers
481 views

Is $2x$ documented?

According to the official documentation of Times[], multiplication of $x$ and $y$ is represented as one of x*y x×y ...
2
votes
1answer
73 views

Question about iteration [closed]

I have the following expression: sol1 = (11 + 3*δ - 11*θ + 4*m*θ - 3*δ*θ - 8*Sqrt[(-(2 + δ))*(-1 + θ)*(1 - θ + m*θ)])/(4 + 4*δ) I want to plug numbers into $ \...
14
votes
1answer
208 views

Memory leak in the system function: how to free memory without restarting the kernel?

$HistoryLength = 0; Warming up: TextSentences[StringJoin@RandomChoice[Join[Alphabet["Russian"], {" ", "."}], 100]]; No ...
0
votes
3answers
76 views

Detecting errors and providing alternative results [closed]

I have the following piece of code: ...
2
votes
2answers
127 views

Vectors and Matrices

Mathematica makes no distinction between columns and rows. Yet, that is a BIG deal in the classroom. Does anyone have a source that explains how Mathematica manages to make every vector a list and ...
6
votes
1answer
301 views

Operator currying: how to convert f[a,b][c,d] to {a+c,b+d}?

This question is related to this golfing question (but I'm not interested in golfing, only in functional operator composition): How can we convert f[a,b][c,d] to <...
22
votes
1answer
221 views

Possible Memory Leak Issues in NestWhile

Consider the following code snippet: NestWhile[{#[[1]]+1,Pause@.001;ConstantArray[0,{100, 100}]}&, {1}, (#[[1]] <= 10000) &, 2] In theory, when ...
2
votes
1answer
82 views

Basic question regarding returning values from user-defined functions [closed]

I'm new to Mathematica today. I would like to write a function that will implement the following pseudocode: f[x_]:= Do something return y I have searched ...
6
votes
1answer
77 views

Can I stop a running NDSolve calculation without losing the data it obtained so far?

I would like to solve a system of ODEs numerically using NDSolve on an interval {t,t0,tf}. For the systems I currently solve, ...
1
vote
0answers
55 views

Can I store output data in the Notebook file? Specifically output from NDSolve[ ]

I am having some outputs from NDSolve of the form {{x→InterpolatingFunction[…], y→InterpolatingFunction, … }} and the ...
7
votes
1answer
956 views

The Wolfram Kernel must be activated for WolframScript to use it

I'm using the free Wolfram Engine for developers, but somehow I cannot activate it. ...
3
votes
2answers
146 views

Print characters from list with a For-loop

Suppose I have the list primary = {"b","a","e"} I want to get the following output with a For-loop (or While-loop) "b" "a" "e" My code is: ...
10
votes
1answer
632 views

Row vectors and column vectors (Mathematica vs Matlab)

As far as I know, Mathematica does not distinguish between row vectors and column vectors: all vectors are seen as lists. I know ways to bypass this as suggested here Product between a column vector ...
1
vote
1answer
166 views

Error plots in MMA 12.0

Suppose I have the following data and associated quartiles: data = RandomReal[{0, 1}, {40, 10}]; qs = Quartiles[data] I want to make an ErrorListPlot from the ...
11
votes
2answers
221 views

Selecting elements from a list where the order is set by another list

I have two lists, list A and list B. All of the elements of A are members of ...
8
votes
2answers
227 views

Surprising behavior of Part[ ]

Look at this list list={1,2,3,4} Obiously list[[1, 2]] throws the error: During evaluation of Part::partd: Part ...
2
votes
0answers
34 views

one Dataset from multiple csv files

In one folder I have many csv files, all sharing an identical header. I can use SemanticImport to produce a Dataset from each ...
0
votes
1answer
129 views

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

I am a programmer and would like to understand another field outside of the procedural thinking of if-else and for. I would ...
16
votes
2answers
357 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
57 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
565 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 ...
3
votes
1answer
83 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
92 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
110 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
34 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
62 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
140 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 ...
6
votes
2answers
123 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
53 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
88 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
71 views

Defining iterative algorithms [closed]

Assume the iterative algorithm of interest to be as follows: ...
3
votes
2answers
80 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
122 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
38 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
61 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
88 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
164 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
75 views

Inspecting Mathematica object

I'm using ProofObject for my question, but it applies to other objects too. FindEquationalProof returns ...