# Questions tagged [numerical-methods]

Algorithms which solve mathematical problems by means of numerical approximation (as opposed to symbolic computation).

211 questions
Filter by
Sorted by
Tagged with
108 views

### Integration loop over multiple doping and temperature levels

I want to perform some calculations on a large dataset. The code can be found below, where I want to calculate the values for 'results_nr' over a large loop (1000 x 910) values. Can you help me out ...
• 21
121 views

### Parallelise numerical integration with OpenMP in C++

I would like to parallelise with OpenMP a one-dimensional integral using the integrate() function implemented in the Boost library. I found a rather obscure ...
• 289
1k views

### A probability distribution function, to be called repeatedly during numerical integration

I am trying to speed up as much a possible this function in C++. As I explained in another post, Implementing multidimensional integral for a custom function in C++, this function will be used inside ...
• 289
112 views

### Calculating square roots using binary search

I'm trying to find the square root of a number (num) using binary search in Rust. I'm new to Rust, but I've done quite a bit of programming in other languages, ...
• 121
173 views

### Implementing multidimensional integral for a custom function in C++

I am not an expert with C++, but I am trying to implement a 4-dimensional integral using GSL numerical integration approach. The code below shows the whole algorithm. Although it seems correct what I ...
• 289
1 vote
54 views

### Calculate the value of PI in JS

I have created an algorithm which calculates the value of PI in JavaScript. Can this algorithm to be improved? ...
• 155
1 vote
92 views

### Three efficient JavaScript functions that converge to pi extremely fast

I am learning JavaScript and decided to translate my Python scripts into JavaScript. Approximations of π are extremely popular programming challenges and I am sure they must be a staple of the ...
• 1,686
1 vote
104 views

### Calculating sine and cosine

Are there any thing that I have to consider to improve the following code in either performance and others? Any comments and suggestions are welcome! ...
96 views

• 133
170 views

### Linear Interpolation for sorted arrays

I have made a linear interpolation functions as a side project of mine. It assumes everything is sorted before hand - x and f(x) are the same length. I would like to ask for: general recommendations ...
63 views

### Newton Raphson and polynomials in C

I have the following code, that defines: A polynomial struct with some useful functions. The newton Raphson algorithm for polynomials. and calculates sqrt(2). ...
• 842
1 vote
121 views

### Numerical Double Integration using numba and scipy

Please see the following code. I am using it to calculate the double integration. Please help me to improve the code. ...
4k views

### pure Python Bézier curve implementation

I came up with this recursive pure-Python implementation of De Casteljau's algorithm for computing points on a Bézier curve: ...
• 179
664 views

### Simpson's method for numerically computing the integration of a function

I have implemented the Simpson's rule for numerical integration. Check this video for the implemented function. ...
• 415
1 vote
214 views

### What would be the computationally faster way to implement this 2D numerical integration?

I am interested in doing a 2D numerical integration. Right now I am using the scipy.integrate.dblquad but it is very slow. Please see the code below. My need is to ...
1 vote
145 views

### Implementation of Newton's method of finding root of a function

The following is an implementation of Newton's method of finding root of a function. ...
• 415
1 vote
188 views

### Simple definite integral calculator

I made this code to compute definite integrals in Processing. It works by getting the rectangle between the maximum value between the previous function value and the current function value, and then I ...
• 119
111 views

### Fortran 90 / openmp heat transfer simulation optimization

I'm a newbie playing around with Fortran 90 and openmp and wrote the code below (a simple 2D heat transfer simulation) for testing purposes. So far I don't see any speedup by using openmp / parallel ...
• 141
1 vote
223 views

### Get the best rational approximations for any real number in builtin Python

Best rational approximations is a technical term and not subjective. The best rational approximations are the convergents of a value plus it's semi convergents that are closer to the original value ...
81 views

### Estimate area of cropped circle with Monte Carlo

I looking around and not finding anything, I developed a simple function for estimating the area of a possibly cropped circle inside a frame. It uses a very basic MC implementation. It is pretty fast ...
• 575
4k views

### IEEE 754 square root with Newton-Raphson

I have an implementation of the sqrt function that uses a combination of IEEE 754, packed bitfields, and the Newton-Raphson algorithm: ...
• 1,704
1k views

### Mean π: Archimedes vs. Gauss - π computation through generalized means

I've written this simplified code to compute Pi for educational/demonstration purposes. These methods are based upon the generalized means: see a presentation on Pi and the AGM. Archimedes' method ...
101 views

### Arbitrary precision Euler-Mascheroni constant via a Brent-McMillan algorithm with no math module

Utilizing the below relation, I am able to compute the Euler constant to great precision on a single thread quickly and simply. My process is to compute the natural log via the AGM(utilizing Pi an ...
1 vote
60 views

### Euler-Mascheroni Single Thread Speed Improvements

The below code was written to generate γ, for educational purposes. My general methodology is as follows: Compute Gamma via the accepted answer's algorithm here. In order to do this I need to ...