Double multiplication vs addition speed
<h2>Background</h2>

<p>I'm an aerospace engineering and EECS student. I'm at the point where I work with a lot of math and physics, but haven't gotten into algorithms or assembly language yet.</p>

<p>I design and code a comically wide variety of programs, from business proposal software to satellite hardware controllers.</p>

<p>Most of this work involves doing math in some other medium, then writing code to implement it.</p>

<p>I algebraically simplify these equations before putting them into code. But before I expend the time to do so, I would like to know whether I should favor more addition operations, or more multiplication operations. (I already know division is much more costly.)</p>

<hr>

<h2>Example</h2>

<p><a href="https://i.stack.imgur.com/ezkmH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ezkmH.png" alt="B sub-x prime"></a></p>

<p>This is an equation I've derived from some other work, and this is pretty typical of what I see.</p>

<p>We can plainly see that there are at least a handful of ways to simplify this equation. Since the simplification is at my discretion, I'd like to pick the option that favors performance as much as <strong><em>practical</em></strong>. I'm not going for bleeding-edge performance at the cost of algorithm design time.</p>

<hr>

<h2>The Question</h2>

<p><strong>In general, which double operation is faster: addition or multiplication?</strong></p>

<p>I know the only definitive way to know which is faster is to write and run benchmarks, but that isn't the point here. <em>This is not a high enough priority in what I do to justify writing test code every time I need to simplify an equation.</em> What I need is a rule of thumb to apply to my algebra.</p>

<p>If the difference is so marginal as to border on negligible or inconclusive, that's an acceptable answer, so long as I know it makes nearly no difference.</p>

<hr>

<h2>Backing Research</h2>

<p>I know that, in C and C++, <a href="https://stackoverflow.com/q/33152446/1519716">the optimizer takes care of the algebra</a>, so it's a null-issue. However, as I understand it, <a href="https://stackoverflow.com/q/5981460/1519716">the Java compiler does not do algebraic simplification/optimization</a>. Specifically, <a href="https://stackoverflow.com/a/5981492/1519716">this answer</a> indicates this to be the case, and that the programmer should do this sort of optimization.</p>

<p>There are scattered answers for this across the internet, but I can't come up with a conclusive answer. <a href="http://pages.physics.cornell.edu/~cmuhlberger/documents/astr415-homework1-report.pdf" rel="nofollow noreferrer">A former University of Maryland physics student</a> ran these tests on Java, but the double performance data is absent in the tables, and the graph scales make the results indiscernible. <a href="http://lemire.me/blog/2010/07/19/is-multiplication-slower-than-addition/" rel="nofollow noreferrer">This University of Quebec CS professor's tests</a> only reveal results for integer operations. <a href="https://stackoverflow.com/a/21819771/1519716">This SO answer</a> explains that, on a hardware level, multiplication is a more complicated operation, but I'm also aware that engineers design processors with these sorts of things in mind.</p>

<p>Other marginally helpful links:</p>

<ul>
<li><a href="https://stackoverflow.com/q/329613/1519716">SO: Decimal vs Double Speed</a></li>
<li><a href="http://www.ibm.com/developerworks/ibm/library/it-haggar_bytecode/" rel="nofollow noreferrer">IBM article on Java bytecode</a></li>
<li><a href="https://stackoverflow.com/q/12569367/1519716">SO: Theory - Addition operation versus multiplication operation</a></li>
<li><a href="https://stackoverflow.com/q/7072097/1519716">SO: (n - Multiplication) vs (n/2 - multiplication + 2 additions) which is better?</a></li>
</ul>