Questions tagged [numerical-methods]

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

Numerical methods include the study of algorithms that use numerical approximation (as opposed to general symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics). Numerical methods naturally find applications in all fields of science and engineering, and include implementations of many important aspects of computation including: solving ordinary and partial differential equations, numerical linear algebra, stochastic differential equations, Markov chains, and so forth.

Numerical methods use several approaches to calculate observables. For example, iterative methods that form successive approximations that converge to the exact solution only in a limit. A convergence test, often involving the residual, is specified in order to decide when a sufficiently accurate solution has (hopefully) been found. Examples include Newton's method, the bisection method, and Jacobi iteration. Another example is the use of discretization, a procedure that is used when continuous problems must sometimes be replaced by a discrete problem whose solution is known to approximate that of the continuous problem.

The field of numerical methods includes many sub-disciplines. Some of the major ones are:

  • Computing values of functions

  • Interpolation, extrapolation, and regression

  • Solving equations and systems of equations

  • Solving eigenvalue or singular value problems

  • Optimization

  • Evaluating integrals

  • Differential equations

2104 questions
7
votes
2 answers

Is fixed point math faster than floating point?

Years ago, in the early 1990's, I built graphics packages that optimized calculations based on fixed point arithmetic and pre-computed tables for cos, sin, and scaled equations for sqrt and log approximation using Newton's approximation methods.…
Aaron
  • 583
  • 1
  • 5
  • 12
7
votes
3 answers

Python Numerical Integration for Volume of Region

For a program, I need an algorithm to very quickly compute the volume of a solid. This shape is specified by a function that, given a point P(x,y,z), returns 1 if P is a point of the solid and 0 if P is not a point of the solid. I have tried using…
Lambda
  • 270
  • 2
  • 12
7
votes
1 answer

Fast Numerical Integration in Python

I have a program that involves computing a definite integral many times, and have been struggling to find a way to do so quickly. The integrals I need to solve are of the following form: I have to solve this integral for many different values of…
shadowprice
  • 617
  • 2
  • 7
  • 14
7
votes
2 answers

Matlab: Is it possible to numerically solve a system of ode's with a mixture of initial and terminal conditions?

I'm trying to use ode45 to solve a system of ODE's: [X,Y]= ode45(@sys,[0, T],y0); where, function dy = sys(t,y) dy(1) = f_1(y) dy(2) = f_2(y) dy(3) = f_3(y) end The problem is that the function ode45 requires that y0 be…
Vokram
  • 2,097
  • 4
  • 19
  • 27
7
votes
6 answers

Simpson's rule in Python

For a numerical methods class, I need to write a program to evaluate a definite integral with Simpson's composite rule. I already got this far (see below), but my answer is not correct. I am testing the program with f(x)=x, integrated over 0 to 1,…
Geraldine
  • 771
  • 3
  • 9
  • 23
7
votes
2 answers

What algorithms do FPUs use to compute transcendental functions?

What methods would a modern FPU use to compute transcendental functions? For example, Intel CPUs provide instructions such as FSIN, FCOS, FYL2X, etc. I am curious as to what algorithms would be used to actually implement these in hardware. My naïve…
NPE
  • 486,780
  • 108
  • 951
  • 1,012
6
votes
3 answers

Why does math.pow result in ValueError: math domain error?

Here is the code: exp = 1.79 def calc(t): return pow(t - 1, exp) The input values of t range from 0 to 1 (e.g. 0.04). This code throws a "math domain exception," but I'm not sure why. How can I solve this?
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
6
votes
7 answers

Comparing Root-finding (of a function) algorithms in Python

I would like to compare different methods of finding roots of functions in python (like Newton's methods or other simple calc based methods). I don't think I will have too much trouble writing the algorithms What would be a good way to make the…
Meo
  • 161
  • 1
  • 2
6
votes
4 answers

Limiting Number of Decimal Places in GWT?

In pure Java, I would normally have a function like the one below for limiting the number of decimal places to decimalCount for a given number value. However, according to the GWT docs, "GWT does not provide full emulation for the date and number…
Chris Cashwell
  • 22,308
  • 13
  • 63
  • 94
6
votes
3 answers

Solving a delay differential equation (DDE) system constrained to give nonnegative solutions

In MATLAB, ode45 has a parameter called NonNegative which constrains the solutions to be nonnegative. They even wrote a paper about how this method works and how it's not something as stupid as just setting y_i to 0 whenever it becomes negative, as…
6
votes
3 answers

What is the numerical method used in this implementation of IRR?

The ActiveState Recipes site has a function implementing Internal Rate of Return in Python: def irr(cashflows, iterations=100): """The IRR or Internal Rate of Return is the annualized effective compounded return rate which can be earned…
wk2752
  • 157
  • 1
  • 8
6
votes
3 answers

Summing a finite prefix of an infinite series

The number π can be calculated with the following infinite series sum: I want to define a Haskell function roughlyPI that, given a natural number k, calculates the series sum from 0 to the k value. Example: roughlyPi 1000 (or whatever) =>…
6
votes
1 answer

What is a typical use case of iterative solvers for linear systems in R?

I wonder if iterative solvers are a faster way to solve linear systems (non-sparse, symmetric, positive definite). I tried conjugate gradient methods from the R packages Rlinsolve and cPCG, but both seem to be not very accurate and slower compared…
Nairolf
  • 2,418
  • 20
  • 34
6
votes
1 answer

Woodbury identity for fast matrix inversion—slower than expected

The Woodbury matrix identity states that the inverse of a rank-k correction of some matrix can be computed by doing a rank-k correction to the inverse of the original matrix. If A is a p × p full rank matrix that is rank corrected by UCV where U is…
jds
  • 7,910
  • 11
  • 63
  • 101
6
votes
1 answer

SciPy SLSQP Claims Constraints Incompatible when Constraints are Compatible

I have a constrained optimization problem where the objective function is convex under some inequality constraints over the input vector. The only issue is that SLSQP claims that the constraints are incompatible, which is untrue. I've checked both…
QtizedQ
  • 311
  • 1
  • 10