컴퓨터는 작은 소수점 여러 개를 곱할 때 문제가 발생하곤 합니다. 이를 부동 소수점 언더플로
underflow
라고 하죠. 즉, 곱셈으로 인해 소수점이 점점 작아지면서 소수점 이하 자릿수를 추적하
는 데 컴퓨터가 한계에 부딪히게 됩니다. 이 문제를 해결할 수 있는 영리한 수학 도구가 있습니
다. 곱하는 각 소수에
log
()
를 취해 곱셈 대신 덧셈을 하면 됩니다. 이는
1
장에서 다룬 로그의
덧셈 속성 덕분입니다. 이렇게 하면 수치적으로 더 안정적이며
exp
()
함수로 덧셈 결과를 곱셈
결과로 변환할 수 있습니다.
곱셈 대신 로그 덧셈을 사용하도록 코드를 수정해봅시다(예제
6
-
6
).
log
()
함수의 밑은 기본
값이
e
입니다. 기술적으로는 모든 밑이 가능하지만
e
x
의 미분은 자기 자신이라 계산적으로 더
효율적이기 때문에 기본값
e
를 사용하는 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.