# Questions tagged [numerical-methods]

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

166 questions
Filter by
Sorted by
Tagged with
453 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 ...
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. ...
170 views

### Approximating pi/4 using Wallis Product - SICP exercise 1.31

From SICP The sum procedure is only the simplest of a vast number of similar abstractions that can be captured as higher-order procedures. Write an analagous procedure called product that ...
1k views

862 views

### 1D shock tube problem written in Fortran

I have written a simple Euler solver for the 1D shock tube problem. Eventually, I plan to extend this code to solve the full 3D compressible Navier-Stokes equations. Therefore, I want to start with ...
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 ...
2k views

### Recursive calculation of second order derivative

I am writing code to do some numerical task using the routines of the book Numerical Recipes. One of my objectives is to calculate the second derivative of a function and have a routine that ...
423 views

### Monte Carlo simulation of amoeba population

I wrote a simple Python simulation to answer the "Amoeba" population question posed here: A population of amoebas starts with 1. After 1 period that amoeba can divide into 1, 2, 3, or 0 (it can die)...
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). ...
599 views

### Calculating pi by adding areas of thin rectangles

I wrote a small program for fun to try to prove Pi by taking a certain precision and radius and using it to calculate the area of the circle. My method should be giving me an area that is just ...
3k views

### Implementation of exp function in C using Taylor Series expansion

I am trying to write code to calcultate ex using: $$e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \cdots$$ This is the code I have, which works ...
153 views

### Square root calculation in Scheme (SICP Exercise 1.7)

I have done exercise 1.7 in SICP (calculate square root precision when change in guesses is under a certain value), but I am calling the change-in-precision function twice in each iteration, which ...
154 views

### atof revisited

In an answer to this question I mentioned best effort. Here I try to explain what I meant. Please keep in mind that the implementation is intentionally incomplete (missing features such as ...
94 views

### Integer square root

This essentially performs the same function as exact-integer-sqrt in math.numeric-tower. ...
617 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 ...
2k 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 ...
253 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 (...
508 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 ...
4k views

### Sqrt (square root) function

As an exercise in learning Scala, I implemented a square root function like this: ...
116 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 ...
3k views

### Pi by Monte-Carlo

I was inspired by this SO post to investigate a good Java8 way to calculate Pi based on simulation. I used a similar task to learn about parallel programming on both CUDA, and Intel Xeon Phi ...
231 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 ...
380 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 ...
195 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 ...
328 views

422 views

### Utility Method to find the Square root of a number

Utility to calculate the square root of a number. The method also accept an epsilon value, which controls the precision. The epsilon value could range to any number including zero. I am expecting a ...
1k views

### Poker Odds Calculation with Monte Carlo

I have created an Odds Calculator in Java. The program gives me the odds, but I want to make sure that they are correct. Maybe someone can tell me a calculator I can compare my results with or knows ...
562 views

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

Below is the solution: ...
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 ...