Evaluating expression (numerical analysis)

In summary, when evaluating the expression (1+1/x)*x-x with x = 10^(15) in Octave, the result is 1.125. This is because Octave uses double precision floating point representation, and when subtracting two nearly equal quantities, precision is lost. This can occur due to the summation of two values of vastly different magnitudes and the subsequent subtraction.
  • #1
blob84
25
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
  • #2
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.
 
  • #3
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.
 

1. What is numerical analysis?

Numerical analysis is a branch of mathematics and computer science that deals with the development and use of algorithms to solve mathematical problems using numerical approximations and methods.

2. Why is evaluating expressions important in numerical analysis?

Evaluating expressions is important in numerical analysis because it allows us to find approximate solutions to complex mathematical problems that cannot be solved analytically. It also helps us to understand the behavior and properties of these solutions.

3. What are the common methods used for evaluating expressions in numerical analysis?

The common methods used for evaluating expressions in numerical analysis include the bisection method, the Newton-Raphson method, and the secant method. These methods involve iteratively improving an initial guess for the solution until it reaches a desired level of accuracy.

4. How do errors affect the evaluation of expressions in numerical analysis?

Errors can significantly affect the evaluation of expressions in numerical analysis. These errors can arise from rounding and truncation during calculations, as well as from the use of approximations and assumptions in mathematical models. They can lead to inaccurate solutions and must be carefully controlled and minimized in order to obtain reliable results.

5. What are some applications of numerical analysis in real life?

Numerical analysis has many real-life applications, such as in engineering, physics, economics, and computer graphics. It is used to solve problems involving complex systems and equations, such as predicting the weather, designing structures, and simulating physical phenomena. It is also used in financial analysis and optimization, as well as in creating realistic visual effects in movies and video games.

Similar threads

Replies
4
Views
423
Replies
1
Views
756
Replies
4
Views
673
  • Computing and Technology
Replies
4
Views
775
Replies
3
Views
977
  • General Math
Replies
1
Views
1K
Replies
3
Views
276
  • Differential Equations
Replies
3
Views
1K
Replies
4
Views
1K
Replies
7
Views
1K
Back
Top