Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [numerical-methods]

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

8
votes
0answers
141 views

Root finding and integration

I am trying to implement the modified Next Reaction Method with time varying propensities as mentioned in sections IV and V of this paper. At one step in the process this expression must be evaluated: ...
6
votes
0answers
80 views

Metropolis Monte Carlo Sampler in Rust

the following is an implementation of the standard Metropolis Hastings Monte Carlo sampler. You can read more about it here. At the end I am going to give you a link to the Rust playground, so you ...
5
votes
0answers
81 views

Implementing numerical integration in Python

I have this Python code that implements a rectangular numerical integration. It evaluates the (K-1)-dimensional integral for arbitrary integer \$K \geq 1\$ $$\int_{u_K = 0}^{\gamma}\int_{u_{K-1} = 0}^...
5
votes
0answers
271 views

Quasi-Random Number Generators

I would like to communicate a piece of code which I hope will soon be broadly useful for everyone who programs in C++: A set of quasi-random number generators proposed for addition to boost.random. To ...
5
votes
0answers
2k views

Linear Interpolation C++

I have to write a collection of methods for performing linear, bilinear and trilinear interpolation. I have also to write some tests to show that interpolation is exact for polynomials (which should ...
4
votes
0answers
58 views

Bisection and Newton's method for finding a root of an equation

In an attempt to learn Rust, I've written up implementations of the bisection method and Newton's method for finding roots of an equation. Both methods come in two variants: the first one searches for ...
4
votes
0answers
139 views

Verilog implementation of trapezoidal integration method

Any and all comments are welcome in this review. Problem I've been doing a lot with numerical integration methods recently and have mostly been programming in Python. But...speedups! And FPGAs are ...
4
votes
0answers
144 views

Numerical integration with Numba

I'm a bit new to working with Numba, but I got the gist of it. I wonder if there any more advanced tricks to make four nested for loops even faster that what I have ...
3
votes
0answers
256 views

Complex multiplication and integration with CUDA

I want to perform multiplication on two vectors and integrate it in a vector called acc_y. The acc_y variable will update over ...
3
votes
0answers
1k views

Numerical Differentiation by Finite Differences

Numerical differentiation is known to be ill-conditioned unless using a Chebyshev series, but this requires global information about the function and a priori knowledge of a compact domain on which ...
3
votes
0answers
98 views

Simple finite difference employing Maccormack technique

I am relatively new to programming and while I am fairly comfortable with the math, I cannot say with confidence that I feel the same way with programming. Anyway here is a simple finite difference ...
3
votes
0answers
133 views

Calculating Pi to a tolerance

I'm taking my first steps in the Scala world, though I'm not wholly unfamiliar with functional style. Apparently one way of calculating Pi is to sum the terms of the infinite series: $$4 * (\frac{1}{...
3
votes
0answers
100 views

Computing nth roots of a number - SICP exercise 1.45

From SICP Exercise 1.45: We saw in 1.3.3 that attempting to compute square roots by naively finding a fixed point of x/y does not converge, and that this can be fixed by average damping. ...
3
votes
0answers
64 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 ...
3
votes
0answers
106 views

Volatility updating with Heston-Nandi model

I'm trying to program a volatility updating rule using iteration. I start with the well-known Heston-Nandi model where the returns dynamics are: $$ \left\{ \begin{array}{rcl} R_{t+1} &=&...
2
votes
0answers
361 views

Computing the square root of a number using binary search

This is implemented in MIPS assembly. I've hard-coded the initial guess, as I haven't figured out how to allow the user to input a negative or non-negative integer to then display the result back to ...
2
votes
0answers
166 views

Estimate π using an infinite series

Looking for style and speed review π PI An estimate is \$\frac{4}{1} - \frac{4}{3} + \frac{4}{5} - \frac{4}{7} + \frac{4}{9} - \frac{4}{11} + \frac{4}{13} - \frac{4}{15} + \frac{4}{17} \$... The ...
2
votes
0answers
88 views

Multithreaded Monte Carlo pi approximation with own pseudorandom number generator - follow up

This is a follow up of the question I posted previously here. I made some changes, based in the answer by MikeMB, making use of asynchronous calls (with std::async ...
2
votes
0answers
68 views

Numerical differentiation using the y-intercept

I have a routine for determining the derivative of a function using the y-intercept (B) to infer the finite difference step (h). ...
2
votes
0answers
30 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 ...
1
vote
0answers
194 views

Numerical differentiation on sphere with Python

I have ported from Fortran to Python an algorithm that calculates the numerical derivative along the x direction (longitudinal) of a scalar function s on a ...
1
vote
0answers
80 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 ...