TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: When designing an algorithm, how can the maths be coded?

1 pointsby saadalemalmost 6 years ago
I'm a little bit confused with how the maths can be coded into an algorithm..

1 comment

db48xalmost 6 years ago
There are a lot of different types of algorithms. Some algorithms don&#x27;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&#x27;s equations. It&#x27;s again just simple arithmetic, but this time applied over and over to every point in the space.<p>Your question is quite broad, you might try narrowing it down to one specific, concrete question.