?

Average Error: 6.0 → 0.1
Time: 12.9s
Precision: binary64
Cost: 1092

?

\[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
\[\begin{array}{l} \mathbf{if}\;z \cdot z \leq 1.02 \cdot 10^{+300}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + z \cdot \frac{y \cdot 4}{\frac{-1}{z}}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
(FPCore (x y z t)
 :precision binary64
 (if (<= (* z z) 1.02e+300)
   (+ (* x x) (* (* y 4.0) (- t (* z z))))
   (+ (* x x) (* z (/ (* y 4.0) (/ -1.0 z))))))
double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 1.02e+300) {
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	} else {
		tmp = (x * x) + (z * ((y * 4.0) / (-1.0 / z)));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x * x) - ((y * 4.0d0) * ((z * z) - t))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((z * z) <= 1.02d+300) then
        tmp = (x * x) + ((y * 4.0d0) * (t - (z * z)))
    else
        tmp = (x * x) + (z * ((y * 4.0d0) / ((-1.0d0) / z)))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return (x * x) - ((y * 4.0) * ((z * z) - t));
}
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z * z) <= 1.02e+300) {
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	} else {
		tmp = (x * x) + (z * ((y * 4.0) / (-1.0 / z)));
	}
	return tmp;
}
def code(x, y, z, t):
	return (x * x) - ((y * 4.0) * ((z * z) - t))
def code(x, y, z, t):
	tmp = 0
	if (z * z) <= 1.02e+300:
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)))
	else:
		tmp = (x * x) + (z * ((y * 4.0) / (-1.0 / z)))
	return tmp
function code(x, y, z, t)
	return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t)))
end
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(z * z) <= 1.02e+300)
		tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z))));
	else
		tmp = Float64(Float64(x * x) + Float64(z * Float64(Float64(y * 4.0) / Float64(-1.0 / z))));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x * x) - ((y * 4.0) * ((z * z) - t));
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z * z) <= 1.02e+300)
		tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
	else
		tmp = (x * x) + (z * ((y * 4.0) / (-1.0 / z)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 1.02e+300], N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[(z * N[(N[(y * 4.0), $MachinePrecision] / N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 1.02 \cdot 10^{+300}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot x + z \cdot \frac{y \cdot 4}{\frac{-1}{z}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.0
Target6.0
Herbie0.1
\[x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right) \]

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 z z) < 1.02000000000000002e300

    1. Initial program 0.1

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]

    if 1.02000000000000002e300 < (*.f64 z z)

    1. Initial program 61.2

      \[x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right) \]
    2. Applied egg-rr61.2

      \[\leadsto x \cdot x - \color{blue}{\frac{y \cdot 4}{\frac{1}{z \cdot z - t}}} \]
    3. Taylor expanded in z around inf 61.3

      \[\leadsto x \cdot x - \frac{y \cdot 4}{\color{blue}{\frac{1}{{z}^{2}}}} \]
    4. Simplified57.3

      \[\leadsto x \cdot x - \frac{y \cdot 4}{\color{blue}{\frac{\frac{1}{z}}{z}}} \]
      Proof

      [Start]61.3

      \[ x \cdot x - \frac{y \cdot 4}{\frac{1}{{z}^{2}}} \]

      unpow2 [=>]61.3

      \[ x \cdot x - \frac{y \cdot 4}{\frac{1}{\color{blue}{z \cdot z}}} \]

      associate-/r* [=>]57.3

      \[ x \cdot x - \frac{y \cdot 4}{\color{blue}{\frac{\frac{1}{z}}{z}}} \]
    5. Applied egg-rr0.4

      \[\leadsto x \cdot x - \color{blue}{\frac{y \cdot 4}{\frac{-1}{z}} \cdot \left(-z\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot z \leq 1.02 \cdot 10^{+300}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + z \cdot \frac{y \cdot 4}{\frac{-1}{z}}\\ \end{array} \]

Alternatives

Alternative 1
Error0.2
Cost1600
\[\begin{array}{l} t_1 := z \cdot \left(y \cdot z\right)\\ \left(4 \cdot t_1 - \left(t_1 \cdot 8 + y \cdot \left(t \cdot -4\right)\right)\right) + x \cdot x \end{array} \]
Alternative 2
Error16.2
Cost1105
\[\begin{array}{l} \mathbf{if}\;x \leq -7.4 \cdot 10^{+23}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-41} \lor \neg \left(x \leq -5 \cdot 10^{-81}\right) \land x \leq 2:\\ \;\;\;\;\left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 3
Error7.9
Cost1104
\[\begin{array}{l} t_1 := \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ t_2 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{if}\;z \leq -2.2 \cdot 10^{+142}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{-48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-49}:\\ \;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+149}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error8.3
Cost1104
\[\begin{array}{l} t_1 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{if}\;z \leq -8 \cdot 10^{+111}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-48}:\\ \;\;\;\;x \cdot x + \left(z \cdot z\right) \cdot \left(y \cdot -4\right)\\ \mathbf{elif}\;z \leq 7 \cdot 10^{-54}:\\ \;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+144}:\\ \;\;\;\;\left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error27.6
Cost1101
\[\begin{array}{l} \mathbf{if}\;x \cdot x \leq 1.12 \cdot 10^{-218} \lor \neg \left(x \cdot x \leq 1.06 \cdot 10^{-69}\right) \land x \cdot x \leq 7.8 \cdot 10^{-12}:\\ \;\;\;\;t \cdot \left(y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x\\ \end{array} \]
Alternative 6
Error0.9
Cost1097
\[\begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{+143} \lor \neg \left(z \leq 10^{+150}\right):\\ \;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\ \end{array} \]
Alternative 7
Error29.8
Cost976
\[\begin{array}{l} t_1 := t \cdot \left(y \cdot 4\right)\\ t_2 := z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\ \mathbf{if}\;z \leq -3.1 \cdot 10^{-48}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.55 \cdot 10^{-152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.55 \cdot 10^{-217}:\\ \;\;\;\;x \cdot x\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-68}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error41.6
Cost192
\[x \cdot x \]

Error

Reproduce?

herbie shell --seed 2023018 
(FPCore (x y z t)
  :name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
  :precision binary64

  :herbie-target
  (- (* x x) (* 4.0 (* y (- (* z z) t))))

  (- (* x x) (* (* y 4.0) (- (* z z) t))))