2 ms·
> better to put your mathematics in the comments, than the reverse I respectfully, and strongly, disagree. Try to implement the conjugate gradient algorithm (
by enriquto 8y ago
> better to put your mathematics in the comments, than the reverse
I respectfully, and strongly, disagree. Try to implement the conjugate gradient algorithm (or a variation of it) https://en.wikipedia.org/wiki/Conjugate_gradient_method https://en.wikipedia.org/wiki/Conjugate_gradient_method Using your style, you will obtain an unreadable mess. Better make your code isomorphic to your math, and then explain the meaning of everything in the comments.
> force = (g_constant * mass[0] * mass[1])/(radius 2)
> Communicates far more than the algebraic alternative.
I don't see how this is clearer than something like this
// Newton's law of gravitation
//
// m : mass of first body
// M : mass of second body
// G : universal gravitational constant
// r : distance between the two bodies
// F : force between the two bodies
F = G * m * M / (r^2)
- mjburgess 8y agoThe problem arises at the 1000-line program level and above.