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

471 questions
Filter by
Sorted by
Tagged with
32 views

### Using NetMeasurements for basic neural network

I have a neural network that works fine, but I would like to obtain some results on the Validation Set which provides some metrics on the performance of the training. I am obtaining some strange ...
• 229
55 views

• 229
96 views

### Calculate The Declining Balance Method For Depreciation?

I have code generated by AI Aria in Opera browser The code gives wrong answer only for: Depreciation factor=1? ...
• 14.2k
94 views

### Indeterminate Lyapunov exponenet for four-wing attractor

We are using Chris K's answer on another question for finding Lyapunov Exponents for a dynamical system (Four-Wing Attractor) ...
• 2,550
1 vote
58 views

### Why is GraphPropertyDistribution[.] taking an infinite amount of time to run?

This code is from the documentation: ...
• 6,233
196 views

### Python Code to Mathematica for Classical Map of Kicked Top

I am trying to convert this Python code for Classical map of kicked top to Mathematica. For a single trajectory, I am able to ...
• 2,550
1 vote
55 views

### Why this code does not show three legend lines?

My code shows empty legend lines. What should I do to show the graph with three legend lines? ...
197 views

### Fixing a code which covers $[-k,k]\times[-k,k]$ for a given $k\in\mathbb{N}$, with smaller rectangles of equal area?

Motivation: From this post we, initially, wanted to cover a rectangle using smaller, non-overlapping rectangles with the same area: the difference between the total area of the smaller rectangles and ...
• 71
221 views

### Improve performance of Linear Optimization

EDIT I am reframing the question here by pulling out the relevant part about linear optimization, you can find the original question and the entire code down below. I am trying to increase the ...
• 456
444 views

### A simpler or more concise way to divide the boundary of a polygon into equal arc lengths?

I am really looking just for the least amount of code needed to do this but it is still readable. Here is the same polygon but the border is respectively split up into 10, 20, and 30 points along the ...
1 vote
164 views

### How to show the limit of two functions in a code approach zero?

I don't know how to shorten the program, the entire code is required to understand everything: ...
• 71
1 vote
69 views

### How to join two disconnected curves with listplot

Actually I want to join the blue and the red curve with another curve (definitely not a straight line, but some smooth curve) to show the transition from blue to red. How can I do this? Please help. ...
• 43
54 views

### Plotting diagram of complex equation [closed]

I have this equation: q1[t_] := -I*γ*Sin[θ] + ((γ*Cos[θ])/n^2)*(I*ξ[t]*y+z*α[t]) and the main code is the following with the definition of each parameters: ...
87 views

### Why is StoppingTest in red? What other option to stop NDSolve?

The following stripped down code works, but I'm experiencing some strange warnings: from an old document made with Mathematica 7.0 (but used in version 13.2), I'm getting several warning messages ...
• 4,103
206 views

### how to balance a matrix by proportional adjustment of rows and columns

Given a matrix: ClearAll[mat, refR, refC]; mat = { {21.2, 29, 19.9}, {9, 48.8, 22.4}, {49.8, 62.2, 7.8} }; I want to adjust the elements of ...
• 6,233
54 views

### Part specification error

I am doing a solved exercise shared here. However, while running the code, I encountered an error on page-8, under the Dynamics section. with error : I think this error is due to the absence of ...
• 2,550
1 vote
146 views

### Number operator

Suppose CR is my creation operator and AR is my annihilation operator. I have to show that ...
• 2,550
79 views

### Mathematical Equations Puzzle: Perfect Sixes

pI have given the following problem to my students Write some code that solves the perfect sixes problem for all numbers it works for! The perfect sixes problem asks you to solve some equations: \...
1 vote
112 views

### How can I roll up a line to get a circle? [closed]

I am trying to transfer n1=4 points that I have on a line, on a circle. suppose: ...
1 vote
104 views

### Matlab to Mathematica code to solve system of ODEs [closed]

I have the following system of second order non-homogeneous DEs: \begin{align} 0 &= 2 x_t - J_{\pi_t}(x_t) \frac{\epsilon - 1}{\theta} (1 + \varphi) + \frac{\partial J_{x_t}(x_t)}{\partial x_t} \...
• 479
57 views

### How to solve Equation for different variable in Mathematica?

I want to solve the given equation for $(n=m=3)$ and I want the output variable $q_{1,1}, q_{1,2}, q_{2,1}, q_{2,2}$ Given Equation Given Equation-2 The output should be required Output Here is my ...
137 views

### Create a set of vectors from given pairwise dot product

Assume I am given a list of all the pairwise dot products of an unknown set of $n$ vectors. How can I efficiently generate such a set (or all possible sets) with the extra constraint that all vectors ...
• 571
1 vote
102 views

• 1,642
637 views

### Mathematica for Theoretical Physics by Gerd Baumann : Henonmap

I was following a solved problem from the book mentioned below on the Henon map. However, even after correcting that I still get an error on execution. I am unable to find the exact cause. ...
• 2,550
1 vote
152 views

### Again with filling in a plot

I really don't understand how filling works, and here I am with a new question about. I need to colour the region in the first quadrant, created by the functions $x+2$ and $-3x+5$. Hence $x$ runs from ...
• 961
208 views

### Collapse (hide) code inside a function

I often use structures similar to the "func" below, however I would like to be able to "hide" the function definitions (similar to cell grouping using a group opener). I think an ...
• 151
98 views

### Speed up functions using variable types but not Compile

I am writing a large numerical code and I have set up many functions that take several arguments as input. In the functions I am using several built in Mathematica functions, such as Sum[], Part[], ...
• 283
115 views

### Unable to solve the given equation

I am trying to solve the given system in terms of $r$, for which I use the following code: ...
• 2,401
1 vote
172 views

### Plot of massless particles on unstable null circular geodesic : Finding an alternative for GraphicsMeshFindIntersections and reducing code length

My friend and I were trying to reproduce Figure 4(left) from this paper(page 7). We succeeded in reproducing the result after writing a lengthy and complicated code. Here I dissect the code in steps: ...
• 2,401
82 views

### Trouble with output of Reduce as a root object for a 3d Plot

I am trying to find the value of $r_0$ using $L^2=\frac{{r_0}^3 f'({r_0})}{2 f({r_0})-{r_0} f'({r_0})}$ and making a 3d plot with the help of the code given below: ...
• 2,401
196 views

### Converting specific positions of a List into Sublist

Suppose I have a List of numbers: num = Range[5] I want to combine the second and the third element into a sublist to get the result as {1,{2,3},4,5}. I tried ...
• 2,401
1 vote