Numerical analysis is the study of algorithms that use numerical approximation, as opposed to general symbolic manipulations.
Questions tagged [numerical-analysis]
263 questions
58
votes
3 answers
BigDecimal multiply by zero
I am performing a simple multiplication with BigDecimal and I have found some strange behaviour when multiplying by zero (multiplying by zero is correct in this use-case).
Basic maths tells me that anything multiplied by zero will equal zero…

Richard
- 9,972
- 4
- 26
- 32
37
votes
5 answers
Signal processing library in Java?
I'd like to compute power spectral density of time series; do some bandpass, lowpass, and highpass filtering; maybe some other basic stuff.
Is there a nice open-source Java library to do this?
I've hunted a bit without success (e.g., Googling "power…

dfrankow
- 20,191
- 41
- 152
- 214
22
votes
9 answers
Integer cube root
I'm looking for fast code for 64-bit (unsigned) cube roots. (I'm using C and compiling with gcc, but I imagine most of the work required will be language- and compiler-agnostic.) I will denote by ulong a 64-bit unisgned integer.
Given an input n I…

Charles
- 11,269
- 13
- 67
- 105
20
votes
2 answers
What algorithm is R using to calculate mean?
I am curious to know what algorithm R's mean function uses. Is there some reference to the numerical properties of this algorithm?
I found the following C code in summary.c:do_summary():
case REALSXP:
PROTECT(ans = allocVector(REALSXP, 1));
for (i =…

Zach
- 2,445
- 3
- 20
- 25
16
votes
1 answer
Emulating fixed precision in python
For a university course in numerical analysis we are transitioning from Maple to a combination of Numpy and Sympy for various illustrations of the course material. This is because the students already learn Python the semester before.
One of the…

JKaerts
- 173
- 4
16
votes
3 answers
Why is Matlab's inv slow and inaccurate?
I read at a few places (in the doc and in this blog post : http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/ ) that the use of inv in Matlab is not recommended because it is slow and inaccurate.
I am trying to find the reason of this…

simark
- 490
- 3
- 9
15
votes
4 answers
Why is the output of inv() and pinv() not equal in Matlab and Octave?
I have noticed that if A is a NxN matrix and it has the inverse matrix. But what the inv() and pinv() function output is different.
- My environment is Win7x64 SP1, Matlab R2012a, Cygwin Octave 3.6.4, FreeMat 4.2
Have a look at the examples from…

myme5261314
- 462
- 1
- 5
- 14
14
votes
2 answers
Which floating-point comparison is more accurate, and why?
I'm experimenting with different implementations of the Newton method for calculating square roots. One important decision is when to terminate the algorithm.
Obviously it won't do to use the absolute difference between y*y and x where y is the…

lindelof
- 34,556
- 31
- 99
- 140
13
votes
1 answer
Binary GCD Algorithm vs. Euclid's Algorithm on modern computers
http://en.wikipedia.org/wiki/Binary_GCD_algorithm
This Wikipedia entry has a very dissatisfying implication: the Binary GCD algorithm was at one time as much as 60% more efficient than the standard Euclid Algorithm, but as late as 1998 Knuth…

Jonathan Schneider
- 26,852
- 13
- 75
- 99
11
votes
2 answers
Solving equation using bisection method
Is there a bisection method I can find online, specifically for python?
For example, given these equations how can I solve them using the bisection method?
x^3 = 9
3 * x^3 + x^2 = x + 5
cos^2x + 6 = x

bbnn
- 3,505
- 10
- 50
- 68
11
votes
6 answers
How do I generate points that match a histogram?
I am working on a simulation system. I will soon have experimental data (histograms) for the real-world distribution of values for several simulation inputs.
When the simulation runs, I would like to be able to produce random values that match…

AShelly
- 34,686
- 15
- 91
- 152
9
votes
2 answers
Solve this equation with fixed point iteration
How can I solve this equation
x3 + x - 1 = 0
using fixed point iteration?
Is there any fixed-point iteration code (especially in Python) I can find online?

bbnn
- 3,505
- 10
- 50
- 68
8
votes
2 answers
Lambert W function implementation in Java
I'm working on a project and have found myself in a situation where I need a function to be able to get at least an approximation of the value of W(x), the Lambert W function, where x can be any real number. I'm working in Java. I couldn't find…

Graham
- 1,044
- 1
- 8
- 11
8
votes
5 answers
Calculating average of two values, minimizing errors
I am doing some floating point calculations and the results are not as accurate as I want them to be.
This is the algorithm:
...
center = (max_x + min_x) / 2
distance = old_x - center
new_x = center + (distance * factor)
return new_x
min_x,…

MxLDevs
- 19,048
- 36
- 123
- 194
8
votes
1 answer
How to pass a hard coded differential equation through Runge-Kutta 4
I'm trying to implement Runge-Kutta for example problems
dy/dt = y - t^2 + 1 and dy/dt = t * y + t^3 in C# and I cannot seem to get the output I'm expecting. I have split my program into several classes to try and look at the work individually. I…

Wesley Lethem
- 81
- 2