Hacker News new | ask | show | jobs
by atum47 618 days ago
I've been wondering about something and I don't know if this is the place to ask it, but here it goes. I saw a video the other day about how the Nintendo 64 did not have the ability to calculate sine, so they used a lookup table from 0 to 2PI (with some clever trick to reduce the size of the table). Would it have been possibly to train a NN and store the weights or even a function and store the coefficients to calculate the sine, cosine?
5 comments

Neural networks often have trigonometric functions internally, so it would be massively more computation than necessary.

If you have a few spare CPU cycles, a hybrid approximation could start with a sparse lookup table of values as the initial guess for a few rounds of a numerical approximation technique. Or you just store the first few coefficients of a polynomial approximation (as in the OP's work).

Take a look at CORDIC if you aren't familiar with it; that was a common trig hack back in the day, and still sees some use in the embedded space.

Neural nets can be useful when you have samples of a function but no idea how to approximate it, but that's not the case here.

Obviously you could train some kind of neural net to calculate any function, but this would never make sense for a well-known function like sine. Neural nets are a great solution when you need to evaluate something that isn't easy to analyze mathematically, but there are already many known techniques for calculating and approximating trigonometric functions.

Training a neural net to calculate sines is like the math equivalent of using an LLM to reverse a string. Sure, you *can*, but the idea only makes sense if you don't understand how fundamentally solvable the problem is with a more direct approach.

It's always worth looking if mathematicians already have a solution to a problem before reaching for AI/ML techniques. Unfortunately, a lot of effort is probably being spent these days programming some kind of AI/ML to solve problems that have a known, efficient, maybe even proven optimal solution that developers just don't know about.

> using an LLM to reverse a string.

  Input: Please reverse the string "Dlrow, Olleh!"
  Output (chatgpt): Sure! The reversed string is "!helleO ,worldD"
  Output (liquid): The reversed string is "!ehT, Llord!"
  Output (llama): The reversed string is "Hellol, Wlod."
  Output (phi): The reversed string of "Dlrow, Olleh!" is "!HoleL ,owrdL" or "Hello, World!" backwards.
  Output (qwen): The reversed string of "Dlrow, Olleh!" is "!hlelo ,wolrD".
Honestly some of them are doing better than I expected.
A neural network is essentially just a curve fitter, so yeah. You might find this[1] video illuminating.

The main strength of a neural network comes into play when there's a lot of different inputs, not just a handful. For the simpler cases like sin(x) we have other tools like the one posted here.

[1]: https://www.youtube.com/watch?v=FBpPjjhJGhk But what is a neural network REALLY?

The usual conservation trick is to have a table from 0 to PI/2 and use two additional index bits to generate the other three quadrants.