Questions tagged [machine-precision]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
53 views

verifying Ramanujan constant

The famous Ramanujan constant $ e^{\pi \sqrt{163}} $ is a near-integer. see the link here. I tried to calculate this number with matlab and failed. Matlab cannot even deliver the first 9 apparently ...
S. Kohn's user avatar
  • 1,084
1 vote
0 answers
36 views

Proof that $\epsilon_{mach} \leq \frac{1}{2} b^{1-n}$

I have a question about the proof of the following statement: For each set of machine numbers $F(b, n, E_{min}, E_{max})$ with $E_{min} < E_{max}$ the following inequality holds: $\epsilon_{mach} \...
Felix Gervasi's user avatar
0 votes
1 answer
56 views

Simulation of a pendulum without using the angle with the Euler-Cromer method.

I am trying to create a computer simulation of a simple pendulum with a mass $m$ hanging from an inextensible and negligibly massless string, but without using the angle, only using the positions of ...
Huntwer's user avatar
  • 21
2 votes
1 answer
70 views

Numerically stable way to compute ugly double fraction

I am looking for a numerically stable version of this (ugly) equation $$ s^2=\frac{1}{\frac{1}{\beta_1}+\frac{1}{\beta_2}W} $$ where $$ \beta_1 = c_1-c_2m+(m-c_2)b\\ \beta_2 = \frac{1}{2}\left((a-m)^2-...
mto_19's user avatar
  • 260
0 votes
0 answers
36 views

Practical limit on optimization tending to negative infinity

Consider $f:\mathbb R^n\to\mathbb R$ $$f(\mathbf x):=\sum_i{e^{x_i}}$$ The gradient of $f(\mathbf x)$ is the function itself. Notably, the gradient magnitude decreases exponentially, if the goal is to ...
Phoenix's user avatar
  • 159
1 vote
0 answers
38 views

Most accurate way to multiply with inverse Cholesky decomposition

What is the most accurate way to compute $x^TA^{-1}y$ for two vectors $x$ and $y$, and a symmetric positive definite matrix $A$? With a Cholesky decomposition $A=LL^T$, one could either apply both $L$ ...
bansed's user avatar
  • 11
1 vote
0 answers
51 views

relative error of p-norm of a perturbated matrix

I am working on a question related to sensitivity of linear system, and the following step is difficult to prove. my work: $\tilde{a}_{ij}-a_{ij}=a_{ij}\epsilon_{ij}$ then, $\tilde{A}-A=A_{\epsilon}$ ...
tsd's user avatar
  • 11
1 vote
2 answers
145 views

Another way to compute the epsilon machine

Why the next program computes the machine precision? I mean, it can be proved that the variable $u$ will give us the epsilon machine. But I don't know the reason of this. Let $a = \frac{4}{3}$ $b = a −...
xenuti's user avatar
  • 119
1 vote
2 answers
107 views

Alternate expression for $\operatorname{atanh}(x)$ for $\lvert x \rvert \to 1$

The inverse hyperbolic tangent function $\operatorname{atanh}$ is defined as: $$\operatorname{atanh}(x) = \frac{1}{2}\log\left(\frac{1 + x}{1 - x}\right)$$ In computers using floating point arithmetic,...
Yimin Rong's user avatar
0 votes
1 answer
61 views

Numpy/PyTorch break problem symmetry due to numeric precision

In my problem, I apply a linear transformation to a Gaussian random variable $Y \in \mathbb{R}^n$, by multiplying it with a matrix $\mathbf{f} \in \mathbb{R}^{n \times d}$, with $d<<n$. With $\...
dherrera's user avatar
  • 212
0 votes
1 answer
33 views

What is the resulting precision from an exponent operation?

Say I want to perform exponentiation on some decimal number (like a measured weight) and some integer exponent (like ^2 or ^3). What are the general rules for the resulting precision(significant ...
SunsetQuest's user avatar
-1 votes
1 answer
106 views

What is the result of (271698268*271698267)/2?

I need the answer in non-scientific form, to precision. The problem is I'm getting different results from different methods. Method Output Output (plain) Python ...
Dr-Bracket's user avatar
3 votes
2 answers
84 views

Why plot of a sinusoid with a large phase appears like a staircase?

I plotted the following in MATLAB and Desmos: y = cos(x + 6998666554443343) (1) The plot is shown here: Plot of (1) This staircase behaviour seems to appear with ...
Manvendra Sharma's user avatar
0 votes
0 answers
34 views

Prevent numerical precision error when calculating $\frac1{|Y|}\sum_{y\in Y}\left|f(y)-q(y)\right|$ in a clever way

Let $Y\subseteq[0,1)$ be a nonempty set and $f,q:[0,1)\to[0,1)$. I want to compute $$A:=\frac1{|Y|}\sum_{y\in Y}\left|f(y)-q(y)\right|$$ in a computer program. Now, the problem is that $|Y|$ is large ...
0xbadf00d's user avatar
  • 13.5k
1 vote
0 answers
136 views

Sum of radicals positivity

I have a sum of square roots each with a coefficient, for example like this: √2 + 2√3 - 4√5 + 2√6 + ... How do I know if the sum is positive or negative without ...
gXLg's user avatar
  • 11
1 vote
0 answers
22 views

How to calculate converted value for each number in a set using a conversion rate, having its sum equal exactly a rounded fixed converted total?

Say I have three numeric values: a total, converted total, and a conversion rate. These are fixed, given numbers, and the two totals always have the precision of two decimal places. ...
Dr. Barry's user avatar
0 votes
2 answers
162 views

Evaluating $a(b + c)$ more accurately with FMA

I'm using machine-precision floating-point arithmetic, and every so often it happens that I need to evaluate an expression of the form $a(b + c)$. I found that the accuracy can be improved using FMA (...
user2373145's user avatar
2 votes
0 answers
81 views

Numerically stable evaluation of factored univariate real polynomial

Suppose we have a real univariate factored polynomial, meaning we have its factors: an arbitrary number of polynomials of degree less than or equal to two. To simplify things, if necessary, let's ...
user2373145's user avatar
0 votes
0 answers
74 views

How can I determine the reason for the mismatch between the value of this infinite continued fraction and the expected result?

How can I determine the reason for the mismatch between the value of this infinite continued fraction and the expected result? $$6.9431070487= \lim\limits_{n\rightarrow\infty}7- \frac{7}{129- \dfrac{...
user avatar
1 vote
0 answers
50 views

Method for finding the largest positive difference between two pairs of IEEE 754 double precision floating point numbers and fixed-point numbers

I have two pairs of IEEE 754 double precision (64-bit) floating-point numbers and unsigned fixed-point numbers, and I'm trying to find which pair has the greatest difference. The fixed-point numbers ...
Polynomial's user avatar
1 vote
1 answer
83 views

Machine Precison for Roundoff

Given the machine precision (machine epsilon) whose definition is that it is the smallest $\epsilon_{mach}$ such that 1 + $\epsilon_{mach}$ > 1. I found an explanation online to show that for ...
VirgOpta's user avatar
0 votes
0 answers
530 views

Are there any ways to increase the precision in MATLAB without built in functions?

I am a beginner learning about MATLAB scientific computation, floating point numbers, and numerical error. When I am using a very small $x$ value for some equations, such as $y(x) = (\exp(x)-1-x)/x^2$,...
cronk's user avatar
  • 31
1 vote
5 answers
131 views

How can we calculate $\ln(x) - 1$ at $x \approx e$ using standard double precision arithmetic?

This question is inspired by the fact that decent mathematical libraries in programming languages compute sine of double precision approximation of $\pi$ correctly to the last bit (example is in Julia)...
Yrogirg's user avatar
  • 3,589
2 votes
0 answers
42 views

Computing log of a number with low precision calculator

Say I have a low-precision calculator that displays numbers with only 8-digits mantissa. For example, 0.00432137378 would read ...
fricadelle's user avatar
14 votes
1 answer
488 views

Why does this desmos plot of the integral of $\sqrt{1+e^x}$ have these discontinuities?

I computed the integral of $\sqrt{1+e^x}$ by hand and got $$2\sqrt{1+e^x} + \ln\left(\sqrt{1+e^x} - 1\right) - \ln\left(\sqrt{1+e^x} + 1\right) + C,$$ or $$2\sqrt{1+e^x} + \ln\left(\frac{\left(\sqrt{1+...
Zhiyuan Liu's user avatar
26 votes
3 answers
1k views

Why do different calculators disagree on $\cos(452175521116192774 )$?

I want to calculate cosine of 452175521116192774 radians (it is around $4.52\cdot10^{17}$) Here is what different calculators say: Wolframalpha Desmos Geogebra Python 3.9 (standard math module) ...
musava_ribica's user avatar
8 votes
2 answers
333 views

Reduce precision of fraction

Say I have a reduced fraction where the numerator and denominator can only be integers: $$ \frac{1071283}{28187739} $$ and I want to reduce it more, accepting the lose of precision. I could just ...
Mobz's user avatar
  • 191
0 votes
0 answers
51 views

Discrete power series?

I have a pattern. I have a box made of $n\times n\times n$ boxes where n is a power of 2. I flatten this box into an $n^3$ flat sequence of boxes. I then have an $n/2 \times n / 2 \times n/2$ box, ...
Makogan's user avatar
  • 3,319
0 votes
0 answers
22 views

Minimum of floating-point numbers

I'm reading the book Numerical Analysis by Gautschi, and in the first chapter the author makes the following assertion: The set of floating-point numbers on a computer is denoted $\mathbb R(t,s)$ such ...
Davi Barreira's user avatar
1 vote
1 answer
47 views

Computing nested functions to arbitrary precision

Let's say I want to compute $e^\pi$ to arbitrary precision. I have a function $pi()$ which computes $\pi$ to arbitrary precision and $exp(x)$ which computes $e^x$ to arbitrary precision. Now, how can ...
DavidsKanal's user avatar
0 votes
0 answers
72 views

How precise is the result after calculating a/b?

I have two numbers, $a$ and $b$, where the precision of $a$ is $n$ bits and the precision of $b$ is $m$ bits. How many bits of precision are preserved after calculating a/b on a normal computer ...
Gamer2015's user avatar
  • 121
3 votes
0 answers
124 views

Limit of Euler's number failing due to precision errors - A surprising case. Why does it happen?

It is a known fact that floating point precision errors are bound to happen when one forces a computer to deal with very large or very small numbers, especially when both things are done at the same ...
Danilo Guimarães's user avatar
3 votes
1 answer
323 views

Avoiding catastrophic cancellation in $1-\operatorname{sinc}x$

When I try to calculate the function $f(x)=1-\operatorname{sinc}x$ for small values of $x$ I get large relative errors due to catastrophic cancellation. I want an accurate way to calculate $f(x)$ ...
Ken Whatmough's user avatar
1 vote
0 answers
85 views

Relative error of a number in machine epsilon units

I came across an estimation of the relative error between two representations of the same number, one implemented in C++ and another one via a computer algebra program, that was in units of machine ...
hal's user avatar
  • 121
1 vote
1 answer
156 views

Help Simplifying Function with Bessel Functions

I'm trying to calculate a function that includes Bessel functions and am running into precision issues, generally due to a small difference between large numbers. The function is $$F=\frac{J_0(K\phi)...
tkw954's user avatar
  • 137
1 vote
0 answers
55 views

How to avoid overflows and numerical issues when computing derivatives?

I'm trying to compute the derivative of this quantity w.r.t to $\mu$ and $k$: $$ \mathcal{L}(t) = - \eta_n\log\left(1-P(t)\right) $$ Where $\eta_n$ is just a weighting factor and P(t) is the cdf of ...
ИванКарамазов's user avatar
0 votes
1 answer
1k views

Roundoff errors and finite difference approximation

Let us consider the centered finite difference approximation of the first derivative of a smooth function $$f'(x_i) = \frac{f(x+h) - f(x-h)}{2h}$$ It's well known that if we do a $\text{loglog}$ plot ...
andereBen's user avatar
  • 695
1 vote
1 answer
260 views

Explanation of the precision and the accuracy used by Wolfram Mathematica when performing arithmetic operations on floating point numbers

The numerical value for the precision in mathematica is given out by $MachinePrecision, and this is also the number of relevant digits showed in the output console ...
FRANCESCO's user avatar
1 vote
1 answer
113 views

Rounding in floating point operations

I'm given this set of floating point numbers: And I'm given the function: I'm then asked to find the value of f for: So I've done this: Now my guess is that I need to convert the exact value (1....
zcb's user avatar
  • 53
0 votes
1 answer
33 views

Given an analytic function can I derive to what precision I need to evaluate its arguments to get a result of a given precision?

Suppose I have some arbitrary analytic function over the reals e.g.: $$ x \mapsto \frac{\sqrt{\sin(x)+2e^x}}{x^2 - \ln(x^x)} $$ Given some input of arbitrary precision $x$ how can I evaluate such an ...
Jamesernator's user avatar
0 votes
0 answers
28 views

Exponencial mantissa

I try to compute a function of type $e^x$. Since its natural fast-growing behaviour, the most natural behaviour is to decompose the resulting number into its mantissa and exponent components. However, ...
Bruno Lobo's user avatar
1 vote
1 answer
74 views

Why is this function not being graphed as expected?

I am interested in the Rastrigin function: https://en.wikipedia.org/wiki/Rastrigin_function. I have read that the local minimums of this function occur at integer coordinates. However, when I plug ...
Jabrove's user avatar
  • 128
0 votes
1 answer
147 views

Finding a machine number such that $fl(x)=x(1+\delta)$.

The guide book asks me for A real number $x$ in range of a machine with $\beta=2$ (binary) and $n=24$ (24 mantissa positions), such that it satisfy $fl(x)=x(1+\delta)$, with $|\delta|$ as big ...
Lennis Mariana's user avatar
2 votes
1 answer
2k views

Machine epsilon: why is $(1 + \epsilon) + \epsilon = 1$?

My book on real analysis has the following statement: I don't understand how the first equation can possibly be true, by definition of machine epsilon. Machine epsilon is defined as the smallest ...
Aleksandr Hovhannisyan's user avatar
1 vote
1 answer
82 views

How to Calculate the Precision Required to Exactly Produce the Repeating Sequence of Digits in the Decimal Expansion of a Fraction

Say I am given a fraction $\frac{p}{q}$ and wish to express it as a decimal such that the repeating sequence of digits is accurately displayed at least once and preferably twice in the printed output. ...
mlchristians's user avatar
  • 2,623
2 votes
0 answers
37 views

Tough test polynomials for (finite precision) complex root finding methods, especially Aberth's method

Today I have implemented Aberth's method for complex polynomial root finding. And I have to say I am enchanted about its astonishing performance and its intriguing simplicity. Before I go on believing ...
oliver's user avatar
  • 365
1 vote
0 answers
350 views

Floating-point rounding error in numerical differentiation formula

In Numerical Analysis by Timothy Sauer (Pearson, 2nd Edition) it says that $\tilde{f'}(x+h) = f(x+h) + \epsilon_{\text{mach}}$, where $\tilde{f'}(x)$ is the floating-point representation of the given ...
K. Claesson's user avatar
2 votes
0 answers
50 views

Finding the real roots of a univariate polynomial on the interval [0,1]

I have numerous, univariate polynomials with degree in excess of 100 and with very, very large coefficients (Here's an example coefficient ...
HXSP1947's user avatar
  • 287
2 votes
1 answer
124 views

Calculator Confusion using Windows and Androids

I just came across this calculation, it's really confusing. I ran the following calculations in windows and android calculators. $1/98\cdot 98 = 1$ $1/98 = 0.0102040816326531$ $0.0102040816326531 * ...
Jeeva's user avatar
  • 123
1 vote
0 answers
67 views

computing standard deviation without mean produces illegal result!

I would like to compute STD in one-pass, without first computing the mean: Hence, I decided to use the following [formula][1]: std dev = sqrt [(B - A^2/N)/N] ...
sramij's user avatar
  • 111