Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
0answers
43 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.: ...
5
votes
1answer
60 views

Ignore message in `Check` without silencing

Check[expr,failexpr,checkedMessages] will evaluate expr and if it encounters any of the messages in ...
2
votes
2answers
229 views

How do I write this matrix?

The following code gives 20 data as output. How can I make a 5*4 matrix by that data list?
2
votes
1answer
30 views

How to select Input|Output Cell Groups in the Notebook?

I am trying to convert a Cell expression to an image. I created a new notebook and copied the cells that need to be rendered. ...
0
votes
0answers
41 views

magic square with prime numbers of any order

how could you create a script in Mathematica that generates magic squares of order n, but that the numbers that form the square are all primes I've looked at what's in other answers but I can not ...
1
vote
2answers
94 views
1
vote
2answers
52 views

How can I construct a matrix by programming in mathematica?

I want to write a matrix in Mathematica by programming. How can I write it? The matrix is : $ M= \begin{bmatrix} 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & ...
0
votes
2answers
40 views

An Alternative Solution to a List Manipulation Example

Is there any way to write a code that has a function include Block[ ] and Do[ ] loop instead of my code? Here is my code: ...
2
votes
1answer
38 views

How to define a function that can transform integrands to the unit hypercube?

We know most integrands can easily be transformed to the unit hypercube: $$\int_{a_1}^{b_1}\cdots\int_{a_d}^{b_d}{\rm d}^{d}x\, f(\vec{x})=\int_0^1{\rm d}^dx\,f(\vec{x})\prod_{i=1}^{d}(b_i-a_i)\ ,$$ ...
1
vote
1answer
42 views

How can I print only the lines for a file that contain consecutive digits?

I have a text file containing a list of numbers. I want to print only the lines that contain a number, the digits of which are consecutive digits. The input list: 123 321 567 765 124 568 The output ...
0
votes
0answers
17 views

FormCalc installation error in Mac

I have a Mac and I followed Feyninstall procedure, I have downloaded FeynArts and Looptools successfully. I have a problem with FormCalc. So checking install.log-FormCalc, the error is the following: ...
0
votes
2answers
54 views

Total does not give the output expected

Using the three matrices given below, I like to perform the operation stated in Quiet[...]/.{Interderminate->0}. ...
-1
votes
0answers
35 views

Reverse element in each pair using procedural and rule based programming [duplicate]

data={{x1,y1,z1},{x2,y2,z2},{x3,y3,z3}} after programming it look like this {{z1,y1,x1},{z2,y2,x2},{z3,y3,x3}} only by ...
0
votes
0answers
31 views

Solving a Volterra integral Equation with singularities

Dears, I am trying to solve the equation in the below picture. What I did is: I used wavelet functions and substitute the wavelet instead of u, where I have the ...
3
votes
3answers
211 views

What is wrong with Module? or me? [closed]

The following code does not give me an answer. It looks all is working when each command inside Module is individually run. But ...
2
votes
1answer
71 views

Recall the names of functions used in a long MMA code

Suppose you have a very long code in which many new functions are created. For efficient programming, very short and easily iterated function names are preferred. ...
0
votes
0answers
23 views

Symbol that constrains execution time relative to the computation that is performed

I'm looking for a way to implement a symbol that is like TimeConstrained in that it limits the execution time given to a certain operation, however does so on the ...
3
votes
3answers
120 views

Infinite While loop

I have an exercise where I need to input a multi-digit number and evaluate the square of the sum of its digits. I am new to Mathematica and I can't figure out why I'm getting an infinite loop. This is ...
3
votes
1answer
46 views

What is a good way to implement a versatile folder structure checking system?

I'm writing an 'application' (set of *.wl and *.wls files) that requires a given folder structure to function; I am not sure how this structure will eventually look like, because it changes as I ...
29
votes
3answers
495 views

Analogies to Help New Users

In many of the classes that I teach, I require students to learn the basics of Mathematica which we use throughout the semester to do computations and to submit homeworks (in notebook form). Some ...
3
votes
1answer
61 views

FindShortestTour finds very long tour

The documentation claims FindShortestTour works extremely well for hundreds or thousands of cities. I show an example set of 5 cities where it does an abominable job. I also show a couple of absurd ...
4
votes
1answer
207 views

Pythagorean quadruples

I am very interested in the problem that deals with the Pythagorean quadrruples, which are listed in rosettacode. Unfortunately, I have not been able to find any way to compute them with Mathematica. ...
10
votes
3answers
576 views

Can I use Compile to speed up InverseCDF?

I'm repeatedly issuing the command P = InverseCDF[NormalDistribution[0, 1], T] where T is either a 36- or 64-vector of real numbers (points in the unit ...
3
votes
3answers
322 views

How to create a fractal tree?

I want to create a fractal tree, using translation and rotation. Code below is working for one level, but when I try loop, it is not giving output. Code is given below: ...
4
votes
1answer
55 views

FindShortestTour shows erratic behaviour wrt 2nd argument

FindShortestTour behaves erratically. It should return a {distance, ordering} pair, and it does this for most values of its ...
0
votes
0answers
19 views

Why does the contour plot shows blank part? [duplicate]

when I try to plot some complicated functions coming from chi-square distribution, the plot gives me a result with a blank part. I try to narrow the spaced vertical bin using Log for multiple times ...
1
vote
1answer
78 views

What resources can I use to become familiar with high level syntax?

I was reading a question about dropping higher order terms and realized that I have a serous gap in knowledge when it comes to the finer points of mathematica computational programming. Are there any ...
3
votes
1answer
116 views

Taking a long time to produce output

In the following, I want to know b[1000], but it is taking a very long time even for b[30]. Please help ...
3
votes
1answer
248 views

How to calculate all possible resistances made from 5 distinct resistors in series and/or parallel? [closed]

Five distinct resistors resistors={1,2,3,4,5} are given. The objective is to find a list of all possible resistances obtained by configuring all these resistors in ...
0
votes
1answer
47 views

How to randomly generate a list of function calls from a list of args and a list of functions?

I want to generate a list of simple trigonometric questions in TeXForm, for example, as follows. ...
1
vote
2answers
58 views

Compound Statements and returning earlier results in () parentheses

I am trying to debug some script and need to Print[] out some results, sometimes before, and sometimes after, certain executions. These 3 trials exemplify my ...
4
votes
1answer
111 views

Jaro distance in MMA

I'm trying to program Jaro distance as requested by this page I've done the following code that works well for the next two pairs ("MARTHA", "MARHTA") and ("DIXON", "DICKSONX") but when I try with ("...
0
votes
2answers
163 views

Delay operator and Apply used when for applying function of a function

I define my own function like that: DelayL1t[(q_: 1) a_[t_]] := q Apply[a, {t - L1[t]/c}] DelayL2t[(q_: 1) a_[t_]] := q Apply[a, {t - L2[t]/c}] if I just do : ...
1
vote
2answers
143 views

Integration of a function that oscillates rapidly (apparently)

I would like to know if you could help me solve some doubts about the integration of a function that oscillates rapidly (apparently) that depends on time and two angular variables. The parameters S ...
2
votes
1answer
77 views

How to calculate linear conflicts on a board?

Thanks to your help to solve previous problems, I have been able to advance in the learning of mathematica. It seems that this project to make a solver for the 8-puzzle has surpassed my abilities in ...
0
votes
0answers
56 views

Help! SystemException[“MemoryAllocationFailure”]

I am trying to run this code: ...
5
votes
1answer
68 views

What is a compact way to generate the list of $n^m$ composite functions, given a list of n functions and a composition depth of m?

Introduction. An image says more than a thousand words. The functions sym4ref (pmm) and sym4rot (p4) create symmetries of a geometric object in the 2D Euclidean Space. ( pmm, p4 refer to the list of ...
5
votes
0answers
91 views

Use Mathematica with Go Language

I would like to know if I can use Go and Wolfram Language? Example C ...
4
votes
5answers
281 views

How to build these functions without nested For loops?

I am trying to solve the 8-puzzle using two heuristics, which are: Pieces out of place and Distance Manhattan. After consulting several websites for example see and some books, I'm with some doubts, ...
2
votes
1answer
141 views

Overlap two images and give movement and the result record it in an animated gif

I need to put the circular image 1 in the image with the hole 2 (and cover the gap) the idea is to create an animated gif that shows the image 1 turning to the right and image 2 to the left in a size ...
5
votes
1answer
84 views

The reason behind ControlToBoxes (DynamicDump`)

Background I'm trying to establish best practices for custom controllers programming. This question is about one top level aspect of it. WRI suggested (few talks I don't remember right now) to ...
6
votes
3answers
130 views

How to create a variable List

I need, given "n", create a list {a1,a2,...,an}. For example: Given n=3, the list that must be created is composed by the symbolic variables {a1,a2,a3}. Sorry if this question is simple. Does anybody ...
3
votes
1answer
75 views

Speeding up filling a matrix when approximating a double integral

I want to approximate a double integral in the process of solving a partial-integro differential equation, to then put it, next to the differential part. The integral is (after some simplifications): \...
0
votes
1answer
129 views

How to compare two datasets having almost the same y-axis but different x-axis

I have plots of two datasets that have almost the same values on the y-axis but different values on the x-axis. lets suppose p1={x1,y1} and ...
1
vote
3answers
125 views

Computation performance involving multiple numeric integrals

I have the following code that has been running for more than three days without an answer, unfortunately. Now, my institution provides us with a computer with Intel Xeon CPU E-52650 v3 @ 20 CPU, 2....
2
votes
1answer
83 views

using functions with the same name doing different stuff

I am trying to use functions with the same name, but which do different stuff. Let me show an example. ...
0
votes
1answer
56 views

about matrix manipulation

I have a large matrix and I want to extract different sub-matrices that actually have elements on different positions. Using Extract and mention the position of ...
0
votes
1answer
138 views

Bellman-Kalaba algorithm optimization

I wrote a Bellman-Kalaba algorithm which finds the shortest paths between all vertices in graph (for now only distances). It works correctly but it is written iteration by iteration and I have a ...
1
vote
0answers
92 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 ...
0
votes
1answer
60 views

How can I define a derivation in Mathematica?

I would like to define a derivation in Mathematica. As an example something like this: for an operator O and operators $A,B$ in a two dimensional vector space with $$ O \times A = a \\ O \times B = b \...