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

5 votes
3 answers
473 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 ...
Rhys Bradshaw's user avatar
0 votes
1 answer
38 views

reassigning a variable with a divide operator gives nan in program when zero is entered [closed]

Please keep in mind that I am very new to programming. I was given a the following question as my assignment in C++: Write a program that computes the value of an nth degree polynomial $$A(x)=a_0+...
user284187's user avatar
3 votes
0 answers
87 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
4 votes
1 answer
61 views

Array Math to Calculate Ice Thickness -- Need Help Simplifying

I posted this on Stack but since it's working code, it was suggested I post it here. I wrote this code to calculate ice thickness using the following equation from Stephenson, 2011. It's a daily ...
emmahaggerty's user avatar
2 votes
1 answer
92 views

Efficiently generate a random position inside an outer rectangle but outside an inner rectangle

It should be a uniform distribution (ie: every point is equally as likely). I also don't want to use the simple solution of: "in a loop check to see if the current generated point is within the ...
Ryan Peschel's user avatar
2 votes
2 answers
74 views

Can I make my percolation in python function more efficient?

We've been tasked with finding out how many randomly distributed discs with radius = 1 it takes to form a chain of discs from the left side to the other of a square with side length = sqrt(n), and ...
Emilio's user avatar
  • 23
2 votes
1 answer
131 views

Multithreaded sparse linear solver in Python

I would like to know if there are any multithreaded sparse linear solvers for LU decomposed sparse matrices. I want to increase the solving speed of a system like: ...
aqw's user avatar
  • 29
6 votes
4 answers
436 views

Optimal Solution for the Four Divisors Problem on LeetCode

I recently encountered the Four Divisors problem on LeetCode and managed to achieve a 100% beat rate with my solution. I'd like to share it with you all and gather feedback on its effectiveness and ...
BrunoBarreto's user avatar
-1 votes
1 answer
77 views

Sine function guessing cognitive app

Please help with improving this application. It is a guessing game, for learning the values of the sine function, and boosting brain power in the process. ...
Attila Vajda's user avatar
2 votes
1 answer
110 views

Combinations of elements in array

I wrote this code to get all possible arrangements for an array containing 3 elements: ...
John's user avatar
  • 49
3 votes
1 answer
206 views

Taking array of numbers, having a max weight, and distributing excess weight to ln max weight numbers

The goal is to take an array of numbers, have a max weight (saying 40%), and if any number above the max_num = sum * weight is present, remove the excess and ...
Bob Linux's user avatar
  • 131
7 votes
4 answers
2k views

A simple Vector library in C

I recently started working on my own vector library for a project and I thought it would be a good idea to get some insight on the code that I have written so far. It's very simple as I'm new to C. ...
cguybtw's user avatar
  • 79
4 votes
1 answer
87 views

Rating math quality via unit-in-the-last-place (ULP) differences

Goal Please review code in fp.h and fp.c to index and compare floating point values. Background C code can perform floating ...
chux - Reinstate Monica's user avatar
1 vote
1 answer
259 views

Implementing Preconditioned conjugate gradient

I have implemented the Preconditioned Conjugate Gradient (PCG) method for solving a system of linear equations in Python and I would appreciate it if someone could verify its correctness since I am ...
blov's user avatar
  • 29
2 votes
1 answer
255 views

Python integer optimization with PuLP involving polynomials that I think can be faster

I have a problem where we are given multivariate polynomials in variables like y_i and z_j and the goal is to express them as sums of products of terms of the form y_i-z_j with nonnegative integer ...
Matt Samuel's user avatar

15 30 50 per page
1
2 3 4 5
42