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.

0
votes
0answers
42 views

Linear programming with FindMinimum [on hold]

Need some help. Why on this apparently legitimate code, is there no computation ? Hint the y[.] stay blue. ...
3
votes
1answer
44 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 ...
23
votes
3answers
362 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
54 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
180 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. ...
8
votes
2answers
479 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 ...
4
votes
1answer
53 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 ...
0
votes
1answer
61 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
113 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
236 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
42 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
109 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
145 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
140 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
65 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
44 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 ...
4
votes
0answers
88 views

Use Mathematica with Go Language

I would like to know if I can use Go and Wolfram Language? Example C ...
4
votes
5answers
274 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
123 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
78 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
126 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
70 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
98 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
118 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
82 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
103 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
89 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
57 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 \...
3
votes
2answers
123 views

Function on a block matrix

I am trying to write a program of the following nature. Let $A = [[a_{ij}]]$ be a $4 \times 4$ matrix. I have to divide it in the form $$ A = \begin{bmatrix} P & Q \\ R & S\end{bmatrix}$$ ...
0
votes
0answers
29 views

MakeExpression[BoxData[“1”], StandardForm]

I am a new user. After clearing all the variables and functions from the "memory", the answer format have changed. For example an input of 1 provides an ...
3
votes
1answer
65 views

Evaluate generated notebook and show it when done

Bug introduced in V11.1 or earlier and persists through V11.3 [CASE:4061569], confirmed (bug is described below) Goal My goal is the following: Create a notebook programmatically, while ...
-4
votes
1answer
62 views

how can i convert my matlab conde into mathematica or atleast convert the bisection program? [duplicate]

(Convert matlab code into mathematica code) (I'm fairly new to mathematica) (bisect function matlab code:) ...
0
votes
1answer
30 views

Multivariate recursion with entire negative line as initial domain [closed]

I am trying to write a recursion program with all the negative value n<=0 as the initial domain, where f[n] is 0. The following simplified code is successful to ...
6
votes
0answers
93 views

Automated Phone Attendant with Mathematica [closed]

I'm considering using an old notebook with a built-in modem as an automated attendant. Basically, it would have the following functionalities: static menu pre-recorded messages caller interaction via ...
2
votes
1answer
62 views

Abort long evaluation and show intermediate results

I am doing a time-intensive calculation and I would like to have the option to stop the calculation but obtain the current (last) result. Generally, I do some groundwork as what can be done before ...
0
votes
0answers
40 views
3
votes
2answers
127 views

Writing a bisection root finder

I'm trying to make a simple function that will calculate roots of equations by using bisection method. My code isn't working right. Can anyone take a look and help me? Here is the code: ...
1
vote
0answers
76 views

Programming paradigms [closed]

I need a comparison table showing the solution of the same problem with different paradigms like function based, rule based, procedural etc. I remember seeing such a comparison in the Wolfram ...
0
votes
1answer
96 views

Collatz Conjecture [duplicate]

By definition of Collatz Conjecture or $3n+1$, regardless of the sequence (ie.$ m1,m2,m3....mn$), at the end, it eventually produces 1 at the end. For example, if ...
0
votes
1answer
70 views

While loop problem

I have a simple code for bisection method that isn't working correctly. Can someone please tell me what is wrong. ...
4
votes
1answer
50 views

“Locator” positions are wrong/on the wrong plot

I have implemented a simple climate model for my students to play around with in Mathematica. There is a multi-panel plot; the first has CO2 emissions, and you can drag the line around to set up ...
2
votes
2answers
47 views

Count elements from list and order it in a matrix

I have a list ({{A,A},{A,B},{A,B},{B,B},{B,A}}) I need to order it in a matrix where elements are the number of times that each pair appear at the list. What can I ...
1
vote
1answer
41 views

create one list from one list with random sample

I have a list, then I want to pick 2 elements (RandomSample[list,2]) put them in a new list (those two element will be one element in the new list, like list of ...
0
votes
2answers
130 views

How to write if statement and for loop? [closed]

I am trying to write a function that will find a sum of all diagonal elements of matrix. I don't know how to do it correctly. This is how I tried do do it. ...
6
votes
2answers
220 views

Improve my implementation of the Diamond square algorithm

Some time ago, I began to explore the magnificent world of the terrain generation using the computer. Investigating on the Internet know about the existence of the diamond square algorithm. Try to ...
3
votes
1answer
98 views

Why doesn't my package load and execute? [duplicate]

This might be a stupid question but I simply don't get my head around this. I'm trying to define variables and functions in different files (tried everything: nb, m, ...) and include them for use in a ...