Strange behaviour of a function handel
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Rubén Pérez Sanz
 el 12 de Jun. de 2021
  
    
    
    
    
    Respondida: Steven Lord
    
      
 el 12 de Jun. de 2021
            Hi there,
I have constructed a function handle that reads like:
delta   = 0.0173
L       = 10555
H_f     = @(k,N)1/2*((delta/k+L+N)-sqrt((delta/k+L+N)^2-4*L*N))
For values k=1 and very very very large numbers of N=1.e+40 the value that matlab throws up is zero. However, I can prove analytically that for any k>0, the limit of H_f as N-->inf is equal to L = 10555.
I would like to know what I am missing something or if I am doing sth wrong.
KR
1 comentario
  Stephen23
      
      
 el 12 de Jun. de 2021
				"I would like to know what I am missing something or if I am doing sth wrong."
You seem to be assuming that numeric mathematics (with limited precision) is the same as analytic mathematics or algebra.
It isn't.
Consider that each value has limited precision, and each operation accumulates floating point error.
Respuesta aceptada
  Steven Lord
    
      
 el 12 de Jun. de 2021
        According to Google Bill Gates has a net worth of 126.5 billion USD. If you saw him on the street and handed him a $20 bill, would that change his net worth?
Technically yes, it would. And if you were one of Bill Gates's accountants you might actually care. Maybe.
Practically no, it would not. You wouldn't say he had a net worth of 126.5 billion plus 20 USD. That $20 is negligible compared to $126.5 billion.
Why do I bring this up?
N = 1e40;
L = 1e6; % 1 million
N2 = N + L;
N == N2 % is N exactly equal to N2?
Relative to N, L is negligible. It's that $20 to Bill Gates.
In fact, the distance from N to the next largest number exactly representable in double precision is:
distanceToNextLargest = eps(N)
N == (N + distanceToNextLargest) % these two numbers are distinct
0 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Logical en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


