The 2024 Developer Survey results are live! See the results

# Questions tagged [mathematics]

For code that aims to solve problems in all branches of mathematics. (Please do NOT use this tag for incidental trivial use of arithmetic. A simple test to apply is: would an amateur or professional mathematician take an interest in the question?)

634 questions
Filter by
Sorted by
Tagged with
30 views

### Numerical Solution for Geodesic Equations in Schwarzschild Spacetime [closed]

In python I programed a code that numerically solves the geodesic equations in Schwarschild spacetime. The code is not working however. I got this error message: "TypeError: MatrixSpecial.zeros() ...
69 views

### Benchmarking Square root functions

Here's a follow-up to my posts about square roots (Studies on Square Roots and More Square Root). I've tidied up the code, but there's still a lot to do according to the feedback of the other posts. ...
• 141
669 views

### More Square Root

This is a follow up question to my Studies on Square Roots post. I'm posting additional code for solving for square root similar to the other, but with more code to benchmark. ...
• 141
752 views

### Studies on Square Roots

This post marks the beginning of my ventures into calculating square roots. However, I have no idea how the processor, more specifically the FPU with the fsqrt ...
• 141
1k views

### Implementation of Euler-Maruyama numerical solver

I am trying to write a python implementation of Euler-Maruyama and Milstein schemes for numerically solving stochastic differential equations. The pseudo-code for the algorithms is in the Wikipedia ...
• 397
914 views

### Optimizing Pi Estimation Code

I'm trying to write a program in Python that estimates pi, but to get a more accurate estimation in a feasible amount of time, I want to make it faster. I'm using a method that estimates the area of ...
41 views

• 183
1 vote
151 views

### Interleave Bits Generically

This commonly referenced "bit twiddling" site has an interesting algorithm for interleaving the bits of two 32-bit integers. Here is my attempt at completely generalizing the algorithm using ...
• 1,940
185 views

### Design an algorithm to predict words based on a skeleton from a given dictionary

The model I'm building first selects a secret word at random from a list. The model which uses an API then returns a row of underscores (space separated)—one for each letter in the secret word—and ...
• 232
134 views

### generate prime factors via wheel factorization

I want to factor random values of n that range from uint.MinValue to uint.MaxValue as ...
• 1,940
204 views

### 32-bit deterministic Miller-Rabin primality test

Are there any ways in which this code could be improved? I'm particularly interested in the ModularExponentiation function as it is the primary bottleneck during ...
• 1,940
2k views

### Newton Fractal writen in C

The code has no errors, it is just slow. It takes 1.19s to start. How can I reduce runtime without using threads or multiple processes? I have tried compiler optimization ...
287 views

### Identify distance degeneracies on square and hexagonal lattices

I have an interest in how the number of ways you can reach from the origin to a certain distance on both square and hexagonal lattices. If L is the square of the distance and integer pairs (i, j) are ...
• 473
131 views

### Improving execution time of physics, data acquisition triggering system simulation

Background I'm attempting to write a physics simulation code, one portion of which involves simulating the triggering system of some equipment. The equipment works as follows: environmental noise (...
82 views

### Python script that generates images using Thue-Morse sequence

In mathematics, the Thue–Morse sequence, or Prouhet–Thue–Morse sequence, is the binary sequence (an infinite sequence of 0s and 1s) obtained by starting with 0 and successively appending the Boolean ...
• 3,178
1 vote
236 views

### C++ Unsign 128 Bit Intrinsic Number

Per feed back for this question, I have written an unsigned 128 bit integer for Windows. The class first determines if it is in a 64 bit environment. It only creates the class if it is in a Windows ...
• 369
1k views

### Arcsine function for a real-time control program

I have been developing control software for a three-phase induction motor. The main task of this C++ code is to control the torque of the motor. In one part of the algorithm (The control algorithm is ...
• 355
1 vote
587 views

### Removing Elements from an Array Based on a Second Array

I've written a function that takes two arrays of integers as input and removes all the elements in the first array that are also present in the second array. I would like to share my code with you and ...
• 523
1 vote
52 views

### Optimizing the Dig Pow function

I have written a Python function to solve the Dig Pow problem, where the goal is to find a number k such that the sum of each digit of n raised to a specific and ...
• 523
1 vote
89 views

### Efficient N-Dimensional AABB Subdivision Algorithm

This is supposed to subdivide a n-dimensional aabb (axis aligned bounding box) into 2ⁿ equal pieces as if sliced by n planes that are perpendicular to only one axis and parallel to the rest of the ...
82 views

### Readable Backprogragation calculations in Numpy Neural Network

As an exercise we should write a small Neural Network with the following structure: There should be additionally a bias for each layer and sigmoid should be used as the activation function. The ...
• 51
58 views

...
541 views

### Fast approximate sin/cos function in Rust

Over the past month or so, I’ve been trying to create an extremely fast, platform agnostic, auto-vectorizing sin/cos function for fun. I initially started with sleef-rs’s fast sin function, and ...
174 views

### Using Ada's access type and generics to solve an ODE

This post is linked to Ada: Convert float to decimal I have produced Ada codes which uses the Euler algorithm Euler method to solve an ordinary differential equation. The codes given below are working ...
176 views

### Graph function in console

I created a program for drawing graphs of functions and want to hear ideas on "how to improve this program", because I'm only starting to write programs in Python. Would be very good to hear ...
• 91
149 views

### Ackermann-Péter function call count using Writer monad

I'm quite new to Monads and I tried add function call counting to the Ackermann function code. The goal was simplicity, not performance. I want to have code review on the ...
1k views

### Compute the sum of even numbers between two values

Recently I was watching two YouTube videos criticizing a function which sums the even elements in an inclusive range, the original function looks like this: ...
• 145
1 vote
66 views

### Fixing math library functions in Black-Scholes options pricing model

I've amended a code for the Black-Scholes formula for European pricing options found here at the bottom of the page and fixed the math functions accordingly. Unlike the code on the website, mine has ...
• 113
287 views

### Finite difference estimation of partial derivatives for arbitrary grids in python

I am currently working on testing some codes on python to solve differential equations by finite differences, but some problems and equations i am dealing with are: Too big to keep manually writing ...
• 123