?

Average Error: 29.0 → 7.3
Time: 21.0s
Precision: binary64
Cost: 13768

?

\[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+126}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{+142}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2} - {z}^{2}}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
(FPCore (x y z)
 :precision binary64
 (if (<= y -5.8e+126)
   (* 0.5 y)
   (if (<= y 9.2e+142)
     (* 0.5 (+ y (/ (- (pow x 2.0) (pow z 2.0)) y)))
     (* 0.5 y))))
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) {
	double tmp;
	if (y <= -5.8e+126) {
		tmp = 0.5 * y;
	} else if (y <= 9.2e+142) {
		tmp = 0.5 * (y + ((pow(x, 2.0) - pow(z, 2.0)) / y));
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
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
    real(8) :: tmp
    if (y <= (-5.8d+126)) then
        tmp = 0.5d0 * y
    else if (y <= 9.2d+142) then
        tmp = 0.5d0 * (y + (((x ** 2.0d0) - (z ** 2.0d0)) / y))
    else
        tmp = 0.5d0 * y
    end if
    code = tmp
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) {
	double tmp;
	if (y <= -5.8e+126) {
		tmp = 0.5 * y;
	} else if (y <= 9.2e+142) {
		tmp = 0.5 * (y + ((Math.pow(x, 2.0) - Math.pow(z, 2.0)) / y));
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
def code(x, y, z):
	return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
def code(x, y, z):
	tmp = 0
	if y <= -5.8e+126:
		tmp = 0.5 * y
	elif y <= 9.2e+142:
		tmp = 0.5 * (y + ((math.pow(x, 2.0) - math.pow(z, 2.0)) / y))
	else:
		tmp = 0.5 * y
	return tmp
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)
	tmp = 0.0
	if (y <= -5.8e+126)
		tmp = Float64(0.5 * y);
	elseif (y <= 9.2e+142)
		tmp = Float64(0.5 * Float64(y + Float64(Float64((x ^ 2.0) - (z ^ 2.0)) / y)));
	else
		tmp = Float64(0.5 * y);
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -5.8e+126)
		tmp = 0.5 * y;
	elseif (y <= 9.2e+142)
		tmp = 0.5 * (y + (((x ^ 2.0) - (z ^ 2.0)) / y));
	else
		tmp = 0.5 * y;
	end
	tmp_2 = tmp;
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_] := If[LessEqual[y, -5.8e+126], N[(0.5 * y), $MachinePrecision], If[LessEqual[y, 9.2e+142], N[(0.5 * N[(y + N[(N[(N[Power[x, 2.0], $MachinePrecision] - N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+126}:\\
\;\;\;\;0.5 \cdot y\\

\mathbf{elif}\;y \leq 9.2 \cdot 10^{+142}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2} - {z}^{2}}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.0
Target0.2
Herbie7.3
\[y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right) \]

Derivation?

  1. Split input into 2 regimes
  2. if y < -5.79999999999999971e126 or 9.20000000000000009e142 < y

    1. Initial program 59.9

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Taylor expanded in y around inf 9.4

      \[\leadsto \color{blue}{0.5 \cdot y} \]

    if -5.79999999999999971e126 < y < 9.20000000000000009e142

    1. Initial program 6.6

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Taylor expanded in y around 0 5.7

      \[\leadsto \color{blue}{0.5 \cdot y + 0.5 \cdot \frac{{x}^{2} - {z}^{2}}{y}} \]
    3. Simplified5.7

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

      [Start]5.7

      \[ 0.5 \cdot y + 0.5 \cdot \frac{{x}^{2} - {z}^{2}}{y} \]

      rational.json-simplify-1 [=>]5.7

      \[ \color{blue}{0.5 \cdot \frac{{x}^{2} - {z}^{2}}{y} + 0.5 \cdot y} \]

      rational.json-simplify-2 [=>]5.7

      \[ 0.5 \cdot \frac{{x}^{2} - {z}^{2}}{y} + \color{blue}{y \cdot 0.5} \]

      rational.json-simplify-51 [=>]5.7

      \[ \color{blue}{0.5 \cdot \left(y + \frac{{x}^{2} - {z}^{2}}{y}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+126}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{+142}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2} - {z}^{2}}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \]

Alternatives

Alternative 1
Error7.7
Cost3016
\[\begin{array}{l} t_0 := \frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;t_0 \leq 10^{+306}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(1 - y \cdot -0.5\right)\\ \end{array} \]
Alternative 2
Error7.8
Cost1224
\[\begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{+127}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+142}:\\ \;\;\;\;\frac{0.5}{y} \cdot \left(x \cdot x + \left(y \cdot y - z \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \]
Alternative 3
Error27.2
Cost192
\[0.5 \cdot y \]

Error

Reproduce?

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