FastMath dist3

Percentage Accurate: 97.9% → 100.0%
Time: 7.5s
Alternatives: 6
Speedup: 1.9×

Specification

?
\[\begin{array}{l} \\ \left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \end{array} \]
(FPCore (d1 d2 d3)
 :precision binary64
 (+ (+ (* d1 d2) (* (+ d3 5.0) d1)) (* d1 32.0)))
double code(double d1, double d2, double d3) {
	return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
}
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    code = ((d1 * d2) + ((d3 + 5.0d0) * d1)) + (d1 * 32.0d0)
end function
public static double code(double d1, double d2, double d3) {
	return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
}
def code(d1, d2, d3):
	return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0)
function code(d1, d2, d3)
	return Float64(Float64(Float64(d1 * d2) + Float64(Float64(d3 + 5.0) * d1)) + Float64(d1 * 32.0))
end
function tmp = code(d1, d2, d3)
	tmp = ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
end
code[d1_, d2_, d3_] := N[(N[(N[(d1 * d2), $MachinePrecision] + N[(N[(d3 + 5.0), $MachinePrecision] * d1), $MachinePrecision]), $MachinePrecision] + N[(d1 * 32.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 97.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \end{array} \]
(FPCore (d1 d2 d3)
 :precision binary64
 (+ (+ (* d1 d2) (* (+ d3 5.0) d1)) (* d1 32.0)))
double code(double d1, double d2, double d3) {
	return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
}
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    code = ((d1 * d2) + ((d3 + 5.0d0) * d1)) + (d1 * 32.0d0)
end function
public static double code(double d1, double d2, double d3) {
	return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
}
def code(d1, d2, d3):
	return ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0)
function code(d1, d2, d3)
	return Float64(Float64(Float64(d1 * d2) + Float64(Float64(d3 + 5.0) * d1)) + Float64(d1 * 32.0))
end
function tmp = code(d1, d2, d3)
	tmp = ((d1 * d2) + ((d3 + 5.0) * d1)) + (d1 * 32.0);
end
code[d1_, d2_, d3_] := N[(N[(N[(d1 * d2), $MachinePrecision] + N[(N[(d3 + 5.0), $MachinePrecision] * d1), $MachinePrecision]), $MachinePrecision] + N[(d1 * 32.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32
\end{array}

Alternative 1: 100.0% accurate, 1.9× speedup?

\[\begin{array}{l} \\ d1 \cdot \left(d3 + \left(d2 + 37\right)\right) \end{array} \]
(FPCore (d1 d2 d3) :precision binary64 (* d1 (+ d3 (+ d2 37.0))))
double code(double d1, double d2, double d3) {
	return d1 * (d3 + (d2 + 37.0));
}
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    code = d1 * (d3 + (d2 + 37.0d0))
end function
public static double code(double d1, double d2, double d3) {
	return d1 * (d3 + (d2 + 37.0));
}
def code(d1, d2, d3):
	return d1 * (d3 + (d2 + 37.0))
function code(d1, d2, d3)
	return Float64(d1 * Float64(d3 + Float64(d2 + 37.0)))
end
function tmp = code(d1, d2, d3)
	tmp = d1 * (d3 + (d2 + 37.0));
end
code[d1_, d2_, d3_] := N[(d1 * N[(d3 + N[(d2 + 37.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d1 \cdot \left(d3 + \left(d2 + 37\right)\right)
\end{array}
Derivation
  1. Initial program 95.7%

    \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
  2. Step-by-step derivation
    1. cancel-sign-sub95.7%

      \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
    2. +-commutative95.7%

      \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
    3. *-commutative95.7%

      \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
    4. distribute-lft-out100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
    5. distribute-lft-neg-out100.0%

      \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
    6. distribute-rgt-neg-in100.0%

      \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
    7. distribute-lft-out--100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
    8. associate-+r+100.0%

      \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
    9. +-commutative100.0%

      \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
    10. associate--l+100.0%

      \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
    11. sub-neg100.0%

      \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
    12. metadata-eval100.0%

      \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
    13. metadata-eval100.0%

      \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
    14. associate-+l+100.0%

      \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
    15. metadata-eval100.0%

      \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 51.4% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -38:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d2 \leq -1.25 \cdot 10^{-26} \lor \neg \left(d2 \leq -1.05 \cdot 10^{-36}\right) \land \left(d2 \leq -7.8 \cdot 10^{-41} \lor \neg \left(d2 \leq -3.4 \cdot 10^{-45}\right) \land \left(d2 \leq -1.5 \cdot 10^{-61} \lor \neg \left(d2 \leq -1 \cdot 10^{-64}\right) \land \left(d2 \leq -1.7 \cdot 10^{-81} \lor \neg \left(d2 \leq -1.7 \cdot 10^{-82}\right) \land \left(d2 \leq -3.9 \cdot 10^{-121} \lor \neg \left(d2 \leq -6.5 \cdot 10^{-136}\right) \land \left(d2 \leq -5.9 \cdot 10^{-140} \lor \neg \left(d2 \leq -1.05 \cdot 10^{-146}\right) \land \left(d2 \leq -2.55 \cdot 10^{-173} \lor \neg \left(d2 \leq -3.3 \cdot 10^{-190}\right) \land \left(d2 \leq -3.15 \cdot 10^{-198} \lor \neg \left(d2 \leq -1.2 \cdot 10^{-211}\right) \land \left(d2 \leq -3 \cdot 10^{-216} \lor \neg \left(d2 \leq -7.6 \cdot 10^{-226}\right) \land \left(d2 \leq -3.35 \cdot 10^{-239} \lor \neg \left(d2 \leq -1.75 \cdot 10^{-239}\right) \land \left(d2 \leq -1.2 \cdot 10^{-248} \lor \neg \left(d2 \leq -9.2 \cdot 10^{-253}\right) \land \left(d2 \leq -7.2 \cdot 10^{-258} \lor \neg \left(d2 \leq -1.3 \cdot 10^{-280}\right) \land \left(d2 \leq -9.8 \cdot 10^{-291} \lor \neg \left(d2 \leq -5.2 \cdot 10^{-301}\right) \land \left(d2 \leq -1.5 \cdot 10^{-306} \lor \neg \left(d2 \leq 2.4 \cdot 10^{-295}\right) \land \left(d2 \leq 3.7 \cdot 10^{-291} \lor \neg \left(d2 \leq 1.5 \cdot 10^{-286}\right) \land \left(d2 \leq 2.6 \cdot 10^{-286} \lor \neg \left(d2 \leq 1.05 \cdot 10^{-285}\right) \land \left(d2 \leq 1.35 \cdot 10^{-284} \lor \neg \left(d2 \leq 1.8 \cdot 10^{-283}\right) \land \left(d2 \leq 5.8 \cdot 10^{-280} \lor \neg \left(d2 \leq 8.5 \cdot 10^{-232}\right) \land \left(d2 \leq 3.7 \cdot 10^{-215} \lor \neg \left(d2 \leq 2 \cdot 10^{-210}\right) \land \left(d2 \leq 4.5 \cdot 10^{-207} \lor \neg \left(d2 \leq 2.3 \cdot 10^{-191}\right) \land \left(d2 \leq 1.5 \cdot 10^{-169} \lor \neg \left(d2 \leq 3.4 \cdot 10^{-167}\right) \land \left(d2 \leq 2.55 \cdot 10^{-160} \lor \neg \left(d2 \leq 4.6 \cdot 10^{-159}\right) \land \left(d2 \leq 1.05 \cdot 10^{-134} \lor \neg \left(d2 \leq 3.2 \cdot 10^{-73}\right) \land d2 \leq 1.32 \cdot 10^{-64}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right):\\ \;\;\;\;d1 \cdot 37\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d3\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3)
 :precision binary64
 (if (<= d2 -38.0)
   (* d1 d2)
   (if (or (<= d2 -1.25e-26)
           (and (not (<= d2 -1.05e-36))
                (or (<= d2 -7.8e-41)
                    (and (not (<= d2 -3.4e-45))
                         (or (<= d2 -1.5e-61)
                             (and (not (<= d2 -1e-64))
                                  (or (<= d2 -1.7e-81)
                                      (and (not (<= d2 -1.7e-82))
                                           (or (<= d2 -3.9e-121)
                                               (and (not (<= d2 -6.5e-136))
                                                    (or (<= d2 -5.9e-140)
                                                        (and (not
                                                              (<=
                                                               d2
                                                               -1.05e-146))
                                                             (or (<=
                                                                  d2
                                                                  -2.55e-173)
                                                                 (and (not
                                                                       (<=
                                                                        d2
                                                                        -3.3e-190))
                                                                      (or (<=
                                                                           d2
                                                                           -3.15e-198)
                                                                          (and (not
                                                                                (<=
                                                                                 d2
                                                                                 -1.2e-211))
                                                                               (or (<=
                                                                                    d2
                                                                                    -3e-216)
                                                                                   (and (not
                                                                                         (<=
                                                                                          d2
                                                                                          -7.6e-226))
                                                                                        (or (<=
                                                                                             d2
                                                                                             -3.35e-239)
                                                                                            (and (not
                                                                                                  (<=
                                                                                                   d2
                                                                                                   -1.75e-239))
                                                                                                 (or (<=
                                                                                                      d2
                                                                                                      -1.2e-248)
                                                                                                     (and (not
                                                                                                           (<=
                                                                                                            d2
                                                                                                            -9.2e-253))
                                                                                                          (or (<=
                                                                                                               d2
                                                                                                               -7.2e-258)
                                                                                                              (and (not
                                                                                                                    (<=
                                                                                                                     d2
                                                                                                                     -1.3e-280))
                                                                                                                   (or (<=
                                                                                                                        d2
                                                                                                                        -9.8e-291)
                                                                                                                       (and (not
                                                                                                                             (<=
                                                                                                                              d2
                                                                                                                              -5.2e-301))
                                                                                                                            (or (<=
                                                                                                                                 d2
                                                                                                                                 -1.5e-306)
                                                                                                                                (and (not
                                                                                                                                      (<=
                                                                                                                                       d2
                                                                                                                                       2.4e-295))
                                                                                                                                     (or (<=
                                                                                                                                          d2
                                                                                                                                          3.7e-291)
                                                                                                                                         (and (not
                                                                                                                                               (<=
                                                                                                                                                d2
                                                                                                                                                1.5e-286))
                                                                                                                                              (or (<=
                                                                                                                                                   d2
                                                                                                                                                   2.6e-286)
                                                                                                                                                  (and (not
                                                                                                                                                        (<=
                                                                                                                                                         d2
                                                                                                                                                         1.05e-285))
                                                                                                                                                       (or (<=
                                                                                                                                                            d2
                                                                                                                                                            1.35e-284)
                                                                                                                                                           (and (not
                                                                                                                                                                 (<=
                                                                                                                                                                  d2
                                                                                                                                                                  1.8e-283))
                                                                                                                                                                (or (<=
                                                                                                                                                                     d2
                                                                                                                                                                     5.8e-280)
                                                                                                                                                                    (and (not
                                                                                                                                                                          (<=
                                                                                                                                                                           d2
                                                                                                                                                                           8.5e-232))
                                                                                                                                                                         (or (<=
                                                                                                                                                                              d2
                                                                                                                                                                              3.7e-215)
                                                                                                                                                                             (and (not
                                                                                                                                                                                   (<=
                                                                                                                                                                                    d2
                                                                                                                                                                                    2e-210))
                                                                                                                                                                                  (or (<=
                                                                                                                                                                                       d2
                                                                                                                                                                                       4.5e-207)
                                                                                                                                                                                      (and (not
                                                                                                                                                                                            (<=
                                                                                                                                                                                             d2
                                                                                                                                                                                             2.3e-191))
                                                                                                                                                                                           (or (<=
                                                                                                                                                                                                d2
                                                                                                                                                                                                1.5e-169)
                                                                                                                                                                                               (and (not
                                                                                                                                                                                                     (<=
                                                                                                                                                                                                      d2
                                                                                                                                                                                                      3.4e-167))
                                                                                                                                                                                                    (or (<=
                                                                                                                                                                                                         d2
                                                                                                                                                                                                         2.55e-160)
                                                                                                                                                                                                        (and (not
                                                                                                                                                                                                              (<=
                                                                                                                                                                                                               d2
                                                                                                                                                                                                               4.6e-159))
                                                                                                                                                                                                             (or (<=
                                                                                                                                                                                                                  d2
                                                                                                                                                                                                                  1.05e-134)
                                                                                                                                                                                                                 (and (not
                                                                                                                                                                                                                       (<=
                                                                                                                                                                                                                        d2
                                                                                                                                                                                                                        3.2e-73))
                                                                                                                                                                                                                      (<=
                                                                                                                                                                                                                       d2
                                                                                                                                                                                                                       1.32e-64)))))))))))))))))))))))))))))))))))))))))))))))
     (* d1 37.0)
     (* d1 d3))))
double code(double d1, double d2, double d3) {
	double tmp;
	if (d2 <= -38.0) {
		tmp = d1 * d2;
	} else if ((d2 <= -1.25e-26) || (!(d2 <= -1.05e-36) && ((d2 <= -7.8e-41) || (!(d2 <= -3.4e-45) && ((d2 <= -1.5e-61) || (!(d2 <= -1e-64) && ((d2 <= -1.7e-81) || (!(d2 <= -1.7e-82) && ((d2 <= -3.9e-121) || (!(d2 <= -6.5e-136) && ((d2 <= -5.9e-140) || (!(d2 <= -1.05e-146) && ((d2 <= -2.55e-173) || (!(d2 <= -3.3e-190) && ((d2 <= -3.15e-198) || (!(d2 <= -1.2e-211) && ((d2 <= -3e-216) || (!(d2 <= -7.6e-226) && ((d2 <= -3.35e-239) || (!(d2 <= -1.75e-239) && ((d2 <= -1.2e-248) || (!(d2 <= -9.2e-253) && ((d2 <= -7.2e-258) || (!(d2 <= -1.3e-280) && ((d2 <= -9.8e-291) || (!(d2 <= -5.2e-301) && ((d2 <= -1.5e-306) || (!(d2 <= 2.4e-295) && ((d2 <= 3.7e-291) || (!(d2 <= 1.5e-286) && ((d2 <= 2.6e-286) || (!(d2 <= 1.05e-285) && ((d2 <= 1.35e-284) || (!(d2 <= 1.8e-283) && ((d2 <= 5.8e-280) || (!(d2 <= 8.5e-232) && ((d2 <= 3.7e-215) || (!(d2 <= 2e-210) && ((d2 <= 4.5e-207) || (!(d2 <= 2.3e-191) && ((d2 <= 1.5e-169) || (!(d2 <= 3.4e-167) && ((d2 <= 2.55e-160) || (!(d2 <= 4.6e-159) && ((d2 <= 1.05e-134) || (!(d2 <= 3.2e-73) && (d2 <= 1.32e-64))))))))))))))))))))))))))))))))))))))))))))))) {
		tmp = d1 * 37.0;
	} else {
		tmp = d1 * d3;
	}
	return tmp;
}
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    real(8) :: tmp
    if (d2 <= (-38.0d0)) then
        tmp = d1 * d2
    else if ((d2 <= (-1.25d-26)) .or. (.not. (d2 <= (-1.05d-36))) .and. (d2 <= (-7.8d-41)) .or. (.not. (d2 <= (-3.4d-45))) .and. (d2 <= (-1.5d-61)) .or. (.not. (d2 <= (-1d-64))) .and. (d2 <= (-1.7d-81)) .or. (.not. (d2 <= (-1.7d-82))) .and. (d2 <= (-3.9d-121)) .or. (.not. (d2 <= (-6.5d-136))) .and. (d2 <= (-5.9d-140)) .or. (.not. (d2 <= (-1.05d-146))) .and. (d2 <= (-2.55d-173)) .or. (.not. (d2 <= (-3.3d-190))) .and. (d2 <= (-3.15d-198)) .or. (.not. (d2 <= (-1.2d-211))) .and. (d2 <= (-3d-216)) .or. (.not. (d2 <= (-7.6d-226))) .and. (d2 <= (-3.35d-239)) .or. (.not. (d2 <= (-1.75d-239))) .and. (d2 <= (-1.2d-248)) .or. (.not. (d2 <= (-9.2d-253))) .and. (d2 <= (-7.2d-258)) .or. (.not. (d2 <= (-1.3d-280))) .and. (d2 <= (-9.8d-291)) .or. (.not. (d2 <= (-5.2d-301))) .and. (d2 <= (-1.5d-306)) .or. (.not. (d2 <= 2.4d-295)) .and. (d2 <= 3.7d-291) .or. (.not. (d2 <= 1.5d-286)) .and. (d2 <= 2.6d-286) .or. (.not. (d2 <= 1.05d-285)) .and. (d2 <= 1.35d-284) .or. (.not. (d2 <= 1.8d-283)) .and. (d2 <= 5.8d-280) .or. (.not. (d2 <= 8.5d-232)) .and. (d2 <= 3.7d-215) .or. (.not. (d2 <= 2d-210)) .and. (d2 <= 4.5d-207) .or. (.not. (d2 <= 2.3d-191)) .and. (d2 <= 1.5d-169) .or. (.not. (d2 <= 3.4d-167)) .and. (d2 <= 2.55d-160) .or. (.not. (d2 <= 4.6d-159)) .and. (d2 <= 1.05d-134) .or. (.not. (d2 <= 3.2d-73)) .and. (d2 <= 1.32d-64)) then
        tmp = d1 * 37.0d0
    else
        tmp = d1 * d3
    end if
    code = tmp
end function
public static double code(double d1, double d2, double d3) {
	double tmp;
	if (d2 <= -38.0) {
		tmp = d1 * d2;
	} else if ((d2 <= -1.25e-26) || (!(d2 <= -1.05e-36) && ((d2 <= -7.8e-41) || (!(d2 <= -3.4e-45) && ((d2 <= -1.5e-61) || (!(d2 <= -1e-64) && ((d2 <= -1.7e-81) || (!(d2 <= -1.7e-82) && ((d2 <= -3.9e-121) || (!(d2 <= -6.5e-136) && ((d2 <= -5.9e-140) || (!(d2 <= -1.05e-146) && ((d2 <= -2.55e-173) || (!(d2 <= -3.3e-190) && ((d2 <= -3.15e-198) || (!(d2 <= -1.2e-211) && ((d2 <= -3e-216) || (!(d2 <= -7.6e-226) && ((d2 <= -3.35e-239) || (!(d2 <= -1.75e-239) && ((d2 <= -1.2e-248) || (!(d2 <= -9.2e-253) && ((d2 <= -7.2e-258) || (!(d2 <= -1.3e-280) && ((d2 <= -9.8e-291) || (!(d2 <= -5.2e-301) && ((d2 <= -1.5e-306) || (!(d2 <= 2.4e-295) && ((d2 <= 3.7e-291) || (!(d2 <= 1.5e-286) && ((d2 <= 2.6e-286) || (!(d2 <= 1.05e-285) && ((d2 <= 1.35e-284) || (!(d2 <= 1.8e-283) && ((d2 <= 5.8e-280) || (!(d2 <= 8.5e-232) && ((d2 <= 3.7e-215) || (!(d2 <= 2e-210) && ((d2 <= 4.5e-207) || (!(d2 <= 2.3e-191) && ((d2 <= 1.5e-169) || (!(d2 <= 3.4e-167) && ((d2 <= 2.55e-160) || (!(d2 <= 4.6e-159) && ((d2 <= 1.05e-134) || (!(d2 <= 3.2e-73) && (d2 <= 1.32e-64))))))))))))))))))))))))))))))))))))))))))))))) {
		tmp = d1 * 37.0;
	} else {
		tmp = d1 * d3;
	}
	return tmp;
}
def code(d1, d2, d3):
	tmp = 0
	if d2 <= -38.0:
		tmp = d1 * d2
	elif (d2 <= -1.25e-26) or (not (d2 <= -1.05e-36) and ((d2 <= -7.8e-41) or (not (d2 <= -3.4e-45) and ((d2 <= -1.5e-61) or (not (d2 <= -1e-64) and ((d2 <= -1.7e-81) or (not (d2 <= -1.7e-82) and ((d2 <= -3.9e-121) or (not (d2 <= -6.5e-136) and ((d2 <= -5.9e-140) or (not (d2 <= -1.05e-146) and ((d2 <= -2.55e-173) or (not (d2 <= -3.3e-190) and ((d2 <= -3.15e-198) or (not (d2 <= -1.2e-211) and ((d2 <= -3e-216) or (not (d2 <= -7.6e-226) and ((d2 <= -3.35e-239) or (not (d2 <= -1.75e-239) and ((d2 <= -1.2e-248) or (not (d2 <= -9.2e-253) and ((d2 <= -7.2e-258) or (not (d2 <= -1.3e-280) and ((d2 <= -9.8e-291) or (not (d2 <= -5.2e-301) and ((d2 <= -1.5e-306) or (not (d2 <= 2.4e-295) and ((d2 <= 3.7e-291) or (not (d2 <= 1.5e-286) and ((d2 <= 2.6e-286) or (not (d2 <= 1.05e-285) and ((d2 <= 1.35e-284) or (not (d2 <= 1.8e-283) and ((d2 <= 5.8e-280) or (not (d2 <= 8.5e-232) and ((d2 <= 3.7e-215) or (not (d2 <= 2e-210) and ((d2 <= 4.5e-207) or (not (d2 <= 2.3e-191) and ((d2 <= 1.5e-169) or (not (d2 <= 3.4e-167) and ((d2 <= 2.55e-160) or (not (d2 <= 4.6e-159) and ((d2 <= 1.05e-134) or (not (d2 <= 3.2e-73) and (d2 <= 1.32e-64)))))))))))))))))))))))))))))))))))))))))))))):
		tmp = d1 * 37.0
	else:
		tmp = d1 * d3
	return tmp
function code(d1, d2, d3)
	tmp = 0.0
	if (d2 <= -38.0)
		tmp = Float64(d1 * d2);
	elseif ((d2 <= -1.25e-26) || (!(d2 <= -1.05e-36) && ((d2 <= -7.8e-41) || (!(d2 <= -3.4e-45) && ((d2 <= -1.5e-61) || (!(d2 <= -1e-64) && ((d2 <= -1.7e-81) || (!(d2 <= -1.7e-82) && ((d2 <= -3.9e-121) || (!(d2 <= -6.5e-136) && ((d2 <= -5.9e-140) || (!(d2 <= -1.05e-146) && ((d2 <= -2.55e-173) || (!(d2 <= -3.3e-190) && ((d2 <= -3.15e-198) || (!(d2 <= -1.2e-211) && ((d2 <= -3e-216) || (!(d2 <= -7.6e-226) && ((d2 <= -3.35e-239) || (!(d2 <= -1.75e-239) && ((d2 <= -1.2e-248) || (!(d2 <= -9.2e-253) && ((d2 <= -7.2e-258) || (!(d2 <= -1.3e-280) && ((d2 <= -9.8e-291) || (!(d2 <= -5.2e-301) && ((d2 <= -1.5e-306) || (!(d2 <= 2.4e-295) && ((d2 <= 3.7e-291) || (!(d2 <= 1.5e-286) && ((d2 <= 2.6e-286) || (!(d2 <= 1.05e-285) && ((d2 <= 1.35e-284) || (!(d2 <= 1.8e-283) && ((d2 <= 5.8e-280) || (!(d2 <= 8.5e-232) && ((d2 <= 3.7e-215) || (!(d2 <= 2e-210) && ((d2 <= 4.5e-207) || (!(d2 <= 2.3e-191) && ((d2 <= 1.5e-169) || (!(d2 <= 3.4e-167) && ((d2 <= 2.55e-160) || (!(d2 <= 4.6e-159) && ((d2 <= 1.05e-134) || (!(d2 <= 3.2e-73) && (d2 <= 1.32e-64)))))))))))))))))))))))))))))))))))))))))))))))
		tmp = Float64(d1 * 37.0);
	else
		tmp = Float64(d1 * d3);
	end
	return tmp
end
function tmp_2 = code(d1, d2, d3)
	tmp = 0.0;
	if (d2 <= -38.0)
		tmp = d1 * d2;
	elseif ((d2 <= -1.25e-26) || (~((d2 <= -1.05e-36)) && ((d2 <= -7.8e-41) || (~((d2 <= -3.4e-45)) && ((d2 <= -1.5e-61) || (~((d2 <= -1e-64)) && ((d2 <= -1.7e-81) || (~((d2 <= -1.7e-82)) && ((d2 <= -3.9e-121) || (~((d2 <= -6.5e-136)) && ((d2 <= -5.9e-140) || (~((d2 <= -1.05e-146)) && ((d2 <= -2.55e-173) || (~((d2 <= -3.3e-190)) && ((d2 <= -3.15e-198) || (~((d2 <= -1.2e-211)) && ((d2 <= -3e-216) || (~((d2 <= -7.6e-226)) && ((d2 <= -3.35e-239) || (~((d2 <= -1.75e-239)) && ((d2 <= -1.2e-248) || (~((d2 <= -9.2e-253)) && ((d2 <= -7.2e-258) || (~((d2 <= -1.3e-280)) && ((d2 <= -9.8e-291) || (~((d2 <= -5.2e-301)) && ((d2 <= -1.5e-306) || (~((d2 <= 2.4e-295)) && ((d2 <= 3.7e-291) || (~((d2 <= 1.5e-286)) && ((d2 <= 2.6e-286) || (~((d2 <= 1.05e-285)) && ((d2 <= 1.35e-284) || (~((d2 <= 1.8e-283)) && ((d2 <= 5.8e-280) || (~((d2 <= 8.5e-232)) && ((d2 <= 3.7e-215) || (~((d2 <= 2e-210)) && ((d2 <= 4.5e-207) || (~((d2 <= 2.3e-191)) && ((d2 <= 1.5e-169) || (~((d2 <= 3.4e-167)) && ((d2 <= 2.55e-160) || (~((d2 <= 4.6e-159)) && ((d2 <= 1.05e-134) || (~((d2 <= 3.2e-73)) && (d2 <= 1.32e-64)))))))))))))))))))))))))))))))))))))))))))))))
		tmp = d1 * 37.0;
	else
		tmp = d1 * d3;
	end
	tmp_2 = tmp;
end
code[d1_, d2_, d3_] := If[LessEqual[d2, -38.0], N[(d1 * d2), $MachinePrecision], If[Or[LessEqual[d2, -1.25e-26], And[N[Not[LessEqual[d2, -1.05e-36]], $MachinePrecision], Or[LessEqual[d2, -7.8e-41], And[N[Not[LessEqual[d2, -3.4e-45]], $MachinePrecision], Or[LessEqual[d2, -1.5e-61], And[N[Not[LessEqual[d2, -1e-64]], $MachinePrecision], Or[LessEqual[d2, -1.7e-81], And[N[Not[LessEqual[d2, -1.7e-82]], $MachinePrecision], Or[LessEqual[d2, -3.9e-121], And[N[Not[LessEqual[d2, -6.5e-136]], $MachinePrecision], Or[LessEqual[d2, -5.9e-140], And[N[Not[LessEqual[d2, -1.05e-146]], $MachinePrecision], Or[LessEqual[d2, -2.55e-173], And[N[Not[LessEqual[d2, -3.3e-190]], $MachinePrecision], Or[LessEqual[d2, -3.15e-198], And[N[Not[LessEqual[d2, -1.2e-211]], $MachinePrecision], Or[LessEqual[d2, -3e-216], And[N[Not[LessEqual[d2, -7.6e-226]], $MachinePrecision], Or[LessEqual[d2, -3.35e-239], And[N[Not[LessEqual[d2, -1.75e-239]], $MachinePrecision], Or[LessEqual[d2, -1.2e-248], And[N[Not[LessEqual[d2, -9.2e-253]], $MachinePrecision], Or[LessEqual[d2, -7.2e-258], And[N[Not[LessEqual[d2, -1.3e-280]], $MachinePrecision], Or[LessEqual[d2, -9.8e-291], And[N[Not[LessEqual[d2, -5.2e-301]], $MachinePrecision], Or[LessEqual[d2, -1.5e-306], And[N[Not[LessEqual[d2, 2.4e-295]], $MachinePrecision], Or[LessEqual[d2, 3.7e-291], And[N[Not[LessEqual[d2, 1.5e-286]], $MachinePrecision], Or[LessEqual[d2, 2.6e-286], And[N[Not[LessEqual[d2, 1.05e-285]], $MachinePrecision], Or[LessEqual[d2, 1.35e-284], And[N[Not[LessEqual[d2, 1.8e-283]], $MachinePrecision], Or[LessEqual[d2, 5.8e-280], And[N[Not[LessEqual[d2, 8.5e-232]], $MachinePrecision], Or[LessEqual[d2, 3.7e-215], And[N[Not[LessEqual[d2, 2e-210]], $MachinePrecision], Or[LessEqual[d2, 4.5e-207], And[N[Not[LessEqual[d2, 2.3e-191]], $MachinePrecision], Or[LessEqual[d2, 1.5e-169], And[N[Not[LessEqual[d2, 3.4e-167]], $MachinePrecision], Or[LessEqual[d2, 2.55e-160], And[N[Not[LessEqual[d2, 4.6e-159]], $MachinePrecision], Or[LessEqual[d2, 1.05e-134], And[N[Not[LessEqual[d2, 3.2e-73]], $MachinePrecision], LessEqual[d2, 1.32e-64]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], N[(d1 * 37.0), $MachinePrecision], N[(d1 * d3), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -38:\\
\;\;\;\;d1 \cdot d2\\

\mathbf{elif}\;d2 \leq -1.25 \cdot 10^{-26} \lor \neg \left(d2 \leq -1.05 \cdot 10^{-36}\right) \land \left(d2 \leq -7.8 \cdot 10^{-41} \lor \neg \left(d2 \leq -3.4 \cdot 10^{-45}\right) \land \left(d2 \leq -1.5 \cdot 10^{-61} \lor \neg \left(d2 \leq -1 \cdot 10^{-64}\right) \land \left(d2 \leq -1.7 \cdot 10^{-81} \lor \neg \left(d2 \leq -1.7 \cdot 10^{-82}\right) \land \left(d2 \leq -3.9 \cdot 10^{-121} \lor \neg \left(d2 \leq -6.5 \cdot 10^{-136}\right) \land \left(d2 \leq -5.9 \cdot 10^{-140} \lor \neg \left(d2 \leq -1.05 \cdot 10^{-146}\right) \land \left(d2 \leq -2.55 \cdot 10^{-173} \lor \neg \left(d2 \leq -3.3 \cdot 10^{-190}\right) \land \left(d2 \leq -3.15 \cdot 10^{-198} \lor \neg \left(d2 \leq -1.2 \cdot 10^{-211}\right) \land \left(d2 \leq -3 \cdot 10^{-216} \lor \neg \left(d2 \leq -7.6 \cdot 10^{-226}\right) \land \left(d2 \leq -3.35 \cdot 10^{-239} \lor \neg \left(d2 \leq -1.75 \cdot 10^{-239}\right) \land \left(d2 \leq -1.2 \cdot 10^{-248} \lor \neg \left(d2 \leq -9.2 \cdot 10^{-253}\right) \land \left(d2 \leq -7.2 \cdot 10^{-258} \lor \neg \left(d2 \leq -1.3 \cdot 10^{-280}\right) \land \left(d2 \leq -9.8 \cdot 10^{-291} \lor \neg \left(d2 \leq -5.2 \cdot 10^{-301}\right) \land \left(d2 \leq -1.5 \cdot 10^{-306} \lor \neg \left(d2 \leq 2.4 \cdot 10^{-295}\right) \land \left(d2 \leq 3.7 \cdot 10^{-291} \lor \neg \left(d2 \leq 1.5 \cdot 10^{-286}\right) \land \left(d2 \leq 2.6 \cdot 10^{-286} \lor \neg \left(d2 \leq 1.05 \cdot 10^{-285}\right) \land \left(d2 \leq 1.35 \cdot 10^{-284} \lor \neg \left(d2 \leq 1.8 \cdot 10^{-283}\right) \land \left(d2 \leq 5.8 \cdot 10^{-280} \lor \neg \left(d2 \leq 8.5 \cdot 10^{-232}\right) \land \left(d2 \leq 3.7 \cdot 10^{-215} \lor \neg \left(d2 \leq 2 \cdot 10^{-210}\right) \land \left(d2 \leq 4.5 \cdot 10^{-207} \lor \neg \left(d2 \leq 2.3 \cdot 10^{-191}\right) \land \left(d2 \leq 1.5 \cdot 10^{-169} \lor \neg \left(d2 \leq 3.4 \cdot 10^{-167}\right) \land \left(d2 \leq 2.55 \cdot 10^{-160} \lor \neg \left(d2 \leq 4.6 \cdot 10^{-159}\right) \land \left(d2 \leq 1.05 \cdot 10^{-134} \lor \neg \left(d2 \leq 3.2 \cdot 10^{-73}\right) \land d2 \leq 1.32 \cdot 10^{-64}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right):\\
\;\;\;\;d1 \cdot 37\\

\mathbf{else}:\\
\;\;\;\;d1 \cdot d3\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d2 < -38

    1. Initial program 94.3%

      \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
    2. Step-by-step derivation
      1. cancel-sign-sub94.3%

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
      2. +-commutative94.3%

        \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
      3. *-commutative94.3%

        \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
      4. distribute-lft-out100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
      5. distribute-lft-neg-out100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
      6. distribute-rgt-neg-in100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
      7. distribute-lft-out--100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
      8. associate-+r+100.0%

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
      10. associate--l+100.0%

        \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
      11. sub-neg100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
      12. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
      13. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
      14. associate-+l+100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
      15. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in d2 around inf 76.2%

      \[\leadsto \color{blue}{d1 \cdot d2} \]

    if -38 < d2 < -1.25000000000000005e-26 or -1.04999999999999995e-36 < d2 < -7.79999999999999982e-41 or -3.40000000000000004e-45 < d2 < -1.50000000000000006e-61 or -9.99999999999999965e-65 < d2 < -1.6999999999999999e-81 or -1.69999999999999988e-82 < d2 < -3.9e-121 or -6.50000000000000011e-136 < d2 < -5.9000000000000002e-140 or -1.05e-146 < d2 < -2.5499999999999999e-173 or -3.30000000000000019e-190 < d2 < -3.15000000000000008e-198 or -1.2000000000000001e-211 < d2 < -3.00000000000000013e-216 or -7.59999999999999963e-226 < d2 < -3.35000000000000019e-239 or -1.75000000000000003e-239 < d2 < -1.20000000000000002e-248 or -9.2000000000000001e-253 < d2 < -7.19999999999999958e-258 or -1.3e-280 < d2 < -9.79999999999999988e-291 or -5.1999999999999996e-301 < d2 < -1.50000000000000012e-306 or 2.3999999999999998e-295 < d2 < 3.7000000000000001e-291 or 1.5e-286 < d2 < 2.6e-286 or 1.04999999999999992e-285 < d2 < 1.34999999999999992e-284 or 1.8e-283 < d2 < 5.8e-280 or 8.5e-232 < d2 < 3.70000000000000009e-215 or 2.0000000000000001e-210 < d2 < 4.49999999999999992e-207 or 2.30000000000000011e-191 < d2 < 1.5e-169 or 3.3999999999999997e-167 < d2 < 2.55e-160 or 4.59999999999999957e-159 < d2 < 1.05e-134 or 3.19999999999999986e-73 < d2 < 1.32e-64

    1. Initial program 99.9%

      \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
    2. Step-by-step derivation
      1. cancel-sign-sub99.9%

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
      2. +-commutative99.9%

        \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
      3. *-commutative99.9%

        \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
      4. distribute-lft-out99.9%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
      5. distribute-lft-neg-out99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
      6. distribute-rgt-neg-in99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
      7. distribute-lft-out--99.9%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
      8. associate-+r+99.9%

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
      9. +-commutative99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
      10. associate--l+99.9%

        \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
      11. sub-neg99.9%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
      12. metadata-eval99.9%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
      13. metadata-eval99.9%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
      14. associate-+l+99.9%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
      15. metadata-eval99.9%

        \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in d2 around 0 99.9%

      \[\leadsto \color{blue}{d1 \cdot \left(37 + d3\right)} \]
    6. Taylor expanded in d3 around 0 66.4%

      \[\leadsto \color{blue}{37 \cdot d1} \]
    7. Step-by-step derivation
      1. *-commutative66.4%

        \[\leadsto \color{blue}{d1 \cdot 37} \]
    8. Simplified66.4%

      \[\leadsto \color{blue}{d1 \cdot 37} \]

    if -1.25000000000000005e-26 < d2 < -1.04999999999999995e-36 or -7.79999999999999982e-41 < d2 < -3.40000000000000004e-45 or -1.50000000000000006e-61 < d2 < -9.99999999999999965e-65 or -1.6999999999999999e-81 < d2 < -1.69999999999999988e-82 or -3.9e-121 < d2 < -6.50000000000000011e-136 or -5.9000000000000002e-140 < d2 < -1.05e-146 or -2.5499999999999999e-173 < d2 < -3.30000000000000019e-190 or -3.15000000000000008e-198 < d2 < -1.2000000000000001e-211 or -3.00000000000000013e-216 < d2 < -7.59999999999999963e-226 or -3.35000000000000019e-239 < d2 < -1.75000000000000003e-239 or -1.20000000000000002e-248 < d2 < -9.2000000000000001e-253 or -7.19999999999999958e-258 < d2 < -1.3e-280 or -9.79999999999999988e-291 < d2 < -5.1999999999999996e-301 or -1.50000000000000012e-306 < d2 < 2.3999999999999998e-295 or 3.7000000000000001e-291 < d2 < 1.5e-286 or 2.6e-286 < d2 < 1.04999999999999992e-285 or 1.34999999999999992e-284 < d2 < 1.8e-283 or 5.8e-280 < d2 < 8.5e-232 or 3.70000000000000009e-215 < d2 < 2.0000000000000001e-210 or 4.49999999999999992e-207 < d2 < 2.30000000000000011e-191 or 1.5e-169 < d2 < 3.3999999999999997e-167 or 2.55e-160 < d2 < 4.59999999999999957e-159 or 1.05e-134 < d2 < 3.19999999999999986e-73 or 1.32e-64 < d2

    1. Initial program 94.2%

      \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
    2. Step-by-step derivation
      1. cancel-sign-sub94.2%

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
      2. +-commutative94.2%

        \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
      3. *-commutative94.2%

        \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
      4. distribute-lft-out99.9%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
      5. distribute-lft-neg-out99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
      6. distribute-rgt-neg-in99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
      7. distribute-lft-out--100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
      8. associate-+r+100.0%

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
      10. associate--l+100.0%

        \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
      11. sub-neg100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
      12. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
      13. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
      14. associate-+l+100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
      15. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in d3 around inf 55.6%

      \[\leadsto \color{blue}{d1 \cdot d3} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification63.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d2 \leq -38:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{elif}\;d2 \leq -1.25 \cdot 10^{-26} \lor \neg \left(d2 \leq -1.05 \cdot 10^{-36}\right) \land \left(d2 \leq -7.8 \cdot 10^{-41} \lor \neg \left(d2 \leq -3.4 \cdot 10^{-45}\right) \land \left(d2 \leq -1.5 \cdot 10^{-61} \lor \neg \left(d2 \leq -1 \cdot 10^{-64}\right) \land \left(d2 \leq -1.7 \cdot 10^{-81} \lor \neg \left(d2 \leq -1.7 \cdot 10^{-82}\right) \land \left(d2 \leq -3.9 \cdot 10^{-121} \lor \neg \left(d2 \leq -6.5 \cdot 10^{-136}\right) \land \left(d2 \leq -5.9 \cdot 10^{-140} \lor \neg \left(d2 \leq -1.05 \cdot 10^{-146}\right) \land \left(d2 \leq -2.55 \cdot 10^{-173} \lor \neg \left(d2 \leq -3.3 \cdot 10^{-190}\right) \land \left(d2 \leq -3.15 \cdot 10^{-198} \lor \neg \left(d2 \leq -1.2 \cdot 10^{-211}\right) \land \left(d2 \leq -3 \cdot 10^{-216} \lor \neg \left(d2 \leq -7.6 \cdot 10^{-226}\right) \land \left(d2 \leq -3.35 \cdot 10^{-239} \lor \neg \left(d2 \leq -1.75 \cdot 10^{-239}\right) \land \left(d2 \leq -1.2 \cdot 10^{-248} \lor \neg \left(d2 \leq -9.2 \cdot 10^{-253}\right) \land \left(d2 \leq -7.2 \cdot 10^{-258} \lor \neg \left(d2 \leq -1.3 \cdot 10^{-280}\right) \land \left(d2 \leq -9.8 \cdot 10^{-291} \lor \neg \left(d2 \leq -5.2 \cdot 10^{-301}\right) \land \left(d2 \leq -1.5 \cdot 10^{-306} \lor \neg \left(d2 \leq 2.4 \cdot 10^{-295}\right) \land \left(d2 \leq 3.7 \cdot 10^{-291} \lor \neg \left(d2 \leq 1.5 \cdot 10^{-286}\right) \land \left(d2 \leq 2.6 \cdot 10^{-286} \lor \neg \left(d2 \leq 1.05 \cdot 10^{-285}\right) \land \left(d2 \leq 1.35 \cdot 10^{-284} \lor \neg \left(d2 \leq 1.8 \cdot 10^{-283}\right) \land \left(d2 \leq 5.8 \cdot 10^{-280} \lor \neg \left(d2 \leq 8.5 \cdot 10^{-232}\right) \land \left(d2 \leq 3.7 \cdot 10^{-215} \lor \neg \left(d2 \leq 2 \cdot 10^{-210}\right) \land \left(d2 \leq 4.5 \cdot 10^{-207} \lor \neg \left(d2 \leq 2.3 \cdot 10^{-191}\right) \land \left(d2 \leq 1.5 \cdot 10^{-169} \lor \neg \left(d2 \leq 3.4 \cdot 10^{-167}\right) \land \left(d2 \leq 2.55 \cdot 10^{-160} \lor \neg \left(d2 \leq 4.6 \cdot 10^{-159}\right) \land \left(d2 \leq 1.05 \cdot 10^{-134} \lor \neg \left(d2 \leq 3.2 \cdot 10^{-73}\right) \land d2 \leq 1.32 \cdot 10^{-64}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right):\\ \;\;\;\;d1 \cdot 37\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d3\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 75.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := d1 \cdot \left(d2 + 37\right)\\ \mathbf{if}\;d3 \leq 1150000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d3 \leq 1.4 \cdot 10^{+39}:\\ \;\;\;\;d1 \cdot d3\\ \mathbf{elif}\;d3 \leq 7 \cdot 10^{+40}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;d3 \leq 1.35 \cdot 10^{+41} \lor \neg \left(d3 \leq 4.8 \cdot 10^{+44}\right) \land \left(d3 \leq 9 \cdot 10^{+62} \lor \neg \left(d3 \leq 4.4 \cdot 10^{+63}\right) \land \left(d3 \leq 9 \cdot 10^{+87} \lor \neg \left(d3 \leq 1.5 \cdot 10^{+88}\right) \land \left(d3 \leq 9.2 \cdot 10^{+109} \lor \neg \left(d3 \leq 10^{+112}\right) \land \left(d3 \leq 6.2 \cdot 10^{+119} \lor \neg \left(d3 \leq 1.3 \cdot 10^{+131}\right) \land \left(d3 \leq 3.4 \cdot 10^{+139} \lor \neg \left(d3 \leq 1.82 \cdot 10^{+140}\right) \land \left(d3 \leq 2.1 \cdot 10^{+156} \lor \neg \left(d3 \leq 3.2 \cdot 10^{+156}\right) \land \left(d3 \leq 1.25 \cdot 10^{+184} \lor \neg \left(d3 \leq 2.15 \cdot 10^{+187}\right) \land \left(d3 \leq 4.1 \cdot 10^{+220} \lor \neg \left(d3 \leq 4.2 \cdot 10^{+220}\right) \land \left(d3 \leq 1.3 \cdot 10^{+231} \lor \neg \left(d3 \leq 1.35 \cdot 10^{+231}\right) \land \left(d3 \leq 1.6 \cdot 10^{+235} \lor \neg \left(d3 \leq 1.65 \cdot 10^{+235}\right) \land \left(d3 \leq 1.05 \cdot 10^{+270} \lor \neg \left(d3 \leq 1.1 \cdot 10^{+270}\right) \land \left(d3 \leq 3.5 \cdot 10^{+283} \lor \neg \left(d3 \leq 3.6 \cdot 10^{+283}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right):\\ \;\;\;\;d1 \cdot d3\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d2\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3)
 :precision binary64
 (let* ((t_0 (* d1 (+ d2 37.0))))
   (if (<= d3 1150000.0)
     t_0
     (if (<= d3 1.4e+39)
       (* d1 d3)
       (if (<= d3 7e+40)
         t_0
         (if (or (<= d3 1.35e+41)
                 (and (not (<= d3 4.8e+44))
                      (or (<= d3 9e+62)
                          (and (not (<= d3 4.4e+63))
                               (or (<= d3 9e+87)
                                   (and (not (<= d3 1.5e+88))
                                        (or (<= d3 9.2e+109)
                                            (and (not (<= d3 1e+112))
                                                 (or (<= d3 6.2e+119)
                                                     (and (not
                                                           (<= d3 1.3e+131))
                                                          (or (<= d3 3.4e+139)
                                                              (and (not
                                                                    (<=
                                                                     d3
                                                                     1.82e+140))
                                                                   (or (<=
                                                                        d3
                                                                        2.1e+156)
                                                                       (and (not
                                                                             (<=
                                                                              d3
                                                                              3.2e+156))
                                                                            (or (<=
                                                                                 d3
                                                                                 1.25e+184)
                                                                                (and (not
                                                                                      (<=
                                                                                       d3
                                                                                       2.15e+187))
                                                                                     (or (<=
                                                                                          d3
                                                                                          4.1e+220)
                                                                                         (and (not
                                                                                               (<=
                                                                                                d3
                                                                                                4.2e+220))
                                                                                              (or (<=
                                                                                                   d3
                                                                                                   1.3e+231)
                                                                                                  (and (not
                                                                                                        (<=
                                                                                                         d3
                                                                                                         1.35e+231))
                                                                                                       (or (<=
                                                                                                            d3
                                                                                                            1.6e+235)
                                                                                                           (and (not
                                                                                                                 (<=
                                                                                                                  d3
                                                                                                                  1.65e+235))
                                                                                                                (or (<=
                                                                                                                     d3
                                                                                                                     1.05e+270)
                                                                                                                    (and (not
                                                                                                                          (<=
                                                                                                                           d3
                                                                                                                           1.1e+270))
                                                                                                                         (or (<=
                                                                                                                              d3
                                                                                                                              3.5e+283)
                                                                                                                             (not
                                                                                                                              (<=
                                                                                                                               d3
                                                                                                                               3.6e+283)))))))))))))))))))))))))))
           (* d1 d3)
           (* d1 d2)))))))
double code(double d1, double d2, double d3) {
	double t_0 = d1 * (d2 + 37.0);
	double tmp;
	if (d3 <= 1150000.0) {
		tmp = t_0;
	} else if (d3 <= 1.4e+39) {
		tmp = d1 * d3;
	} else if (d3 <= 7e+40) {
		tmp = t_0;
	} else if ((d3 <= 1.35e+41) || (!(d3 <= 4.8e+44) && ((d3 <= 9e+62) || (!(d3 <= 4.4e+63) && ((d3 <= 9e+87) || (!(d3 <= 1.5e+88) && ((d3 <= 9.2e+109) || (!(d3 <= 1e+112) && ((d3 <= 6.2e+119) || (!(d3 <= 1.3e+131) && ((d3 <= 3.4e+139) || (!(d3 <= 1.82e+140) && ((d3 <= 2.1e+156) || (!(d3 <= 3.2e+156) && ((d3 <= 1.25e+184) || (!(d3 <= 2.15e+187) && ((d3 <= 4.1e+220) || (!(d3 <= 4.2e+220) && ((d3 <= 1.3e+231) || (!(d3 <= 1.35e+231) && ((d3 <= 1.6e+235) || (!(d3 <= 1.65e+235) && ((d3 <= 1.05e+270) || (!(d3 <= 1.1e+270) && ((d3 <= 3.5e+283) || !(d3 <= 3.6e+283)))))))))))))))))))))))))) {
		tmp = d1 * d3;
	} else {
		tmp = d1 * d2;
	}
	return tmp;
}
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    real(8) :: t_0
    real(8) :: tmp
    t_0 = d1 * (d2 + 37.0d0)
    if (d3 <= 1150000.0d0) then
        tmp = t_0
    else if (d3 <= 1.4d+39) then
        tmp = d1 * d3
    else if (d3 <= 7d+40) then
        tmp = t_0
    else if ((d3 <= 1.35d+41) .or. (.not. (d3 <= 4.8d+44)) .and. (d3 <= 9d+62) .or. (.not. (d3 <= 4.4d+63)) .and. (d3 <= 9d+87) .or. (.not. (d3 <= 1.5d+88)) .and. (d3 <= 9.2d+109) .or. (.not. (d3 <= 1d+112)) .and. (d3 <= 6.2d+119) .or. (.not. (d3 <= 1.3d+131)) .and. (d3 <= 3.4d+139) .or. (.not. (d3 <= 1.82d+140)) .and. (d3 <= 2.1d+156) .or. (.not. (d3 <= 3.2d+156)) .and. (d3 <= 1.25d+184) .or. (.not. (d3 <= 2.15d+187)) .and. (d3 <= 4.1d+220) .or. (.not. (d3 <= 4.2d+220)) .and. (d3 <= 1.3d+231) .or. (.not. (d3 <= 1.35d+231)) .and. (d3 <= 1.6d+235) .or. (.not. (d3 <= 1.65d+235)) .and. (d3 <= 1.05d+270) .or. (.not. (d3 <= 1.1d+270)) .and. (d3 <= 3.5d+283) .or. (.not. (d3 <= 3.6d+283))) then
        tmp = d1 * d3
    else
        tmp = d1 * d2
    end if
    code = tmp
end function
public static double code(double d1, double d2, double d3) {
	double t_0 = d1 * (d2 + 37.0);
	double tmp;
	if (d3 <= 1150000.0) {
		tmp = t_0;
	} else if (d3 <= 1.4e+39) {
		tmp = d1 * d3;
	} else if (d3 <= 7e+40) {
		tmp = t_0;
	} else if ((d3 <= 1.35e+41) || (!(d3 <= 4.8e+44) && ((d3 <= 9e+62) || (!(d3 <= 4.4e+63) && ((d3 <= 9e+87) || (!(d3 <= 1.5e+88) && ((d3 <= 9.2e+109) || (!(d3 <= 1e+112) && ((d3 <= 6.2e+119) || (!(d3 <= 1.3e+131) && ((d3 <= 3.4e+139) || (!(d3 <= 1.82e+140) && ((d3 <= 2.1e+156) || (!(d3 <= 3.2e+156) && ((d3 <= 1.25e+184) || (!(d3 <= 2.15e+187) && ((d3 <= 4.1e+220) || (!(d3 <= 4.2e+220) && ((d3 <= 1.3e+231) || (!(d3 <= 1.35e+231) && ((d3 <= 1.6e+235) || (!(d3 <= 1.65e+235) && ((d3 <= 1.05e+270) || (!(d3 <= 1.1e+270) && ((d3 <= 3.5e+283) || !(d3 <= 3.6e+283)))))))))))))))))))))))))) {
		tmp = d1 * d3;
	} else {
		tmp = d1 * d2;
	}
	return tmp;
}
def code(d1, d2, d3):
	t_0 = d1 * (d2 + 37.0)
	tmp = 0
	if d3 <= 1150000.0:
		tmp = t_0
	elif d3 <= 1.4e+39:
		tmp = d1 * d3
	elif d3 <= 7e+40:
		tmp = t_0
	elif (d3 <= 1.35e+41) or (not (d3 <= 4.8e+44) and ((d3 <= 9e+62) or (not (d3 <= 4.4e+63) and ((d3 <= 9e+87) or (not (d3 <= 1.5e+88) and ((d3 <= 9.2e+109) or (not (d3 <= 1e+112) and ((d3 <= 6.2e+119) or (not (d3 <= 1.3e+131) and ((d3 <= 3.4e+139) or (not (d3 <= 1.82e+140) and ((d3 <= 2.1e+156) or (not (d3 <= 3.2e+156) and ((d3 <= 1.25e+184) or (not (d3 <= 2.15e+187) and ((d3 <= 4.1e+220) or (not (d3 <= 4.2e+220) and ((d3 <= 1.3e+231) or (not (d3 <= 1.35e+231) and ((d3 <= 1.6e+235) or (not (d3 <= 1.65e+235) and ((d3 <= 1.05e+270) or (not (d3 <= 1.1e+270) and ((d3 <= 3.5e+283) or not (d3 <= 3.6e+283))))))))))))))))))))))))):
		tmp = d1 * d3
	else:
		tmp = d1 * d2
	return tmp
function code(d1, d2, d3)
	t_0 = Float64(d1 * Float64(d2 + 37.0))
	tmp = 0.0
	if (d3 <= 1150000.0)
		tmp = t_0;
	elseif (d3 <= 1.4e+39)
		tmp = Float64(d1 * d3);
	elseif (d3 <= 7e+40)
		tmp = t_0;
	elseif ((d3 <= 1.35e+41) || (!(d3 <= 4.8e+44) && ((d3 <= 9e+62) || (!(d3 <= 4.4e+63) && ((d3 <= 9e+87) || (!(d3 <= 1.5e+88) && ((d3 <= 9.2e+109) || (!(d3 <= 1e+112) && ((d3 <= 6.2e+119) || (!(d3 <= 1.3e+131) && ((d3 <= 3.4e+139) || (!(d3 <= 1.82e+140) && ((d3 <= 2.1e+156) || (!(d3 <= 3.2e+156) && ((d3 <= 1.25e+184) || (!(d3 <= 2.15e+187) && ((d3 <= 4.1e+220) || (!(d3 <= 4.2e+220) && ((d3 <= 1.3e+231) || (!(d3 <= 1.35e+231) && ((d3 <= 1.6e+235) || (!(d3 <= 1.65e+235) && ((d3 <= 1.05e+270) || (!(d3 <= 1.1e+270) && ((d3 <= 3.5e+283) || !(d3 <= 3.6e+283))))))))))))))))))))))))))
		tmp = Float64(d1 * d3);
	else
		tmp = Float64(d1 * d2);
	end
	return tmp
end
function tmp_2 = code(d1, d2, d3)
	t_0 = d1 * (d2 + 37.0);
	tmp = 0.0;
	if (d3 <= 1150000.0)
		tmp = t_0;
	elseif (d3 <= 1.4e+39)
		tmp = d1 * d3;
	elseif (d3 <= 7e+40)
		tmp = t_0;
	elseif ((d3 <= 1.35e+41) || (~((d3 <= 4.8e+44)) && ((d3 <= 9e+62) || (~((d3 <= 4.4e+63)) && ((d3 <= 9e+87) || (~((d3 <= 1.5e+88)) && ((d3 <= 9.2e+109) || (~((d3 <= 1e+112)) && ((d3 <= 6.2e+119) || (~((d3 <= 1.3e+131)) && ((d3 <= 3.4e+139) || (~((d3 <= 1.82e+140)) && ((d3 <= 2.1e+156) || (~((d3 <= 3.2e+156)) && ((d3 <= 1.25e+184) || (~((d3 <= 2.15e+187)) && ((d3 <= 4.1e+220) || (~((d3 <= 4.2e+220)) && ((d3 <= 1.3e+231) || (~((d3 <= 1.35e+231)) && ((d3 <= 1.6e+235) || (~((d3 <= 1.65e+235)) && ((d3 <= 1.05e+270) || (~((d3 <= 1.1e+270)) && ((d3 <= 3.5e+283) || ~((d3 <= 3.6e+283)))))))))))))))))))))))))))
		tmp = d1 * d3;
	else
		tmp = d1 * d2;
	end
	tmp_2 = tmp;
end
code[d1_, d2_, d3_] := Block[{t$95$0 = N[(d1 * N[(d2 + 37.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, 1150000.0], t$95$0, If[LessEqual[d3, 1.4e+39], N[(d1 * d3), $MachinePrecision], If[LessEqual[d3, 7e+40], t$95$0, If[Or[LessEqual[d3, 1.35e+41], And[N[Not[LessEqual[d3, 4.8e+44]], $MachinePrecision], Or[LessEqual[d3, 9e+62], And[N[Not[LessEqual[d3, 4.4e+63]], $MachinePrecision], Or[LessEqual[d3, 9e+87], And[N[Not[LessEqual[d3, 1.5e+88]], $MachinePrecision], Or[LessEqual[d3, 9.2e+109], And[N[Not[LessEqual[d3, 1e+112]], $MachinePrecision], Or[LessEqual[d3, 6.2e+119], And[N[Not[LessEqual[d3, 1.3e+131]], $MachinePrecision], Or[LessEqual[d3, 3.4e+139], And[N[Not[LessEqual[d3, 1.82e+140]], $MachinePrecision], Or[LessEqual[d3, 2.1e+156], And[N[Not[LessEqual[d3, 3.2e+156]], $MachinePrecision], Or[LessEqual[d3, 1.25e+184], And[N[Not[LessEqual[d3, 2.15e+187]], $MachinePrecision], Or[LessEqual[d3, 4.1e+220], And[N[Not[LessEqual[d3, 4.2e+220]], $MachinePrecision], Or[LessEqual[d3, 1.3e+231], And[N[Not[LessEqual[d3, 1.35e+231]], $MachinePrecision], Or[LessEqual[d3, 1.6e+235], And[N[Not[LessEqual[d3, 1.65e+235]], $MachinePrecision], Or[LessEqual[d3, 1.05e+270], And[N[Not[LessEqual[d3, 1.1e+270]], $MachinePrecision], Or[LessEqual[d3, 3.5e+283], N[Not[LessEqual[d3, 3.6e+283]], $MachinePrecision]]]]]]]]]]]]]]]]]]]]]]]]]], N[(d1 * d3), $MachinePrecision], N[(d1 * d2), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 + 37\right)\\
\mathbf{if}\;d3 \leq 1150000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d3 \leq 1.4 \cdot 10^{+39}:\\
\;\;\;\;d1 \cdot d3\\

\mathbf{elif}\;d3 \leq 7 \cdot 10^{+40}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;d3 \leq 1.35 \cdot 10^{+41} \lor \neg \left(d3 \leq 4.8 \cdot 10^{+44}\right) \land \left(d3 \leq 9 \cdot 10^{+62} \lor \neg \left(d3 \leq 4.4 \cdot 10^{+63}\right) \land \left(d3 \leq 9 \cdot 10^{+87} \lor \neg \left(d3 \leq 1.5 \cdot 10^{+88}\right) \land \left(d3 \leq 9.2 \cdot 10^{+109} \lor \neg \left(d3 \leq 10^{+112}\right) \land \left(d3 \leq 6.2 \cdot 10^{+119} \lor \neg \left(d3 \leq 1.3 \cdot 10^{+131}\right) \land \left(d3 \leq 3.4 \cdot 10^{+139} \lor \neg \left(d3 \leq 1.82 \cdot 10^{+140}\right) \land \left(d3 \leq 2.1 \cdot 10^{+156} \lor \neg \left(d3 \leq 3.2 \cdot 10^{+156}\right) \land \left(d3 \leq 1.25 \cdot 10^{+184} \lor \neg \left(d3 \leq 2.15 \cdot 10^{+187}\right) \land \left(d3 \leq 4.1 \cdot 10^{+220} \lor \neg \left(d3 \leq 4.2 \cdot 10^{+220}\right) \land \left(d3 \leq 1.3 \cdot 10^{+231} \lor \neg \left(d3 \leq 1.35 \cdot 10^{+231}\right) \land \left(d3 \leq 1.6 \cdot 10^{+235} \lor \neg \left(d3 \leq 1.65 \cdot 10^{+235}\right) \land \left(d3 \leq 1.05 \cdot 10^{+270} \lor \neg \left(d3 \leq 1.1 \cdot 10^{+270}\right) \land \left(d3 \leq 3.5 \cdot 10^{+283} \lor \neg \left(d3 \leq 3.6 \cdot 10^{+283}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right):\\
\;\;\;\;d1 \cdot d3\\

\mathbf{else}:\\
\;\;\;\;d1 \cdot d2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if d3 < 1.15e6 or 1.40000000000000001e39 < d3 < 6.9999999999999998e40

    1. Initial program 96.3%

      \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
    2. Step-by-step derivation
      1. cancel-sign-sub96.3%

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
      2. +-commutative96.3%

        \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
      3. *-commutative96.3%

        \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
      4. distribute-lft-out100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
      5. distribute-lft-neg-out100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
      6. distribute-rgt-neg-in100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
      7. distribute-lft-out--99.9%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
      8. associate-+r+99.9%

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
      9. +-commutative99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
      10. associate--l+100.0%

        \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
      11. sub-neg100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
      12. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
      13. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
      14. associate-+l+100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
      15. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in d3 around 0 69.7%

      \[\leadsto \color{blue}{d1 \cdot \left(37 + d2\right)} \]

    if 1.15e6 < d3 < 1.40000000000000001e39 or 6.9999999999999998e40 < d3 < 1.35e41 or 4.80000000000000026e44 < d3 < 8.99999999999999997e62 or 4.3999999999999997e63 < d3 < 9.0000000000000005e87 or 1.50000000000000003e88 < d3 < 9.20000000000000042e109 or 9.9999999999999993e111 < d3 < 6.1999999999999999e119 or 1.3e131 < d3 < 3.4000000000000002e139 or 1.82e140 < d3 < 2.09999999999999981e156 or 3.20000000000000002e156 < d3 < 1.25e184 or 2.1499999999999999e187 < d3 < 4.09999999999999981e220 or 4.20000000000000014e220 < d3 < 1.2999999999999999e231 or 1.35e231 < d3 < 1.60000000000000003e235 or 1.65e235 < d3 < 1.05000000000000005e270 or 1.10000000000000005e270 < d3 < 3.49999999999999995e283 or 3.60000000000000017e283 < d3

    1. Initial program 98.1%

      \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
    2. Step-by-step derivation
      1. cancel-sign-sub98.1%

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
      2. +-commutative98.1%

        \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
      3. *-commutative98.1%

        \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
      4. distribute-lft-out99.9%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
      5. distribute-lft-neg-out99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
      6. distribute-rgt-neg-in99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
      7. distribute-lft-out--100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
      8. associate-+r+100.0%

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
      10. associate--l+100.0%

        \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
      11. sub-neg100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
      12. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
      13. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
      14. associate-+l+100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
      15. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in d3 around inf 83.6%

      \[\leadsto \color{blue}{d1 \cdot d3} \]

    if 1.35e41 < d3 < 4.80000000000000026e44 or 8.99999999999999997e62 < d3 < 4.3999999999999997e63 or 9.0000000000000005e87 < d3 < 1.50000000000000003e88 or 9.20000000000000042e109 < d3 < 9.9999999999999993e111 or 6.1999999999999999e119 < d3 < 1.3e131 or 3.4000000000000002e139 < d3 < 1.82e140 or 2.09999999999999981e156 < d3 < 3.20000000000000002e156 or 1.25e184 < d3 < 2.1499999999999999e187 or 4.09999999999999981e220 < d3 < 4.20000000000000014e220 or 1.2999999999999999e231 < d3 < 1.35e231 or 1.60000000000000003e235 < d3 < 1.65e235 or 1.05000000000000005e270 < d3 < 1.10000000000000005e270 or 3.49999999999999995e283 < d3 < 3.60000000000000017e283

    1. Initial program 75.0%

      \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
    2. Step-by-step derivation
      1. cancel-sign-sub75.0%

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
      2. +-commutative75.0%

        \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
      3. *-commutative75.0%

        \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
      4. distribute-lft-out100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
      5. distribute-lft-neg-out100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
      6. distribute-rgt-neg-in100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
      7. distribute-lft-out--100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
      8. associate-+r+100.0%

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
      10. associate--l+100.0%

        \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
      11. sub-neg100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
      12. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
      13. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
      14. associate-+l+100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
      15. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in d2 around inf 98.4%

      \[\leadsto \color{blue}{d1 \cdot d2} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification74.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d3 \leq 1150000:\\ \;\;\;\;d1 \cdot \left(d2 + 37\right)\\ \mathbf{elif}\;d3 \leq 1.4 \cdot 10^{+39}:\\ \;\;\;\;d1 \cdot d3\\ \mathbf{elif}\;d3 \leq 7 \cdot 10^{+40}:\\ \;\;\;\;d1 \cdot \left(d2 + 37\right)\\ \mathbf{elif}\;d3 \leq 1.35 \cdot 10^{+41} \lor \neg \left(d3 \leq 4.8 \cdot 10^{+44}\right) \land \left(d3 \leq 9 \cdot 10^{+62} \lor \neg \left(d3 \leq 4.4 \cdot 10^{+63}\right) \land \left(d3 \leq 9 \cdot 10^{+87} \lor \neg \left(d3 \leq 1.5 \cdot 10^{+88}\right) \land \left(d3 \leq 9.2 \cdot 10^{+109} \lor \neg \left(d3 \leq 10^{+112}\right) \land \left(d3 \leq 6.2 \cdot 10^{+119} \lor \neg \left(d3 \leq 1.3 \cdot 10^{+131}\right) \land \left(d3 \leq 3.4 \cdot 10^{+139} \lor \neg \left(d3 \leq 1.82 \cdot 10^{+140}\right) \land \left(d3 \leq 2.1 \cdot 10^{+156} \lor \neg \left(d3 \leq 3.2 \cdot 10^{+156}\right) \land \left(d3 \leq 1.25 \cdot 10^{+184} \lor \neg \left(d3 \leq 2.15 \cdot 10^{+187}\right) \land \left(d3 \leq 4.1 \cdot 10^{+220} \lor \neg \left(d3 \leq 4.2 \cdot 10^{+220}\right) \land \left(d3 \leq 1.3 \cdot 10^{+231} \lor \neg \left(d3 \leq 1.35 \cdot 10^{+231}\right) \land \left(d3 \leq 1.6 \cdot 10^{+235} \lor \neg \left(d3 \leq 1.65 \cdot 10^{+235}\right) \land \left(d3 \leq 1.05 \cdot 10^{+270} \lor \neg \left(d3 \leq 1.1 \cdot 10^{+270}\right) \land \left(d3 \leq 3.5 \cdot 10^{+283} \lor \neg \left(d3 \leq 3.6 \cdot 10^{+283}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right):\\ \;\;\;\;d1 \cdot d3\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot d2\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 63.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -38 \lor \neg \left(d2 \leq 37\right):\\ \;\;\;\;d1 \cdot d2\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot 37\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3)
 :precision binary64
 (if (or (<= d2 -38.0) (not (<= d2 37.0))) (* d1 d2) (* d1 37.0)))
double code(double d1, double d2, double d3) {
	double tmp;
	if ((d2 <= -38.0) || !(d2 <= 37.0)) {
		tmp = d1 * d2;
	} else {
		tmp = d1 * 37.0;
	}
	return tmp;
}
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    real(8) :: tmp
    if ((d2 <= (-38.0d0)) .or. (.not. (d2 <= 37.0d0))) then
        tmp = d1 * d2
    else
        tmp = d1 * 37.0d0
    end if
    code = tmp
end function
public static double code(double d1, double d2, double d3) {
	double tmp;
	if ((d2 <= -38.0) || !(d2 <= 37.0)) {
		tmp = d1 * d2;
	} else {
		tmp = d1 * 37.0;
	}
	return tmp;
}
def code(d1, d2, d3):
	tmp = 0
	if (d2 <= -38.0) or not (d2 <= 37.0):
		tmp = d1 * d2
	else:
		tmp = d1 * 37.0
	return tmp
function code(d1, d2, d3)
	tmp = 0.0
	if ((d2 <= -38.0) || !(d2 <= 37.0))
		tmp = Float64(d1 * d2);
	else
		tmp = Float64(d1 * 37.0);
	end
	return tmp
end
function tmp_2 = code(d1, d2, d3)
	tmp = 0.0;
	if ((d2 <= -38.0) || ~((d2 <= 37.0)))
		tmp = d1 * d2;
	else
		tmp = d1 * 37.0;
	end
	tmp_2 = tmp;
end
code[d1_, d2_, d3_] := If[Or[LessEqual[d2, -38.0], N[Not[LessEqual[d2, 37.0]], $MachinePrecision]], N[(d1 * d2), $MachinePrecision], N[(d1 * 37.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -38 \lor \neg \left(d2 \leq 37\right):\\
\;\;\;\;d1 \cdot d2\\

\mathbf{else}:\\
\;\;\;\;d1 \cdot 37\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d2 < -38 or 37 < d2

    1. Initial program 91.7%

      \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
    2. Step-by-step derivation
      1. cancel-sign-sub91.7%

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
      2. +-commutative91.7%

        \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
      3. *-commutative91.7%

        \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
      4. distribute-lft-out100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
      5. distribute-lft-neg-out100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
      6. distribute-rgt-neg-in100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
      7. distribute-lft-out--100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
      8. associate-+r+100.0%

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
      10. associate--l+100.0%

        \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
      11. sub-neg100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
      12. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
      13. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
      14. associate-+l+100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
      15. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in d2 around inf 73.8%

      \[\leadsto \color{blue}{d1 \cdot d2} \]

    if -38 < d2 < 37

    1. Initial program 99.9%

      \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
    2. Step-by-step derivation
      1. cancel-sign-sub99.9%

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
      2. +-commutative99.9%

        \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
      3. *-commutative99.9%

        \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
      4. distribute-lft-out99.9%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
      5. distribute-lft-neg-out99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
      6. distribute-rgt-neg-in99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
      7. distribute-lft-out--99.9%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
      8. associate-+r+99.9%

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
      9. +-commutative99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
      10. associate--l+99.9%

        \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
      11. sub-neg99.9%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
      12. metadata-eval99.9%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
      13. metadata-eval99.9%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
      14. associate-+l+99.9%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
      15. metadata-eval99.9%

        \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in d2 around 0 99.1%

      \[\leadsto \color{blue}{d1 \cdot \left(37 + d3\right)} \]
    6. Taylor expanded in d3 around 0 44.2%

      \[\leadsto \color{blue}{37 \cdot d1} \]
    7. Step-by-step derivation
      1. *-commutative44.2%

        \[\leadsto \color{blue}{d1 \cdot 37} \]
    8. Simplified44.2%

      \[\leadsto \color{blue}{d1 \cdot 37} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d2 \leq -38 \lor \neg \left(d2 \leq 37\right):\\ \;\;\;\;d1 \cdot d2\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot 37\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 75.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;d2 \leq -2.4 \cdot 10^{+15}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d3 + 37\right)\\ \end{array} \end{array} \]
(FPCore (d1 d2 d3)
 :precision binary64
 (if (<= d2 -2.4e+15) (* d1 d2) (* d1 (+ d3 37.0))))
double code(double d1, double d2, double d3) {
	double tmp;
	if (d2 <= -2.4e+15) {
		tmp = d1 * d2;
	} else {
		tmp = d1 * (d3 + 37.0);
	}
	return tmp;
}
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    real(8) :: tmp
    if (d2 <= (-2.4d+15)) then
        tmp = d1 * d2
    else
        tmp = d1 * (d3 + 37.0d0)
    end if
    code = tmp
end function
public static double code(double d1, double d2, double d3) {
	double tmp;
	if (d2 <= -2.4e+15) {
		tmp = d1 * d2;
	} else {
		tmp = d1 * (d3 + 37.0);
	}
	return tmp;
}
def code(d1, d2, d3):
	tmp = 0
	if d2 <= -2.4e+15:
		tmp = d1 * d2
	else:
		tmp = d1 * (d3 + 37.0)
	return tmp
function code(d1, d2, d3)
	tmp = 0.0
	if (d2 <= -2.4e+15)
		tmp = Float64(d1 * d2);
	else
		tmp = Float64(d1 * Float64(d3 + 37.0));
	end
	return tmp
end
function tmp_2 = code(d1, d2, d3)
	tmp = 0.0;
	if (d2 <= -2.4e+15)
		tmp = d1 * d2;
	else
		tmp = d1 * (d3 + 37.0);
	end
	tmp_2 = tmp;
end
code[d1_, d2_, d3_] := If[LessEqual[d2, -2.4e+15], N[(d1 * d2), $MachinePrecision], N[(d1 * N[(d3 + 37.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.4 \cdot 10^{+15}:\\
\;\;\;\;d1 \cdot d2\\

\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d3 + 37\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if d2 < -2.4e15

    1. Initial program 94.2%

      \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
    2. Step-by-step derivation
      1. cancel-sign-sub94.2%

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
      2. +-commutative94.2%

        \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
      3. *-commutative94.2%

        \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
      4. distribute-lft-out100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
      5. distribute-lft-neg-out100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
      6. distribute-rgt-neg-in100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
      7. distribute-lft-out--100.0%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
      8. associate-+r+100.0%

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
      10. associate--l+100.0%

        \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
      11. sub-neg100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
      12. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
      13. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
      14. associate-+l+100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
      15. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in d2 around inf 76.6%

      \[\leadsto \color{blue}{d1 \cdot d2} \]

    if -2.4e15 < d2

    1. Initial program 96.2%

      \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
    2. Step-by-step derivation
      1. cancel-sign-sub96.2%

        \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
      2. +-commutative96.2%

        \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
      3. *-commutative96.2%

        \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
      4. distribute-lft-out99.9%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
      5. distribute-lft-neg-out99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
      6. distribute-rgt-neg-in99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
      7. distribute-lft-out--99.9%

        \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
      8. associate-+r+99.9%

        \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
      9. +-commutative99.9%

        \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
      10. associate--l+100.0%

        \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
      11. sub-neg100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
      12. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
      13. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
      14. associate-+l+100.0%

        \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
      15. metadata-eval100.0%

        \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in d2 around 0 76.9%

      \[\leadsto \color{blue}{d1 \cdot \left(37 + d3\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;d2 \leq -2.4 \cdot 10^{+15}:\\ \;\;\;\;d1 \cdot d2\\ \mathbf{else}:\\ \;\;\;\;d1 \cdot \left(d3 + 37\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 26.7% accurate, 4.3× speedup?

\[\begin{array}{l} \\ d1 \cdot 37 \end{array} \]
(FPCore (d1 d2 d3) :precision binary64 (* d1 37.0))
double code(double d1, double d2, double d3) {
	return d1 * 37.0;
}
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    code = d1 * 37.0d0
end function
public static double code(double d1, double d2, double d3) {
	return d1 * 37.0;
}
def code(d1, d2, d3):
	return d1 * 37.0
function code(d1, d2, d3)
	return Float64(d1 * 37.0)
end
function tmp = code(d1, d2, d3)
	tmp = d1 * 37.0;
end
code[d1_, d2_, d3_] := N[(d1 * 37.0), $MachinePrecision]
\begin{array}{l}

\\
d1 \cdot 37
\end{array}
Derivation
  1. Initial program 95.7%

    \[\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) + d1 \cdot 32 \]
  2. Step-by-step derivation
    1. cancel-sign-sub95.7%

      \[\leadsto \color{blue}{\left(d1 \cdot d2 + \left(d3 + 5\right) \cdot d1\right) - \left(-d1\right) \cdot 32} \]
    2. +-commutative95.7%

      \[\leadsto \color{blue}{\left(\left(d3 + 5\right) \cdot d1 + d1 \cdot d2\right)} - \left(-d1\right) \cdot 32 \]
    3. *-commutative95.7%

      \[\leadsto \left(\color{blue}{d1 \cdot \left(d3 + 5\right)} + d1 \cdot d2\right) - \left(-d1\right) \cdot 32 \]
    4. distribute-lft-out100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(\left(d3 + 5\right) + d2\right)} - \left(-d1\right) \cdot 32 \]
    5. distribute-lft-neg-out100.0%

      \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{\left(-d1 \cdot 32\right)} \]
    6. distribute-rgt-neg-in100.0%

      \[\leadsto d1 \cdot \left(\left(d3 + 5\right) + d2\right) - \color{blue}{d1 \cdot \left(-32\right)} \]
    7. distribute-lft-out--100.0%

      \[\leadsto \color{blue}{d1 \cdot \left(\left(\left(d3 + 5\right) + d2\right) - \left(-32\right)\right)} \]
    8. associate-+r+100.0%

      \[\leadsto d1 \cdot \left(\color{blue}{\left(d3 + \left(5 + d2\right)\right)} - \left(-32\right)\right) \]
    9. +-commutative100.0%

      \[\leadsto d1 \cdot \left(\left(d3 + \color{blue}{\left(d2 + 5\right)}\right) - \left(-32\right)\right) \]
    10. associate--l+100.0%

      \[\leadsto d1 \cdot \color{blue}{\left(d3 + \left(\left(d2 + 5\right) - \left(-32\right)\right)\right)} \]
    11. sub-neg100.0%

      \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(\left(d2 + 5\right) + \left(-\left(-32\right)\right)\right)}\right) \]
    12. metadata-eval100.0%

      \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \left(-\color{blue}{-32}\right)\right)\right) \]
    13. metadata-eval100.0%

      \[\leadsto d1 \cdot \left(d3 + \left(\left(d2 + 5\right) + \color{blue}{32}\right)\right) \]
    14. associate-+l+100.0%

      \[\leadsto d1 \cdot \left(d3 + \color{blue}{\left(d2 + \left(5 + 32\right)\right)}\right) \]
    15. metadata-eval100.0%

      \[\leadsto d1 \cdot \left(d3 + \left(d2 + \color{blue}{37}\right)\right) \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{d1 \cdot \left(d3 + \left(d2 + 37\right)\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in d2 around 0 62.9%

    \[\leadsto \color{blue}{d1 \cdot \left(37 + d3\right)} \]
  6. Taylor expanded in d3 around 0 23.0%

    \[\leadsto \color{blue}{37 \cdot d1} \]
  7. Step-by-step derivation
    1. *-commutative23.0%

      \[\leadsto \color{blue}{d1 \cdot 37} \]
  8. Simplified23.0%

    \[\leadsto \color{blue}{d1 \cdot 37} \]
  9. Add Preprocessing

Developer target: 100.0% accurate, 1.9× speedup?

\[\begin{array}{l} \\ d1 \cdot \left(\left(37 + d3\right) + d2\right) \end{array} \]
(FPCore (d1 d2 d3) :precision binary64 (* d1 (+ (+ 37.0 d3) d2)))
double code(double d1, double d2, double d3) {
	return d1 * ((37.0 + d3) + d2);
}
real(8) function code(d1, d2, d3)
    real(8), intent (in) :: d1
    real(8), intent (in) :: d2
    real(8), intent (in) :: d3
    code = d1 * ((37.0d0 + d3) + d2)
end function
public static double code(double d1, double d2, double d3) {
	return d1 * ((37.0 + d3) + d2);
}
def code(d1, d2, d3):
	return d1 * ((37.0 + d3) + d2)
function code(d1, d2, d3)
	return Float64(d1 * Float64(Float64(37.0 + d3) + d2))
end
function tmp = code(d1, d2, d3)
	tmp = d1 * ((37.0 + d3) + d2);
end
code[d1_, d2_, d3_] := N[(d1 * N[(N[(37.0 + d3), $MachinePrecision] + d2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d1 \cdot \left(\left(37 + d3\right) + d2\right)
\end{array}

Reproduce

?
herbie shell --seed 2024096 
(FPCore (d1 d2 d3)
  :name "FastMath dist3"
  :precision binary64

  :alt
  (* d1 (+ (+ 37.0 d3) d2))

  (+ (+ (* d1 d2) (* (+ d3 5.0) d1)) (* d1 32.0)))