# Questions tagged [code-review]

This tag is intended for the review and improvement of style for already functioning code. It not meant to change the objective of the code.

304 questions
Filter by
Sorted by
Tagged with
25 views

### Improvement of a method to plot values of a section of a line that moves with time

I have this code which animates a layer of fluid moving on the outside of an ellipse with a moving black point on the cylinder surface itself. I want to plot a line from the origin to the outer layer ...
53 views

### help with improving my code

I am fairly new to MMA-12 and have written the following code to calculate possible coordinates (for given constraints [see If[]] in the code) and get the ...
483 views

### Is this a bug or my mistake?

This: Graph[{1 \[DirectedEdge] 2, 2 \[DirectedEdge] 3, 4 \[DirectedEdge] 1}] AdjacencyMatrix[%] // MatrixForm generates: But, this ...
96 views

### How can I map edgeweights from a matrix onto edges along the paths generated by another matrix

Suppose that we have two matrices with identical dimensions: matA and matB. I want to identify a set of pathways using ...
64 views

### How to automize Shannon's Entropy calculation using a MM function

With the following code, I calculate Shannon's Entropy function HH1 for a given matrix mat. ...
63 views

### How can I index a function with the type of dataset used

I have the following code which serves my purpose for a single matrix input. For one or two matrices, the operation can be done manually, but I have 65 matrices and ...
43 views

### How can I use DeleteMissing[] to delete “complicated rules” from a matrix

The following works as intended: ...
76 views

### Solving an equation in integers giving an errormessage

I've the following code: ...
314 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 ? ...
58 views

69 views

### Mathematica only graphs the upper part of my cylinder

I have this code which first is supposed to make random points, draw lines through the points and then make these lines radical axes of cylinders. I have two problems with my code. First, it only ...
150 views

### Can someone please explain the code from another question

Source: Position of a pattern-matched part of an expression Can someone please explain the following code by Leonid Shifrin. ...
105 views

### Dealing with stiffness in solving Mukhanov-Sasaki equation

The code that I wrote is rather long, but I have included the whole code. ...
61 views

### I have a working code, but work very slowly. want to improve the code

I have working code which gives the result as expected by me. But the problem is it is taking too much of time to give me those results. I have a determinant function which depends on z1,z2,z3, kt,m, ...
25 views

### Relative Chop for Fractions with Trigonometric Terms

I have a fraction, which contains long sums of various terms that might include trigonometric functions in both the numerator and denominator. I want to get rid of the negligible terms. This is my ...
187 views

### Animated Lissajous Curves Parametric Plot

I love mathematical GIFs' power to illustrate and communicate math concepts widely. I haven't had much luck with the build-in ListAnimate on MMA Online but ...
242 views

### When computation takes a long time, how to find out if this is normal or if my script contains an error?

I study mechanical engineering and I' working on my first bigger project on Mathematica right now. It's a multibody problem that leads to a system of 4 large equations I'm supposed to solve ...
63 views

### Find and number sublists

I implemented the following routine. array1 = {12, -12, 14, 12, 1, -3, 1, 1, 2, 7, 8, 102, 2, 3, 3, 1, 332, 11, 23, 2, -2, 13, 12, 1, 1, 1, 1, 1, 1, -121, 131}; ...
95 views

### How can I make my code containing a For loop more Mathematica-style?

I know there are a lot of questions on this site regarding the use of For loops and how to avoid them in Mathematica. However, in my case I believe it is justified,...
76 views

### Trying to obtain a numeric solution to an inequality. Code might be not working as intended

I need to check whether an inequality can have solutions in the real numbers, given some extra constraints on the variables. I suspect that no solutions exist but I would like some verification of ...
56 views

...
123 views

### Better code for reversing and joining matrices

I am writing a function to reverse a matrix and join the reversed version to the original one, making a new matrix which I call A. And after doing this, I reverse <...
518 views

### Is there a faster way to vectorize a matrix than this?

I want to put all the columns stacked up, as a vector. The fastest code I could come up with was Transpose[{Flatten[Transpose[A]]}] Is there a faster way?
The twin prime constant is defined as $$C _2 = { \prod \limits_{p \geqslant 3 }} \, \frac{p(p-2)}{(p-1)^2}.$$ Translating this directly in Mathematica code gives: ...