Skip to main content

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

How to push the performance of this compiled function

I have the function optvals solving for two variables. For the given example of variables, I need the program to run atmost in a millisecond. The main part of the ...
Dotman's user avatar
  • 456
2 votes
1 answer
76 views

Value Assignment and Checking for Subscripted Variables

I'm using a subscript as a counter in some code. Here, I give a value: Subscript[θ, 1] = 0 Without making any other assignments, I want to check if other ...
rhomboidRhipper's user avatar
2 votes
1 answer
94 views

Need help in implementing q-SeriesToq-Product in Mathematica

In Mathematica Guidebook for symbolic computations (https://www.amazon.com/dp/0387950206/wolframresearch-20), in the Exercises, 30 (c)(p. 359), there is a question: I have no clue how to implement ...
Sangama's user avatar
  • 23
1 vote
0 answers
72 views

Sum of disjoint product of sets [closed]

If we have the following sets and we need to apply the Sum of disjoint product property to them, as in the following example: Take: $$P_1=\{x_1 x_4\}$$ $$P_2=\{x_2 x_5\}$$ $$P_3=\{x_1 x_3 x_5\}$$ <...
Emad kareem's user avatar
4 votes
4 answers
99 views

Why does FindInstance require specifying variables, and how to transform a list of logical expressions into the list of its variables [duplicate]

It would be convenient to have a function VarsfromLogical which out of {a+b>c,c+d==a} outputs {a,b,c,d} Incidentally, I use ...
florin's user avatar
  • 1,798
0 votes
0 answers
63 views

How can a program be configured for these steps?

Is it possible to create a program that implements sequential mathematical steps... in order to be circulated to more than one selected set? Step 1: For the following sets: $$S_1=\{x_1,x_2,x_3\},S_2=\{...
Emad kareem's user avatar
6 votes
1 answer
278 views

Hyperlinks that open smoothly in the same window

Suppose that I have test1.nb and test2.nb in my local disk. For simplicity, suppose that ...
imida k's user avatar
  • 4,295
1 vote
0 answers
57 views

RQ / LQ / QL of general matrices implementation in Mathematica?

Does anyone know if there are Mathematica implementations for the LAPACK routines RQ, LQ and QL factorizations for general sized matrices? It would even be great if the RQ factorization allowed a user ...
Moo's user avatar
  • 3,334
1 vote
1 answer
65 views

Finding terms in a geometric sequence reaching target remainder

I want to find how many terms I need to sum such that the resulting expression is smaller or equal than the target remainder. For example: ...
Tony's user avatar
  • 11
0 votes
1 answer
73 views

Using conditionals for a given function in Mathematica [closed]

I have two versions of a function (A and B) When A fails, I get ...
tommy J's user avatar
  • 21
1 vote
1 answer
87 views

Recursive application of Grad in scalars

I am looking for an efficient way to apply Grad recursively to a scalar function. The code I have so far is in the structure below. I define the scalar function outside the loop, take its derivatives ...
Felipe's user avatar
  • 499
5 votes
1 answer
124 views

Where should global variables be defined in a package?

I am trying to understand two of the answers to the question 114769 Package functions and symbolic calculations ...
florin's user avatar
  • 1,798
2 votes
0 answers
61 views

Are there public Mathematica scripts for computing Lyapunov's first focal value for planar systems?

This seemed to me a utility which must have been created already hundreds of times, but I only found an implementation of 2022, which did not work on my example, so I needed to fix it first. Here's my ...
florin's user avatar
  • 1,798
4 votes
1 answer
141 views

How to modify the size and positionning of an edge in a flow chart using LayeredGraphPlot command?

Hello, I am trying to make the diagonal edge (\mu N) horizontal and short in the following code corresponding to a flow chart: ...
Rim ADENANE's user avatar
0 votes
1 answer
76 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
242 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
95 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
  • 41
4 votes
2 answers
59 views

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

Consider this function. ...
Ted Ersek's user avatar
  • 929
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
191 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,491
0 votes
0 answers
66 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,070
0 votes
0 answers
90 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
  • 41
4 votes
3 answers
144 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
175 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
  • 41
2 votes
0 answers
81 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
56 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
255 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
76 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
175 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,263
11 votes
1 answer
320 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
297 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
244 views

How to Vectorize this Function?

I have been puzzling over how to vectorize the following function: ...
MMAUser's user avatar
  • 409
4 votes
1 answer
140 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
146 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
182 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
32 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
39 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
102 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
123 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
48 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
6 votes
5 answers
224 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
206 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
213 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
86 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
150 views

How to update this Association?

I have the following association, assoc: ...
nilo de roock's user avatar
2 votes
0 answers
129 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
59 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
45 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
73 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,798

1
2 3 4 5
32