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
4
votes
3answers
234 views

How to programmatically modify a function definition

I would like to know an efficient method (without converting Mathematica Code to strings and string processing) of modifying a function definition programmatically. For example, I would like to tidy ...
2
votes
0answers
85 views

Why Does Subsets[…,{n}] not Output a Packed List, Even Though it Doesn't Unpack?

Assume list is packed. I expect Subsets[] is a structural operation because it depends on the number of elements, not on what ...
0
votes
1answer
21 views

Speak misses words when executed first time in new cell

Version->12.1.1 for Microsoft Windows (64-bit) (June 19, 2020) ReleaseID->12.1.1.0 (6959458, 2020061902) PatchLevel->0 When I evaluate for the first time in a new input cell: ...
3
votes
0answers
74 views

Vector arrow notation in Mathematica

I want a fast way to type vectors in Text boxes like this: $\vec a$ I can do this manually with ctrl+7+"-> " which creates this ...
0
votes
0answers
14 views

How do I combine evaluated expressions with unevaluated expressions

I want this function PrintEvalExpr[Sin[Pi/2]] Which outputs Sin[Pi/2] == 1 I can either not evaluate, or evaluate but not at ...
10
votes
2answers
239 views

i_:0|1 varies in v12.1: incompatible change or bug?

Just check i_: 0 | 1 // FullForm In v12.0 or earlier the output is Alternatives[Optional[Pattern[i, Blank[]], 0], 1] But in ...
0
votes
0answers
41 views

Extention of Times operation causes bug in Expand?

I have the following code in Mathematica 11.01 : ...
2
votes
1answer
43 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
64 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
44 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 ...
1
vote
1answer
33 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
39 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
167 views

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

For example, I have the following ...
8
votes
2answers
367 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
63 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
38 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 ...
12
votes
7answers
775 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
92 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
134 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
76 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
85 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
77 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: ...
6
votes
1answer
150 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
75 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
36 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
92 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
75 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
380 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
85 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
709 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
489 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
226 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
180 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
388 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
229 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
99 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
67 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 ...
13
votes
2answers
3k 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
241 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: ...
11
votes
1answer
904 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
198 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 ...

1
2 3 4 5
10