Average Error: 0.1 → 0.1
Time: 18.8s
Precision: binary64
Cost: 832
\[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
\[3 + \left(x \cdot \left(x \cdot 9\right) + \left(-4 \cdot x\right) \cdot 3\right) \]
(FPCore (x) :precision binary64 (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))
(FPCore (x) :precision binary64 (+ 3.0 (+ (* x (* x 9.0)) (* (* -4.0 x) 3.0))))
double code(double x) {
	return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
double code(double x) {
	return 3.0 + ((x * (x * 9.0)) + ((-4.0 * x) * 3.0));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 3.0d0 * ((((x * 3.0d0) * x) - (x * 4.0d0)) + 1.0d0)
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = 3.0d0 + ((x * (x * 9.0d0)) + (((-4.0d0) * x) * 3.0d0))
end function
public static double code(double x) {
	return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
}
public static double code(double x) {
	return 3.0 + ((x * (x * 9.0)) + ((-4.0 * x) * 3.0));
}
def code(x):
	return 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0)
def code(x):
	return 3.0 + ((x * (x * 9.0)) + ((-4.0 * x) * 3.0))
function code(x)
	return Float64(3.0 * Float64(Float64(Float64(Float64(x * 3.0) * x) - Float64(x * 4.0)) + 1.0))
end
function code(x)
	return Float64(3.0 + Float64(Float64(x * Float64(x * 9.0)) + Float64(Float64(-4.0 * x) * 3.0)))
end
function tmp = code(x)
	tmp = 3.0 * ((((x * 3.0) * x) - (x * 4.0)) + 1.0);
end
function tmp = code(x)
	tmp = 3.0 + ((x * (x * 9.0)) + ((-4.0 * x) * 3.0));
end
code[x_] := N[(3.0 * N[(N[(N[(N[(x * 3.0), $MachinePrecision] * x), $MachinePrecision] - N[(x * 4.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(3.0 + N[(N[(x * N[(x * 9.0), $MachinePrecision]), $MachinePrecision] + N[(N[(-4.0 * x), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right)
3 + \left(x \cdot \left(x \cdot 9\right) + \left(-4 \cdot x\right) \cdot 3\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.1
Target0.1
Herbie0.1
\[3 + \left(\left(9 \cdot x\right) \cdot x - 12 \cdot x\right) \]

Derivation

  1. Initial program 0.1

    \[3 \cdot \left(\left(\left(x \cdot 3\right) \cdot x - x \cdot 4\right) + 1\right) \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot \mathsf{fma}\left(3, x, -4\right), 3, 3\right)} \]
    Proof
  3. Applied egg-rr0.1

    \[\leadsto \color{blue}{\left(3 + \left(x \cdot x\right) \cdot 9\right) + \left(x \cdot -4\right) \cdot 3} \]
  4. Simplified0.1

    \[\leadsto \color{blue}{3 + \left(x \cdot \left(x \cdot 9\right) + \left(-4 \cdot x\right) \cdot 3\right)} \]
    Proof

Alternatives

Alternative 1
Error2.0
Cost584
\[\begin{array}{l} t_0 := 9 \cdot \left(x \cdot x\right)\\ \mathbf{if}\;x \leq -0.56:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.195:\\ \;\;\;\;3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error2.0
Cost584
\[\begin{array}{l} t_0 := \left(9 \cdot x\right) \cdot x\\ \mathbf{if}\;x \leq -0.56:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.195:\\ \;\;\;\;3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.5
Cost584
\[\begin{array}{l} t_0 := \left(9 \cdot x\right) \cdot x\\ \mathbf{if}\;x \leq -1.55:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;-12 \cdot x + 3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error0.1
Cost576
\[x \cdot \left(-12 + x \cdot 9\right) + 3 \]
Alternative 5
Error2.0
Cost448
\[x \cdot \left(9 \cdot x\right) + 3 \]
Alternative 6
Error21.2
Cost64
\[3 \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x)
  :name "Diagrams.Tangent:$catParam from diagrams-lib-1.3.0.3, D"
  :precision binary64

  :herbie-target
  (+ 3.0 (- (* (* 9.0 x) x) (* 12.0 x)))

  (* 3.0 (+ (- (* (* x 3.0) x) (* x 4.0)) 1.0)))