fma_test1

Percentage Accurate: 3.4% → 99.3%
Time: 5.3s
Alternatives: 3
Speedup: 19.0×

Specification

?
\[0.9 \leq t \land t \leq 1.1\]
\[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 + t \cdot 2 \cdot 10^{-16}\\ t\_1 \cdot t\_1 + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) \end{array} \end{array} \]
(FPCore (t)
 :precision binary64
 (let* ((t_1 (+ 1.0 (* t 2e-16))))
   (+ (* t_1 t_1) (- -1.0 (* 2.0 (* t 2e-16))))))
double code(double t) {
	double t_1 = 1.0 + (t * 2e-16);
	return (t_1 * t_1) + (-1.0 - (2.0 * (t * 2e-16)));
}
real(8) function code(t)
    real(8), intent (in) :: t
    real(8) :: t_1
    t_1 = 1.0d0 + (t * 2d-16)
    code = (t_1 * t_1) + ((-1.0d0) - (2.0d0 * (t * 2d-16)))
end function
public static double code(double t) {
	double t_1 = 1.0 + (t * 2e-16);
	return (t_1 * t_1) + (-1.0 - (2.0 * (t * 2e-16)));
}
def code(t):
	t_1 = 1.0 + (t * 2e-16)
	return (t_1 * t_1) + (-1.0 - (2.0 * (t * 2e-16)))
function code(t)
	t_1 = Float64(1.0 + Float64(t * 2e-16))
	return Float64(Float64(t_1 * t_1) + Float64(-1.0 - Float64(2.0 * Float64(t * 2e-16))))
end
function tmp = code(t)
	t_1 = 1.0 + (t * 2e-16);
	tmp = (t_1 * t_1) + (-1.0 - (2.0 * (t * 2e-16)));
end
code[t_] := Block[{t$95$1 = N[(1.0 + N[(t * 2e-16), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$1 * t$95$1), $MachinePrecision] + N[(-1.0 - N[(2.0 * N[(t * 2e-16), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := 1 + t \cdot 2 \cdot 10^{-16}\\
t\_1 \cdot t\_1 + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\end{array}
\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 3 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: 3.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 + t \cdot 2 \cdot 10^{-16}\\ t\_1 \cdot t\_1 + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) \end{array} \end{array} \]
(FPCore (t)
 :precision binary64
 (let* ((t_1 (+ 1.0 (* t 2e-16))))
   (+ (* t_1 t_1) (- -1.0 (* 2.0 (* t 2e-16))))))
double code(double t) {
	double t_1 = 1.0 + (t * 2e-16);
	return (t_1 * t_1) + (-1.0 - (2.0 * (t * 2e-16)));
}
real(8) function code(t)
    real(8), intent (in) :: t
    real(8) :: t_1
    t_1 = 1.0d0 + (t * 2d-16)
    code = (t_1 * t_1) + ((-1.0d0) - (2.0d0 * (t * 2d-16)))
end function
public static double code(double t) {
	double t_1 = 1.0 + (t * 2e-16);
	return (t_1 * t_1) + (-1.0 - (2.0 * (t * 2e-16)));
}
def code(t):
	t_1 = 1.0 + (t * 2e-16)
	return (t_1 * t_1) + (-1.0 - (2.0 * (t * 2e-16)))
function code(t)
	t_1 = Float64(1.0 + Float64(t * 2e-16))
	return Float64(Float64(t_1 * t_1) + Float64(-1.0 - Float64(2.0 * Float64(t * 2e-16))))
end
function tmp = code(t)
	t_1 = 1.0 + (t * 2e-16);
	tmp = (t_1 * t_1) + (-1.0 - (2.0 * (t * 2e-16)));
end
code[t_] := Block[{t$95$1 = N[(1.0 + N[(t * 2e-16), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$1 * t$95$1), $MachinePrecision] + N[(-1.0 - N[(2.0 * N[(t * 2e-16), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := 1 + t \cdot 2 \cdot 10^{-16}\\
t\_1 \cdot t\_1 + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\end{array}
\end{array}

Alternative 1: 99.3% accurate, 3.8× speedup?

\[\begin{array}{l} \\ \left(t \cdot t\right) \cdot 4 \cdot 10^{-32} \end{array} \]
(FPCore (t) :precision binary64 (* (* t t) 4e-32))
double code(double t) {
	return (t * t) * 4e-32;
}
real(8) function code(t)
    real(8), intent (in) :: t
    code = (t * t) * 4d-32
end function
public static double code(double t) {
	return (t * t) * 4e-32;
}
def code(t):
	return (t * t) * 4e-32
function code(t)
	return Float64(Float64(t * t) * 4e-32)
end
function tmp = code(t)
	tmp = (t * t) * 4e-32;
end
code[t_] := N[(N[(t * t), $MachinePrecision] * 4e-32), $MachinePrecision]
\begin{array}{l}

\\
\left(t \cdot t\right) \cdot 4 \cdot 10^{-32}
\end{array}
Derivation
  1. Initial program 3.4%

    \[\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) \]
  2. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot \left(t \cdot \frac{1}{5000000000000000} + 1\right) + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    2. distribute-rgt-inN/A

      \[\leadsto \left(\left(t \cdot \frac{1}{5000000000000000}\right) \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right) + 1 \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right)\right) + \left(\color{blue}{-1} - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    3. *-lft-identityN/A

      \[\leadsto \left(\left(t \cdot \frac{1}{5000000000000000}\right) \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right) + \left(1 + t \cdot \frac{1}{5000000000000000}\right)\right) + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    4. associate-+l+N/A

      \[\leadsto \left(t \cdot \frac{1}{5000000000000000}\right) \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right) + \color{blue}{\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right)} \]
    5. *-commutativeN/A

      \[\leadsto \left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + \left(\color{blue}{\left(1 + t \cdot \frac{1}{5000000000000000}\right)} + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right) \]
    6. associate-*r*N/A

      \[\leadsto \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) \cdot \frac{1}{5000000000000000} + \left(\color{blue}{\left(1 + t \cdot \frac{1}{5000000000000000}\right)} + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\color{blue}{\left(1 + t \cdot \frac{1}{5000000000000000}\right)} + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right) \]
    8. associate-+r-N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) + -1\right) - \color{blue}{2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)}\right) \]
    9. metadata-evalN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) + \left(\mathsf{neg}\left(1\right)\right)\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    10. sub-negN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) - 1\right) - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    11. +-commutativeN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(t \cdot \frac{1}{5000000000000000} + 1\right) - 1\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    12. *-lft-identityN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + 1\right) - 1\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    13. associate--l+N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + \left(1 - 1\right)\right) - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    14. metadata-evalN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + 0\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    15. +-rgt-identityN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    16. *-lft-identityN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(t \cdot \frac{1}{5000000000000000} - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    17. associate-*r*N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(t \cdot \frac{1}{5000000000000000} - \left(2 \cdot t\right) \cdot \color{blue}{\frac{1}{5000000000000000}}\right) \]
    18. distribute-rgt-out--N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \frac{1}{5000000000000000} \cdot \color{blue}{\left(t - 2 \cdot t\right)} \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{\left(t \cdot t\right) \cdot 4 \cdot 10^{-32}} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 25.1% accurate, 6.3× speedup?

\[\begin{array}{l} \\ t \cdot 4 \cdot 10^{-32} \end{array} \]
(FPCore (t) :precision binary64 (* t 4e-32))
double code(double t) {
	return t * 4e-32;
}
real(8) function code(t)
    real(8), intent (in) :: t
    code = t * 4d-32
end function
public static double code(double t) {
	return t * 4e-32;
}
def code(t):
	return t * 4e-32
function code(t)
	return Float64(t * 4e-32)
end
function tmp = code(t)
	tmp = t * 4e-32;
end
code[t_] := N[(t * 4e-32), $MachinePrecision]
\begin{array}{l}

\\
t \cdot 4 \cdot 10^{-32}
\end{array}
Derivation
  1. Initial program 3.4%

    \[\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) \]
  2. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot \left(t \cdot \frac{1}{5000000000000000} + 1\right) + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    2. distribute-rgt-inN/A

      \[\leadsto \left(\left(t \cdot \frac{1}{5000000000000000}\right) \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right) + 1 \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right)\right) + \left(\color{blue}{-1} - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    3. *-lft-identityN/A

      \[\leadsto \left(\left(t \cdot \frac{1}{5000000000000000}\right) \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right) + \left(1 + t \cdot \frac{1}{5000000000000000}\right)\right) + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    4. associate-+l+N/A

      \[\leadsto \left(t \cdot \frac{1}{5000000000000000}\right) \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right) + \color{blue}{\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right)} \]
    5. *-commutativeN/A

      \[\leadsto \left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + \left(\color{blue}{\left(1 + t \cdot \frac{1}{5000000000000000}\right)} + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right) \]
    6. associate-*r*N/A

      \[\leadsto \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) \cdot \frac{1}{5000000000000000} + \left(\color{blue}{\left(1 + t \cdot \frac{1}{5000000000000000}\right)} + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\color{blue}{\left(1 + t \cdot \frac{1}{5000000000000000}\right)} + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right) \]
    8. associate-+r-N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) + -1\right) - \color{blue}{2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)}\right) \]
    9. metadata-evalN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) + \left(\mathsf{neg}\left(1\right)\right)\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    10. sub-negN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) - 1\right) - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    11. +-commutativeN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(t \cdot \frac{1}{5000000000000000} + 1\right) - 1\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    12. *-lft-identityN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + 1\right) - 1\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    13. associate--l+N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + \left(1 - 1\right)\right) - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    14. metadata-evalN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + 0\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    15. +-rgt-identityN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    16. *-lft-identityN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(t \cdot \frac{1}{5000000000000000} - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    17. associate-*r*N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(t \cdot \frac{1}{5000000000000000} - \left(2 \cdot t\right) \cdot \color{blue}{\frac{1}{5000000000000000}}\right) \]
    18. distribute-rgt-out--N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \frac{1}{5000000000000000} \cdot \color{blue}{\left(t - 2 \cdot t\right)} \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{\left(t \cdot t\right) \cdot 4 \cdot 10^{-32}} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. rem-exp-logN/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\log \left(t \cdot t\right)}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    2. sum-logN/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\log t + \log t}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    3. flip-+N/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\frac{\log t \cdot \log t - \log t \cdot \log t}{\log t - \log t}}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    4. +-inversesN/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\frac{0}{\log t - \log t}}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    5. +-inversesN/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\frac{\log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) \cdot \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) - \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) \cdot \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right)}{\log t - \log t}}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    6. +-inversesN/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\frac{\log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) \cdot \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) - \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) \cdot \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right)}{0}}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    7. +-inversesN/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\frac{\log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) \cdot \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) - \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) \cdot \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right)}{\log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) - \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right)}}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    8. flip-+N/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) + \log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right)}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    9. log-prodN/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\log \left({t}^{\left(\frac{\frac{2}{2}}{2}\right)} \cdot {t}^{\left(\frac{\frac{2}{2}}{2}\right)}\right)}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    10. sqr-powN/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\log \left({t}^{\left(\frac{2}{2}\right)}\right)}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    11. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\log \left({t}^{1}\right)}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    12. unpow1N/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\log t}\right), \frac{1}{25000000000000000000000000000000}\right) \]
    13. rem-exp-log25.1%

      \[\leadsto \mathsf{*.f64}\left(t, \frac{1}{25000000000000000000000000000000}\right) \]
  6. Applied egg-rr25.1%

    \[\leadsto \color{blue}{t} \cdot 4 \cdot 10^{-32} \]
  7. Add Preprocessing

Alternative 3: 23.6% accurate, 19.0× speedup?

\[\begin{array}{l} \\ 4 \cdot 10^{-32} \end{array} \]
(FPCore (t) :precision binary64 4e-32)
double code(double t) {
	return 4e-32;
}
real(8) function code(t)
    real(8), intent (in) :: t
    code = 4d-32
end function
public static double code(double t) {
	return 4e-32;
}
def code(t):
	return 4e-32
function code(t)
	return 4e-32
end
function tmp = code(t)
	tmp = 4e-32;
end
code[t_] := 4e-32
\begin{array}{l}

\\
4 \cdot 10^{-32}
\end{array}
Derivation
  1. Initial program 3.4%

    \[\left(1 + t \cdot 2 \cdot 10^{-16}\right) \cdot \left(1 + t \cdot 2 \cdot 10^{-16}\right) + \left(-1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) \]
  2. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot \left(t \cdot \frac{1}{5000000000000000} + 1\right) + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    2. distribute-rgt-inN/A

      \[\leadsto \left(\left(t \cdot \frac{1}{5000000000000000}\right) \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right) + 1 \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right)\right) + \left(\color{blue}{-1} - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    3. *-lft-identityN/A

      \[\leadsto \left(\left(t \cdot \frac{1}{5000000000000000}\right) \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right) + \left(1 + t \cdot \frac{1}{5000000000000000}\right)\right) + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    4. associate-+l+N/A

      \[\leadsto \left(t \cdot \frac{1}{5000000000000000}\right) \cdot \left(1 + t \cdot \frac{1}{5000000000000000}\right) + \color{blue}{\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right)} \]
    5. *-commutativeN/A

      \[\leadsto \left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + \left(\color{blue}{\left(1 + t \cdot \frac{1}{5000000000000000}\right)} + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right) \]
    6. associate-*r*N/A

      \[\leadsto \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) \cdot \frac{1}{5000000000000000} + \left(\color{blue}{\left(1 + t \cdot \frac{1}{5000000000000000}\right)} + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\color{blue}{\left(1 + t \cdot \frac{1}{5000000000000000}\right)} + \left(-1 - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right)\right) \]
    8. associate-+r-N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) + -1\right) - \color{blue}{2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)}\right) \]
    9. metadata-evalN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) + \left(\mathsf{neg}\left(1\right)\right)\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    10. sub-negN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) - 1\right) - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    11. +-commutativeN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(t \cdot \frac{1}{5000000000000000} + 1\right) - 1\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    12. *-lft-identityN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(\left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + 1\right) - 1\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    13. associate--l+N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + \left(1 - 1\right)\right) - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    14. metadata-evalN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(\left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) + 0\right) - 2 \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    15. +-rgt-identityN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(1 \cdot \left(t \cdot \frac{1}{5000000000000000}\right) - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    16. *-lft-identityN/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(t \cdot \frac{1}{5000000000000000} - \color{blue}{2} \cdot \left(t \cdot \frac{1}{5000000000000000}\right)\right) \]
    17. associate-*r*N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \left(t \cdot \frac{1}{5000000000000000} - \left(2 \cdot t\right) \cdot \color{blue}{\frac{1}{5000000000000000}}\right) \]
    18. distribute-rgt-out--N/A

      \[\leadsto \frac{1}{5000000000000000} \cdot \left(\left(1 + t \cdot \frac{1}{5000000000000000}\right) \cdot t\right) + \frac{1}{5000000000000000} \cdot \color{blue}{\left(t - 2 \cdot t\right)} \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{\left(t \cdot t\right) \cdot 4 \cdot 10^{-32}} \]
  4. Add Preprocessing
  5. Applied egg-rr23.5%

    \[\leadsto \color{blue}{4 \cdot 10^{-32}} \]
  6. Add Preprocessing

Developer Target 1: 21.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := 1 + t \cdot 2 \cdot 10^{-16}\\ \mathsf{fma}\left(t\_1, t\_1, -1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) \end{array} \end{array} \]
(FPCore (t)
 :precision binary64
 (let* ((t_1 (+ 1.0 (* t 2e-16)))) (fma t_1 t_1 (- -1.0 (* 2.0 (* t 2e-16))))))
double code(double t) {
	double t_1 = 1.0 + (t * 2e-16);
	return fma(t_1, t_1, (-1.0 - (2.0 * (t * 2e-16))));
}
function code(t)
	t_1 = Float64(1.0 + Float64(t * 2e-16))
	return fma(t_1, t_1, Float64(-1.0 - Float64(2.0 * Float64(t * 2e-16))))
end
code[t_] := Block[{t$95$1 = N[(1.0 + N[(t * 2e-16), $MachinePrecision]), $MachinePrecision]}, N[(t$95$1 * t$95$1 + N[(-1.0 - N[(2.0 * N[(t * 2e-16), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := 1 + t \cdot 2 \cdot 10^{-16}\\
\mathsf{fma}\left(t\_1, t\_1, -1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right)
\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024139 
(FPCore (t)
  :name "fma_test1"
  :precision binary64
  :pre (and (<= 0.9 t) (<= t 1.1))

  :alt
  (! :herbie-platform default (let ((x (+ 1 (* t 1/5000000000000000))) (z (- -1 (* 2 (* t 1/5000000000000000))))) (fma x x z)))

  (+ (* (+ 1.0 (* t 2e-16)) (+ 1.0 (* t 2e-16))) (- -1.0 (* 2.0 (* t 2e-16)))))