Average Error: 28.7 → 0.1
Time: 12.3s
Precision: binary64
Cost: 832
\[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
\[\left(\frac{z - x}{\frac{y}{z + x}} - y\right) \cdot -0.5 \]
(FPCore (x y z)
 :precision binary64
 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
(FPCore (x y z) :precision binary64 (* (- (/ (- z x) (/ y (+ z x))) y) -0.5))
double code(double x, double y, double z) {
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
double code(double x, double y, double z) {
	return (((z - x) / (y / (z + x))) - y) * -0.5;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (((z - x) / (y / (z + x))) - y) * (-0.5d0)
end function
public static double code(double x, double y, double z) {
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
public static double code(double x, double y, double z) {
	return (((z - x) / (y / (z + x))) - y) * -0.5;
}
def code(x, y, z):
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
def code(x, y, z):
	return (((z - x) / (y / (z + x))) - y) * -0.5
function code(x, y, z)
	return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0))
end
function code(x, y, z)
	return Float64(Float64(Float64(Float64(z - x) / Float64(y / Float64(z + x))) - y) * -0.5)
end
function tmp = code(x, y, z)
	tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
end
function tmp = code(x, y, z)
	tmp = (((z - x) / (y / (z + x))) - y) * -0.5;
end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(N[(N[(z - x), $MachinePrecision] / N[(y / N[(z + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] * -0.5), $MachinePrecision]
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\left(\frac{z - x}{\frac{y}{z + x}} - y\right) \cdot -0.5

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original28.7
Target0.2
Herbie0.1
\[y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right) \]

Derivation

  1. Initial program 28.7

    \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
  2. Simplified0.1

    \[\leadsto \color{blue}{\left(\frac{z - x}{\frac{y}{x + z}} - y\right) \cdot -0.5} \]
    Proof

    [Start]28.7

    \[ \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]

    sub-neg [=>]28.7

    \[ \frac{\color{blue}{\left(x \cdot x + y \cdot y\right) + \left(-z \cdot z\right)}}{y \cdot 2} \]

    +-commutative [=>]28.7

    \[ \frac{\color{blue}{\left(-z \cdot z\right) + \left(x \cdot x + y \cdot y\right)}}{y \cdot 2} \]

    neg-sub0 [=>]28.7

    \[ \frac{\color{blue}{\left(0 - z \cdot z\right)} + \left(x \cdot x + y \cdot y\right)}{y \cdot 2} \]

    associate-+l- [=>]28.7

    \[ \frac{\color{blue}{0 - \left(z \cdot z - \left(x \cdot x + y \cdot y\right)\right)}}{y \cdot 2} \]

    sub0-neg [=>]28.7

    \[ \frac{\color{blue}{-\left(z \cdot z - \left(x \cdot x + y \cdot y\right)\right)}}{y \cdot 2} \]

    neg-mul-1 [=>]28.7

    \[ \frac{\color{blue}{-1 \cdot \left(z \cdot z - \left(x \cdot x + y \cdot y\right)\right)}}{y \cdot 2} \]

    *-commutative [=>]28.7

    \[ \frac{\color{blue}{\left(z \cdot z - \left(x \cdot x + y \cdot y\right)\right) \cdot -1}}{y \cdot 2} \]

    times-frac [=>]28.7

    \[ \color{blue}{\frac{z \cdot z - \left(x \cdot x + y \cdot y\right)}{y} \cdot \frac{-1}{2}} \]

    associate--r+ [=>]28.7

    \[ \frac{\color{blue}{\left(z \cdot z - x \cdot x\right) - y \cdot y}}{y} \cdot \frac{-1}{2} \]

    div-sub [=>]28.7

    \[ \color{blue}{\left(\frac{z \cdot z - x \cdot x}{y} - \frac{y \cdot y}{y}\right)} \cdot \frac{-1}{2} \]

    associate-/l* [=>]12.7

    \[ \left(\frac{z \cdot z - x \cdot x}{y} - \color{blue}{\frac{y}{\frac{y}{y}}}\right) \cdot \frac{-1}{2} \]

    *-inverses [=>]12.7

    \[ \left(\frac{z \cdot z - x \cdot x}{y} - \frac{y}{\color{blue}{1}}\right) \cdot \frac{-1}{2} \]

    /-rgt-identity [=>]12.7

    \[ \left(\frac{z \cdot z - x \cdot x}{y} - \color{blue}{y}\right) \cdot \frac{-1}{2} \]

    difference-of-squares [=>]12.7

    \[ \left(\frac{\color{blue}{\left(z + x\right) \cdot \left(z - x\right)}}{y} - y\right) \cdot \frac{-1}{2} \]

    +-commutative [<=]12.7

    \[ \left(\frac{\color{blue}{\left(x + z\right)} \cdot \left(z - x\right)}{y} - y\right) \cdot \frac{-1}{2} \]

    *-commutative [=>]12.7

    \[ \left(\frac{\color{blue}{\left(z - x\right) \cdot \left(x + z\right)}}{y} - y\right) \cdot \frac{-1}{2} \]

    associate-/l* [=>]0.1

    \[ \left(\color{blue}{\frac{z - x}{\frac{y}{x + z}}} - y\right) \cdot \frac{-1}{2} \]

    metadata-eval [=>]0.1

    \[ \left(\frac{z - x}{\frac{y}{x + z}} - y\right) \cdot \color{blue}{-0.5} \]
  3. Final simplification0.1

    \[\leadsto \left(\frac{z - x}{\frac{y}{z + x}} - y\right) \cdot -0.5 \]

Alternatives

Alternative 1
Error25.6
Cost1108
\[\begin{array}{l} t_0 := \frac{0.5}{y} \cdot \left(x \cdot x\right)\\ t_1 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{if}\;y \leq -1.1 \cdot 10^{+41}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -1.25 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-259}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+74}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
Alternative 2
Error25.2
Cost1108
\[\begin{array}{l} t_0 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{if}\;y \leq -1.35 \cdot 10^{+41}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{-30}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{-82}:\\ \;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;y \leq -3 \cdot 10^{-253}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+79}:\\ \;\;\;\;x \cdot \frac{x}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
Alternative 3
Error25.2
Cost1108
\[\begin{array}{l} t_0 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{if}\;y \leq -1.1 \cdot 10^{+41}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -2 \cdot 10^{-25}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{-83}:\\ \;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;y \leq -1.26 \cdot 10^{-256}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+79}:\\ \;\;\;\;\frac{x}{\frac{y}{x}} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
Alternative 4
Error25.3
Cost1108
\[\begin{array}{l} t_0 := -0.5 \cdot \frac{z}{\frac{y}{z}}\\ \mathbf{if}\;y \leq -1.1 \cdot 10^{+41}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -1.3 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-81}:\\ \;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;y \leq -1.55 \cdot 10^{-250}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+79}:\\ \;\;\;\;\frac{x}{\frac{y}{x}} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
Alternative 5
Error25.3
Cost1108
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{+41}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq -4.4 \cdot 10^{-26}:\\ \;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-80}:\\ \;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x\right)\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-251}:\\ \;\;\;\;\frac{z \cdot \left(z \cdot -0.5\right)}{y}\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+79}:\\ \;\;\;\;\frac{x}{\frac{y}{x}} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
Alternative 6
Error16.7
Cost1106
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{-254} \lor \neg \left(y \leq 2.2 \cdot 10^{-133}\right) \land \left(y \leq 4.6 \cdot 10^{-20} \lor \neg \left(y \leq 1.5 \cdot 10^{+79}\right)\right):\\ \;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{x}} \cdot 0.5\\ \end{array} \]
Alternative 7
Error6.8
Cost1106
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{-33} \lor \neg \left(z \leq 2.2 \cdot 10^{-68} \lor \neg \left(z \leq 2.65 \cdot 10^{-8}\right) \land z \leq 7 \cdot 10^{+16}\right):\\ \;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\ \end{array} \]
Alternative 8
Error16.9
Cost1104
\[\begin{array}{l} t_0 := \frac{x}{\frac{y}{x}} \cdot 0.5\\ t_1 := -0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \mathbf{if}\;y \leq -1.55 \cdot 10^{-250}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{-128}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-20}:\\ \;\;\;\;-0.5 \cdot \left(\frac{z \cdot z}{y} - y\right)\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+79}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error0.1
Cost832
\[-0.5 \cdot \left(\frac{z - x}{y} \cdot \left(z + x\right) - y\right) \]
Alternative 10
Error24.2
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1.1 \cdot 10^{+41} \lor \neg \left(y \leq 1250\right):\\ \;\;\;\;y \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \end{array} \]
Alternative 11
Error27.1
Cost192
\[y \cdot 0.5 \]

Error

Reproduce

herbie shell --seed 2022364 
(FPCore (x y z)
  :name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
  :precision binary64

  :herbie-target
  (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))

  (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))