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

506 questions
Filter by
Sorted by
Tagged with
88 views

### How can I speed up my calculations with loops? Python

I wrote this code. But it works very slowly. I'm figuring out how many times I have to run the case generator to find numbers less than or equal to inv, in this case six. I count the number of ...
38 views

### A prime number checker (Multi numbers).py

so obviously this SIMPLE code checks if the number is prime or not. I need to make it more advanced, easier to use, fewer lines or any improvement. ...
4k views

### Project Euler #5 (LCM of 1-20)

Challenge: 2520 is the smallest number divisible by 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by 1-20? Solution: ...
324 views

### Probability that Three Pieces Form a Triangle

I wrote some code to estimate the solution to the following problem: If you break a line segment at two random points, what is the probability that the new line segments can form a triangle? The ...
45 views

### Binomial Expansion Calculator

So i wrote a program with the documentation for my fx cg50 calculator's micropython to calculate various items, each of which are: Pascal Triangle Entry Pascal Triangle Level/Entire Row Binomial ...
38 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! ...
65 views

### Efficiently calculate the value of an arithmetic sequence

I need to calculate the value for the following function: $$f(n) = -1 + 2 - 3 + ... + -1^n$$ The time limit to calculate a given value of $n$ is less than 1 second. My approach does not meet that ...
141 views

### Scan-line algorithm to fill in a triangle

I wrote the following script to fill a Triangle. ...
51 views

### Converting an equirectangular image to a cubemap

I've written a program that does three things: Take an equirectangular image and ... ... cut horizontally-overlapping image areas. ... fill the image from the bottom with black so it has a ratio of 2:...
65 views

### Exponentiation by squaring in x64 Linux Assembly

I am learning some assembly for a compiler project I am working on and I have come across the Exponentiation by Squaring algorithm when it came to calculating x ^ n. To get a grasp on how the ...
34 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 ...
62 views

### Determine if points are within a rotated rectangle

Using only Python 2.7 and the standard library (no imports): Determine if a point is inside the rotated rectangle. ...
59 views

### Integer pairs of a product in Python

This bit of code is looking for the pair of integers that make up a product. You can input any integer and it returns the pairs of numbers that, when multiplied together, make it up. I have done a ...
336 views

### Quadratic Expression Factorer and Solver

I have decided to create a program that can factor and solve quadratic expressions in micropython, where the standard library is limited, and i have no idea how to implement external modules onto it, ...
46 views

### A Level Statistics Calculator/Helper For A Casio Fx-CG50 Calculator's MicroPython

I have made a program for my calculator's micropython, that can solve various a level statistics questions for me. However due to the limitations of the ...
617 views

### Convert Decimal to Fraction

This code below converts number from decimal to fraction. I don't know if there's a better way or better methods to do this job so any advice would be appreciated. ...
207 views

### Quadratic equation solver in Ruby

I wrote a simple quadratic equation solver with Ruby to help me solve quadratic equations. Please tell me what I did right or wrong, and what I can do to improve it. ...
64 views

### Euler Transform on Leibniz Series of Pi

So i read about simple series for Pi named Leibniz Series for Pi. Here is its Link:- Series . I made a program for it and soon realised that it converges very slows . So i did Euler accelerate for ...
41 views

### Recursive Function to Produce Constrained List of Integer Partitions

I have modified a recursive function designed to print all the integer partitions of a positive integer to create a function that returns all partitions of the "number" parameter if they ...
172 views

### Find the best matching combination of numbers

I need to manipulate chunks quantity until total will be as close as possible to the ...
43 views

### Finding the lowest perfect square that can be added to a number to make another perfect square

The code below returns the smallest perfect square that can be added to a number n to result in a perfect square. It works perfectly fine but I need it to run ...
45 views

### A library of 2D Shapes with functions for their intersections

The goal was as much code reuse as I could get. Shooting for a pure-function-y style. Would love any feedback on general architecture, adherence to standard practice and usability - as well as ideas ...
320 views

### MMMRjs a product of BYTES Genesis

We have published a product today called MMMR.js this product is licensed under the MIT license and is built by Syed Mohammad Sannan. The uniqueness of this product is that it is built with and for ...
45 views

### Python's OOP for Calculating Growth of Money

I am making an OOP to calculate growth of money according to theory of interest. I have made 3 classes: Contribution which contain data of a deposit and its growth, ...
39 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 ...
29 views

### Solving the game of 24 recursively in APL

The "game of 24" as I called it in the title is a maths game in which you are given four numbers and have to combine them in an expression using only the four basic arithmetic operations <...
103 views

### Factoring and solving a quadratic polynomial

So i code stuff for my fx-cg50 calculator's micropython as I'm an a level student and a python beginner, and i need help pointing out the bugs and some programming tips to further improve my code, and ...
1k views

### Project Euler Problem 21 in Python: Summing amicable numbers

Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b ...
67 views

### C - Division from scratch

I wrote this code where division can be done without using C's builtin operator: ...
69 views

### Python - A Numeric Matrix Calculator/Processor

it's the second object oriented program i've worked on, more details on https://hyperskill.org/projects/96?goal=391. I've added as much documentation as needed, as a first time, to explain each ...
39 views

### Convolution function

I implemented the following function using the matrix object from breeze library. Basically it is just a glorified while loop. The convolution there is extremely ...
2k views

### Calculator in C++

I made a calculator in C++. I wanted to ask is this code well written, understandable, and alright. ...
48 views

### Solving roots of negative numbers

As part of an assignment for college summer classes, I was tasked with writing a program that solves roots of negative numbers. I've ran it through the test cases I was provided and it computes ...
41 views

### Multiplying by certain elementary symmetric polynomials

Let me preface this with saying that it's probably not necessary to understand all the math behind this to review my code. Unless you have a lot of spare time or a very strong interest I also wouldn't ...
74 views

### A Credit Payment Calculator

So I've attempted this project from hyperskills where you're asked to make a calculator script that can calculate annuity and differentiated payments given that 3 of 4 values are known. I think i went ...
26 views

### Vectorization of Mersenne Twister? [closed]

Ahoy friends. Right now i'm selling a huge amount of HDDs and usually i used DBAN or nwipe to perform this actions. Unfortunately the PRNG Mersenne Twister is quite slow, so i get a throughput of ...
61 views

### Simple math library in Rust

So, I've tried to make a simple math library in Rust. What do you think about it? ...
3k views

This is the question I am facing at level 3 of Google Foobar: There are two types: Mach bombs (M) and Facula bombs (F). The bombs, once released into the LAMBCHOP's inner workings, will ...
37 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 ...
1k views

### Calculating pi using bash

I've written a little program to calculate pi using the Nilakantha series: For this formula, take three and start alternating between adding and subtracting fractions with numerators of 4 and ...
47 views

### Graphing various mathematical functions in Python

1) This code's task is to create graphs of various algebraic, logarithmic and trigonometric functions and relations using Python's matplotlib.plyplot module. ...
9k views

### Finding greatest value in array smaller than x

Code review requested to make this code simpler, cleaner, and better. Input array is sorted. This program finds the greatest number smaller than x. So, in an ...
75 views

### Simulated annealing for magic square-of-squares puzzle

I'm working on a function that takes in a NumPy array containing only mutually distinct positive square numbers. I want the function to pick an element at random, find if there is a lower positive ...
56 views

### Python: Function to Find 2 Closest Points Among [x,y] Coordinates

I'm writing some code in Python that takes a set of [x,y] coordinates (in a list of tuples) and also an x-value. I need to find the two closest x coordinates to my x-value. To find the closest x, I ...
26 views

### Statistics Calculator for Listed and Grouped Data

I made a statistics calculator based on raw data for my Edexcel IAL Statistics 1 course which I'm going to use in my calculator's MicroPython. I would like some suggestions for ways to further improve ...
50 views

### Python extended Euclidean algortihm + inverse modulo

I programmed the extended Euclidean algorithm together with the inverse modulo because I am making an RSA system from scratch. Any feedback regarding efficiency etc. is welcome :) ...
61 views

### Compute the derivative of a function

1.11 Arranging the derivative of a function The derivative of any function f (x) at x0 can be estimated according to the following formula: Write a program that prints three columns of ...
75 views

### Rock Paper Scissors without arrays and if-statements, how to reduce

As working on a little private programming challenge, I tried "Rock Paper Scissors" without arrays or if-statements. It works as intended, though, I am sure this can be done a little bit more ...