From Newsgroup: sci.math
On 10/21/2026 9:30 AM, Lawrence DrCOOliveiro wrote:
On Tue, 20 Oct 2026 17:15:28 -0000 (UTC), Thomas Koenig wrote:
But the attitude of not caring about speed can have grave results
when the inefficiencies pile up.
ThatrCOs not usually how code works, though. Execution time tends to
follow a Pareto distribution -- spend your effort on the 10% of the
code where 90% of the time is being spent, and that gives significant improvements without having to mess around with the other 90% of the
code.
This is true of code. Yet, you can math yourself to a better solution.
The /obvious/ example everyone here knows is sum of integers, as
int sumint( int a ) {
int value = 0 ;
for ( int i = 1 ; i <= a ; i++ )
value += i ;
return value ;
}
whereas a mathematician might code it as
int sumint( int a ) { return a * ( a + 1 ) / 2 ; }
which is much faster for a large a.
The point I'm making here is that if you myopically focus too much on
the hot code, you might miss an obvious mathematical optimization.
I added sci.math in case the wizards there want to add more obvious ex-
amples I may not be aware of.
Best wishes, and happy optimizations!
--
Johann | email: invalid -> com |
http://www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | via Easynews.com
https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
Federated at
https://fed.brid.gy/bsky/myrkraverk.bsky.social
--- Synchronet 3.22a-Linux NewsLink 1.2