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.

121 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
164 views

How to use RunProcess to run python interpreter

In a related question How to use RunProcess to import external function? @taliesin provides a very nice answer illustrating using RunProcess to launch a GO http server. Has anyone, or does anyone ...
2
votes
0answers
129 views

How to efficiently find parts of a string with beginning and ending specified?

I'm trying to find specific URL addresses from a html document. The addresses can be found between the strings "href=\"" and "\" class=\"listing". The problem is not including strings like this: "href=...
2
votes
0answers
241 views

How can I do multiple (double) integral with periodic boundary conditions?

I am trying to do a simple double integral $\int_0^l \left[\int_0^l h^3 h_{xxx}dx\right]dx$ with periodic boundary conditions $h[0,\tau]=h[l,\tau]$ $h_x[0,\tau]=h_x[l,\tau]$ $h_{xx}[0,\tau]=h_{...
2
votes
0answers
639 views

Maximizing Large Multivariable Function over Region with Parameter Constraints

Brand new Mathematica user here. I have a complicated function to maximize, and thought I would try software like Mathematica instead of taking derivatives by hand. I found some Mathematica ...
2
votes
0answers
132 views

Simulating a system of nonlinear ODEs?

I was trying to simulate a system of ODEs on Mathematica in an effort to try to understand how to muck around with Mathematica but for some reason the following lines of code do not yield any results; ...
1
vote
0answers
51 views

Can Mathematica warn you about mistyped variables?

In other dynamical programming languages like Python, mistyping a variable, e.g. mistyping var1 as bar1 in the example below, immediately results in an error. ...
1
vote
0answers
32 views

Adding a module to teach Mathematica the Laplace transform of particular Mittag-Leffler functions

Mathematica 11.3 is not aware of a useful Laplace transform LaplaceTransform[t^(-a) MittagLefflerE[a, a, t^a], t, s] which for ...
1
vote
0answers
18 views

Question about AsymptoticEqual[nChebyshevPsi[x], x, x -> Infinity]

Given the partial sum function nChebyshevPsi[x_] := Sum[MangoldtLambda[y], {y, x}] I would like a True response from ...
1
vote
0answers
95 views

How to use Mathematica to find the coordinates of 7 points?

Could anyone please help me with using Mathematica to find the coordinates of 7 equally spaced points on the unit sphere $S^3$ in $\mathbb{R}^4$? Thanks a lot!
1
vote
0answers
71 views

Faster methods for performing repeated list manipulations?

I've done my best to pore over the other posts on this site, and to the best of my ability I can't seem to find a good solution to my problem, so I apologize in advance if elements of my question are ...
1
vote
1answer
110 views

Assert that prints message and aborts computation?

I'd like to add asserts which check for condition, print useful message and abort computation on failure. IE, ...
1
vote
0answers
51 views

Wrapping an association with a specialization of the buildin `Set` (=) function?

I want to wrap some association data into a dedicated symbol (S by example) ...
1
vote
0answers
42 views

A newbie question about the use of the FourierSeries functions

Although I have had no previous experience with the Mathematica Fourier Series functions ( or package ), I am writing a tutorial on Fourier Analysis and Transformations in a Mathematica Notebook, ...
1
vote
0answers
50 views

Making a function $ f(n) $ tangential to another function $ g(n) $ by choosing appropriate constants

I have two functions $ f(n) = 1/(1+n) + b, (n \geq 0,b \geq 0) $ and $ g(n) = pn^2 + qn + r $. Assuming that I know the value of $ p, q $, and $ r $, I am trying to find a value for the constant $ b $ ...
1
vote
0answers
59 views

ConditionalExpression still resulting from Assuming a Module's local variables

I have a memoizing, recursive function whose MWE looks like this (the two fake inputs/ICs are from 'K' and 'Bfun2', the latter just a quick way to check the results coming out of the Residue.: ...
1
vote
0answers
110 views

Will my procedure be correct?

I am facing a problem when trying to solve the exercise of page 210 of the book GRAPHICS with MATHEMATICA, FRACTALS, JULIA SETS, PATTERNS and NATURAL FORMS of the authors CHONAT GETZ and JANET ...
1
vote
0answers
500 views

Obtaining Explicit Expressions for Tensor Contractions in xCoba

I Would like to know, how to reduce a general Tensor expression such as Cd[-c][Cd[c][h[-a,-b]]] (D'alambertian of some unknown two component tensor) to an explicit ...
1
vote
0answers
85 views

Computationally Employ Sum over Ordered Partitions?

I have the following function defined, with two inputs $g$ and $h$: ...
1
vote
0answers
32 views

Monitor and record ethernet port upload speeds

Can I use Mathematica to monitor and record ethernet port upload speeds? I briefly looked at DeviceStream; not sure if that can be made to work or if that's the ...
1
vote
0answers
155 views

What is the shortest way to calculate Euler's Phi function ( excluding EulerPhi )?

With the risk of closure by the duplicate zombies ( this one might do: How can I write the natural numbers less than $n$ that are coprime to $n$? ) I dare to ask the following question. My hobby ...
1
vote
0answers
41 views

how to use ScheduledTask to monitor changes (date modified) on external files

The following code was copied from here. It seems not working on version 11.0.1.0 ... ...
1
vote
0answers
98 views

Vectorization of 10^5 vectors

I've got a question regarding vectorization. I try to make it simple and as low on physics as possible. So: I have 10^5 random generated vectors(just x and y component and z is set) with {[-5,5],[-5,...
1
vote
0answers
68 views

How to put images on a map so that they disapear when another image passes over them

We are working to create a pacman type of game and we cannot figure out for to get colored dots on the maze to represent the food the pacman eats. Here is our code so far: ...
1
vote
0answers
48 views

Extracting elements with a certain criteria from a pre existing list

Here I take just a random list of triples of size 10 ...
1
vote
0answers
125 views

Apply a test function to variable arguments

I want to provide a function f[x_,y___] which applies a pattern matching test also on the optional parameters (e.g. request that they are vectors of numerical quantities). In case of one single ...
1
vote
0answers
160 views

A faster way to make a loop that takes as input previous iteration values

As mention in other answers, I know that there are faster ways to construct loop in Mathematica, using Fold or ListTable. In my ...
1
vote
0answers
44 views

How can I make the output start to be calculated after certain time?

Good day, I have a problem. I want to run two matrix based on time given. I used TimeUsed. given, matrix a and b; a={{g*t, 2}, {3, 4}} b={{3, 4}, {5, h*t}} I ...
1
vote
0answers
101 views

Using Which with a list

In a While loop I have: Y1 = Table[A1[[k]], {k, 1, j}]; c1 = Last[Flatten[Position[Y1, 1]]]; a1p[j] = Which[c1 == j, 0, c1 < j, t[j] - t[c1], True, t[j]]; I ...
1
vote
0answers
69 views

How Defer[1+Evaluate[1+1] work?

I want to generate some expressions. The expression is not evaluated expect some parts will evaluate first. A simple example is Defer[1+1+1] and in this expression ...
1
vote
0answers
191 views

Help with calculating a complicated integral

Edit: The question is solved : )) Thank you for your attention ! I am sorry for mass questions, but the question bothers me a lot. So I would like to ask this question here. This problem arises when ...
1
vote
0answers
160 views

Should I Remove the initial symbols of Module?

Often we use Module to construct complicate function. Consider that Module create new vars every time we run the function, should I remove the initial values at the end of Module-function?Or should I ...
1
vote
0answers
139 views

Retrieve rendered graphics via WSTP

I am planning on using Mathematica as calculation and rendering backend for an application, i.e., call Mathematica via WSTP and use EvaluatePacket to have it ...
1
vote
0answers
155 views

Simulations using alternative initial conditions

With help from some of you guys here in this forum, I have developed the following code, which works perfectly. My questions are: how to automate the simulations with varying initial conditions. In ...
1
vote
0answers
121 views

Updating procedural fitting algorithm to more efficient style?

For some time now, I have used this procedural programming approach to fit data in my research that is too cumbersome for the built in Mathematica functions. (Although this simple example works fine ...
1
vote
0answers
73 views

Settings to disable global scope

I am building a fairly large application in Mathematica, and globally scoped variables are causing issues. I would like globally scoped variables to be out-of-scope for my expressions, except by ...
1
vote
0answers
157 views

Finding Values of All Nine Constants in q-hypergeometric Equation

I suspect that an identity of the form $$\sum_{j=-n}^{j=n}(-1)^jq^{j(5j+1)/2}=\sum_{r=0}^{n}f_{ar+bn+c}(-1)^{n-r}q^{(n-r)(dr+en+f)/2}\frac{(q;q)_{gr+hn+j}}{(q;q)_{n-r}}$$ for $a, \dots , j$ integer ...
1
vote
0answers
163 views

Sum slowing down computations

I am trying to compute higher order Casimir invariants for some representations of certain groups. I can get the quadratic, cubic and quartic but beyond that things are taking too long to the point I ...
1
vote
0answers
888 views

Interpolating function as a model in Mathematica's procedures for fitting

Is it possible to use interpolating function with parameters as a model for NonLinearModelFit (and other integrated methods for fitting)? Similar question was ...
1
vote
0answers
485 views

Return Functions from parallel execution of module

I wrote a module which numerically solves an ODE using NDSolve. The result from this is e.g. either ...
0
votes
1answer
43 views

TogglerBar linked to Buttons that override input list

This question is about extending the solution provided here. How do I allow the user to change x outside the TogglerGrid function so that the TogglerBar shows the new values of x? I've set it up ...
0
votes
0answers
21 views

How to terminate NestWhileList when f is applied to a List

I made the following function to demonstrate a Number Theory theorem: ...
0
votes
0answers
78 views

FindRoot & Non-negativity constraints

I employ FindRoot to solve a large optimization problem. I formulate the optimization problem in terms of first-order conditions (in that specific problem, methods based on the objective function do ...
0
votes
0answers
41 views
0
votes
0answers
32 views

Generalization of the nested for loop

...
0
votes
0answers
35 views

ComplexExpand in Module doesn't work as it should, when there is function at the left

I'm new with mathematica and I'm having a problem. I hope you can help me. I made a module to built a system that I can use to find some condition for given polynomial is a Shur polynomial. (Actually ...
0
votes
0answers
38 views

RSolveValue, Table and general programming

If I have the following code: ...
0
votes
0answers
44 views

Count data fitting with Nonhomogeneous Poisson process

Following is count data needed to model with a nonhomogeneous Poisson process (NHPP). For each row-wise e.g. 8:15-8:30, every 12 intervals of 15 minutes size and 15 days of data collected. I have ...
0
votes
0answers
28 views

Question about converting Mma expressions to TeX

When I want to convert the following expression Integrate[1/(1 + t (-I - 1)) (-I - 1), {t, 0, 1}] to TeX, I do: ...
0
votes
0answers
113 views

Import and merge PDF files

I have a folder with several pdf no more than 50, I would like to import them to be disordered and that the output was a single pdf (you can imagine it as a proof of form A and we want to produce form ...
0
votes
0answers
45 views