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
41 views

Seeking Wolfram Mathematica Techniques for Detailed Step-by-Step Solution of Integral Equation Transformation

Hello Mathematica Community, I am working on a mathematical problem where I need to transform an integral equation into a simpler form using Euler's Formula and the Error Function. My current ...
Rob_'s user avatar
  • 1
0 votes
1 answer
72 views

How to define a custom operator/rule to convert $f(t-a) g(x-t-b)$ into $f(t-a) g(x-a-b)$?

I want to define a rule or an operator such that I can have an input like Sin[t-2]Cos[x-5](z-x-t-9)^2 //.someRule to get the output ...
Mohamed Mostafa's user avatar
1 vote
2 answers
203 views

Simplifying products of DiracDelta

I want to simplify expressions containing DiracDelta products. For example I want to simplify the expression $$\delta(z-2)\delta(k-5)\delta(t-z-k-9)$$ to give the answer $$\delta(z-2)\delta(k-5)\delta(...
Mohamed Mostafa's user avatar
2 votes
1 answer
93 views

How to write code realizing this manual operation? [closed]

I want to use the output of N[E,15]. However the output is really 2.71828182845904523533978449066641588615`15. if you copy the ...
amon xu's user avatar
  • 31
0 votes
0 answers
36 views

Commutator for Solving Coefficients in a Hamiltonian

I am relatively new to Mathematica but I understand the basics. I want to solve for coefficients by commutator constraints and I have problems implementing the commutator. The setup is the following: ...
iron's user avatar
  • 1
4 votes
2 answers
51 views

How to post message about invalid options and return unevaluated input?

Consider this function. ...
Ted Ersek's user avatar
  • 884
1 vote
0 answers
28 views

Generator of limits of successions according to type of indeterminacy. Correct syntax

I am trying to make a limit generator with 3 columns, number of the exercise, the second column is the limit (perfectly written with n-->00), and the third column is the result of the limit. I have ...
wilma's user avatar
  • 11
6 votes
2 answers
186 views

Listing all user-defined definitions used in a function call

Is it possible to obtain all user defined definitions (and attributes) that are used in the evaluation of certain command (or alternatively just their symbols which I could imagine being easier when ...
Kvothe's user avatar
  • 4,187
0 votes
0 answers
65 views

Successive multiplications using Mathematica tools

Successive rotations on the unit circle Given an arbitrary starting point $z$ on the unit circle in the complex plane, the goal is to compute a cycle of rotations by $\pi$/2 with successive ...
dantopa's user avatar
  • 1,050
0 votes
0 answers
84 views

How to compute the infinite continued fraction?

I am reading the article "Eigenvalues and eigenfunctions of spin-weighted spheroidal harmonics in four and higher dimensions", which is on https://arxiv.org/abs/gr-qc/0511111. I want to ...
amon xu's user avatar
  • 31
4 votes
3 answers
136 views

Arrange solutions of equations in column form in a table

If we have the following system of equations: ...
Emad kareem's user avatar
0 votes
1 answer
138 views

How to compute the continued fraction to a generic step by Mathematica?

I am reading the article "Eigenvalues and eigenfunctions of spin-weighted spheroidal harmonics in four and higher dimensions", which is on https://arxiv.org/abs/gr-qc/0511111. I want to ...
amon xu's user avatar
  • 31
2 votes
0 answers
72 views

Large Structured Programming with Compile

Is it possible or wise to build a large program structure with only Compile? With FunctionCompile it is possible to create ...
Michael Haring's user avatar
0 votes
1 answer
50 views

Use table data to substitute into a function

If I have the following function Rx = Subscript[x, 1] Subscript[x, 2] + Subscript[x, 3] - Subscript[x, 1] Subscript[x, 2] Subscript[x, 3] I want to add it as a ...
Emad kareem's user avatar
1 vote
1 answer
253 views

Enumeration of a sequence involving closure operators

Let us call a collection $\mathcal{F} \subseteq \mathcal{P}(X)$ special if it satisfies the following two conditions: $\emptyset, X \in \mathcal{F}$ For all $U, V \in \mathcal{F}$, it holds that $U \...
user227351's user avatar
0 votes
0 answers
72 views

Do loop Implementation

I want to generalise the following algorithm to a loop overall possible subsets of the original set. the algorithm has the following form: ver={X41,X42,X43,X44} and ...
Faktor 2's user avatar
1 vote
1 answer
160 views

Code to generate mandala with message

A long time ago they gave me many answers to these questions, Code that generates a mandala is it possible to enter text in the center something like "abcde" , without the quotes and maybe ...
zeros's user avatar
  • 2,253
11 votes
1 answer
311 views

Online Mathematica-based direct polling

I teach several in-person university courses in which my lecture slides are in Mathematica (SlideShow environment), projected for all students to see. These slides are also distributed before class ...
David G. Stork's user avatar
-3 votes
1 answer
290 views

Proving conjecture on number series

I have a conjecture that Stephen Lucas's identities for Pi and its convergent could be generalized as follows: ...
Alex's user avatar
  • 51
5 votes
2 answers
228 views

How to Vectorize this Function?

I have been puzzling over how to vectorize the following function: ...
MMAUser's user avatar
  • 379
4 votes
1 answer
137 views

Use of ? when not meaning help [closed]

Trying desperately to understand Michael Trott's Happy Harmonic 2017! post: https://community.wolfram.com/groups/-/m/t/2858495 What does the use of ? in ?t1, ?t2 and ? = (t21 - t12)...mean? The ...
Linda's user avatar
  • 43
1 vote
3 answers
133 views

Plotting Average Positions of 2D Random Walk

I need to generate a plot that shows the averaged position at n steps of 1000 different random walks that are each 1000 steps long. So far I am using ...
Mandty24's user avatar
1 vote
1 answer
116 views

Simple SDP using Hermitian matrices

I would like to run the following semidefinite program $$ \textrm{Minimize}\,\, \textrm{tr}\big({AX}\big)\\ \textrm{subject to}\,\, X \geq B_1\,, X \geq B_2\,, $$ where $A$, $B_1$ and $B_2$ are ...
mathematica_beginner's user avatar
0 votes
0 answers
31 views

Generate random arithmetic test with MMA

I have been trying for a long time to generate a question test where operations with 2 rationals appear printed. Can someone help me with the code? shows the following errors. a) The options appear ...
Pamela's user avatar
  • 55
1 vote
0 answers
36 views

More generic version of `Variables` [duplicate]

What's the best way to extend Variables to work on expressions that are not polynomial? IE, the following returns {x,y}, but I ...
Yaroslav Bulatov's user avatar
2 votes
1 answer
95 views

Caching result of evaluation in the notebook?

Sometimes I have a cell which takes a while to re-evaluate, but the result is quite small. It would be nice to have an easy way to "cache" some computations by embedding the result in the ...
Yaroslav Bulatov's user avatar
4 votes
2 answers
119 views

Turning expr+replacement rules into a function which automatically applies replacement rules?

What's a good pattern to turn expression+replacement rules into a function which automatically applies these replacement rules? IE, I'm finding a common pattern in my code, have some programmatically ...
Yaroslav Bulatov's user avatar
0 votes
0 answers
44 views

Nest n-times a multi-variable function with only one of the variables being updated with previous function value

I have a function y1 of three variables, x, y, and z. (y1 also depends upon f1 defined previously). I would like to Nest or interate, such that on the nth iteration, the y1's 3rd variable, z, will be ...
Thomas 's user avatar
5 votes
4 answers
189 views

Select applied to multiple objects

I have a matrix and want to extract rows according to some criterion. Then I have other matrices and want to extract the same rows. For example, if my criterion is to find rows where all the ...
John Bechhoefer's user avatar
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 ...
Rim ADENANE's user avatar
1 vote
3 answers
200 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 ...
Rim ADENANE's user avatar
10 votes
1 answer
211 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 ...
Adalbert Hanßen's user avatar
0 votes
0 answers
68 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 ?
lewis robinson's user avatar
1 vote
1 answer
124 views

How to update this Association?

I have the following association, assoc: ...
nilo de roock's user avatar
0 votes
0 answers
44 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 ...
Igor Kotelnikov's user avatar
2 votes
0 answers
121 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 ...
John Matis's user avatar
0 votes
1 answer
57 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 ...
Adalbert Hanßen's user avatar
1 vote
0 answers
41 views

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

we define the following three dimensional system: ...
Rim ADENANE's user avatar
0 votes
0 answers
72 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 ...
florin's user avatar
  • 1,592
0 votes
1 answer
83 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 ...
Pamela's user avatar
  • 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: ...
florin's user avatar
  • 1,592
4 votes
2 answers
125 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.
user7770957's user avatar
1 vote
1 answer
194 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 ...
charmin's user avatar
  • 1,159
3 votes
1 answer
260 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. We can ...
user227351's user avatar
1 vote
0 answers
59 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?
florin's user avatar
  • 1,592
7 votes
4 answers
704 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-...
jjoIV's user avatar
  • 173
0 votes
1 answer
85 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, ...
padre's user avatar
  • 263
0 votes
1 answer
103 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 < ...
taylor's user avatar
  • 101
5 votes
2 answers
273 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 ...
padre's user avatar
  • 263
0 votes
1 answer
140 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: ...
Osama's user avatar
  • 13

1
2 3 4 5
32