Skip to main content

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?)

41 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5 votes
0 answers
57 views

Exploring how densities can be approximated by histograms in R

...
user21582991's user avatar
5 votes
0 answers
416 views

Sequence and Series Calculator

The Sequences & Series involved are Arithmetic and Geometric. stores and allows you to calculate using these given formulas and import fractions into micropython Support for micropython! ...
Eren Yaegar's user avatar
5 votes
0 answers
895 views

Recursive factorial calculations in Rust

I am trying to calculate very large factorials. I am looking to speed it up as 10000! takes approximately a minute and a half. ...
Jared Mackey's user avatar
5 votes
0 answers
169 views

Kernel density regression in Julia

Here is a naive implementation of a kernel density regression algorithm in Julia. The code works, but there is quite a bit of room for improvement though. First, there is not an optimal bandwidth ...
Vincent's user avatar
  • 561
4 votes
0 answers
661 views

A Very Simple Support Vector Machine with SMO Algorithm Implementation

Context. I was looking for some simple implementation of SVM with the SMO algorithm that can be used as an in-class problem together with a simple mathematical explanation of how it works. The problem ...
guest's user avatar
  • 141
4 votes
0 answers
2k views

Satellite orbit simulation in Matlab using Runge Kutta 4

I have a satellite orbit simulation in Matlab (Using Runge Kutta 4). It seems ugly and I don't know how to fix it. fx.m file: function v = fx(t,x,vx) v = vx; ...
tanpham's user avatar
  • 41
3 votes
0 answers
85 views

Toom-3 big-integer multiplication algorithm

I am developing a C++ big integer library for C++11, 14, 17, 20, etc., as an exercise. The Toom-3 algorithm is resisting me a little bit. AFAICT, it does produce the right results but not as fast as I ...
Atmo's user avatar
  • 201
3 votes
0 answers
89 views

Speed up a JavaScript function for inverting matrices using Gauss elimination

I wrote this function and I'm interested if it can be sped up by improving the code. The function accepts either column major 1D array or 2D row major array. Maybe there are some obvious JS tricks ...
user9163823's user avatar
3 votes
0 answers
44 views

Plot of massless particles on the unstable null circular geodesic

My friend and I were trying to reproduce Figure 4(left), page 7, from the paper "Probing phase structure of black holes with Lyapunov exponents", Guo 2022. We succeeded in reproducing the ...
codebpr's user avatar
  • 131
3 votes
0 answers
305 views

converting from byte arrays to strings of integers, and back

I have this code to go from an array of bytes (arbitrarily long) to a "bigint" string (really, an arbitrarily long string composed of integers 0-9), and go from that long integer string into ...
Lance's user avatar
  • 341
3 votes
0 answers
81 views

How to simplify the following distance function for the taxicab ring metric space?

Consider the taxicab ring metric space shown below. This is a discrete metric space in which we have both a grid and concentric diamond rings. This metric space stretches infinitely in all four ...
Aadit M Shah's user avatar
3 votes
0 answers
458 views

Making a fast Mandelbrot Fractal viewer

I'm making a Mandelbrot set viewer in JavaFX. It takes a while, like maybe 5 seconds to finish. Here's my code: ...
bychtromae's user avatar
3 votes
0 answers
65 views

Optimising multiplication of matrix rows with matrix slice/page

I've recently vectorized most of the code for an optimization problem but this one still eludes me. As the procedure and not the actual values are important here, I have replaced the original matrices ...
deemel's user avatar
  • 131
3 votes
0 answers
62 views

"Academic interest" implementation of a Finite State Machine

Context I'm playing around the concept of a Finite State Machine. While I understand the basic principles behind it, I want to implement a simple, yet generic class which could be reused in the ...
Igor Soloydenko's user avatar
3 votes
0 answers
127 views

Gradient computation in JavaScript

I'm working with some math-heavy code in JavaScript. I just realized that there's a render that currently takes about 30 minutes. 95% of that time is spent in a single ~40 line function that I've ...
Slater Victoroff's user avatar
3 votes
0 answers
1k views

Computing intersection of 2D infinite lines

I wrote a small program to compute intersection of 2D infinite lines using Boost Geometry A line is defined by two points in Line class. The ...
cromod's user avatar
  • 329
3 votes
0 answers
73 views

Slow multiplication in a modulo

I am willing to get a linear output of a product in a ring Z/nZ For that I have successfully implemented a code that does a Product in a modulo However, it is not optimized to output the steps ...
lopata's user avatar
  • 131
3 votes
0 answers
200 views

Calculating continued fraction expansions (without requiring arbitrary precision decimals)

I'm writing a program that will compute a continued fraction expansion of a number. I've been learning Racket/Scheme for a few weeks and I wanted to see what I can do better. Usage: This program ...
Chris Brooks's user avatar
2 votes
0 answers
80 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 ...
Ξένη Γήινος's user avatar
2 votes
0 answers
160 views

JavaScript functions to generate Pythagorean triples

I am sure you know what Pythagorean triples are, in the extremely unlikely case that you don't know: A Pythagorean triple consists of three positive integers a, b, and c, such that $$a^2 + b^2 = c^2$$...
Ξένη Γήινος's user avatar
2 votes
0 answers
77 views

Haskell proof checker for FOL with equality

Is this a correct implementation in Haskell of a proof checker for first order logic with equality? I am most interested in if it is correct, and if the functions can be made clearer. I would like it ...
user695931's user avatar
2 votes
0 answers
217 views

Maximizing Efficiency of Collatz Conjecture Program Python

My question is very simple. I wrote this program for pure entertainment. It takes a numerical input and finds the length of every Collatz Sequence up to and including that number. I want to make it ...
Ghull's user avatar
  • 41
2 votes
0 answers
203 views

Gradient descent algorithm for solving localization problem in 3-dimensional space

Task This code accomplishes the Time Difference of Arrival (TDoA) multilateration problem (see) using gradient descent (known otherwise as steepest descent). Goal I'm looking to: a) Improve speed: In ...
10GeV's user avatar
  • 295
2 votes
0 answers
438 views

Code is timeout - Hamming Number

I have a problem with my code, because his is required a long time to be done(only when I put big numbers like 2000)... I am trying to do the Hamming Numbers kata on codewars.com: A Hamming number is ...
MarkoKovacevic's user avatar
2 votes
0 answers
129 views

Division safe from overflow for fixedpoint

So I was investigating overflow safe division for a class that uses an int64 member with a given RESOLUTION ( 10000 ) for the fractional part. To preserve precision in the fractional part during an ...
Sir Rogers's user avatar
2 votes
0 answers
97 views

Shutting down all lamps with minimum number of switch presses

I found an optimization problem written in Finnish but I will translate it into English. The following is an example case. I have \$n=120\$ lamps in a circle, and enumerated by \$L_1,…,L_{120}\$. ...
sagemathematician's user avatar
2 votes
0 answers
737 views

Python RSA/DSA File Cryptography, Key Generation, Key Protection

I have forked a previous version of my script, critiqued here: Generate public/private keys, encrypt, decrypt, sign, verify This program allows you to encrypt and decrypt raw files using RSA keys ...
FodderOverflow's user avatar
2 votes
0 answers
417 views

Matrix inverse by elimination

Because I had trouble in finding a reliable source on the internet for the matrix inverse algorithm using Gaussian elimination, I wrote one myself. Matrix.h ...
I am an Idiot.'s user avatar
2 votes
0 answers
122 views

Improved Atkin-Bernstein sieve for generating primes

This is a class from my personal code library, and from a package which deals with integer sequences. It implements an interface ...
Peter Taylor's user avatar
  • 24.1k
2 votes
0 answers
581 views

Factoring a polynomial with integer coefficients

I haven't programmed in a while and need to improve my code in any way possible: efficiency, readability, etc. This program is for getting integer coefficients of any polynomial and factoring: ex. $$ ...
Julian Yocum's user avatar
2 votes
0 answers
259 views

Roots of Unity in R

I have a paper on the definition of (i) available here. I was curious about the simultaneous real numbers associated with the roots of unity, and noticed there was not a routine in R. I have this ...
Fred Viole's user avatar
1 vote
0 answers
147 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 ...
Kittoes0124's user avatar
  • 1,940
1 vote
0 answers
44 views

Iterating over de Bruijn sequences in JavaScript

I have just put this code together, it's not quite the most elegant but it seems to get the job done. Does it seem alright? I could not find anywhere a "de Bruijn sequence algorithm", so I ...
Lance's user avatar
  • 341
1 vote
0 answers
117 views

Integrate a normal map via a 2D gradient field

This code transforms a normal map into a 2D gradient field and then iteratively integrates it to a likely solution. I don't have a lot of experience with C++/CUDA yet and would appreciate some advice ...
Niklas Hauber's user avatar
1 vote
0 answers
173 views

Applied Solution Based On Polya Enumeration Theorem

Problem A function solution(w, h, s) that takes 3 integers and returns the number of unique, non-equivalent configurations that can be found on a grid w blocks wide, h blocks tall and s possible ...
Anit Shrestha's user avatar
1 vote
0 answers
562 views

PowerShell - Find Least Common Multiple of a series of numbers

I am a Windows power user, a system tweaker, my idol is Leanardo da Vinci, and now I want to be a hacker. I am extremely new to programming, but I really am a fast learner if I am interested in the ...
Ξένη Γήινος's user avatar
1 vote
0 answers
2k views

Great-circle distance in Java

Today's assignment states that I need to write a complete java program which will calculate the relative orthodromic distance between two sets of geographic coordinates declared by the user. When the ...
E's computer class's user avatar
1 vote
0 answers
118 views

Solidity: verifying primality certificates, bounty for large primes

This is my first smart contract, and it isn't finished yet, but the remaining bits are complicated enough that I'd like to make sure I'm on the right track first. My concerns are: At line 117, is the ...
Pr0methean's user avatar
1 vote
0 answers
562 views

Python palindrome function; is it possible to write it without using string conversion?

I hope this question is okay to ask on Code Review; this is a little function I wrote in Python 2.7.12 that checks if a number is a palindrome. It works fine but I'd like to know if there is a purely ...
MadHatter's user avatar
  • 837
1 vote
0 answers
1k views

Snell's law using Zoeppritz equation by matrices

I have created the following code to calculate Snell's law angles, based on Zoeppritz equations on complex plane. The code works, seems it is returning valid values, but after all the code just looks ...
Lin's user avatar
  • 253
0 votes
0 answers
89 views

A Java program interfacing with Gnuplot for generating triangle wave plots

Intro I have this repository. Given this command ...
coderodde's user avatar
  • 28.7k