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
2
votes
1 answer

How to avoid floating point exception when using pow?

I use a C library which uses the pow function on two double values double a = pow(b, c) At the moment, I have b = 0.62 and c = 1504, which means that a should be nearly 0 (3.6e-312). But I have a floating point exception. How to avoid it and…
2
votes
3 answers

Speed up a program that calculate the average of the neighbors in a huge array

I have a problem with the speed of my program. I want to calculate the average of four neighbors in a huge array. Here is a part of my code. Do you have any ideas how to change the last line? Or should I use another array? for a in…
kame
  • 20,848
  • 33
  • 104
  • 159
2
votes
1 answer

numpy numerical differentiation

I've plotted a curve along the width of an array, of the sum of the array columns: import numpy as np from astropy.io import fits import matplotlib.pyplot as plt #def plot_slope(x, y): # xs = x[1:] - x[:-1] # ys = y[1:] - y[:-1] # …
Jim421616
  • 1,434
  • 3
  • 22
  • 47
2
votes
2 answers

Python numerically solved harmonic oscillator graph generates unwanted results

Ive been trying to numerically solve for the graph of a basic harmonic oscillator but a problem occurs when acceleration on the object is proportional to the inverse of the distance from the centre: import math from pylab import * xg = [2] xt =…
2
votes
0 answers

What's the numerical limit on data type double in C++?

I am dealing with very large numbers in my C++ application which can exceed 64bit variables and when look at: qDebug("lowest: %f", std::numeric_limits::lowest()); qDebug("max: %f", std::numeric_limits::max()); the output is:…
dcfyg
  • 75
  • 9
2
votes
3 answers

Python Function That Receives Letter, Returns (0-Based) Numerical Position Within Alphabet

I'm trying to create a Python function that receives a letter (a string with only one alphabetic character) and returns the 0-based numerical position of that letter in the alphabet. It should not be case-sensitive, and I can't use import. So…
HappyHands31
  • 4,001
  • 17
  • 59
  • 109
2
votes
1 answer

tensorflow one numerical output

i am new to tensorflow and i have looked through the tutorials and executed them successfully. Now i have to solve a Problem where my output should NOT be a categorical one like MNIST Labels (1-10). i want to Count objects in an Image and therefore…
Biba
  • 1,595
  • 1
  • 12
  • 17
2
votes
2 answers

What gets converted to what when comparing a double to an integer for identity?

OK, so I know you're generally not supposed to compare two floating-point numbers for equality. However, in William Kahan's How Futile are Mindless Assessments of Roundoff in Floating-Point Computation? he shows the following code (pseudo-code, I…
JackJ
  • 23
  • 2
2
votes
0 answers

Using R to compute an integration

The problem is below: I am trying to compute the integration above by using R. Since I am new in R, I am not sure if my code is computing this integration correctly or not. I would appreciate if anyone can help me about this R code. My code is…
Jimmy Dur
  • 121
  • 5
2
votes
3 answers

Scipy odeint breaks on discontinuous dynamics function e.g. xdot = -sgn(x)

I am trying to use Python and scipy.integrate.odeint to simulate the following dynamical system: But this integration breaks numerically in Python resulting in the following and similar images (usually even worse than this): Generated using the…
2
votes
1 answer

Linear regression / line finding for non-function lines

I want to find a line having a number of points which are around that line. Line is in 2D space and is defined by two points, or by one point and an angle. What would be the algorithm for it? There's a lot about this on SO and in internet and also…
Arek
  • 1,276
  • 1
  • 10
  • 19
2
votes
2 answers

Avoid round off error in exponential calculation

Due to rounding error cannot get ratio between two numbers: Ratio=exp(x)/(exp(x)+exp(y)) such that x=-1.11e4 and y=-1.12e4. Any mathematical or computational trick to do?
ASE
  • 1,702
  • 2
  • 21
  • 29
2
votes
0 answers

Machine epsilon subtraction in MATLAB

Using MATLAB: Why does 1-eps == 1-eps*4/3 return FALSE. With M mantissa bits, shouldn't eps*4/3 be 1.0101...*2^-M which will be rounded to eps when subtracted from 1?
bnorm
  • 399
  • 2
  • 16
2
votes
0 answers

Solving double integral numerically in python

I am trying to solve a double integral numerically using areas of rectangles, where the integral looks like is just a function of two variables (theta and phi). Here's my attempt so far: from math import* import numpy as np N = 100000 T =…
Matuba
  • 43
  • 4
2
votes
3 answers

what's the purpose/point of the REAL() Datatype in mysql?

what's the purpose/point of the REAL() Datatype in mysql? You have float,double and decimal which i understand but where does the "real" datatype come into it? Any ideas? Thank you in advance ;-) is real the same as float or double?
Imran
  • 11,350
  • 20
  • 68
  • 78