The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [numerical-methods]

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

Filter by
Sorted by
Tagged with
2
votes
0answers
443 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
190 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
144 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}{...
2
votes
0answers
89 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
104 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. ...
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
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 ...
1
vote
2answers
518 views

Bisection method solver

I have a simple bisection method solver that I was told it has some problems in design and I need my code to be reviewed, so I was hoping for someone to give me guideline on how to improve my code. ...
1
vote
1answer
41 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 ...
1
vote
1answer
76 views

Runge-Kutta Fourth Order in C

I've found that the Runge-Kutta (4th order) calculations in some software I wrote are the bottleneck. Is there anything obvious I can do to improve efficiency here? Note that Compiler optimizations ...
1
vote
2answers
683 views

Bisection method for finding the root of a function

For those who aren't familiar with the bisection method for finding the root of a function (i.e. finding where \$f(x) = 0\$) the basic idea is: Take a function \$f(x)\$ and an interval \$[a,b]\$ If \$...
1
vote
2answers
568 views

Functional abstraction to find nth root of a number - Newton raphson

Below is the solution: ...
1
vote
0answers
206 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
87 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 ...
0
votes
1answer
82 views

A quartic polynomial in four variables, for numerical integration

About half year ago, I derived a integral of a piecewise polynomial, which was a complex formula. Below is one of that formula: Obviously, the above formula has relationship with four varibles \$u_i,\...
0
votes
1answer
118 views

Summation for π [closed]

I was going through my Java book's exercise solutions and comparing and incorporating the author's techniques into my repertoire. Most of the time, my approach is identical to the author's. When it ...
0
votes
1answer
41 views

A simple clusterness measure of data in one dimension using Java

Problem definition Given \$X = (x_1, \dots, x_n)\$ such that \$x_1 \leq x_2 \leq \dots \leq x_n \$. Let \$x_{\min} = \min X = x_1\$, \$x_{\max} = \max X = x_n\$ and \$r = x_{\max} - x_{\min}\$. Also, ...