# 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.

74 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3k views

### Fast Spherical Harmonics radiative transfer

This is a rather specific question and I apologize for spamming you with some lengthy code. But it could be interesting for some reader and maybe you can help out, so please bear with me. I am using ...
• 7,713
208 views

### What do “Analyze Notebook" and "Analyze Cells" Do?

What does "Analyze Notebook" and "Analyze Cells" do? They seem to, at least, point out some coding errors that are already highlighted in a notebook. Do they do anything else? Is ...
• 1,607
108 views

### Techniques in debugging with preview of possibly large expressions + garbage collection issues

First of all, all appreciate all suggestions how to rephrase the title to make it more friendly. Here's the background: Let's say your top level procedure flow is complicated, involves url calls, ...
• 137k
1k views

### Wick Contractions; help with a piece of code

An alternative title to this thread could be, understanding another person's code. A few years back there was a workshop on Mathematica and applications to theoretical physics; if you want I can ...
369 views

### Problem with the accuracy of the real-coded Genetic algorithm

Since there is no Genetic algorithm implemented in the Mathematica i tried to write a very simple genetic algorithm myself. The accuracy of the results depend upon rounding up the obtained parameters. ...
• 791
851 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 ...
• 753
404 views

• 543
1 vote
77 views

...
• 1,709
1 vote
367 views

### Problem with Wick Contraction

I'm trying to compute wick contractions knowing that: $\langle a_a a_b \rangle = \delta_{ab}$. So far I've the following ...
• 119
1 vote
46 views

### understanding en fixing the error in DSolve system

Why does this code not work: ...
• 287
1 vote
64 views

### Speed up for SequencePredictorFunction?

From Google Dive: SequencePredictorFunction is here, along with my test data. From pastbin: prediction function and data is here. Using the ...
• 4,996
1 vote
48 views

### Is there a way to test if a code don't have any issues without actually running it?

I have a code that is too much for my computer to hold. This code will be computed later in a powerful system. Is there a way to verify if there is some syntax error or another issue with the code ...
• 578
1 vote
92 views

### Numerical integration graph and convergence

I am trying to do the following integral numerically, My question is that, after the integration, when I tried to plot, the plot does not show anything on it. What did I do wrong? Furthermore, I ...
1 vote
142 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 ...
• 683
1 vote
82 views

### Funny behavior when integrating

Having the defined the following: ...
• 2,202
1 vote
201 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 ...
1 vote
112 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 ...
• 4,996
1 vote
209 views

### How to eliminate all terms of a variable with square root in an equation?

I did the following thing: take an equation with square root terms, by moving terms and squaring two sides, finally ending up with a polynomial of the specific variable. My algorithm is like this: ...
• 7,921
1 vote
337 views

### Collision detection algorithm (discrete) with sweep and prune algorithm for periodic boundary conditions

EDIT: Question Updated with solution approach, but solution much slower than original implementation. Any ideas to speed up implementation? In the discussion on collision detection (see here) I asked ...
• 2,931
1 vote
115 views

### How to Fold (FoldList) this in a more compact (efficient) way?

Example code: x = Table[something[i], {i, 5}] Table[Fold[f1[#1, f2[#2, a], a] &, x[[i]], {c1, c2, c3}], {i, Length[x]}] This above is just an example. I ...
• 4,996
1 vote
94 views

...
• 4,996
1 vote
203 views

### Am I simulating correctly my hidden markov chain?

I want to simulate a hidden markov model, in which $y_t|y_{t-1},x_t=i \sim N(\theta_0y_{t-1}+\theta_i,\sigma^2)$, where $y_t$ is the observations or data, and $x_t$ is the state variable of the ...
1 vote
88 views

### Problem with converting recursive code to iterative

I am trying to convert a snippet that uses recursion into one that uses iteration for drawing an L-tree, but my code produces duplicate points. How do I avoid generating them? Recursive version: <...
• 7,138
1 vote
82 views

### Implementing normalization/rescalement from a Tutorial

I'm trying to implement a rescale/normalization as is described in here by mathematical expressions in page 10, and code in the top part of page 16. The notebook is also available here. The objective ...
1 vote
152 views

### How to tweak the following purely numerical code

I am using the following numerical function in my program and I would like to speed it up. ...
• 665