Skip to main content

Questions tagged [numerical-methods]

Questions on numerical methods; methods for approximately solving various problems that often do not admit exact solutions. Such problems can be in various fields. Numerical methods provide a way to solve problems quickly and easily compared to analytic solutions.

Filter by
Sorted by
Tagged with
17 votes
1 answer
4k views

Could this approximation be made simpler ? Solve $n!=a^n 10^k$

I need to find the smallest value of $n$ such that $$\frac{a^n}{n!}\leq 10^{-k}$$ in which $a$ and $k$ are given (these can be large numbers). I set the problem as : solve for $n$ the equation $$n!...
Claude Leibovici's user avatar
36 votes
7 answers
29k views

Simple numerical methods for calculating the digits of $\pi$

Are there any simple methods for calculating the digits of $\pi$? Computers are able to calculate billions of digits, so there must be an algorithm for computing them. Is there a simple algorithm that ...
e.James's user avatar
  • 3,317
6 votes
5 answers
56k views

Solution of tanx = x?

How do I find the solutions of tanx = x upto any number of decimals? (Of course, there is the graphical method but it just helps in finding the approximate value.....
Pushpak Dagade's user avatar
85 votes
3 answers
72k views

What algorithm is used by computers to calculate logarithms?

I would like to know how logarithms are calculated by computers. The GNU C library, for example, uses a call to the fyl2x() assembler instruction, which means that ...
zar's user avatar
  • 4,602
7 votes
1 answer
2k views

What's the motivation for Runge-Kutta methods?

Recently, I have been taking a course on ODEs and learning Runge-Kutta methods. To be specific, the 4th order Runge-Kutta method on solving initial value problems. My instructor and the textbook told ...
Hgtcl's user avatar
  • 434
26 votes
5 answers
2k views

How could I improve this approximation?

In a computer application, I need to solve trillions of times an equation which can be reduced to $$f(x)=\sin(x)-a x=0$$ Newton methods (quadratic and higher orders) are used for the solution. ...
Claude Leibovici's user avatar
9 votes
3 answers
33k views

The mode of the Poisson Distribution

Lately, I am doing an investigation on Stirling's formula and its applications. So I thought I could use it to prove that the mode of the Poisson model is approximately equal to the mean. Of course, ...
Zugzwang14's user avatar
  • 1,799
4 votes
3 answers
7k views

Trapezoid rule error analysis

How can I prove that the max error of the trapezoid rule for the integral $\int_{a}^{b}{f(x)\, \mathrm{d}x} $ is: $$\Delta=-\frac{1}{12n^2}f''(c)(b-a)^3 \text{for } c \in (a,b) \ ?$$ I know that to ...
Pedro Amorim's user avatar
28 votes
7 answers
24k views

Algorithm to compute Gamma function

The question is simple. I would like to implement the Gamma function in my calculator written in C; however, I have not been able to find an easy way to programmatically compute an approximation to ...
houbysoft's user avatar
  • 553
4 votes
2 answers
2k views

Deriving the central Euler method and intuition

My professor (Dutch) asked us to determine, among other things, the truncation error of the central Euler method. First of all, this is probably not the correct term, since there are very few results ...
The Coding Wombat's user avatar
30 votes
2 answers
3k views

Calculating $\lim_{n\to\infty}\sqrt{n}\sin(\sin...(\sin(x)..)$

I was asked today by a friend to calculate a limit and I am having trouble with the question. Denote $\sin_{1}:=\sin$ and for $n>1$ define $\sin_{n}=\sin(\sin_{n-1})$. Calculate $\lim_{n\to\infty}\...
Belgi's user avatar
  • 23.2k
6 votes
6 answers
2k views

Calculating the nth super-root when n is greater than 2?

Tetration (literally "4th operator iteration") is iterated exponentiation, much like how exponents are iterated multiplying. For example, $2$^^$3$ is the same as $2^{2^2}$, which is $2^4$ or ...
Nirvana's user avatar
  • 447
38 votes
5 answers
144k views

Help with using the Runge-Kutta 4th order method on a system of 2 first order ODE's.

The original ODE I had was $$ \frac{d^2y}{dx^2}+\frac{dy}{dx}-6y=0$$ with $y(0)=3$ and $y'(0)=1$. Now I can solve this by hand and obtain that $y(1) = 14.82789927$. However I wish to use the 4th order ...
Michael's user avatar
  • 565
31 votes
3 answers
33k views

What is the relationship between cubic B-splines and cubic splines?

What is the relationship between cubic B-splines and cubic splines?
user105627's user avatar
4 votes
1 answer
713 views

Empirical error proof Runge-Kutta algorithm when not knowing exact solution

I'm implementing a RK solver for calculating the solution to the Lorenz system: \begin{equation} \begin{cases} x'(t) = \sigma(y-x) \\ y'(t) = rx-y-z \\ z'(t) = xy-bz \end{cases} \end{equation} The ...
Jorge 's user avatar
  • 51
2 votes
1 answer
4k views

Does fourth-order Runge-Kutta have an higher accuracy than the second-order one?

I'm writing a presentation on modelling fluid flow. We used Runge-Kutta second order to describe the flow as a numerical method. I just want verify that Runge-Kutta fourth order would be of a higher ...
Doug's user avatar
  • 77
2 votes
1 answer
8k views

Lax-Wendroff method for linear advection - Stability analysis

Question 1: Consider the wave equation $$ u_t + c(x) u_x = 0 , $$ where $x\in \Omega \subset \Bbb R$ and $c(x)$ is a function of $x$. (a) Show that the Lax-Wendroff scheme for this PDE is ...
italy's user avatar
  • 1,001
1 vote
2 answers
4k views

Euler's Method Global Error: How to calculate $C_1$ if $error = C_1 h$

My textbook claims that, for small step size $h$, Euler's method has a global error which is at most proportional to $h$ such that error $= C_1h$. It is then claimed that $C_1$ depends on the initial ...
The Pointer's user avatar
  • 4,302
54 votes
5 answers
59k views

Recommendations for Numerical Analysis texts?

I'm in a numerical analysis course right now and it's pretty rigorous but I'm enjoying it a lot. I took a lower level course before that was more oriented towards implementation of numerical methods, ...
asdfghjkl's user avatar
  • 1,345
48 votes
4 answers
41k views

Gradient descent with constraints

In order to find the local minima of a scalar function $p(x), x\in \mathbb{R}^3$, I know we can use the gradient descent method: $$x_{k+1}=x_k-\alpha_k \nabla_xp(x)$$ where $\alpha_k$ is the step size ...
Shiyu's user avatar
  • 5,238
37 votes
2 answers
45k views

Explanation and proof of the 4th order Runge-Kutta method

The 4th order Runge-Kutta (RK4) method is a numerical technique used to solve ordinary differential equations (ODEs) of the following form $$\frac{dy}{dx} = f(x,y), \qquad y(0)=y_0$$ It gives $y_{i+1}$...
gen's user avatar
  • 1,518
30 votes
7 answers
70k views

What is the difference between Finite Difference Methods, Finite Element Methods and Finite Volume Methods for solving PDEs?

Can you help me explain the basic difference between FDM, FEM and FVM? What is the best method and why? Advantage and disadvantage of them?
Anh-Thi DINH's user avatar
22 votes
6 answers
27k views

How to accurately calculate the error function $\operatorname{erf}(x)$ with a computer?

I am looking for an accurate algorithm to calculate the error function $$\operatorname{erf}(x)=\frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2}\ dt$$ I have tried using the following formula, (Handbook of ...
badp's user avatar
  • 1,266
12 votes
2 answers
2k views

What is the difference between Hensel lifting and the Newton-Raphson method?

So in the Newton-Raphson method to iteratively approximate a root of a real polynomial, we start with a crude approximation $x_0 \in \mathbb{R}$ for $f(x)=0$ where $f(x) \in \mathbb{R}[x]$. For the ...
BharatRam's user avatar
  • 2,517
4 votes
1 answer
3k views

Understanding Galerkin method of weighted residuals

I have a puzzlement regarding the Galerkin method of weighted residuals. The following is taken from the book A Finite Element Primer for Beginners, from chapter 1.1. If I have a one dimensional ...
Ohm's user avatar
  • 177
2 votes
2 answers
2k views

Convergence of cos, sin, tan functions

In Radian mode, continually pressing the $\cos$ function of a number causes the result to converge to $x=0.739085133$, a fixed point of $\cos(x)$. Repeating this behavior with the $\sin$ function ...
stevetronix's user avatar
1 vote
3 answers
11k views

How to calculate the square root of a number? [duplicate]

By searching I found few methods but all of them involve guessing which is not what I want. I need to know how to calculate the square root using a formula or something. In other words how does the ...
Mohammad's user avatar
  • 357
1 vote
1 answer
3k views

How to implement a Runge Kutta method (RK4) for a second order differential equation?

problem I have the following system of differential equations; $$ \frac{dx}{dt} = y \tag{1}\label{1}\\ $$ $$ \frac{dy}{dt} = -\lambda^2 x -A \tag{2} \label{2} $$ where $\lambda$ and $A$ values are ...
Savakar Rohan's user avatar
58 votes
12 answers
7k views

What is the fastest/most efficient algorithm for estimating Euler's Constant $\gamma$?

What is the fastest algorithm for estimating Euler's Constant $\gamma \approx0.57721$? Using the definition: $$\lim_{n\to\infty} \sum_{x=1}^{n}\frac{1}{x}-\log n=\gamma$$ I finally get $2$ decimal ...
Argon's user avatar
  • 25.4k
31 votes
6 answers
4k views

Why do I get a converging result when pressing cosine multiple times on a calculator? [duplicate]

I'm trying to comprehend the following: If I choose any starting value (e.g. 1) and keep clicking on cosine on the calculator (in radian mode), it gives me a result of about 0.739085...(I believe it's ...
sobosama's user avatar
  • 415
27 votes
6 answers
9k views

Detecting perfect squares faster than by extracting square root

Given the radix-$r$ representation of a integer $n$, and a small integer constant $k$, there is an $O(\log n)$ algorithm for detecting whether $n$ is a multiple of $k$, namely, division, which ...
MJD's user avatar
  • 65.7k
24 votes
7 answers
9k views

Minimum of the Gamma Function $\Gamma (x)$ for $x>0$. How to find $x_{\min}$?

The $\Gamma (x)$ function has just one minimum for $x>0$ . This result uses some properties of the gamma function: $\Gamma ^{\prime \prime }(x)>0$ and $\Gamma (x)>0$ for all $x>0$ $\Gamma ...
Américo Tavares's user avatar
10 votes
7 answers
10k views

An alternative way to calculate $\log(x)$

How can I replace the $\log(x)$ function by simple math operators like $+,-,\div$, and $\times$? I am writing a computer code and I must use $\log(x)$ in it. However, the technology I am using does ...
Nabeel's user avatar
  • 201
24 votes
3 answers
16k views

Numerically stable algorithm for solving the quadratic equation when $a$ is very small or $0$

Solving $a x^2 + bx +c=0$ for $x$ gives $$x = \frac{-b \pm \sqrt{b^2-4ac}}{2a} \text{, for } a \ne 0$$ But for $a = 0$ we get $$x=-\frac{c}{b}$$ How to implement a numerically stable algorithm ...
coproc's user avatar
  • 1,598
17 votes
2 answers
61k views

Convergence rate of Newton's method

Let $f(x)$ be a polynomial in one variable $x$ and let $\alpha$ be its $\delta$-multiple root ($\delta\ge2$). Show that in the Newton's $x_{k+1}=x_k-f(x_k)/f'(x_k)$, the rate of convergence to $\...
Jimmy Wang's user avatar
11 votes
3 answers
4k views

Is there a mean value theorem for higher order differences?

The standard mean value theorem tells us $\frac{f(x+h)-f(x)}{h} = f'(c)$ for some $c$ between $x$ and $x+h$. Rewriting this, we may see it as $\frac 1h\Delta_h f(x) = f'(c)$. This makes me wonder if ...
nullUser's user avatar
  • 28k
8 votes
10 answers
4k views

How can I find the value of $\ln( |x|)$ without using the calculator?

I want to know if there is a way to find for example $\ln(2)$, without using the calculator ? Thanks
user2849967's user avatar
4 votes
4 answers
2k views

Series of natural numbers which has all same digits

For which $x$ exists sum $1 + 2 + 3 + \ldots + n$, where $n > 3$, which has notation $xxx\ldots x$? In other words, I am looking for a sum of natural numbers which gives a result which has all ...
Lentan's user avatar
  • 67
2 votes
2 answers
13k views

Solving a set of equations with Newton-Raphson

I want to solve this set of equations with Newton-Raphson. Can anybody help me? $$ \cos(x_1)+\cos(x_2)+\cos(x_3)= \frac{3}{5} $$ $$ \cos(3x_1)+\cos(3x_2)+\cos(3x_3)=0 $$ $$ \cos(5x_1)+\cos(5x_2)+\cos(...
alireza's user avatar
  • 21
1 vote
3 answers
1k views

Numerical estimates for the convergence order of trapezoidal-like Runge-Kutta methods

I have to calculate approximations of the solution with the method $$ y^{n+1}=y^n+h \cdot [\rho \cdot f(t^n,y^n)+(1-\rho) \cdot f(t^{n+1},y^{n+1})] ,\quad n=0,\ldots,N-1 \\ y^0=y_0 $$ for various ...
evinda's user avatar
  • 7,863
29 votes
7 answers
31k views

Calculate logarithms by hand

I'm thinking of making a table of logarithms ranging from 100-999 with 5 significant digits. By pen and paper that is. I'm doing this old school. What first came to mind was to use $\log(ab) = \log(a)...
Eberhardt's user avatar
  • 433
22 votes
4 answers
45k views

How to compute the smallest eigenvalue using the power iteration algorithm?

I need to write a program which computes the largest and the smallest (in terms of absolute value) eigenvalues using both power iteration and inverse iteration. I can find them using the inverse ...
ivt's user avatar
  • 1,597
22 votes
1 answer
14k views

Variational formulation of Robin boundary value problem for Poisson equation in finite element methods

So I am confused about some details of obtaining a variational formulation specifically for Poisson's equation. I am in a Scientific Computing class and we just started discussing FEM for Poisson's ...
Fractal20's user avatar
  • 1,509
18 votes
3 answers
6k views

How to evaluate Riemann Zeta function

How do I evaluate this function for given $s$? $$\zeta(s) = \sum_{n=1}^\infty \frac1{n^s} = \frac{1}{1^s} + \frac{1}{2^s} + \frac{1}{3^s} + \cdots$$
Pratik Deoghare's user avatar
12 votes
2 answers
10k views

Derivative of $f(x,y)$ with respect to another function of two variables $k(x,y)$

Suppose that we have a function $f(x,y)$ of two variables: $$f(x,y) = g(x) + h(y) + 5(x-y) = x^2 + y^2 + 5(x-y)$$ where $g(x) = x^2$ and $h(y) = y^2$ are also functions of $x$ and $y$, respectively. ...
Nicholas Kinar's user avatar
11 votes
2 answers
22k views

Explanation of Lagrange Interpolating Polynomial

Can anybody explain to me what Lagrange Interpolating Polynomial is with examples? I know the formula but it doesn't seem intuitive to me.
user avatar
9 votes
2 answers
20k views

When does Newton-Raphson Converge/Diverge?

Is there an analytical way to know an interval where all points when used in Newton-Raphson will converge/diverge? I am aware that Newton-Raphson is a special case of fixed point iteration, where: $...
Anonymous Gal's user avatar
6 votes
1 answer
16k views

Rate of convergence of modified Newton's method for multiple roots

I've got a problem with a modified Newton's method. We've got a function $f \in C^{(k+1)}$ and $r$ which is it's multiple root of multiciplity $k$. Also $f^{(k)}(r) \neq 0$ and $f'(x) \neq 0 $ in the ...
Anne's user avatar
  • 1,557
3 votes
4 answers
4k views

Combining error terms in Simpson's rule

My numerical analysis textbook (Burden and Faires) derives Simpson's rule as $$\begin{align} \int_{x_0}^{x_2}f(x)\,dx&=2hf(x_1)+\frac{h^3}{3}f''(x_1)+\frac{h^5}{60}f^{(4)}(\xi_1) \\&=\frac{h}{...
Peter Woolfitt's user avatar
3 votes
3 answers
2k views

Exponential curve fit

I want to fit a curve of the form $y = ab^x +c$ where a, b and c are constant whereby i have a data of points $(x_i, y_i)$ I can reduced my primary equation into a form $log(y - c) = log(a) + xlog(b)...
Toye_Brainz's user avatar

1
2 3 4 5
25