# Questions tagged [numerical-methods]

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

208 questions
Filter by
Sorted by
Tagged with
60 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 ...
• 219
1 vote
42 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? ...
• 153
1 vote
79 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,500
1 vote
99 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! ...
66 views

• 133
130 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 ...
59 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
99 views

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
575 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. ...
• 353
1 vote
94 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
86 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. ...
• 353
1 vote
147 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
104 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
194 views

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 ...
79 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 ...
• 565
3k 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,705
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 ...
94 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
58 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 ...
429 views

### Calculate the Euler-Mascheroni constant without the math module

The below code was written to generate γ, for educational purposes. Single threaded, no functional zeroes required, no binary splitting(which can all be used to compute competitively like y-cruncher, ...
5k views

### Python π = 1 + (1/2) + (1/3) + (1/4) - (1/5) + (1/6) + (1/7) + (1/8) + (1/9) - (1/10) ...1748 Euler

I wrote this code to show that my reddit post is correct. After the first two terms, the signs are determined as follows: If the denominator is a prime of the form 4m − 1, the sign is positive; if ...
1k views

### Trapezoidal rule for set of data

Here is the question from the book of Mark Newman-Computational Physics Exc 5.1 a) Read in the data and, using the trapezoidal rule, calculate from them the approximate distance traveled by the ...
• 509
334 views

### Evaluating π using Monte Carlo methods - Serial vs OMP

I wrote this simple code for evaluating the π using Monte Carlo method. This is the serial version: ...
• 227