# Questions tagged [numerical-methods]

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

181 questions
Filter by
Sorted by
Tagged with
155 views

567 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 ...
1k 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 ...
779 views

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

Here's the code: ...
743 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, ...
287 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)$$ ...
399 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

675 views

### Linear shooting method to solve a B.V.P

I have wrote a code to approximate the solution of a boundary value problem: x'' = p(t)x'(t)+q(t)x(t)+r(t) x(b) = beta in [a,b] by using Runge-Kutta method ...
3k views

### Double integral solver in TI-84

Here's a program I made for estimating a double integral over a general region. It's pretty accurate, but it's VERY, VERY slow. (Getting an accurate enough result takes about 30 seconds) Here's the ...
291 views

### Approximating π via Monte Carlo simulation

Inspired by a tweet linked to me by a friend and a Haskell implementation by her for the same problem, I decided to try my hand at approximating the value of π using everything in the Haskell standard ...
1k views

### Computing integer square roots in Java - follow-up

(See the previous iteration.) My two previous methods for computing the integer square root of a number $N$ ran in the $\mathcal{O}(\sqrt{N})$ worst case time. Now I have added a method (...
573 views

### Gamma function in Rust

The gamma function is one of a couple nice continuous extensions to the traditional factorial function. I used this Python program as a reference, which in turn, uses this Ada program. As the Ada ...
124 views

### Reinventing the Math Functions

Just for practice in the mathematical side of programming, I decided to rewrite the math functions, with the addition of the root() function, which the Math library ...
403 views

### Newton's Method Polynomial solver in Ruby

I am learning Ruby programming from "Learn Ruby the Hard way" and I am doing the "Ruby koans". I have heard a little bit about "Idiomatic" Ruby but I don't know much about it. How can I make it more ...
217 views

### Simple neural-network simulation in C++ (Round 4)

You may want to take a look at Rounds 1, 2, and 3, though that isn't necessary for understanding what's below. The major change since Round 3 is that my code is much cleaner and I'm including ...
254 views

### Simple neural-network simulation in C++ (Round 3)

As I mentioned at the end of my Round 2 answer, I've needed to expand my code in order to produce faithfully the data needed for Figure 1 of this paper. Unfortunately, the updates have made my script ...
225 views

### Simple neural-network simulation in C++ (Round 2)

Intro Yesterday I posted this question. Since then, I've updated my code to incorporate these suggestions. I've also removed the dependence on C++11. Finally, I've made the following changes that ...
2k views

### Simple neural-network simulation in C++

The C++ code below simulates the timecourse of the membrane potential (V) of a population of 128 leaky integrate-and-fire ...
93 views

### Golden Section Search in Lisp

I implemented the golden section search algorithm recursively in Lisp. My code is: ...
65 views

### Decorator for setting up bracketing rootfinding functions

I'm looking for comments on the use of decorators for the following problem (validating initial guesses for bracketing rootfinding methods), as well as any other comments you might have on the design ...
6k views

### Implementation of Brent's Algorithm to find roots of a polynomial

I made a program that contains a root-finding algorithm for polynomials as a function and contains 3 test polynomials. The algorithm is Brent's method and is based entirely off the pseudocode from ...
1k views

### Root-finding by iterated bisection

Both of the following code give the same result. But I'm not sure where should I put the raise statement. ...
32 views

### Iterative procedure to get 3D coordinates from distance constraints

Imagine you have a series of n points randomly generated in a box in 3D space. You also have a list of distance bounds, e.g. points 5 and 3 should be between 1.0 and 2.0 Angstroms apart. There are ...
1k views

### Buffon's Needle experiment

I was working on a program that simulates the Buffon's Needle experiment. If anyone is not familiar with it, a Wiki link is provided - Buffons's Needle The point of Buffon's experiment is to find ...
201 views

### Monte Carlo Pi (MASM)

I'm currently trying to brush up on my assembly skills and, being at the FPU section of the tutorial, I implemented a very basic version of a Monte-Carlo-Algorithm to compute pi. I deliberately use ...
99 views

### Calculating e^x by math.h and by own means

For this program, the user needs to enter an exponent and the program will calculate $e$ (Euler's number) to the power of the exponent the user inputs. This is done by two ways: By the math.h ...