
Ask HN: When designing an algorithm, how can the maths be coded? - saadalem
I&#x27;m a little bit confused with how the maths can be coded into an algorithm..
======
db48x
There are a lot of different types of algorithms. Some algorithms don't have
any math at all. Consider an algorithm for sorting a list; it just tells you
which elements to swap and how to know once the list is completely sorted. An
algorithm for computing the roots of a polynomial just has to do arithmetic on
a few numbers (it would just plug them into the quadratic equation), and
computers are quite good at arithmetic. More complex algorithms are mostly
just more involved arithmetic on larger sets of data, and more bookkeeping to
keep track of what the numbers mean. For example, if you were simulating
electrodynamics for a small set of charged particles, you would need to know
the positions and velocities of the charged particles, and the current value
for the electric and magnetic field at every point in your simulated space.
Calculating the new value for the two fields is then just a matter of applying
Maxwell's equations. It's again just simple arithmetic, but this time applied
over and over to every point in the space.

Your question is quite broad, you might try narrowing it down to one specific,
concrete question.

