Evaluating expression (numerical analysis)

AI Thread Summary
When evaluating the expression (1+1/x)*x-x in Octave with x set to 10^15, the result is 1.125 due to precision loss from subtracting two nearly equal quantities. Octave utilizes double precision floating point representation, which can lead to inaccuracies when dealing with very large numbers. The calculation of (1 + 1/x) results in a value that, when multiplied by x, approximates 1e15, but the last digit is not represented accurately. This discrepancy arises from the limitations of binary representation in floating point arithmetic. The discussion highlights the classical flaws in numerical analysis related to operations on values of vastly different magnitudes and the subsequent subtraction.
blob84
Messages
25
Reaction score
0
Hello, using octave when I evaluate this expression (1+1/x)*x-x, with x = 10^(15) i get as result 1.125, I didn't undesrtood why,
I know that octave show 15 digits in format long so when i evaluate (1+1/x)*x i get 1e15, the last digit is not visible and it is 1, so when i do substraction i get 1.12500000000000.
 
Mathematics news on Phys.org
blob84 said:
Hello, using octave when I evaluate this expression (1+1/x)*x-x, with x = 10^(15) i get as result 1.125, I didn't undesrtood why,
I know that octave show 15 digits in format long so when i evaluate (1+1/x)*x i get 1e15, the last digit is not visible and it is 1, so when i do substraction i get 1.12500000000000.

It is not my area of expertise but...

You are subtracting two nearly equal quantities from each other. This is a classical way to lose precision.

From what I can discover with a quick trip to Google, Octave works with double precision floating point representation. Likely this would be IEEE floating point. In this format, floating point numbers are expressed in binary with a 53 bit mantissa, an 11 bit exponent and a 1 bit sign for a total of 65 bits. This fits into an eight byte field because the leading bit in the mantissa is always 1 and need not be stored.

http://en.wikipedia.org/wiki/Double-precision_floating-point_format

10-50 is approximately equal to 1.125 * 2-50 add 1 and you get, in binary

1.00000000000000000000000000000000000000000000000001001 [54 bits]

If you hypothesize IEEE floating point with one guard bit, that would fit with a result of 1.125.
 
There are actually two classical flaws. One is in (1 + 1/x), which sums two values of vastly different magnitudes. Second is in the subtraction.
 
Thread 'Video on imaginary numbers and some queries'
Hi, I was watching the following video. I found some points confusing. Could you please help me to understand the gaps? Thanks, in advance! Question 1: Around 4:22, the video says the following. So for those mathematicians, negative numbers didn't exist. You could subtract, that is find the difference between two positive quantities, but you couldn't have a negative answer or negative coefficients. Mathematicians were so averse to negative numbers that there was no single quadratic...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Thread 'Unit Circle Double Angle Derivations'
Here I made a terrible mistake of assuming this to be an equilateral triangle and set 2sinx=1 => x=pi/6. Although this did derive the double angle formulas it also led into a terrible mess trying to find all the combinations of sides. I must have been tired and just assumed 6x=180 and 2sinx=1. By that time, I was so mindset that I nearly scolded a person for even saying 90-x. I wonder if this is a case of biased observation that seeks to dis credit me like Jesus of Nazareth since in reality...
Back
Top