?

Average Error: 28.9 → 7.6
Time: 8.3s
Precision: binary64
Cost: 3016

?

\[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
\[\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 2 \cdot 10^{+299}:\\ \;\;\;\;t_0\\ \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
 (let* ((t_0 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))))
   (if (<= t_0 (- INFINITY)) (* 0.5 y) (if (<= t_0 2e+299) t_0 (* 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 t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = 0.5 * y;
	} else if (t_0 <= 2e+299) {
		tmp = t_0;
	} else {
		tmp = 0.5 * y;
	}
	return tmp;
}
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 t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = 0.5 * y;
	} else if (t_0 <= 2e+299) {
		tmp = t_0;
	} 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):
	t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = 0.5 * y
	elif t_0 <= 2e+299:
		tmp = t_0
	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)
	t_0 = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(0.5 * y);
	elseif (t_0 <= 2e+299)
		tmp = t_0;
	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)
	t_0 = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = 0.5 * y;
	elseif (t_0 <= 2e+299)
		tmp = t_0;
	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_] := Block[{t$95$0 = N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(0.5 * y), $MachinePrecision], If[LessEqual[t$95$0, 2e+299], t$95$0, N[(0.5 * y), $MachinePrecision]]]]
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\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 2 \cdot 10^{+299}:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original28.9
Target0.2
Herbie7.6
\[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 (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y 2)) < -inf.0 or 2.0000000000000001e299 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y 2))

    1. Initial program 63.4

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

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

    if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y 2)) < 2.0000000000000001e299

    1. Initial program 2.6

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

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

Alternatives

Alternative 1
Error7.7
Cost1224
\[\begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+127}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+128}:\\ \;\;\;\;\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 2
Error7.7
Cost1224
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{+127}:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;y \leq 10^{+129}:\\ \;\;\;\;\frac{0.5}{\frac{y}{x \cdot x + \left(y \cdot y - z \cdot z\right)}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array} \]
Alternative 3
Error27.0
Cost192
\[0.5 \cdot y \]

Error

Reproduce?

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