Questions tagged [programming]

Questions on writing non-trivial programs in Mathematica. Do not use this tag for questions on plotting/graphics or for questions on doing mathematics with Mathematica, where the focus is more on the math than the program.

Filter by
Sorted by
Tagged with
0 votes
0 answers
11 views

generate right triangles of different measures with an unknown data

Could you help me improve this code to generate at least 10 "slightly larger" right triangles, but instead of all the results that find an "x" on one of the sides and the type ...
  • 181
0 votes
1 answer
93 views

Finding positive integer triples $(m,n,r)$ with $\frac{mr}{m+n}$ being an integer and $r-n > \frac{mr}{m+n}-1$ and $r\le \max{(m,n)}$

I would like to use Mathematica to find all positive integer triples $(m,n,r)$ satisfying (1) $\frac{mr}{m+n}$ is an integer; (2) $r-n > \frac{mr}{m+n}-1$; (3) $r\le \max{(m,n)}$; (4) $1\le m < ...
  • 101
5 votes
2 answers
255 views

Automated generation of homework questions for line problems

I try to help my children in their subjects, I built a small code so that it has as output questions regarding the equation of the line, but I have not been able to modify it so that the result comes ...
  • 181
0 votes
1 answer
114 views

How can I construct this matrix in Mathematica?

I would be very grateful if you could help me to construct this matrix in Mathematica. This is the code I have so far: ...
  • 11
-1 votes
1 answer
74 views

How to create this function?

Let vowels:= {"A","E","I","O","U"} Let alphabet be some CharacterRange, i.e.: ...
2 votes
3 answers
95 views

Count[] with conditionals [closed]

I run the following code and I got what I want ...
2 votes
0 answers
63 views

How to apply a list with n elements to a function with n arguments? [closed]

The Multinomial function has n arguments. For educational purposes I want to calculate Multinomial over a list (of solutions of the FrobeniusSolve function) like: ...
0 votes
0 answers
106 views

Codewars and Mathematica

I looked up the Wolfram Language on Codewars as the site is great to improve coding. WL is not among the listed languages (I checked the beta versions as well). I assume this is because the language ...
  • 1,262
3 votes
0 answers
88 views

What is a good book to learn mathematics with Mathematica? [duplicate]

I'd like to review first-year college math, and above, while learning Mathematica alongside it. All the books I've looked at that claim to teach some version of math with Mathematica go though two or ...
4 votes
2 answers
280 views

Optimizing combinations of 3D figures

For every complex number $a$ one can define a function $Q_a$ on $\mathbb{C}$ ; $Q_a(b)=$IP[ar, ai, br, bi], $a,b\in \mathbb{C},ar=Re(a),ai=Im(a),br=Re(b),bi=Im(b)$, ...
  • 312
0 votes
1 answer
75 views

How to convert a list of indexed variable names to a list of formal symbols?

I have the following list of indexed variable names: list = {x1,x2,x3,x4}; I would like to build a list of formal symbols from the above list, i.e. ...
1 vote
1 answer
76 views

How can a Style Cell be safely programmatically appended to the Notebook Stylesheet at (Format -> Edit -> Stylesheet)

The purpose of this is to append a DockedCell style definition to the list of cells inside Edit Stylesheet without deleting any ...
  • 1,977
1 vote
0 answers
181 views

Enumeration of a sequence concerning metrizability of certain families of sets

Let $(X,d)$ be a metric space and let $x,y \in X$ be points. We will define the metric segment between the points $x,y$ as the following set: $\left [ x,y \right ]=\left \{ z \in X : d(x,z)+d(z,y)=d(x,...
4 votes
1 answer
180 views

Enumeration of a certain sequence I

Denote by $a(n)$ the number of families $\mathcal{F} \subseteq \mathcal{P}(X)$ on a finite set $X$ with $n$ elements satisfying: $\emptyset, X \in \mathcal{F}$ For all $U, V \in \mathcal{F}$ it holds ...
0 votes
0 answers
56 views

How can an algorithm be written in Mathematica language in a scientific paper? [duplicate]

I have a scientific research in which I used an algorithm in an optimized language to simplify the calculations, which is important and should be included in the paper. Algorithm ...
2 votes
1 answer
126 views

Enumeration of a certain sequence II

Denote by $a(n)$ the number of families $\mathcal{F} \subseteq \mathcal{P}(X)$ on a finite set $X$ with $n$ elements satisfying: $\emptyset, X \in \mathcal{F}$ For all $U, V \in \mathcal{F}$ it holds ...
4 votes
1 answer
48 views

How to select the outermost CellGroup that contains given cell?

Suppose we have a Notebook with a deeply nested structure (this is a simplified example, the Notebook can be huge): ...
0 votes
0 answers
66 views

How to find optimizers with computer in this kind of minimax problem

I have a minimax problem of the form $$\max_{\substack{u_1,\dots,u_n \ge 0 \\ u_1+\dots+u_n = 1}} \min_{\substack{v_1,\dots,v_m \ge 0 \\ v_1+\dots+v_m = 1 \\ v_{j_1} \le v_{j_2} \hspace{1mm} \forall (...
4 votes
0 answers
68 views

What are some basic references for learning "box language" and further mathematica language customization techniques? [duplicate]

I'd like to be able to understand and write mathematica code that is able to customize in some way the output of mathematica in notebooks, for example. I believe I need to learn the so called ...
  • 41
18 votes
2 answers
425 views

Garbage collection for lexical closures

Mathematica is known not to garbage collect temporary variables in certain cases. I am particularly interested in the very useful programming pattern known as a lexical closure. A somewhat trivial ...
  • 6,828
1 vote
0 answers
54 views

How can we call Mathematica functions from another server using the `wolframscript` Python library?

How can we use the wolframclient Python library to call Mathematica functions when Mathematica is running in an another server? For example, if we have Mathematica ...
  • 1,436
2 votes
0 answers
34 views

Does the Wolfram Cloud permit real-time Collaboration?

I am curious if anyone has found a workaround or directly built-in method to work collaboratively with colleagues? Something analogous to the google productivity apps like google docs where different ...
  • 1,063
0 votes
0 answers
29 views

How to suppress Null output when redirecting outputs to separate Notebook/Window?

I've been redirecting outputs to a separate notebook using this simple code to modify the $Post variable: ...
  • 1
1 vote
1 answer
117 views

Tell mathematica to move on to the next step [closed]

...
  • 3,221
0 votes
0 answers
42 views

How to mimic Expand with Thread?

I want to mimic Expand[(a + b) (c + d)] with Thread. My attempt below does not provide the correct result: ...
1 vote
0 answers
30 views

Efficient construction of a formal polynomial using list manipulations

I have a code which is probably extremely inefficient given my inexperience with Mathematica list manipulation. Take as input data: ...
  • 1,307
2 votes
1 answer
112 views

Introduce formal symbols indexed by natural numbers

I'm going to describe a toy example here which I'm hoping with some help, I can then soup up into the more complex application I have in mind. Suppose the input is a list of lists, and for now take ...
  • 1,307
3 votes
3 answers
147 views

Deleting sublists where an element repeats beyond a repetition threshold

I am looking for some help constructing a function Part[M_,N_] which outputs the list of all integer partitions of positive integers up to $M$ such that in each ...
  • 1,307
0 votes
1 answer
62 views

Create list with integer partitions satisfying some conditions

I want to create a function PartSet[N_,M_] of two positive integer variables which outputs a list of all pairs of integer partitions for all integers up to $M$ ...
  • 1,307
19 votes
12 answers
944 views

Partitioning a list based on a criterion for sublists

SeedRandom[1]; alist = RandomInteger[{1, 10}, 20] {2, 5, 1, 8, 1, 1, 9, 7, 1, 5, 2, 9, 6, 2, 2, 2, 4, 3, 2, 7} I would like to divide this list into sublists (...
  • 18.8k
30 votes
6 answers
1k views

What secrets are hidden away in your init.m and where do you place it? Please help me build the ideal init.m

My init.m Feels Like it's Missing Something Although I am familiar with about a dozen or so programming languages I am only sort of, kind of, halfway competent in about three. MMA with it's boxes, ...
10 votes
1 answer
103 views

How to list all possible string arguments of a specific function?

For example, to learn the function Alphabet, we can read its document. But it's rather ambiguous, like "Some languages have extra properties". How to find ...
0 votes
0 answers
53 views

Algorithm: Permutations & Signature

Theoretical side Simple example: If I have two sets $A_1=\{1,3\} ,A_2=\{2,3\}$ and Permutations[{1, 2, 3}]= $\left( \begin{array}{ccc} 1 & 2 & 3 \\ 1 &...
6 votes
4 answers
315 views

How can I efficiently define functions with different names but doing the same stuff?

Recently I have met with with this interesting question:How can I efficiently define functions with different names but doing the same stuff? Somebody may want to ask me why I want to do things like ...
  • 443
6 votes
4 answers
403 views

Is there a more elegant solution than f[a, b, Sequence@@#3,...]?

I am trying to construct a list of many possible combinations using Outer and Permutations. Something that looks like that: <...
2 votes
1 answer
45 views

How to use another algorithm when the first approach is too slow?

I need to write a program that uses an alternate algorithm when the algorithm first attempted is taking too long. Here is a minimal example. ...
  • 6,768
0 votes
0 answers
42 views

TagSetDelay the Plus[ ] function for direcy use with Datasets

I am trying to define a particular behavior of the function Plus[] when the arguments are $n$ Dataset, with $n\geq 3$. (The goal is to mimic the behavior of Plus[] with Datasets instead of numbers) ...
1 vote
3 answers
114 views

Finding the value of a Fibonacci Polinomial

I need to find the value different to 0 when evaluating Fibonacci[x,2]mod(8417525)=0 How can I set up that with an iterative process, trying subsequent natural numbers till it finds the target value? ...
5 votes
1 answer
269 views

Lazy vs strict evaluation approaches - performance comparison

In general, I think there are two methods of evaluating a variable in Mathematica. My question is about performance of the two methods. Suppose that our final goal is to evaluate ...
  • 3,221
0 votes
1 answer
73 views

Issue with the output of pure functions

I am getting the operator & in outputs of pure functions. e.g. with the following code ...
0 votes
2 answers
76 views

Using FindRoot in a Loop: Updating the value of starting point

Consider the following nonlinear equation for $h[\lambda]$ ...
0 votes
0 answers
60 views

My notebook backup function works fine. I am just asking for your critical review before submitting to FunctionRepository

Why the name and what does it do exactly? Youre probably asking yourselves why I named it NotebookBackupStack. All that is explained in ...
  • 1,977
0 votes
0 answers
35 views

how to delete a variable programmatically in a notebook from another notebook

how to delete a variable programmatically in a notebook from another notebook? c = b; I have already tried Remove[c] but ...
2 votes
2 answers
79 views

Could anyone please help with defining a vector function of tons of variables?

Could anyone please help with effectively defining a vector-valued function of tons of variables so that ...
10 votes
2 answers
475 views

What is the most efficient way to define a Loop until function?

Mathematica has the While function which is very convenient when we need to process some code until the attainment of a certain state (identified with a condition). ...
1 vote
1 answer
107 views

How to convert this Mathematica expression to another, as described here?

I am working on a function of which the core will consist of something like: ...
5 votes
1 answer
78 views

How can I separate expressions in Module without suppressing output?

I want to show a progress indicator while statements in a Module are processed. Outside a Module this ca be done like this: ...
9 votes
0 answers
60 views

Does ArgumentsOptions do anything we couldn't do without it?

ArgumentsOptions was new in version 12.2. I looked at the application on that page, and it makes code very difficult to understand. What if anything does ArgumentsOptions do for us that we couldn't do ...
  • 6,768
0 votes
1 answer
48 views

Program works, but then fails when I write it inside Module [duplicate]

I'm new to Wolfram Language; I'm trying to get used to it by writing a bunch of code and programs, being one of them the algorithm for the bisection method. When I write the algorithm outside of a ...
4 votes
1 answer
165 views

Is it possible to improve a code related with iterative closest point (ICP) algorithm?

I am trying to write a code related with ICP algorithm. The purpose of the code is matching a target data with a reference data by translational operation in XYZ axes (3-degree-of-freedom (DOF) ...
  • 157

1
2 3 4 5
31