All Questions
Tagged with mathematics python
202
questions
6
votes
3
answers
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 ...
5
votes
3
answers
909
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 ...
2
votes
1
answer
132
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:
...
4
votes
1
answer
63
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 ...
2
votes
2
answers
77
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 ...
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 ...
2
votes
1
answer
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 ...
1
vote
1
answer
261
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 ...
2
votes
1
answer
256
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 ...
5
votes
1
answer
207
views
Algorithm Optimization -- Automatic Dimensionality of PCA
I have implemented (rather, edited the implementation of) a technique to automatically detect the optimal number of dimensions for PCA, based off of this paper.
This was inspired by ...
7
votes
4
answers
28k
views
Algorithm to get an arbitrary perpendicular vector
Is there a more efficient/direct way to find an arbitrary perpendicular vector of another vector?
...
0
votes
1
answer
164
views
Project Euler problem 12 Python
I'm new to python and programming in general and I found Project Euler problems a good way to practice python. But my code is pretty slow. It seems to work, didn't wait long enough for the code to ...
5
votes
2
answers
3k
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 ...
3
votes
1
answer
109
views
Counting Divisors of a number with restrictions on the divisors
Given a fraction p/q, I want to count the number of unit fraction solutions
$$\frac{p}{q} = \frac{1}{u} + \frac{1}{v}$$
with some contraints
$$lower \le u \le upper$$
By manipulating the first ...
4
votes
2
answers
289
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 ...