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

Segmentation fault core dump error, when trying to read and print an array [closed]

I am trying to create an array by taking the elements from the user input and print them. But unfortunately getting a "segmentation fault core dump error". Below is my simple C program ...
1 vote
0 answers
42 views

How to fit data known up to a proportionality constant using NonlinearModelFit? [duplicate]

Referring to my last question here Problem with NonlinearModelFit in the case of ODE I am still looking for your help in solving the data-fitting problem where the data are only known up to a ...
1 vote
3 answers
156 views

Problem with NonlinearModelFit in the case of ODE

I am asking for your help for fitting a nonlinear ODE to data which are unknown up to a multiplicative constant k. So the constant k appears both in the data, and in the model, where it ...
10 votes
1 answer
203 views

How can I get rid of Background from a String?

For explanatory purposes I have marked parts of a string with different backgrounds. But this string is part of some Mathematica expression, which processed. My program worked fine before I added the ...
0 votes
0 answers
58 views

Are any characters forbidden in naming Mathematica notebooks

Naming conventions for mathematica notebooks. Are any characters forbidden (e.g. !@#$%^&*()-+)? Can they begin with numbers ?
1 vote
1 answer
89 views

How to update this Association?

I have the following association, assoc: ...
0 votes
0 answers
36 views

Is it possible programatically evaluate one cell several times with distinct parameters?

I have an input cell wich I need to evaluate several times with distinct set of parameters. For sure, it is possible to convert the cell into a Module and run it in ...
2 votes
0 answers
77 views

The fastest and most scalable way to write a nested loop

The problem is to find the weights {w1,w2,w3,w4} that satisfy the condition. Which is the fastest and most scalable way (e.g. for 10000 weights) to write this ...
0 votes
1 answer
51 views

How can I distinguish between different structures of actual function parameters?

Overloading functions for different types of parameters is very powerful. I can easily write different versions of a function depending on the function parameters being Integer, Real, Complex, Sring ...
1 vote
0 answers
40 views

Why does the number of fixed points changes when I change the dimension of the system?

we define the following three dimensional system: ...
0 votes
0 answers
71 views

Why isn't my test.wl file executed when I `Get` it from a .nb file? A strange story [duplicate]

I have a test.wl file containing say l= 5+2 I click on execute button of .wl file, but nothing happens. Some days ago this used to reply 7 I click on update and ...
  • 1,250
0 votes
1 answer
65 views

Delete specific files within a directory. How can i do it?

I'm a teacher and I have a lot of files (hundreds) with different names in different directories *for example "religion guide.docx","natural sciences guide.pdf" ,"Algebra 2 ...
  • 55
1 vote
0 answers
69 views

The best way to save input files so they will be executed when called by Get [duplicate]

I have a very simple program which computes fixed points for SIR model: ...
  • 1,250
4 votes
2 answers
122 views

What does the "$" symbol mean in Mathematica programming? [duplicate]

I cannot find any reference to the $ in the Mathematica documentation, yet I frequently see it used, especially on StackExchange.
1 vote
1 answer
182 views

Is there any hope to get the result faster if we use a supercomputer for the given problem?

If an operation in Mathematica (say, computing the determinant of a $88\times88$ parametric matrix) takes much time to be computed on a personal computer (core i7), say a week, then, is there any hope ...
  • 1,159
2 votes
1 answer
214 views

Enumeration of a certain sequence III

Let’s call a collection $\mathcal{F} \subseteq \mathcal{P}(X)$ satisfying: $\emptyset, X \in \mathcal{F}$ For all $U, V \in \mathcal{F}$ it holds that $U \cap V \in \mathcal{F}$. special. And let us ...
1 vote
0 answers
57 views

Is there a way which allows getting the code of commands from contributed packages? [closed]

I guess there is some simple way for getting the code of commands from contributed packages. Is there a specific command for that?
  • 1,250
6 votes
4 answers
620 views

How to elegantly implement this one useful object-oriented feature in Mathematica?

I wrote some Mathematica code that defines a function I want to use repeatedly (f) inside another function (finit) that pre-...
  • 133
0 votes
1 answer
81 views

generate right triangles of different measures with an unknown data

hello (edited and clarified) Could you help me improve this code to generate at least 10 "slightly larger" right triangles, but with small random data between 1 and 20 on two of the sides, ...
  • 223
0 votes
1 answer
99 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)}$ [closed]

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 < ...
  • 111
5 votes
2 answers
266 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 ...
  • 223
0 votes
1 answer
133 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: ...
  • 13
-1 votes
1 answer
79 views

How to create this function? [closed]

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

Count[] with conditionals [closed]

I run the following code and I got what I want ...
2 votes
0 answers
64 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
115 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,358
3 votes
0 answers
91 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
285 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
84 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
81 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 ...
  • 2,327
1 vote
0 answers
190 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,...
5 votes
1 answer
393 views

Enumeration of a certain sequence I

Lets 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 ...
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
138 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
51 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
70 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
70 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
455 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 ...
  • 11.6k
1 vote
0 answers
55 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,456
2 votes
0 answers
45 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,075
0 votes
0 answers
33 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
118 views

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

...
  • 3,379
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
34 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,317
2 votes
1 answer
116 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,317
3 votes
3 answers
149 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,317
0 votes
1 answer
75 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,317
19 votes
12 answers
1k 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 (...
  • 25.2k
31 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
107 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 ...

1
2 3 4 5
32