Average Error: 61.8 → 0.3
Time: 3.4s
Precision: binary64
Cost: 6848
\[0.9 \leq t \land t \leq 1.1\]
\[\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) \]
\[t \cdot \sqrt{\left(t \cdot t\right) \cdot 1.6 \cdot 10^{-63}} \]
(FPCore (t)
 :precision binary64
 (+ (* (+ 1.0 (* t 2e-16)) (+ 1.0 (* t 2e-16))) (- -1.0 (* 2.0 (* t 2e-16)))))
(FPCore (t) :precision binary64 (* t (sqrt (* (* t t) 1.6e-63))))
double code(double t) {
	return ((1.0 + (t * 2e-16)) * (1.0 + (t * 2e-16))) + (-1.0 - (2.0 * (t * 2e-16)));
}
double code(double t) {
	return t * sqrt(((t * t) * 1.6e-63));
}
real(8) function code(t)
    real(8), intent (in) :: t
    code = ((1.0d0 + (t * 2d-16)) * (1.0d0 + (t * 2d-16))) + ((-1.0d0) - (2.0d0 * (t * 2d-16)))
end function
real(8) function code(t)
    real(8), intent (in) :: t
    code = t * sqrt(((t * t) * 1.6d-63))
end function
public static double code(double t) {
	return ((1.0 + (t * 2e-16)) * (1.0 + (t * 2e-16))) + (-1.0 - (2.0 * (t * 2e-16)));
}
public static double code(double t) {
	return t * Math.sqrt(((t * t) * 1.6e-63));
}
def code(t):
	return ((1.0 + (t * 2e-16)) * (1.0 + (t * 2e-16))) + (-1.0 - (2.0 * (t * 2e-16)))
def code(t):
	return t * math.sqrt(((t * t) * 1.6e-63))
function code(t)
	return Float64(Float64(Float64(1.0 + Float64(t * 2e-16)) * Float64(1.0 + Float64(t * 2e-16))) + Float64(-1.0 - Float64(2.0 * Float64(t * 2e-16))))
end
function code(t)
	return Float64(t * sqrt(Float64(Float64(t * t) * 1.6e-63)))
end
function tmp = code(t)
	tmp = ((1.0 + (t * 2e-16)) * (1.0 + (t * 2e-16))) + (-1.0 - (2.0 * (t * 2e-16)));
end
function tmp = code(t)
	tmp = t * sqrt(((t * t) * 1.6e-63));
end
code[t_] := N[(N[(N[(1.0 + N[(t * 2e-16), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(t * 2e-16), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0 - N[(2.0 * N[(t * 2e-16), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[t_] := N[(t * N[Sqrt[N[(N[(t * t), $MachinePrecision] * 1.6e-63), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\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)
t \cdot \sqrt{\left(t \cdot t\right) \cdot 1.6 \cdot 10^{-63}}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original61.8
Target50.6
Herbie0.3
\[\mathsf{fma}\left(1 + t \cdot 2 \cdot 10^{-16}, 1 + t \cdot 2 \cdot 10^{-16}, -1 - 2 \cdot \left(t \cdot 2 \cdot 10^{-16}\right)\right) \]

Derivation

  1. Initial program 61.8

    \[\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. Simplified0.4

    \[\leadsto \color{blue}{t \cdot \left(t \cdot 4 \cdot 10^{-32}\right)} \]
    Proof
    (*.f64 t (*.f64 t 1/25000000000000000000000000000000)): 0 points increase in error, 0 points decrease in error
    (*.f64 t (*.f64 t (Rewrite<= metadata-eval (*.f64 1/5000000000000000 1/5000000000000000)))): 27 points increase in error, 3 points decrease in error
    (*.f64 t (Rewrite=> *-commutative_binary64 (*.f64 (*.f64 1/5000000000000000 1/5000000000000000) t))): 29 points increase in error, 4 points decrease in error
    (*.f64 t (Rewrite<= associate-*r*_binary64 (*.f64 1/5000000000000000 (*.f64 1/5000000000000000 t)))): 12 points increase in error, 29 points decrease in error
    (*.f64 t (*.f64 1/5000000000000000 (Rewrite<= *-commutative_binary64 (*.f64 t 1/5000000000000000)))): 9 points increase in error, 28 points decrease in error
    (*.f64 t (*.f64 1/5000000000000000 (*.f64 t (Rewrite<= metadata-eval (*.f64 1/5000000000000000 1))))): 3 points increase in error, 35 points decrease in error
    (*.f64 t (*.f64 1/5000000000000000 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 t 1/5000000000000000) 1)))): 27 points increase in error, 9 points decrease in error
    (*.f64 t (Rewrite<= *-lft-identity_binary64 (*.f64 1 (*.f64 1/5000000000000000 (*.f64 (*.f64 t 1/5000000000000000) 1))))): 5 points increase in error, 27 points decrease in error
    (Rewrite=> associate-*r*_binary64 (*.f64 (*.f64 t 1) (*.f64 1/5000000000000000 (*.f64 (*.f64 t 1/5000000000000000) 1)))): 39 points increase in error, 3 points decrease in error
    (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 (*.f64 t 1) 1/5000000000000000) (*.f64 (*.f64 t 1/5000000000000000) 1))): 3 points increase in error, 35 points decrease in error
    (*.f64 (Rewrite<= *-commutative_binary64 (*.f64 1/5000000000000000 (*.f64 t 1))) (*.f64 (*.f64 t 1/5000000000000000) 1)): 30 points increase in error, 9 points decrease in error
    (Rewrite=> associate-*l*_binary64 (*.f64 1/5000000000000000 (*.f64 (*.f64 t 1) (*.f64 (*.f64 t 1/5000000000000000) 1)))): 29 points increase in error, 6 points decrease in error
    (*.f64 1/5000000000000000 (*.f64 (Rewrite=> *-rgt-identity_binary64 t) (*.f64 (*.f64 t 1/5000000000000000) 1))): 3 points increase in error, 27 points decrease in error
    (*.f64 1/5000000000000000 (*.f64 t (Rewrite<= +-lft-identity_binary64 (+.f64 0 (*.f64 (*.f64 t 1/5000000000000000) 1))))): 39 points increase in error, 3 points decrease in error
    (*.f64 1/5000000000000000 (*.f64 t (+.f64 (Rewrite<= metadata-eval (+.f64 -1 1)) (*.f64 (*.f64 t 1/5000000000000000) 1)))): 3 points increase in error, 27 points decrease in error
    (*.f64 1/5000000000000000 (*.f64 t (Rewrite<= associate-+r+_binary64 (+.f64 -1 (+.f64 1 (*.f64 (*.f64 t 1/5000000000000000) 1)))))): 27 points increase in error, 7 points decrease in error
    (*.f64 1/5000000000000000 (*.f64 t (+.f64 -1 (+.f64 (Rewrite<= metadata-eval (*.f64 1 1)) (*.f64 (*.f64 t 1/5000000000000000) 1))))): 8 points increase in error, 37 points decrease in error
    (*.f64 1/5000000000000000 (*.f64 t (+.f64 -1 (Rewrite<= distribute-rgt-in_binary64 (*.f64 1 (+.f64 1 (*.f64 t 1/5000000000000000))))))): 13 points increase in error, 28 points decrease in error
    (*.f64 1/5000000000000000 (*.f64 t (+.f64 -1 (Rewrite=> *-lft-identity_binary64 (+.f64 1 (*.f64 t 1/5000000000000000)))))): 7 points increase in error, 27 points decrease in error
    (*.f64 1/5000000000000000 (Rewrite=> distribute-lft-in_binary64 (+.f64 (*.f64 t -1) (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000)))))): 28 points increase in error, 15 points decrease in error
    (*.f64 1/5000000000000000 (+.f64 (*.f64 t (Rewrite<= metadata-eval (-.f64 1 2))) (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 11 points increase in error, 27 points decrease in error
    (*.f64 1/5000000000000000 (+.f64 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 1 t) (*.f64 2 t))) (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 27 points increase in error, 9 points decrease in error
    (*.f64 1/5000000000000000 (+.f64 (-.f64 (Rewrite=> *-lft-identity_binary64 t) (*.f64 2 t)) (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 9 points increase in error, 33 points decrease in error
    (Rewrite<= distribute-lft-out_binary64 (+.f64 (*.f64 1/5000000000000000 (-.f64 t (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000)))))): 29 points increase in error, 14 points decrease in error
    (+.f64 (Rewrite<= distribute-lft-out--_binary64 (-.f64 (*.f64 1/5000000000000000 t) (*.f64 1/5000000000000000 (*.f64 2 t)))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 8 points increase in error, 31 points decrease in error
    (+.f64 (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 t 1/5000000000000000)) (*.f64 1/5000000000000000 (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 25 points increase in error, 7 points decrease in error
    (+.f64 (-.f64 (*.f64 t (Rewrite<= metadata-eval (*.f64 1/5000000000000000 1))) (*.f64 1/5000000000000000 (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 31 points increase in error, 4 points decrease in error
    (+.f64 (-.f64 (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 t 1/5000000000000000) 1)) (*.f64 1/5000000000000000 (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 11 points increase in error, 27 points decrease in error
    (+.f64 (-.f64 (Rewrite<= +-rgt-identity_binary64 (+.f64 (*.f64 (*.f64 t 1/5000000000000000) 1) 0)) (*.f64 1/5000000000000000 (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 28 points increase in error, 11 points decrease in error
    (+.f64 (-.f64 (+.f64 (*.f64 (*.f64 t 1/5000000000000000) 1) (Rewrite<= metadata-eval (+.f64 1 -1))) (*.f64 1/5000000000000000 (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 5 points increase in error, 30 points decrease in error
    (+.f64 (-.f64 (Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (*.f64 (*.f64 t 1/5000000000000000) 1) 1) -1)) (*.f64 1/5000000000000000 (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 13 points increase in error, 26 points decrease in error
    (+.f64 (-.f64 (+.f64 (+.f64 (*.f64 (*.f64 t 1/5000000000000000) 1) (Rewrite<= metadata-eval (*.f64 1 1))) -1) (*.f64 1/5000000000000000 (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 20 points increase in error, 13 points decrease in error
    (+.f64 (-.f64 (+.f64 (Rewrite<= distribute-rgt-in_binary64 (*.f64 1 (+.f64 (*.f64 t 1/5000000000000000) 1))) -1) (*.f64 1/5000000000000000 (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 4 points increase in error, 27 points decrease in error
    (+.f64 (-.f64 (+.f64 (*.f64 1 (Rewrite<= +-commutative_binary64 (+.f64 1 (*.f64 t 1/5000000000000000)))) -1) (*.f64 1/5000000000000000 (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 17 points increase in error, 28 points decrease in error
    (+.f64 (-.f64 (+.f64 (Rewrite=> *-lft-identity_binary64 (+.f64 1 (*.f64 t 1/5000000000000000))) -1) (*.f64 1/5000000000000000 (*.f64 2 t))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 27 points increase in error, 3 points decrease in error
    (+.f64 (-.f64 (+.f64 (+.f64 1 (*.f64 t 1/5000000000000000)) -1) (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 2 t) 1/5000000000000000))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 27 points increase in error, 3 points decrease in error
    (+.f64 (-.f64 (+.f64 (+.f64 1 (*.f64 t 1/5000000000000000)) -1) (Rewrite<= associate-*r*_binary64 (*.f64 2 (*.f64 t 1/5000000000000000)))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 3 points increase in error, 27 points decrease in error
    (+.f64 (Rewrite<= associate-+r-_binary64 (+.f64 (+.f64 1 (*.f64 t 1/5000000000000000)) (-.f64 -1 (*.f64 2 (*.f64 t 1/5000000000000000))))) (*.f64 1/5000000000000000 (*.f64 t (+.f64 1 (*.f64 t 1/5000000000000000))))): 20 points increase in error, 22 points decrease in error
    (+.f64 (+.f64 (+.f64 1 (*.f64 t 1/5000000000000000)) (-.f64 -1 (*.f64 2 (*.f64 t 1/5000000000000000)))) (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 1/5000000000000000 t) (+.f64 1 (*.f64 t 1/5000000000000000))))): 39 points increase in error, 5 points decrease in error
    (+.f64 (+.f64 (+.f64 1 (*.f64 t 1/5000000000000000)) (-.f64 -1 (*.f64 2 (*.f64 t 1/5000000000000000)))) (*.f64 (Rewrite<= *-commutative_binary64 (*.f64 t 1/5000000000000000)) (+.f64 1 (*.f64 t 1/5000000000000000)))): 5 points increase in error, 31 points decrease in error
    (+.f64 (Rewrite<= +-commutative_binary64 (+.f64 (-.f64 -1 (*.f64 2 (*.f64 t 1/5000000000000000))) (+.f64 1 (*.f64 t 1/5000000000000000)))) (*.f64 (*.f64 t 1/5000000000000000) (+.f64 1 (*.f64 t 1/5000000000000000)))): 25 points increase in error, 12 points decrease in error
    (+.f64 (+.f64 (-.f64 -1 (*.f64 2 (*.f64 t 1/5000000000000000))) (Rewrite<= *-lft-identity_binary64 (*.f64 1 (+.f64 1 (*.f64 t 1/5000000000000000))))) (*.f64 (*.f64 t 1/5000000000000000) (+.f64 1 (*.f64 t 1/5000000000000000)))): 12 points increase in error, 26 points decrease in error
    (Rewrite<= associate-+r+_binary64 (+.f64 (-.f64 -1 (*.f64 2 (*.f64 t 1/5000000000000000))) (+.f64 (*.f64 1 (+.f64 1 (*.f64 t 1/5000000000000000))) (*.f64 (*.f64 t 1/5000000000000000) (+.f64 1 (*.f64 t 1/5000000000000000)))))): 27 points increase in error, 6 points decrease in error
    (+.f64 (-.f64 -1 (*.f64 2 (*.f64 t 1/5000000000000000))) (Rewrite<= distribute-rgt-in_binary64 (*.f64 (+.f64 1 (*.f64 t 1/5000000000000000)) (+.f64 1 (*.f64 t 1/5000000000000000))))): 14 points increase in error, 26 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 (+.f64 1 (*.f64 t 1/5000000000000000)) (+.f64 1 (*.f64 t 1/5000000000000000))) (-.f64 -1 (*.f64 2 (*.f64 t 1/5000000000000000))))): 4 points increase in error, 29 points decrease in error
  3. Applied egg-rr0.3

    \[\leadsto t \cdot \color{blue}{\sqrt{\left(t \cdot t\right) \cdot 1.6 \cdot 10^{-63}}} \]
  4. Final simplification0.3

    \[\leadsto t \cdot \sqrt{\left(t \cdot t\right) \cdot 1.6 \cdot 10^{-63}} \]

Alternatives

Alternative 1
Error0.4
Cost320
\[\left(t \cdot t\right) \cdot 4 \cdot 10^{-32} \]

Error

Reproduce

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

  :herbie-target
  (fma (+ 1.0 (* t 2e-16)) (+ 1.0 (* t 2e-16)) (- -1.0 (* 2.0 (* t 2e-16))))

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