# Questions tagged [numerical-methods]

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

160 questions
Filter by
Sorted by
Tagged with
325 views

### Calculating pi to 7 significant figures without using Math.PI

I need to calculate pi to 7 significant figures in Java—without using Math.PI. Here is the code I came up with to do that: ...
321 views

### Monte Carlo Simulation of P-Value

I'm testing Python 3 code to perform a Monte Carlo simulation based on the result of an statistical test. I currently have the result of the statistical test in a pandas dataframe, like this. ...
872 views

### AVX assembly for fast atan2 approximation

I'm writing a fast atan2 approximation, and would like some feedback on my assembly in particular. I know one of the first things is that people will question why I'm using inline assembly instead of ...
244 views

### SICP - exercise 1.7 better end test for square root approximation

Here is exercise 1.7 from SICP: Exercise 1.7 The good-enough? test used in computing square roots will not be very effective for finding the square roots ...
942 views

### Runge-Kutta fourth order integration

I have written a simple code for Runge-Kutta fourth order integration to solve a system of ordinary differential equations and parallelized it using OpenMP. I don't know if it is the best we can do ...
2k views

### Monte Carlo simulation to approximate the value of PI

This is a C++ implementation of a simple Monte Carlo simulation to approximate the value of pi. The program uses the standard library Mersenne twister engine to generate two random numbers between -1....
185 views

### Calculate the closest point to many hyperbolic paraboloids

In this question I asked for a way to compute the closest projected point to a hyperbolic paraboloid using python. Using the iterative approximation answer, I'm able to use the code below to ...
132 views

### Area under curve

The following code is a solution to a Hackerrank problem in Haskell. Given a list of polynomial coeficients a and exponents b, ...
619 views

### Runge Kutta ODE Solver

An ordinary differential equation (ODE) is an equation of the kind $$u'(x)=f(t,u(x)).$$ My program attempts to solve such ODE's numerically through explicit Runge Kutta methods. Instead of writing a ...
3k views

### ODE45 solver implementation in Python

I have a project where I need ODE solver without dependencies to libraries like Scipy. I decide to implement ODE45. According to tutorials from internet and from what I remember from classes I ...
85 views

### Scala Functional Programming ODE Solver

I'm new to both Scala and Functional programming. I've been doing the excellent course Functional Programming Principles in Scala on Coursera and I want to test out what I've learned. I've written a ...
48 views

### Integral implemented using a trapezoidal Riemann sum

I tried to make this a general purpose integral function but I want to know if it's efficient and idiomatic Rust. ...
74 views

2k views

### Multivariable Gradient Descent in Numpy

Just recently started learning ML, first I've gone through the notes of Ng's Coursera stuff. While I have nothing against Octave, I'm trying to solve exercises in Python. It's my beginning with that ...
301 views

### Arbitrary Precision nth Principal Root in Java - MathCore #1

This post is the first in the MathCore series. The next post is here: Arbitrary precision π (Circular Constant) in Java - MathCore #2 Disclaimer My project is too big to be reviewed in a single ...
139 views

437 views

### C++ HyperLogLog Implementation

I'm a scientific C programmer moving my way over to using Modern C++. I found myself needing a HyperLogLog implementation, and I wanted to use this for practice. I plan to move a number of these ...
948 views

### Approximating Pi, Monte Carlo integration

I wrote some code that uses Monte Carlo Integration to Approximate pi in Java and Akka. The tl;dr explanation is you can imagine throwing darts at a square with a circle inscribed inside of it. You ...
662 views

### Calculating the Riemann Zeta Function for x>2 real numbers

Here's the code: ...
532 views

### Monte-Carlo method to estimate Pi runs slower in multiple threads, than in single thread

I'm learning Scala, and I wrote a program to estimate the value of Pi. When I'm using multiple threads, it takes 5-6 times longer to calculate the same iterations. I wrote a similar program in Java, ...
267 views

### Calculation of elasticity for non-linear curve

I've written this code to calculate the elasticity for econometric analysis. Basically, this algorithm estimate the function: $$\epsilon(x) = \frac{x}{f(x)}\ f'(x)$$ ...
356 views

### Generate dictionary of points on n-sphere

This is a long-shot, but my question is to simply optimize this particular function in some code I have written: ...
64 views

### Evaluation of e^x with series expansion

My code calculates $e^x$ with series expansion. Is there any way to make it shorter and cleaner? ...
2k views

### Evaluating a series of Legendre polynomials

The following function represents the electrostatic potential, in spherical coordinates, due to a ring of charge $q=1$ and radius $R=1$, placed in the plane $x$-$y$: \phi(r,\theta) = \sum_{...
2k views

### Calculate the arclength

I am trying to estimate a good approximation for the arclength of the curve $y = \sqrt{1-x^2}$ for $x \in [0, 1]$. I did this using a Bezièr curve, and made it so that the area under the two ...