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

444 questions
Filter by
Sorted by
Tagged with
665 views

### Calculating pi by adding areas of thin rectangles

I wrote a small program for fun to try to prove Pi by taking a certain precision and radius and using it to calculate the area of the circle. My method should be giving me an area that is just ...
823 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 ...
181 views

### Mendelian inheritance

I started out with the Rosalind problems a while back. Turns out it's a great way to learn a new language. I'm still trying to learn Ruby, and while I haven't managed to use regular expressions as ...
8k views

### Add item after every nth step

The purpose of the method is to add a list of items after every nth step (5 for example) where the input items are repeated if needed. I'm looking for an overall review and possible how to remove the ...
747 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 ...
2k views

### Solve 6 simultaneous equations for 8 variables puzzle with Java

I came across this mathematical puzzle, where one really cool answer was a python script to brute force answers. Here's my take, which is essentially a translation of that to Java: ...
1k views

### Calculate Kth Row of Pascal's Triangle

Purpose Implement a solution that returns the values in the Nth row of Pascal's Triangle where N >= 0. Math First three rows ...
706 views

### Generating a maximal geometric progression of integers

I'm working on a program that generates a maximal geometric progression of at least 3 integers when given a number that the greatest value shouldn't exceed. My current code works, and it's quick(ish) ...
3k views

### Implementation of exp function in C using Taylor Series expansion

I am trying to write code to calcultate ex using: $$e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \cdots$$ This is the code I have, which works ...
70 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 ...
500 views

2k views

### Faster(?) factorial calculations

I saw this question, but was unable to answer because of my inexistant knowledge of Rust, so I decided to try and write an algorithm on my own and put it for review. There is the casual way to ...
646 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. ...
1k views

I'm working on a program to handle simplifying square roots (radicals). My biggest issue is, in order to stay precise, I can't have input any longer than 15 digits. Whenever a number is longer than 15 ...
362 views

### Project Euler #12 Java implementation

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, ...
100 views

### Baby Step Giant Step Discrete Log Solver

I've made a concurrent implementation of the Big Step Giant Step discrete log solver in Go. I'm pretty new to this branch of math, but it seems slow. Any way to speed it up or is this the limit of ...
287 views

### Project Euler #11 Java implementation

Project Euler 11 Solution in Java. The problem is at https://projecteuler.net/problem=11 package coderbyte; public class Java { ...
2k views

### Rational Polynomial Factoring method

I have written a class containing methods to factor a polynomial equation using the p over q method. The method returns a string that is the factored equation. Here is the class (can also be found ...
131 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 ...
733 views

### Simple number theory game

I just started JavaScript about a week ago. For my first project, my goal was to use my knowledge of basic JavaScript to create somewhat of a "thinking computer brain," so to speak. I wasn't focused ...
652 views

### Menu driven program to represent polynomials as a data structure using arrays

Write a menu-driven program to represent Polynomials as a data structure using arrays and write functions to add, subtract and multiply two polynomials; multiply a polynomial with a constant, find ...
230 views

### Project Euler, Challenge #12 in Swift

The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, ...
221 views

### Untouchable Numbers

I wrote this program in response to a CodeGolf challenge that required generating this sequence of "untouchable" numbers. This sequence can be found on OEIS as A005114. My initial implementation was ...
769 views

### Numerics for a game theory calculation using expected utility

I am trying to replicate Bruce B. de Mesquita's (BDM) results on political game theory for prediction. Based on where actors stand on issues, their capabilities, salience, BDM's method attempts to ...
111 views

### Decomposing a number as a sum of two products using tree recursion

Below is the problem taken from page6 here. The TAs want to print handouts for their students. However, for some unfathomable reason, both the printers are broken; the first printer only prints ...
152 views

### Vectorizing in Python [closed]

I have the following code: ...