# 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
40 views

### How can I fix this cycle in order to iterate several times? [closed]

I have been working on a code whose only purpose is to get the mean value over four numbers. And I managed to do one cycle, however after trying to repeat this process until a certain condition is ...
91 views

705 views

### Heun's method for a system of ODE's [closed]

I need to solve a system of two ODE's using improved Euler's (Heun) method. Can any one help as I am pretty bad at Mathematica. This is what I've come up with so far ...
103 views

### Maximimize not working properly?

I try to evaluate the Integer Maximum of a given function under constraints. ...
71 views

### (Naive) Manual implementation of DFT results in long sum which is very inefficient to plot, can my approach be saved?

I will do my best to keep this question as short as possible, I am afraid though that I wont be able to get my issue across if I don't elaborate on the background and provide my code as an example. ...
658 views

### Optimizing Mathematica Code

I have implemented the whole Baum-Welch Algorithm for training Hidden Markov Models as described in Rabiner's paper Here is my code that calculates the Forward Probabilities` ...
145 views

### Better way than using multiple flattens?

I am running some calculations with vectors (lists) and in order to perform them, they need to be flattened. Is there a better or neater way to do this? ...
185 views

### How to find all prime power factorizations of an integer

I want to put in $n$ and get the possible factorizations into prime powers. Let's say for 24 I want {{8,3}, {4,2,3}, {2,2,2,3}}. The algorithm for doing this on ...
82 views

### How to create list

I have a law under which the current changes, and i need to find values of current evry f sec. Code is: ...
73 views

### Package for static Mathematica code analysis to produce a Cayley tree?

I am looking for a package which can display a static dependency tree of code from a single Mathematica notebook or from a list of Mma notebooks. (Of course, to prevent such a tool from producing tons ...
385 views

### Quasinormal modes with Mathematica

I want to compute the quasi-normal modes for the Kerr-AdS black hole, so basically after decoupling the angular and the radial equation, I have troubles to compute the separation constant and also the ...
39 views

### Help in performing computation over a list [closed]

I need to compute the quotient $\frac{n-1}{\sigma(n)-n}$ over the list say $\{9,25,49,81,121,169,...\}$ where $\sigma(.)$ is the classic sum of divisor function. I tried to use the following codes ...
177 views

### A modification of a mathematica code that selects perfect square on the list

Below is a code taken from OEIS that generates integers $n$ such that $\sigma(n)-n\mid (n-1)$. ...
897 views

### Two-Point correlation function of Ising data is not giving expected results

Due to the nature of my problem, and readers perhaps not having a physics background, I need to give some context to my problem which is intrinsic to it. The problem however is not a physics one, but ...
154 views

### Speeding and optimizing the Graphics Plot

I am having a Hermitian Matrix(HCF[k]) depending on a parameter $k$. My job is to plot the Eigenvalues of the matrix as the parameter $k$ is changed. But I ...
135 views

### Fourier Transform(first use)

This is in continuation of the question I asked Wrong evaluation of integral in Mathematica? But I will try to make it self contained. I have a periodic function ...
141 views

### Wrong evaluation of integral in Mathematica? Numerical vs symbolic [closed]

I have Mathematica 11.0.1 in Ubuntu 16.04. My problem is that I have an integral but Mathematica is evaluating it wrong. Here is the integral: ...
151 views

### Find Root condition for polynomial

I have the following 12-th order polynomial in $\lambda$ with a parameter dependency in $u$: ...
258 views

### Wolfram|Cloud memory limit exceeded

I have some formulas from a paper (Provably Manipulation-Resistant Reputation Systems) that I would like to run 3 times (with different nummbers). Therefore, I wrote a small programm that now finally ...
231 views

### Population growth model using cohort data method: Is there a way to make the repetitive code simpler?

This is for a little simple project in which we try to model population of a certain species of fish and the impacts of overfishing I do find it rather rudimentary to write it all out as such and was ...
230 views

### FEM - How to use an If rule for different ElementMarker values within NDSolve

This question is partly based off Gonza's question and Mauricio's answer. I wanted to adapt the FEM method to simulate a point pressure being applied to distort an encapsulated material that is ...
128 views

### Problem with my Simpson method for elliptic integral [closed]

Using code I found from here for adaptive Simpson's method, Numerical Integration Via Adaptive Simpson's Method, I tried to implement it into my own equation, \$(1 - (\sin^2[51/2])(\sin^2 x))^{-\...
290 views

### The curious case of missing random-walking particles in the box

Note: I added the entire code I wrote below to generate the initial configuration and have explained step by step what each part of the code does Kindly bear with the code and the explanation. Since ...
947 views

### Problems with stress distribution using FEM

I'm trying to get the displacements u(x,y) and v(x,y) of a beam simply suported, the stress distribution in the middle section should be a linear function: but i'm getting this: My code is: ...
80 views

### Funny behavior when integrating

Having the defined the following: ...
707 views

### Code Review: ECDSA for Mathematica

The code below contains functions related to ECDSA (Elliptic Curve Digital Signature Algorithm) with standard parameters secp256k1. The implementation is based on ...
1k views

### Numerical Integration Via Adaptive Simpson's Method

I have written a code that uses the Adaptive Simpson's method to approximate integration. For those who are unaware of this Adaptive Simpson's method; Adaptive Simpson's method In my code, I count ...
286 views

### Flip the axes in the Histogram Plot

I have a matrix and I would like to plot the square of its element. n = 10; H = RandomReal[{0, 1}, {n, n}];; MatrixForm@H H1=H*H; Histogram[H1[[1]]] First row is ...
158 views

### Nearest numbers in the list

I am just curious that there is any better way to write the code to search the nearest value than what I wrote below ...
138 views

### How to multiply simultaneously more than one rows with each other [closed]

I want to simultaneously multiply more than one rows with each other. Like 1 with 2 and 3 with 4 likewise. ...
157 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 ...
173 views

### How to implement this simple procedural style algorithm efficiently in Mathematica style code?

I am trying to move my C solution code for project euler problem 135 to Mathematica. But I encountered serious performance problem. The algorithm is very simple, here is a plain translation: ...
88 views

### Optimizing my code for Mathematica Online

I defined this function: s[n_] := Block[{m = 1}, While[Mod[++m!, n] != 0]; m] I would use ParallelTable on my laptop, but it ...