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
0
votes
0answers
69 views

What is the meaning of this input? [closed]

Consider the following input to Mathematica: v[{1}] = 10; v[{2}] = 20; v[{3}] = 30; v[{1, 2}] = 50; v[{1, 3}] = 60; v[{2, 3}] = 70; v[{1, 2, 3}] = 100; How does ...
2
votes
1answer
40 views

Splice matching function arguments

Mathematica 12.1 introduces Splice that replaces the old way of using Sequence@@ to "melt" a list of entries. However, the ...
1
vote
1answer
55 views

How do I evaluate my functions over a range of values? [closed]

I want to use the list of data which will come from MapData1 (in code); the first element is θ and second is Action(I). I want to use this Action(I) and Angle(θ) in ...
3
votes
1answer
43 views

Evaluate a Number head as a constant function

I wanted to use the parameters of a function in a distributive way, so for example In[1]:= Through[(Cos+Sin)[x]] Out[1]:= Cos[x]+Sin[x] It works without problems ...
0
votes
1answer
22 views

Help with Evaluation controll/hold all attributes?

I'm making a sort of symbolic derivator, which needs to take its formulas in unevaluated form. ...
1
vote
0answers
37 views

If it possible to define a “function” such that the normal form will have the arguments in order? [closed]

I'm looking for something that acts like this. How could ord be defined for 2 arguments? What about n? Since Mathematica is a term-rewriting system it should be possible, but all my attempts were ...
5
votes
2answers
159 views

Is it possible to pipe(afterthought apply function) with options?

For example, I have the following ...
9
votes
2answers
361 views

How can I plot a parametric equation with ±?

I want to draw a parametric equation with ± like the figure below: But I don't get the result I want when I run the following code. What can I do to get it? ...
2
votes
1answer
46 views

odd output from DifferenceDelta

I would appreciate an explanation of why DifferenceDelta produces a complicated expression for a simple quadratic. I see that this is caused by the Real value <...
1
vote
1answer
34 views

Extracting argument of a specific functions in a large expression

I have a large expression, for example Cos[x]Sin[y]Sqrt[1+z]/(1+x^2)-1/(1+y) I wish to extract the argument inside Sqrt ...
13
votes
7answers
768 views

Getting the “root” Head

I have a dynamic list of function names, like {f1, f2, f3, ...}, and they will enter in computation in various forms ...
5
votes
1answer
80 views

How to label parameters in Manipulate

How do I label the "2" and "3" so they show "square" and "cubed" in Manipulate controls? The following is my code: ...
17
votes
6answers
1k views

A clean way to conceptually extract Parts from a circular list

I quite often run into a situation where I want to treat a list as a circular (repeating) list, and want to take a specific sublist of it, such as... One past the end of the list: ...
7
votes
1answer
133 views

AtomQ[Counts[{a, c, d, b, a, c, b}]] gives True. Why?

I don’t understand this: In[]: AtomQ[Counts[{a, c, d, b, a, c, b}]] Out[]: True It looks like an expression. Does this have to do with the realization ...
1
vote
1answer
73 views

Implement a math command on a list of numbers [closed]

I have a set of numbers and would like to do the same math process on all of them. Example: data1={1,2,3,4,5,6} Then have each number processed as Log(1), Log(2),..... This seems like such a ...
6
votes
2answers
84 views

Assert no unevaluated function applications

Background Suppose I have begun a fresh kernel session, and I have defined the following function alone: F[x_, y_] := x + y; One expected use of ...
5
votes
1answer
72 views

Plotting a NumericQ-protected function with the attribute HoldAll fails

Fixed in 12.1 This works: ClearAll[f1]; f1[x_] /; NumericQ[x] := x; Plot[f1[x]^2, {x, 0, 5}] This does not: ...
7
votes
1answer
147 views

Are Hold attributes Mathematica's way to implement lazy pattern matching à la Haskell?

I'm reading this and I'm having a hard time understanding lazy patterns; in particular I'm baffled with the server-client toy problem and why there is a 'problem' of matching "...too early". The ...
2
votes
1answer
72 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
26 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
75 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
73 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
76 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
44 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
50 views

unexpected `False` for `SymmetricMatrixQ`

Why does the following evaluate to False? ...
9
votes
2answers
377 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
70 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 ]; ];
27
votes
2answers
649 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
483 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
219 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
78 views

Detecting errors and providing alternative results [closed]

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

Vectors and Matrices [duplicate]

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 ...
10
votes
4answers
384 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
226 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
89 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
64 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 ...
11
votes
2answers
2k 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
197 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
801 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 in Product between a column vector and ...
1
vote
1answer
190 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
226 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
230 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
46 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
137 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
379 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
60 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 ...

1
2 3 4 5
10