Average Error: 0.3 → 0
Time: 1.1s
Precision: binary64
\[d \cdot 10 + d \cdot 20 \]
\[30 \cdot d \]
(FPCore (d) :precision binary64 (+ (* d 10.0) (* d 20.0)))
(FPCore (d) :precision binary64 (* 30.0 d))
double code(double d) {
	return (d * 10.0) + (d * 20.0);
}
double code(double d) {
	return 30.0 * d;
}
real(8) function code(d)
    real(8), intent (in) :: d
    code = (d * 10.0d0) + (d * 20.0d0)
end function
real(8) function code(d)
    real(8), intent (in) :: d
    code = 30.0d0 * d
end function
public static double code(double d) {
	return (d * 10.0) + (d * 20.0);
}
public static double code(double d) {
	return 30.0 * d;
}
def code(d):
	return (d * 10.0) + (d * 20.0)
def code(d):
	return 30.0 * d
function code(d)
	return Float64(Float64(d * 10.0) + Float64(d * 20.0))
end
function code(d)
	return Float64(30.0 * d)
end
function tmp = code(d)
	tmp = (d * 10.0) + (d * 20.0);
end
function tmp = code(d)
	tmp = 30.0 * d;
end
code[d_] := N[(N[(d * 10.0), $MachinePrecision] + N[(d * 20.0), $MachinePrecision]), $MachinePrecision]
code[d_] := N[(30.0 * d), $MachinePrecision]
d \cdot 10 + d \cdot 20
30 \cdot d

Error

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.3
Target0
Herbie0
\[d \cdot 30 \]

Derivation

  1. Initial program 0.3

    \[d \cdot 10 + d \cdot 20 \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(d, 10, d \cdot 20\right)} \]
  3. Taylor expanded in d around 0 0

    \[\leadsto \color{blue}{30 \cdot d} \]
  4. Final simplification0

    \[\leadsto 30 \cdot d \]

Reproduce

herbie shell --seed 2022152 
(FPCore (d)
  :name "FastMath test1"
  :precision binary64

  :herbie-target
  (* d 30.0)

  (+ (* d 10.0) (* d 20.0)))