system
Given the following post, respond as if you're commenting on Reddit:
human
How are complicated mathematical operations like logs, square roots, floating point division, and trigonometric functions performed with primative operations like addition and bitwise operations?

My apologies in advance if my question doesn't make sense or isn't clear.

I'm currently working through Nand2Tetris Part 1 as well as the CS:APP textbook, and it is my understanding that CPU designers generally strive to minimize the hardware complexity as best as they can, since it's relatively expensive to try and fit more units/bus lines/whatever it may be into a chip. For example, instead of having a separate instruction for both integer addition and subtraction, the complier can just convert the number that is subtracting to a negative, then do addition on the two numbers instead. 5 - 8, for instance, can be converted to 5 + (-8). For more complicated operations like the ones mentioned in the title, how does the OS or complier convert this to a series of primative instructions that the processor can then read?

Another example that I hope illustrates my question is a scientific calculator, any regular one you can buy from the store for $20. Its CPU is relatively simple, and I'm assuming it wouldn't have dedicated units for complicated mathematical operations. How does this device break complex expressions into simple instructions?
gpt
Ultimately, the way the computer does it is not, in principle, all that different from the way you would do it by hand.  When you pick up paper and pen and do long division or calculate a square root using Newton's method, what you are doing is exactly "perform[ing the operation] with primitive operations."  The optimal method for a computer might not be quite the same as what you do on paper, but it's basically the same idea.

These are then written as software and made available in the standard library for applications to use.  Or maybe even in the microcode, for important functions like integer division.