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
4
votes
2 answers

PHP number_format returns 1.00

I have stored in MySQL the number as total(decimal 16,2) 1423.28 I get it display from PHP after making some calculations: function calculate_balance($total){ //get total paid from another function $total_paid = ... if ($total_paid == 0){ …
Adrian P.
  • 5,060
  • 2
  • 46
  • 47
4
votes
3 answers

Generating a C++ function from a list of argument

I am writing a function f to be used in a Runge Kutta integrator. output RungeKutta(function f, initial conditions IC, etc.) Since the function will be called many times, I am looking for a way to generate the function f at compile time. In this…
4
votes
2 answers

Outer product using CBLAS

I am having trouble utilizing CBLAS to perform an Outer Product. My code is as follows: //===SET UP===// double x1[] = {1,2,3,4}; double x2[] = {1,2,3}; int dx1 = 4; int dx2 = 3; double X[dx1 * dx2]; for (int i = 0; i < (dx1*dx2); i++) {X[i] =…
The Dude
  • 661
  • 2
  • 11
  • 20
4
votes
5 answers

optimizing with IEEE floating point - guaranteed mathematical identities?

I am having some trouble with IEEE floating point rules preventing compiler optimizations that seem obvious. For example, char foo(float x) { if (x == x) return 1; else return 0; } cannot be optimized to just return 1…
Ken
  • 12,933
  • 4
  • 29
  • 32
4
votes
1 answer

A Simple Wrapper for F# to do matrix operations

This is a relatively long post. F# has a matrix and vector type(in PowerPack not in the Core) now. This is great! Even Python's numerical computing ability is from the third part. But the functions provided there is limited to the matrix and vector…
Yin Zhu
  • 16,980
  • 13
  • 75
  • 117
4
votes
3 answers

Break on NaNs or infs

It is often hard to find the origin of a NaN, since it can happen at any step of a computation and propagate itself. So is it possible to make a C++ program halt when a computation returns NaN or inf? The best in my opinion would be to have a crash…
static_rtti
  • 53,760
  • 47
  • 136
  • 192
4
votes
2 answers

Sort numbers with letters numerically and alphabetically

I have a Database on my website with a Long List of #'s (Product #'s) all containing letters (Exp. TC-345, TC-234 or HC-236W 123-234-PWD...) Can we numerically and alphabetically sort the #'s on the website? Currently we store it alphabetically, so…
4
votes
3 answers

gamma or log gamma function in C or C

I am seeking a C or C++ version of gamma and log gamma functions. Are there any code pieces or libraries recommended? If possible, I want to know the principle of the implementations. Thank you!!!
kimi
  • 123
  • 3
  • 6
4
votes
2 answers

Mixing numpy and OO in numerical work

First, I'd like to know if it's good practice in general to use an OO approach in numerical work. Second, a possible use case for OO would be to encapsulate in some object the parameters of some model. Say, I want to study parabolas of the form ax^2…
green diod
  • 1,399
  • 3
  • 14
  • 29
4
votes
4 answers

What's the smallest non-zero, positive floating-point number in Perl?

I have a program in Perl that works with probabilities that can occasionally be very small. Because of rounding error, sometimes one of the probabilities comes out to be zero. I'd like to do a check for the following: use constant TINY_FLOAT =>…
James Thompson
  • 46,512
  • 18
  • 65
  • 82
4
votes
1 answer

Solve non-linear system of equation in Mathematica

I'm trying to solve non-linear system of equations in Mathemtica. I tried Solve and NSolve, I also tried to define a_{ij} and b_{ij} and m33=1 numerical to simplify equation, but Mathematica seems to work too long or I doing something wrong.In…
4
votes
2 answers

GCC giving different numerical results with -O0 and -O2

I'm using 4.1.2. Does anyone have any ideas of the best places in my code to look? Experience with common causes? There are some ugly pointer casts (ie, d = (double) (* (float *) p), where p is pointer-to-int) that I'm working on eliminating, but…
Alex
3
votes
3 answers

Strrep not working in Matlab to make String into function

Hello I am new to MATLAB , I wanted to know how can I make my string into function . I want to access the function as a string from user in standard Matlab format (e.g exp(-10*X)-sin(pi*X)-2*tanh(X) ) Here X is the variable. Then I want to replace…
user841852
  • 197
  • 3
  • 7
  • 15
3
votes
1 answer

Matplotlib embedded PyQt4 graph resizes every time I plot

I have an embedded matplotlib plot in a PyQt4 application. This is the plotting widget I have made based on the Qt4 embedding sample at http://matplotlib.sourceforge.net/examples/user_interfaces/embedding_in_qt4.html. Unfortunately, every time I add…
Sudarshan S
  • 1,235
  • 2
  • 16
  • 25
3
votes
5 answers

How do i check for numeric value in C language?

This question has been asked before, but i've never found a clear and simple answer, so i'm asking it again... I'de like to know, without using any other library than stdio.h, how to check if what the user has entered is a numeric value or not.…
blackjak231
  • 174
  • 1
  • 11