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
6
votes
2answers
7k views

Newton's method to solve cubic equations

I have used the Newton-Raphson method to solve Cubic equations of the form $$ax^3+bx^2+cx+d=0$$ by first iteratively finding one solution, and then reducing the polynomial to a quadratic $$a1*x^2+b1*x+...
4
votes
2answers
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 ...
7
votes
1answer
3k views

Python class that implements the Newton method

Here is a python function I wrote to implement the Newton method for optimization for the case where you are trying to optimize a function that takes a vector input and gives a scalar output. I use ...
11
votes
2answers
4k views

Sqrt (square root) function

As an exercise in learning Scala, I implemented a square root function like this: ...
3
votes
3answers
3k views

Approximating sines and cosines using up to five terms of the Taylor series

I have one programming question: The sine and cosine of \$x\$ can be computed as follows: \$\sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \frac{x^9}{9!} - \dots\$ ...
3
votes
2answers
2k views

Square root approximations, implemented two ways

Which version is more efficient in calculating the square root ? There are 2 versions I have written to calculate square root programatically. Note reqs strictly state not using library functions ? ...
3
votes
1answer
2k views

Solving an ODE numerically with forward Euler method

The goal is to solve an ODE numerically with forward Euler method. The programs works well (numerical solution really near analytical one). The problem I see is that the Euler scheme don't jump to ...
4
votes
1answer
865 views

Gees - GPL Euler equation solver

As a little helper I recently had to write a code that solves the 1-D Euler equations. As it serves my purpose well I though others could make use of it as well. The homepage of the code can be found ...
2
votes
1answer
1k views

Integral using Simpson's Rule

As an answer to this problem: Exercise 1.29 Simpson's Rule is a more accurate method of numerical integration than the method illustrated above. Using Simpson's Rule, the integral of a ...
3
votes
2answers
2k views

Use Newton's Method to compute sqrt(x)

Given the following task: Use Newton's method to compute the square root of a number. Newton's method involves successive approximation. You start with a guess, and then continue averaging ...