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
0answers
20 views

How to make following feynman path integral simulation

I want to do the simulation of Feynman path integral which is given in here. How should I proceed?
1
vote
0answers
83 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
45 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 ...
2
votes
1answer
29 views

Get all step values from a while-loop

I did a loop (first of my life) for an iterative calculation. Is it possible to get all step values as a matrix. That means the "xValue" variable should be like {215.108,219.688,...} and not only the ...
1
vote
1answer
141 views

Help with solving an equation [closed]

Could anyone please help me find the real solution(s) to a system of equations, or could anyone please help me find an effective solver to solve it? The function ...
2
votes
1answer
25 views

Plot GridLines not displaying

GridLines not rendering. Tried changing Background to White and GridLines to Black to see if they render at all but they do not. How do I make GridLines render and can these PlotStyles and settings ...
5
votes
1answer
64 views

Minimization problem and Voronoi Mesh

I have a random convex mesh $Q$, made of $n$ polygons, and I want to test how close it is to a Voronoi tessellation. In other words, I'm looking for generators (seeds) $\{(x_i,y_i)\}_{1\leq i\leq n}$. ...
1
vote
1answer
44 views

Creating a For Loop to simulate matrix changes

I'm trying to create a For loop (Using the For syntax is a necessity for the future work I'd be performing) for a matrix given by the following lines of code: ...
1
vote
1answer
141 views

Search for squares

Could anyone please help me find $a\left(x,y,z\right)$, $b_{i}\left(x,y,x\right),$$c_{i}\left(x,y,z\right)$ and $d\left(x,y,z\right)$ that are sums of squares of polynomials or rational functions such ...
4
votes
0answers
75 views

Neural network for a simple game?

I'm taking a class that is based on the Mathematica coding language, and we must do a 6-week final project. I am considering coding a neural network for a simple game like 2048, pacman, snake, etc. ...
0
votes
2answers
66 views

How to count outputs in Catch command by using Mathematica

I am using the below command in Mathematica (an example): Catch[Do[i; If[EulerPhi[i] > EulerPhi[i + 1], Print[i]], {i, 1, 100}]] Of course, I would like to do ...
3
votes
2answers
80 views

Sorting a Collection of Lists by Comparing Different Parts

I am looking for a way to use Sort[] to sort a collection of lists by comparing different parts of these lists. For example, sorting by comparing the second part of ...
4
votes
2answers
92 views

TableView: How to change column headings?

I am not even sure whether it is possible. I would like to change column headings of TableView output to letters such as A, B, C etc instead of 1,2,3. Here is an example: ...
4
votes
2answers
71 views

Manipulate lists as function arguments

I am trying to write a Demonstration, which I believe means I must write it as a Manipulate, not a DynamicModule. My question is essentially the same as "Dynamic lists as function arguments", but I ...
2
votes
0answers
31 views

FindFaces on Raspbery Pi [closed]

I think this is an standard question but I did'nt find any new answer since years. I try to use FindFaces on raspeberry pi. This function leads to an error message : opencv not available for raspberry ...
8
votes
6answers
326 views

Brute Force for solving Diophantine equation

I'm trying to solve the following Diophantine equation using Mathematica: $$2^x=5^y+3$$ I have a code,but is very slow. Can we speed up ? ...
3
votes
0answers
64 views

Calling custom function from C++

I'm programming a project where I use multivariate symbolic polynomials. At some point I need to perform a PolynomialMod over a prime modulus, but the library GiNaC which I use works only over the ...
7
votes
1answer
261 views

Moving B.C.s in heat diffusion model

I came across the paper Solidification dynamics of an impacted drop regarding a heat equations by Thiévenaz et.al and was interested in knowing how they obtained the graphs presented. From what I ...
2
votes
2answers
74 views

Finding the smallest integer such that a given condition holds with “binary search”

Setup. Suppose we are given a function $$f:\mathbb N\to\{\text{False},\text{True}\}$$ such that $$f(n)=\text{True}\implies f(n+1)=\text{True}$$ and such that $f(n)=\text{True}$ for some $n$ large ...
1
vote
1answer
37 views

Function and patterns. FixedPointList doesn't work with function [closed]

There is a function: Clear[sort]; sort[{a___, b_, c_, d___}] := {a, c, b, d} /; b > c; It perfectly works with NestList function: ...
3
votes
1answer
87 views

NextKSizePartition, or how to partition a set into subsets of size $k$ but incrementally

This question might seem very much like the linked one below but it differs in a very special way; Mr.Wizard suggested I start a new post: Partition a set into subsets of size $k$ What I want is to ...
-2
votes
1answer
124 views

How to use deep clones in Mathematica [closed]

Is there a way to use deep clones in Mathematica? Maybe by making lots of different kernels. In order to execute multiple notebooks I need more than one kernel, is there a way to make them using C# ...
-4
votes
3answers
88 views

How to print by using For loop? [closed]

For[mu = 0; mu < 6, mu++, mu = -4.84*10^(-4) - 17.82*10^(-4)*T1 + 1.53*10^(-4)*T1*2.303*Log[T1]; Print[T1]] I want to get the value of ...
1
vote
1answer
37 views

How can I find EdgeWeights strongly connected components using Manipulate

Given the following Code: ...
17
votes
3answers
793 views

Why use \[FormalN]?

Through a copy of some code from an answer on this site I discovered the existence of: \[FormalN] The documentation describes it as follows: ...
1
vote
1answer
64 views

How can I count the number of edges between connected components of a directed graph

The following code: ...
1
vote
1answer
51 views

Hardy Ramanujan Question [duplicate]

I revised the code I asked about earlier, but I am still not getting an output. According to Mathematica it is (mostly) correct syntax. Here is the revised function: ...
2
votes
1answer
104 views

Implement gradient method in functional programming style

I implemented the gm for quadratic function in Mathematica, but it looks like more in an OOP style, as the pic shows. How to rewrite it in Mathematica style? I tried with following code: ...
1
vote
1answer
39 views

FindInstance confused by CoprimeQ

For some reason when I type FindInstance[a + b == c && CoprimeQ[a, b, c] == True, {a, b, c}, Integers] Mathematica just immediately returns my input as ...
2
votes
2answers
312 views

How can I solve the Ramanujan problem by using Wolfram language? [closed]

The problem like this: find all integers n, 1 ≤ n ≤ 10, 000 such that n is the sum of two cubes of positive integers in two different ways. I want to solve the problem as a procedure in mathematica.
0
votes
1answer
32 views

Subtraction of vectors subtracts whole vector with individual elements

When I'm trying to calculate the value of DP, it subtracts the PCurrent matrix from each element of PGoal. What am I doing wrong? ...
1
vote
0answers
35 views

Need help with While loop [closed]

I'm trying to do the iterative jacobian method but I can't get the output. Any other alternatives using iterative jacobian would be highly appreciated. ...
1
vote
1answer
52 views

How to save matrices from each iteration of i? [closed]

I am trying to get the transformation matrices from DH parameter table and would like to save each matrix (Ai) getting after each iteration of i. How can I do that? ...
6
votes
1answer
99 views

Is it possible to make listable Experimental`NumericalFunction?

I have been playing a bit with the undocumented function Experimental`CreateNumericalFunction and I wanted to know if somebody found a way to make generated ...
3
votes
2answers
135 views

Is there any command similar to Delaunay of matlab?

After finding this webpage where they mention the generation of land using matlab, In its section how it works, explain its operation in detail, I started trying to do it in MMA but I am doubtful of ...
0
votes
1answer
83 views

Why did just get “ nope ” ? I want this{ {2, 1}, {1, 2}, {1, 3}, {2, 2}, {3, 1}}. How can I get that with function “Table”? [closed]

How can I get that with function "Table"? Here are my codes ...
4
votes
3answers
231 views

Writing a program that will filter the integer solutions

I've the following equation: b==(-12 + Sqrt[3] Sqrt[ 3 (-4 + r)^2 + 12 a^2 (-2 + r) - 4 a (-5 + r) (-2 + r) + 4 a^3 (-2 + r)^2] + 3 r)/(6 (-2 + r)) ...
4
votes
1answer
87 views

Is it possible to make Decompose work with coefficients containing radicals?

It appears that Decompose works reliably only on polynomials with integer coefficients, although it seems to be not mentioned in the docs. Can I make it work (or ...
0
votes
1answer
54 views

Getting unexpected results form If expressions [closed]

I'm mystified by this: g[a_, b_, c_] := Module[{d}, d = If[(b < 1), b, b + 1]; If[a < b, d = 0.]; d*c] g[a, 20, 40] ...
0
votes
0answers
76 views

Converting a code with for a loop from MATLAB

In MATLAB I have the following for loop: ...
4
votes
2answers
75 views

Turning Lists of Formulas Into Lists of Ordered Pairs

I'm working with a finite list of linear equations in some amount of variables. Say, {2kx-3y,3y+2kz-x,2x+2y+2z,ky} Is it possible for Mathematica to take this list and output a list of pairs where ...
0
votes
0answers
26 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: ...
2
votes
0answers
78 views

How can I make this “Pick” inside a “Table” run faster?

I am working on becoming more and more familiar with MMA and on a scale from one to ten, I would rate myself as a four or a five. I understand vectorization and that loops-are-very-bad. I have ...
0
votes
1answer
69 views

Change a formula [closed]

have a program consisting of a database of colors in L-a-b format. I want a formula to obtain the desired color by mixing different amounts of colors that are in the database. For example: I want ...
16
votes
2answers
331 views

Improving Performance of an XY Monte Carlo

I normally write my Monte Carlo codes in Fortran for speed, but I was doing some quick and dirty work and wrote one in Mathematica for the XY model on a square lattice (see Kosterlitz-Thouless ...
0
votes
1answer
68 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, ...
3
votes
1answer
60 views

Operate on functions with arbitrarily many arguments

Is it possible to define a function that can operate on another function with arbitrarily many arguments? For example, I want to do error propagation using partial derivatives. It is not clear to me ...
2
votes
2answers
82 views

How to generate vectors with programming

I want to generate all possible vectors programicaly with entrys in $\Bbb Z_4$: $$A_j:=\begin{bmatrix}x_1\\ x_2\end{bmatrix}, \qquad x_i\in \{0,1,2,3\}, j=1,2,\cdots 16.$$
4
votes
4answers
225 views

Programming a recursive formula into Mathematica and find the nth position in the sequence

Well, I have the following recursive formula (where $\text{n}$ gives the position in the sequence): $$\text{P}_\text{n}=\alpha\cdot\text{P}_{\text{n}-1}+\text{P}_{\text{n}-2}\tag1$$ For arbitrary $\...
5
votes
3answers
499 views

Arrange a list in ascending order by deleting list elements

I am new to mathematica and currently learning it by solving some basic problems. I am trying to arrange a list in ascending order using a detailed IF loop. For instance if we start out with $\{1,65,...

1
2 3 4 5
28