Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 283385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:22:08+00:00 2026-05-12T05:22:08+00:00

I recently wrote a Vector 3 class, and I submitted my normalize() function for

  • 0

I recently wrote a Vector 3 class, and I submitted my normalize() function for reviewal to a friend. He said it was good, but that I should multiply by the reciprocal where possible because “multiplying is cheaper than dividing” in CPU time.

My question simply is, why is that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:22:08+00:00Added an answer on May 12, 2026 at 5:22 am

    Think about it in terms of elementary operations that hardware can more easily implement — add, subtract, shift, compare. Multiplication even in a trivial setup requires fewer such elementary steps — plus, it afford advances algorithms that are even faster — see here for example… but hardware generally doesn’t take advantage of those (except maybe extremely specialized hardware). For example, as the wikipedia URL says, “Toom–Cook can do a size-N cubed multiplication for the cost of five size-N multiplications” — that’s pretty fast indeed for very large numbers (Fürer’s algorithm, a pretty recent development, can do Θ(n ln(n) 2Θ(ln*(n))) — again, see the wikipedia page and links therefrom).

    Division’s just intrisically slower, as — again — per wikipedia; even the best algorithms (some of which ARE implemented in HW, just because they’re nowhere as sophisticated and complex as the very best algorithms for multiplication;-) can’t hold a candle to the multiplication ones.

    Just to quantify the issue with not-so-huge numbers, here are some results with gmpy, an easy-to-use Python wrapper around GMP, which tends to have pretty good implementations of arithmetic though not necessarily the latest-and-greatest wheezes. On a slow (first-generation;-) Macbook Pro:

    $ python -mtimeit -s'import gmpy as g; a=g.mpf(198792823083408); b=g.mpf(7230824083); ib=1.0/b' 'a*ib'
    1000000 loops, best of 3: 0.186 usec per loop
    $ python -mtimeit -s'import gmpy as g; a=g.mpf(198792823083408); b=g.mpf(7230824083); ib=1.0/b' 'a/b'
    1000000 loops, best of 3: 0.276 usec per loop
    

    As you see, even at this small size (number of bits in the numbers), and with libraries optimized by exactly the same speed-obsessed people, multiplication by the reciprocal can save 1/3 of the time that division takes.

    It may be only in rare situations that these few nanoseconds are a life-or-death issue, but, when they are, and of course IF you are repeatedly dividing by the same value (to amortize away the 1.0/b operation!), then this knowledge can be a life-saver.

    (Much in the same vein — x*x will often save time compared to x**2 [in languages that have a ** “raise to power” operator, like Python and Fortran] — and Horner’s scheme for polynomial computation is VASTLY preferable to repeated raise-to-power operations!-).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 143k
  • Answers 143k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you have more or less point-to-point requests between few… May 12, 2026 at 8:29 am
  • Editorial Team
    Editorial Team added an answer Thinking in terms of a less tortuous solution, this, too,… May 12, 2026 at 8:29 am
  • Editorial Team
    Editorial Team added an answer Your CSS appears to be incorrect; you will want to… May 12, 2026 at 8:29 am

Related Questions

I recently wrote a parser in Python using Ply (it's a python reimplementation of
I recently wrote a DLL in C# (.Net 2.0) which contains a class that
I recently wrote a class for an assignment in which I had to store
I recently wrote a piece of code which did SomeClass someObject; mysqlpp::StoreQueryResult result =
I recently wrote a small tool to generate a class for each tier I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.