Questions tagged [numerical]

This tag is for questions concerning problems using numbers which either cannot be exactly solved, or where the exact solution may be much more difficult to acquire than by using numerical methods.

This tag is for questions concerning problems using numbers which either cannot be exactly solved, or where the exact solution may be much more difficult to acquire than by using numerical methods.

It includes questions about algorithms, precision and accuracy of underlying numbers, advantages and disadvantages of several methods, error propagation, problems with the underlying numbers and data structures.

508 questions
11
votes
5 answers

Solving nonlinear equations numerically

I need to solve nonlinear minimization (least residual squares of N unknowns) problems in my Java program. The usual way to solve these is the Levenberg-Marquardt algorithm. I have a couple of questions Does anybody have experience on the different…
11
votes
1 answer

logsumexp implementation in C?

Does anybody know of an open source numerical C library that provides the logsumexp-function? The logsumexp(a) function computes the sum of exponentials log(e^{a_1}+...e^{a_n}) of the components of the array a, avoiding numerical overflow.
oceanhug
  • 1,352
  • 1
  • 11
  • 24
11
votes
1 answer

Does unary minus just change sign?

Consider for example the following double-precision numbers: x = 1232.2454545e-89; y = -1232.2454545e-89; Can I be sure that y is always exactly equal to -x (or Matlab's uminus(x))? Or should I expect small numerical differences of the order or eps…
Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
11
votes
7 answers

PHP: Is_numeric returns false on 0

Is_numeric() as well as is_int() returns false if the value is 0. What can i do instead to verify that a specific value is numbers only in PHP? Are we heading straight for the Regular Expressions camp, or are there some nice, handy feature for this…
Industrial
  • 41,400
  • 69
  • 194
  • 289
11
votes
1 answer

OpenCV:src is not a numerical tuple

I've written a program about color detection by using python. But always there's an error around the 'Erode' sentence. Here's part of my program. Thank you. # Convert the image to a Numpy array since most cv2 functions # require Numpy arrays. frame…
user3910024
  • 119
  • 1
  • 1
  • 3
11
votes
10 answers

Why do these division equations result in zero?

The result of all of the division equations in the below for loop is 0. How can I get it to give me a decimal e.g.: 297 / 315 = 0.30793650793650793650793650793651 Code: using System; namespace TestDivide { class Program { static…
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047
10
votes
3 answers

C/C++ for Python programmer

I have to switch from Python to C/C++. Do you know a quick "reference tutorial" or something like that to have a reference to how to start? For example something like the Numpy and Scipy tutorials. I have read a lot of "documentation", for…
brunetto
  • 183
  • 1
  • 2
  • 7
10
votes
2 answers

Limitation of Mathematica optimization module

I have a question regarding Mathematica's global optimization capability. I came across this text related to the NAG toolbox (kind of white paper). Now I tried to solve the test case from the paper. As expected Mathematica was pretty fast in solving…
10
votes
4 answers

python floating number

i am kind of confused why python add some additional decimal number in this case, please help to explain >>> mylist = ["list item 1", 2, 3.14] >>> print mylist ['list item 1', 2, 3.1400000000000001]
user359925
  • 111
  • 1
  • 1
  • 4
10
votes
8 answers

Ruby implementation is_numeric? for Strings, need better alternatives

I wanted to validate 'numericality' of a string (its not an attribute in an active-record model). I just need it to be a valid base 10, positive integer string. I am doing this: class String def numeric? # Check if every character is a digit …
Swanand
  • 12,317
  • 7
  • 45
  • 62
10
votes
3 answers

Fitting a line that passes through the origin (0,0) to data

I have a set of points (x,y) and I need to find the line of best-fit that passes through the origin using MATLAB.
dr_rk
  • 4,395
  • 13
  • 48
  • 74
9
votes
2 answers

Numerical instability FFTW <> Matlab

I am trying to numerically solve the Swift-Hohenberg equation http://en.wikipedia.org/wiki/Swift%E2%80%93Hohenberg_equation using a pseudo-spectral scheme, where the linear terms are treated implicitly in Fourier space, while the nonlinearity is…
wurstl
  • 91
  • 3
9
votes
1 answer

Parallelism: Subtly different floating point results?

I'm trying to debug my parallelism library for the D programming language. A bug report was recently filed that indicates that the low-order bits of some floating point operations that are performed using tasks are non-deterministic across runs. …
dsimcha
  • 67,514
  • 53
  • 213
  • 334
9
votes
3 answers

How can I add floats together in different orders, and always get the same total?

Let's say I have three 32-bit floating point values, a, b, and c, such that (a + b) + c != a + (b + c). Is there a summation algorithm, perhaps similar to Kahan summation, that guarantees that these values can be summed in any order and always…
splicer
  • 5,344
  • 4
  • 42
  • 47
9
votes
2 answers

Numeric vector operator overload+ rvalue reference parameter

I have the numeric vector template class below (vector for numerical calculations). I am trying make it possible to write D=A+B+C where all variables are Vector objects. A, B and C should not be modified. My idea is to use Vector operator+(Vector&&…
Lars Chr
  • 947
  • 1
  • 9
  • 12
1 2
3
33 34