?

Average Error: 27.8 → 5.1
Time: 19.8s
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 -2 \cdot 10^{+163}:\\ \;\;\;\;\frac{\frac{y + z}{\frac{y}{y - z}}}{2}\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{+84}:\\ \;\;\;\;0.5 \cdot \left(y + \frac{{x}^{2} - {z}^{2}}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot \frac{y - z}{y}\right)\\ \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 -2e+163)
   (/ (/ (+ y z) (/ y (- y z))) 2.0)
   (if (<= y 1.55e+84)
     (* 0.5 (+ y (/ (- (pow x 2.0) (pow z 2.0)) y)))
     (* 0.5 (* (+ y z) (/ (- y z) 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 <= -2e+163) {
		tmp = ((y + z) / (y / (y - z))) / 2.0;
	} else if (y <= 1.55e+84) {
		tmp = 0.5 * (y + ((pow(x, 2.0) - pow(z, 2.0)) / y));
	} else {
		tmp = 0.5 * ((y + z) * ((y - z) / 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 <= (-2d+163)) then
        tmp = ((y + z) / (y / (y - z))) / 2.0d0
    else if (y <= 1.55d+84) then
        tmp = 0.5d0 * (y + (((x ** 2.0d0) - (z ** 2.0d0)) / y))
    else
        tmp = 0.5d0 * ((y + z) * ((y - z) / 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 <= -2e+163) {
		tmp = ((y + z) / (y / (y - z))) / 2.0;
	} else if (y <= 1.55e+84) {
		tmp = 0.5 * (y + ((Math.pow(x, 2.0) - Math.pow(z, 2.0)) / y));
	} else {
		tmp = 0.5 * ((y + z) * ((y - z) / 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 <= -2e+163:
		tmp = ((y + z) / (y / (y - z))) / 2.0
	elif y <= 1.55e+84:
		tmp = 0.5 * (y + ((math.pow(x, 2.0) - math.pow(z, 2.0)) / y))
	else:
		tmp = 0.5 * ((y + z) * ((y - z) / 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 <= -2e+163)
		tmp = Float64(Float64(Float64(y + z) / Float64(y / Float64(y - z))) / 2.0);
	elseif (y <= 1.55e+84)
		tmp = Float64(0.5 * Float64(y + Float64(Float64((x ^ 2.0) - (z ^ 2.0)) / y)));
	else
		tmp = Float64(0.5 * Float64(Float64(y + z) * Float64(Float64(y - z) / 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 <= -2e+163)
		tmp = ((y + z) / (y / (y - z))) / 2.0;
	elseif (y <= 1.55e+84)
		tmp = 0.5 * (y + (((x ^ 2.0) - (z ^ 2.0)) / y));
	else
		tmp = 0.5 * ((y + z) * ((y - z) / 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, -2e+163], N[(N[(N[(y + z), $MachinePrecision] / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], If[LessEqual[y, 1.55e+84], 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 * N[(N[(y + z), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+163}:\\
\;\;\;\;\frac{\frac{y + z}{\frac{y}{y - z}}}{2}\\

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot \frac{y - z}{y}\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original27.8
Target0.2
Herbie5.1
\[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 3 regimes
  2. if y < -1.9999999999999999e163

    1. Initial program 64.0

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Applied egg-rr64.0

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

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

      [Start]64.0

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

      rational.json-simplify-4 [=>]64.0

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

      rational.json-simplify-34 [=>]64.0

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

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

      \[ \left(x \cdot x + \color{blue}{\left(y + z\right)} \cdot \left(y - z\right)\right) \cdot \frac{0.5}{y} \]
    4. Taylor expanded in x around 0 64.0

      \[\leadsto \color{blue}{\left(\left(y - z\right) \cdot \left(y + z\right)\right)} \cdot \frac{0.5}{y} \]
    5. Applied egg-rr4.2

      \[\leadsto \color{blue}{\frac{\frac{y + z}{\frac{y}{y - z}}}{2}} \]

    if -1.9999999999999999e163 < y < 1.55000000000000001e84

    1. Initial program 6.9

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

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

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

      [Start]5.3

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

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

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

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

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

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

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

    if 1.55000000000000001e84 < y

    1. Initial program 49.4

      \[\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2} \]
    2. Applied egg-rr49.5

      \[\leadsto \color{blue}{\left(x \cdot x + \left(y \cdot y - z \cdot z\right)\right) \cdot \frac{0.5}{y} + 0} \]
    3. Simplified49.5

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

      [Start]49.5

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

      rational.json-simplify-4 [=>]49.5

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

      rational.json-simplify-34 [=>]49.5

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

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

      \[ \left(x \cdot x + \color{blue}{\left(y + z\right)} \cdot \left(y - z\right)\right) \cdot \frac{0.5}{y} \]
    4. Taylor expanded in x around 0 50.6

      \[\leadsto \color{blue}{0.5 \cdot \frac{\left(y - z\right) \cdot \left(y + z\right)}{y}} \]
    5. Simplified5.4

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

      [Start]50.6

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

      rational.json-simplify-49 [=>]5.4

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

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

Alternatives

Alternative 1
Error5.6
Cost1224
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{+153}:\\ \;\;\;\;\frac{\frac{y + z}{\frac{y}{y - z}}}{2}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+84}:\\ \;\;\;\;\left(x \cdot x + \left(y + z\right) \cdot \left(y - z\right)\right) \cdot \frac{0.5}{y}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot \frac{y - z}{y}\right)\\ \end{array} \]
Alternative 2
Error5.5
Cost1224
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+154}:\\ \;\;\;\;\frac{\frac{y + z}{\frac{y}{y - z}}}{2}\\ \mathbf{elif}\;y \leq 1.36 \cdot 10^{+84}:\\ \;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot \frac{y - z}{y}\right)\\ \end{array} \]
Alternative 3
Error23.7
Cost904
\[\begin{array}{l} \mathbf{if}\;y \leq -1.85 \cdot 10^{-58}:\\ \;\;\;\;0.5 \cdot \left(z + \left(\left(-z\right) + y\right)\right)\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-30}:\\ \;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot \left(-\frac{z}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot 1\right)\\ \end{array} \]
Alternative 4
Error23.7
Cost904
\[\begin{array}{l} \mathbf{if}\;y \leq -1.95 \cdot 10^{-61}:\\ \;\;\;\;0.5 \cdot \left(z + \left(\left(-z\right) + y\right)\right)\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{-31}:\\ \;\;\;\;\frac{\frac{y + z}{-\frac{y}{z}}}{2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\left(y + z\right) \cdot 1\right)\\ \end{array} \]
Alternative 5
Error13.8
Cost704
\[0.5 \cdot \left(\left(y + z\right) \cdot \frac{y - z}{y}\right) \]
Alternative 6
Error27.8
Cost512
\[0.5 \cdot \left(z + \left(\left(-z\right) + y\right)\right) \]
Alternative 7
Error27.9
Cost192
\[0.5 \cdot y \]

Error

Reproduce?

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