?

Average Error: 45.29% → 0.23%
Time: 9.8s
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

Original45.29%
Target0.25%
Herbie0.23%
\[y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right) \]

Derivation?

  1. Initial program 45.29

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

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

    [Start]45.29

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

    sub-neg [=>]45.29

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

    +-commutative [=>]45.29

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

    neg-sub0 [=>]45.29

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

    associate-+l- [=>]45.29

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

    sub0-neg [=>]45.29

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

    neg-mul-1 [=>]45.29

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

    *-commutative [=>]45.29

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

    times-frac [=>]45.31

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

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

Alternatives

Alternative 1
Error10.24%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{-26} \lor \neg \left(z \leq 9.2 \cdot 10^{-85}\right):\\ \;\;\;\;-0.5 \cdot \left(\left(z + x\right) \cdot \frac{z}{y} - y\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\ \end{array} \]
Alternative 2
Error21.68%
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -2.55 \cdot 10^{+188}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq -2.35 \cdot 10^{+91}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\ \end{array} \]
Alternative 3
Error21.65%
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{+194}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{+95}:\\ \;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \end{array} \]
Alternative 4
Error10.2%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-26}:\\ \;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-84}:\\ \;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\ \end{array} \]
Alternative 5
Error0.23%
Cost832
\[-0.5 \cdot \left(\frac{z - x}{y} \cdot \left(z + x\right) - y\right) \]
Alternative 6
Error36.4%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{-95}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-5}:\\ \;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
Alternative 7
Error36.41%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -2.85 \cdot 10^{-95}:\\ \;\;\;\;y \cdot 0.5\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-5}:\\ \;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;y \cdot 0.5\\ \end{array} \]
Alternative 8
Error42.04%
Cost192
\[y \cdot 0.5 \]

Error

Reproduce?

herbie shell --seed 2023090 
(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)))