Gyroid sphere

Percentage Accurate: 46.6% → 93.1%
Time: 3.7s
Alternatives: 4
Speedup: 19.2×

Specification

?
\[\mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (fmax
 (-
  (sqrt
   (+
    (+ (pow (* x 30.0) 2.0) (pow (* y 30.0) 2.0))
    (pow (* z 30.0) 2.0)))
  25.0)
 (-
  (fabs
   (+
    (+
     (* (sin (* x 30.0)) (cos (* y 30.0)))
     (* (sin (* y 30.0)) (cos (* z 30.0))))
    (* (sin (* z 30.0)) (cos (* x 30.0)))))
  0.2)))
double code(double x, double y, double z) {
	return fmax((sqrt(((pow((x * 30.0), 2.0) + pow((y * 30.0), 2.0)) + pow((z * 30.0), 2.0))) - 25.0), (fabs((((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))) + (sin((z * 30.0)) * cos((x * 30.0))))) - 0.2));
}
real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = fmax((sqrt(((((x * 30.0d0) ** 2.0d0) + ((y * 30.0d0) ** 2.0d0)) + ((z * 30.0d0) ** 2.0d0))) - 25.0d0), (abs((((sin((x * 30.0d0)) * cos((y * 30.0d0))) + (sin((y * 30.0d0)) * cos((z * 30.0d0)))) + (sin((z * 30.0d0)) * cos((x * 30.0d0))))) - 0.2d0))
end function
public static double code(double x, double y, double z) {
	return fmax((Math.sqrt(((Math.pow((x * 30.0), 2.0) + Math.pow((y * 30.0), 2.0)) + Math.pow((z * 30.0), 2.0))) - 25.0), (Math.abs((((Math.sin((x * 30.0)) * Math.cos((y * 30.0))) + (Math.sin((y * 30.0)) * Math.cos((z * 30.0)))) + (Math.sin((z * 30.0)) * Math.cos((x * 30.0))))) - 0.2));
}
def code(x, y, z):
	return fmax((math.sqrt(((math.pow((x * 30.0), 2.0) + math.pow((y * 30.0), 2.0)) + math.pow((z * 30.0), 2.0))) - 25.0), (math.fabs((((math.sin((x * 30.0)) * math.cos((y * 30.0))) + (math.sin((y * 30.0)) * math.cos((z * 30.0)))) + (math.sin((z * 30.0)) * math.cos((x * 30.0))))) - 0.2))
function code(x, y, z)
	return fmax(Float64(sqrt(Float64(Float64((Float64(x * 30.0) ^ 2.0) + (Float64(y * 30.0) ^ 2.0)) + (Float64(z * 30.0) ^ 2.0))) - 25.0), Float64(abs(Float64(Float64(Float64(sin(Float64(x * 30.0)) * cos(Float64(y * 30.0))) + Float64(sin(Float64(y * 30.0)) * cos(Float64(z * 30.0)))) + Float64(sin(Float64(z * 30.0)) * cos(Float64(x * 30.0))))) - 0.2))
end
function tmp = code(x, y, z)
	tmp = max((sqrt(((((x * 30.0) ^ 2.0) + ((y * 30.0) ^ 2.0)) + ((z * 30.0) ^ 2.0))) - 25.0), (abs((((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))) + (sin((z * 30.0)) * cos((x * 30.0))))) - 0.2));
end
code[x_, y_, z_] := N[Max[N[(N[Sqrt[N[(N[(N[Power[N[(x * 30.0), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(y * 30.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[(z * 30.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(N[(N[(N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(y * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[N[(y * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(z * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	LET tmp = IF (((sqrt(((((x * (30)) ^ (2)) + ((y * (30)) ^ (2))) + ((z * (30)) ^ (2))))) - (25)) > ((abs(((((sin((x * (30)))) * (cos((y * (30))))) + ((sin((y * (30)))) * (cos((z * (30)))))) + ((sin((z * (30)))) * (cos((x * (30)))))))) - (200000000000000011102230246251565404236316680908203125e-54))) THEN ((sqrt(((((x * (30)) ^ (2)) + ((y * (30)) ^ (2))) + ((z * (30)) ^ (2))))) - (25)) ELSE ((abs(((((sin((x * (30)))) * (cos((y * (30))))) + ((sin((y * (30)))) * (cos((z * (30)))))) + ((sin((z * (30)))) * (cos((x * (30)))))))) - (200000000000000011102230246251565404236316680908203125e-54)) ENDIF IN
	tmp
END code
\mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right)

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 46.6% accurate, 1.0× speedup?

\[\mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (fmax
 (-
  (sqrt
   (+
    (+ (pow (* x 30.0) 2.0) (pow (* y 30.0) 2.0))
    (pow (* z 30.0) 2.0)))
  25.0)
 (-
  (fabs
   (+
    (+
     (* (sin (* x 30.0)) (cos (* y 30.0)))
     (* (sin (* y 30.0)) (cos (* z 30.0))))
    (* (sin (* z 30.0)) (cos (* x 30.0)))))
  0.2)))
double code(double x, double y, double z) {
	return fmax((sqrt(((pow((x * 30.0), 2.0) + pow((y * 30.0), 2.0)) + pow((z * 30.0), 2.0))) - 25.0), (fabs((((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))) + (sin((z * 30.0)) * cos((x * 30.0))))) - 0.2));
}
real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = fmax((sqrt(((((x * 30.0d0) ** 2.0d0) + ((y * 30.0d0) ** 2.0d0)) + ((z * 30.0d0) ** 2.0d0))) - 25.0d0), (abs((((sin((x * 30.0d0)) * cos((y * 30.0d0))) + (sin((y * 30.0d0)) * cos((z * 30.0d0)))) + (sin((z * 30.0d0)) * cos((x * 30.0d0))))) - 0.2d0))
end function
public static double code(double x, double y, double z) {
	return fmax((Math.sqrt(((Math.pow((x * 30.0), 2.0) + Math.pow((y * 30.0), 2.0)) + Math.pow((z * 30.0), 2.0))) - 25.0), (Math.abs((((Math.sin((x * 30.0)) * Math.cos((y * 30.0))) + (Math.sin((y * 30.0)) * Math.cos((z * 30.0)))) + (Math.sin((z * 30.0)) * Math.cos((x * 30.0))))) - 0.2));
}
def code(x, y, z):
	return fmax((math.sqrt(((math.pow((x * 30.0), 2.0) + math.pow((y * 30.0), 2.0)) + math.pow((z * 30.0), 2.0))) - 25.0), (math.fabs((((math.sin((x * 30.0)) * math.cos((y * 30.0))) + (math.sin((y * 30.0)) * math.cos((z * 30.0)))) + (math.sin((z * 30.0)) * math.cos((x * 30.0))))) - 0.2))
function code(x, y, z)
	return fmax(Float64(sqrt(Float64(Float64((Float64(x * 30.0) ^ 2.0) + (Float64(y * 30.0) ^ 2.0)) + (Float64(z * 30.0) ^ 2.0))) - 25.0), Float64(abs(Float64(Float64(Float64(sin(Float64(x * 30.0)) * cos(Float64(y * 30.0))) + Float64(sin(Float64(y * 30.0)) * cos(Float64(z * 30.0)))) + Float64(sin(Float64(z * 30.0)) * cos(Float64(x * 30.0))))) - 0.2))
end
function tmp = code(x, y, z)
	tmp = max((sqrt(((((x * 30.0) ^ 2.0) + ((y * 30.0) ^ 2.0)) + ((z * 30.0) ^ 2.0))) - 25.0), (abs((((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))) + (sin((z * 30.0)) * cos((x * 30.0))))) - 0.2));
end
code[x_, y_, z_] := N[Max[N[(N[Sqrt[N[(N[(N[Power[N[(x * 30.0), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(y * 30.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[(z * 30.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(N[(N[(N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(y * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[N[(y * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(z * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	LET tmp = IF (((sqrt(((((x * (30)) ^ (2)) + ((y * (30)) ^ (2))) + ((z * (30)) ^ (2))))) - (25)) > ((abs(((((sin((x * (30)))) * (cos((y * (30))))) + ((sin((y * (30)))) * (cos((z * (30)))))) + ((sin((z * (30)))) * (cos((x * (30)))))))) - (200000000000000011102230246251565404236316680908203125e-54))) THEN ((sqrt(((((x * (30)) ^ (2)) + ((y * (30)) ^ (2))) + ((z * (30)) ^ (2))))) - (25)) ELSE ((abs(((((sin((x * (30)))) * (cos((y * (30))))) + ((sin((y * (30)))) * (cos((z * (30)))))) + ((sin((z * (30)))) * (cos((x * (30)))))))) - (200000000000000011102230246251565404236316680908203125e-54)) ENDIF IN
	tmp
END code
\mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right)

Alternative 1: 93.1% accurate, 4.5× speedup?

\[\begin{array}{l} \mathbf{if}\;z \cdot 30 \leq 2 \cdot 10^{+51}:\\ \;\;\;\;\mathsf{max}\left(-30 \cdot z - 25, \left|\mathsf{fma}\left(30, x, 30 \cdot y\right)\right| - 0.2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{max}\left(\mathsf{fma}\left(z, 30, z \cdot \frac{-25}{z}\right), \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right)\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  :pre TRUE
  (if (<= (* z 30.0) 2e+51)
  (fmax (- (* -30.0 z) 25.0) (- (fabs (fma 30.0 x (* 30.0 y))) 0.2))
  (fmax
   (fma z 30.0 (* z (/ -25.0 z)))
   (- (fabs (+ (sin (* 30.0 z)) (* 30.0 x))) 0.2))))
double code(double x, double y, double z) {
	double tmp;
	if ((z * 30.0) <= 2e+51) {
		tmp = fmax(((-30.0 * z) - 25.0), (fabs(fma(30.0, x, (30.0 * y))) - 0.2));
	} else {
		tmp = fmax(fma(z, 30.0, (z * (-25.0 / z))), (fabs((sin((30.0 * z)) + (30.0 * x))) - 0.2));
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (Float64(z * 30.0) <= 2e+51)
		tmp = fmax(Float64(Float64(-30.0 * z) - 25.0), Float64(abs(fma(30.0, x, Float64(30.0 * y))) - 0.2));
	else
		tmp = fmax(fma(z, 30.0, Float64(z * Float64(-25.0 / z))), Float64(abs(Float64(sin(Float64(30.0 * z)) + Float64(30.0 * x))) - 0.2));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[N[(z * 30.0), $MachinePrecision], 2e+51], N[Max[N[(N[(-30.0 * z), $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(30.0 * x + N[(30.0 * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(z * 30.0 + N[(z * N[(-25.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(N[Sin[N[(30.0 * z), $MachinePrecision]], $MachinePrecision] + N[(30.0 * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]
f(x, y, z):
	x in [-inf, +inf],
	y in [-inf, +inf],
	z in [-inf, +inf]
code: THEORY
BEGIN
f(x, y, z: real): real =
	LET tmp_2 = IF ((((-30) * z) - (25)) > ((abs((((30) * x) + ((30) * y)))) - (200000000000000011102230246251565404236316680908203125e-54))) THEN (((-30) * z) - (25)) ELSE ((abs((((30) * x) + ((30) * y)))) - (200000000000000011102230246251565404236316680908203125e-54)) ENDIF IN
	LET tmp_3 = IF (((z * (30)) + (z * ((-25) / z))) > ((abs(((sin(((30) * z))) + ((30) * x)))) - (200000000000000011102230246251565404236316680908203125e-54))) THEN ((z * (30)) + (z * ((-25) / z))) ELSE ((abs(((sin(((30) * z))) + ((30) * x)))) - (200000000000000011102230246251565404236316680908203125e-54)) ENDIF IN
	LET tmp_1 = IF ((z * (30)) <= (1999999999999999986441897348723255952923416883888128)) THEN tmp_2 ELSE tmp_3 ENDIF IN
	tmp_1
END code
\begin{array}{l}
\mathbf{if}\;z \cdot 30 \leq 2 \cdot 10^{+51}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot z - 25, \left|\mathsf{fma}\left(30, x, 30 \cdot y\right)\right| - 0.2\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(\mathsf{fma}\left(z, 30, z \cdot \frac{-25}{z}\right), \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z #s(literal 30 binary64)) < 2e51

    1. Initial program 46.6%

      \[\mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
    2. Taylor expanded in z around -inf

      \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
    3. Step-by-step derivation
      1. Applied rewrites30.6%

        \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
      2. Taylor expanded in y around 0

        \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + \left(30 \cdot \left(y \cdot \cos \left(30 \cdot z\right)\right) + \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right)\right| - 0.2\right) \]
      3. Step-by-step derivation
        1. Applied rewrites49.8%

          \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + \mathsf{fma}\left(30, y \cdot \cos \left(30 \cdot z\right), \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right)\right| - 0.2\right) \]
        2. Taylor expanded in z around 0

          \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + 30 \cdot y\right| - 0.2\right) \]
        3. Step-by-step derivation
          1. Applied rewrites56.8%

            \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + 30 \cdot y\right| - 0.2\right) \]
          2. Taylor expanded in x around 0

            \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|30 \cdot x + 30 \cdot y\right| - 0.2\right) \]
          3. Step-by-step derivation
            1. Applied rewrites83.6%

              \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\mathsf{fma}\left(30, x, 30 \cdot y\right)\right| - 0.2\right) \]

            if 2e51 < (*.f64 z #s(literal 30 binary64))

            1. Initial program 46.6%

              \[\mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
            2. Taylor expanded in y around 0

              \[\leadsto \mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\sin \left(30 \cdot x\right) + \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right| - 0.2\right) \]
            3. Step-by-step derivation
              1. Applied rewrites46.3%

                \[\leadsto \mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\sin \left(30 \cdot x\right) + \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right| - 0.2\right) \]
              2. Taylor expanded in x around 0

                \[\leadsto \mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right) \]
              3. Step-by-step derivation
                1. Applied rewrites45.9%

                  \[\leadsto \mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right) \]
                2. Taylor expanded in z around inf

                  \[\leadsto \mathsf{max}\left(z \cdot \left(30 - 25 \cdot \frac{1}{z}\right), \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites56.4%

                    \[\leadsto \mathsf{max}\left(z \cdot \left(30 - 25 \cdot \frac{1}{z}\right), \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right) \]
                  2. Step-by-step derivation
                    1. Applied rewrites56.4%

                      \[\leadsto \mathsf{max}\left(\mathsf{fma}\left(z, 30, z \cdot \frac{-25}{z}\right), \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right) \]
                  3. Recombined 2 regimes into one program.
                  4. Add Preprocessing

                  Alternative 2: 93.0% accurate, 8.9× speedup?

                  \[\begin{array}{l} \mathbf{if}\;z \cdot 30 \leq 2 \cdot 10^{+51}:\\ \;\;\;\;\mathsf{max}\left(-30 \cdot z - 25, \left|\mathsf{fma}\left(30, x, 30 \cdot y\right)\right| - 0.2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{max}\left(z \cdot \left(30 - 25 \cdot \frac{1}{z}\right), \left|\mathsf{fma}\left(30, x, 30 \cdot z\right)\right| - 0.2\right)\\ \end{array} \]
                  (FPCore (x y z)
                    :precision binary64
                    :pre TRUE
                    (if (<= (* z 30.0) 2e+51)
                    (fmax (- (* -30.0 z) 25.0) (- (fabs (fma 30.0 x (* 30.0 y))) 0.2))
                    (fmax
                     (* z (- 30.0 (* 25.0 (/ 1.0 z))))
                     (- (fabs (fma 30.0 x (* 30.0 z))) 0.2))))
                  double code(double x, double y, double z) {
                  	double tmp;
                  	if ((z * 30.0) <= 2e+51) {
                  		tmp = fmax(((-30.0 * z) - 25.0), (fabs(fma(30.0, x, (30.0 * y))) - 0.2));
                  	} else {
                  		tmp = fmax((z * (30.0 - (25.0 * (1.0 / z)))), (fabs(fma(30.0, x, (30.0 * z))) - 0.2));
                  	}
                  	return tmp;
                  }
                  
                  function code(x, y, z)
                  	tmp = 0.0
                  	if (Float64(z * 30.0) <= 2e+51)
                  		tmp = fmax(Float64(Float64(-30.0 * z) - 25.0), Float64(abs(fma(30.0, x, Float64(30.0 * y))) - 0.2));
                  	else
                  		tmp = fmax(Float64(z * Float64(30.0 - Float64(25.0 * Float64(1.0 / z)))), Float64(abs(fma(30.0, x, Float64(30.0 * z))) - 0.2));
                  	end
                  	return tmp
                  end
                  
                  code[x_, y_, z_] := If[LessEqual[N[(z * 30.0), $MachinePrecision], 2e+51], N[Max[N[(N[(-30.0 * z), $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(30.0 * x + N[(30.0 * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(z * N[(30.0 - N[(25.0 * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(30.0 * x + N[(30.0 * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]
                  
                  f(x, y, z):
                  	x in [-inf, +inf],
                  	y in [-inf, +inf],
                  	z in [-inf, +inf]
                  code: THEORY
                  BEGIN
                  f(x, y, z: real): real =
                  	LET tmp_2 = IF ((((-30) * z) - (25)) > ((abs((((30) * x) + ((30) * y)))) - (200000000000000011102230246251565404236316680908203125e-54))) THEN (((-30) * z) - (25)) ELSE ((abs((((30) * x) + ((30) * y)))) - (200000000000000011102230246251565404236316680908203125e-54)) ENDIF IN
                  	LET tmp_3 = IF ((z * ((30) - ((25) * ((1) / z)))) > ((abs((((30) * x) + ((30) * z)))) - (200000000000000011102230246251565404236316680908203125e-54))) THEN (z * ((30) - ((25) * ((1) / z)))) ELSE ((abs((((30) * x) + ((30) * z)))) - (200000000000000011102230246251565404236316680908203125e-54)) ENDIF IN
                  	LET tmp_1 = IF ((z * (30)) <= (1999999999999999986441897348723255952923416883888128)) THEN tmp_2 ELSE tmp_3 ENDIF IN
                  	tmp_1
                  END code
                  \begin{array}{l}
                  \mathbf{if}\;z \cdot 30 \leq 2 \cdot 10^{+51}:\\
                  \;\;\;\;\mathsf{max}\left(-30 \cdot z - 25, \left|\mathsf{fma}\left(30, x, 30 \cdot y\right)\right| - 0.2\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\mathsf{max}\left(z \cdot \left(30 - 25 \cdot \frac{1}{z}\right), \left|\mathsf{fma}\left(30, x, 30 \cdot z\right)\right| - 0.2\right)\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (*.f64 z #s(literal 30 binary64)) < 2e51

                    1. Initial program 46.6%

                      \[\mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
                    2. Taylor expanded in z around -inf

                      \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
                    3. Step-by-step derivation
                      1. Applied rewrites30.6%

                        \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
                      2. Taylor expanded in y around 0

                        \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + \left(30 \cdot \left(y \cdot \cos \left(30 \cdot z\right)\right) + \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right)\right| - 0.2\right) \]
                      3. Step-by-step derivation
                        1. Applied rewrites49.8%

                          \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + \mathsf{fma}\left(30, y \cdot \cos \left(30 \cdot z\right), \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right)\right| - 0.2\right) \]
                        2. Taylor expanded in z around 0

                          \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + 30 \cdot y\right| - 0.2\right) \]
                        3. Step-by-step derivation
                          1. Applied rewrites56.8%

                            \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + 30 \cdot y\right| - 0.2\right) \]
                          2. Taylor expanded in x around 0

                            \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|30 \cdot x + 30 \cdot y\right| - 0.2\right) \]
                          3. Step-by-step derivation
                            1. Applied rewrites83.6%

                              \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\mathsf{fma}\left(30, x, 30 \cdot y\right)\right| - 0.2\right) \]

                            if 2e51 < (*.f64 z #s(literal 30 binary64))

                            1. Initial program 46.6%

                              \[\mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
                            2. Taylor expanded in y around 0

                              \[\leadsto \mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\sin \left(30 \cdot x\right) + \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right| - 0.2\right) \]
                            3. Step-by-step derivation
                              1. Applied rewrites46.3%

                                \[\leadsto \mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\sin \left(30 \cdot x\right) + \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right| - 0.2\right) \]
                              2. Taylor expanded in x around 0

                                \[\leadsto \mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right) \]
                              3. Step-by-step derivation
                                1. Applied rewrites45.9%

                                  \[\leadsto \mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right) \]
                                2. Taylor expanded in z around inf

                                  \[\leadsto \mathsf{max}\left(z \cdot \left(30 - 25 \cdot \frac{1}{z}\right), \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right) \]
                                3. Step-by-step derivation
                                  1. Applied rewrites56.4%

                                    \[\leadsto \mathsf{max}\left(z \cdot \left(30 - 25 \cdot \frac{1}{z}\right), \left|\sin \left(30 \cdot z\right) + 30 \cdot x\right| - 0.2\right) \]
                                  2. Taylor expanded in z around 0

                                    \[\leadsto \mathsf{max}\left(z \cdot \left(30 - 25 \cdot \frac{1}{z}\right), \left|30 \cdot x + 30 \cdot z\right| - 0.2\right) \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites70.2%

                                      \[\leadsto \mathsf{max}\left(z \cdot \left(30 - 25 \cdot \frac{1}{z}\right), \left|\mathsf{fma}\left(30, x, 30 \cdot z\right)\right| - 0.2\right) \]
                                  4. Recombined 2 regimes into one program.
                                  5. Add Preprocessing

                                  Alternative 3: 83.6% accurate, 14.7× speedup?

                                  \[\mathsf{max}\left(-30 \cdot z - 25, \left|\mathsf{fma}\left(30, x, 30 \cdot y\right)\right| - 0.2\right) \]
                                  (FPCore (x y z)
                                    :precision binary64
                                    :pre TRUE
                                    (fmax (- (* -30.0 z) 25.0) (- (fabs (fma 30.0 x (* 30.0 y))) 0.2)))
                                  double code(double x, double y, double z) {
                                  	return fmax(((-30.0 * z) - 25.0), (fabs(fma(30.0, x, (30.0 * y))) - 0.2));
                                  }
                                  
                                  function code(x, y, z)
                                  	return fmax(Float64(Float64(-30.0 * z) - 25.0), Float64(abs(fma(30.0, x, Float64(30.0 * y))) - 0.2))
                                  end
                                  
                                  code[x_, y_, z_] := N[Max[N[(N[(-30.0 * z), $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(30.0 * x + N[(30.0 * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
                                  
                                  f(x, y, z):
                                  	x in [-inf, +inf],
                                  	y in [-inf, +inf],
                                  	z in [-inf, +inf]
                                  code: THEORY
                                  BEGIN
                                  f(x, y, z: real): real =
                                  	LET tmp = IF ((((-30) * z) - (25)) > ((abs((((30) * x) + ((30) * y)))) - (200000000000000011102230246251565404236316680908203125e-54))) THEN (((-30) * z) - (25)) ELSE ((abs((((30) * x) + ((30) * y)))) - (200000000000000011102230246251565404236316680908203125e-54)) ENDIF IN
                                  	tmp
                                  END code
                                  \mathsf{max}\left(-30 \cdot z - 25, \left|\mathsf{fma}\left(30, x, 30 \cdot y\right)\right| - 0.2\right)
                                  
                                  Derivation
                                  1. Initial program 46.6%

                                    \[\mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
                                  2. Taylor expanded in z around -inf

                                    \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites30.6%

                                      \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
                                    2. Taylor expanded in y around 0

                                      \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + \left(30 \cdot \left(y \cdot \cos \left(30 \cdot z\right)\right) + \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right)\right| - 0.2\right) \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites49.8%

                                        \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + \mathsf{fma}\left(30, y \cdot \cos \left(30 \cdot z\right), \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right)\right| - 0.2\right) \]
                                      2. Taylor expanded in z around 0

                                        \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + 30 \cdot y\right| - 0.2\right) \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites56.8%

                                          \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + 30 \cdot y\right| - 0.2\right) \]
                                        2. Taylor expanded in x around 0

                                          \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|30 \cdot x + 30 \cdot y\right| - 0.2\right) \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites83.6%

                                            \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\mathsf{fma}\left(30, x, 30 \cdot y\right)\right| - 0.2\right) \]
                                          2. Add Preprocessing

                                          Alternative 4: 56.0% accurate, 19.2× speedup?

                                          \[\mathsf{max}\left(-30 \cdot z - 25, \left|30 \cdot y\right| - 0.2\right) \]
                                          (FPCore (x y z)
                                            :precision binary64
                                            :pre TRUE
                                            (fmax (- (* -30.0 z) 25.0) (- (fabs (* 30.0 y)) 0.2)))
                                          double code(double x, double y, double z) {
                                          	return fmax(((-30.0 * z) - 25.0), (fabs((30.0 * y)) - 0.2));
                                          }
                                          
                                          real(8) function code(x, y, z)
                                          use fmin_fmax_functions
                                              real(8), intent (in) :: x
                                              real(8), intent (in) :: y
                                              real(8), intent (in) :: z
                                              code = fmax((((-30.0d0) * z) - 25.0d0), (abs((30.0d0 * y)) - 0.2d0))
                                          end function
                                          
                                          public static double code(double x, double y, double z) {
                                          	return fmax(((-30.0 * z) - 25.0), (Math.abs((30.0 * y)) - 0.2));
                                          }
                                          
                                          def code(x, y, z):
                                          	return fmax(((-30.0 * z) - 25.0), (math.fabs((30.0 * y)) - 0.2))
                                          
                                          function code(x, y, z)
                                          	return fmax(Float64(Float64(-30.0 * z) - 25.0), Float64(abs(Float64(30.0 * y)) - 0.2))
                                          end
                                          
                                          function tmp = code(x, y, z)
                                          	tmp = max(((-30.0 * z) - 25.0), (abs((30.0 * y)) - 0.2));
                                          end
                                          
                                          code[x_, y_, z_] := N[Max[N[(N[(-30.0 * z), $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(30.0 * y), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
                                          
                                          f(x, y, z):
                                          	x in [-inf, +inf],
                                          	y in [-inf, +inf],
                                          	z in [-inf, +inf]
                                          code: THEORY
                                          BEGIN
                                          f(x, y, z: real): real =
                                          	LET tmp = IF ((((-30) * z) - (25)) > ((abs(((30) * y))) - (200000000000000011102230246251565404236316680908203125e-54))) THEN (((-30) * z) - (25)) ELSE ((abs(((30) * y))) - (200000000000000011102230246251565404236316680908203125e-54)) ENDIF IN
                                          	tmp
                                          END code
                                          \mathsf{max}\left(-30 \cdot z - 25, \left|30 \cdot y\right| - 0.2\right)
                                          
                                          Derivation
                                          1. Initial program 46.6%

                                            \[\mathsf{max}\left(\sqrt{\left({\left(x \cdot 30\right)}^{2} + {\left(y \cdot 30\right)}^{2}\right) + {\left(z \cdot 30\right)}^{2}} - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
                                          2. Taylor expanded in z around -inf

                                            \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites30.6%

                                              \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + \sin \left(y \cdot 30\right) \cdot \cos \left(z \cdot 30\right)\right) + \sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right)\right| - 0.2\right) \]
                                            2. Taylor expanded in y around 0

                                              \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + \left(30 \cdot \left(y \cdot \cos \left(30 \cdot z\right)\right) + \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right)\right| - 0.2\right) \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites49.8%

                                                \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + \mathsf{fma}\left(30, y \cdot \cos \left(30 \cdot z\right), \cos \left(30 \cdot x\right) \cdot \sin \left(30 \cdot z\right)\right)\right| - 0.2\right) \]
                                              2. Taylor expanded in z around 0

                                                \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + 30 \cdot y\right| - 0.2\right) \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites56.8%

                                                  \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|\sin \left(30 \cdot x\right) + 30 \cdot y\right| - 0.2\right) \]
                                                2. Taylor expanded in x around 0

                                                  \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|30 \cdot y\right| - 0.2\right) \]
                                                3. Step-by-step derivation
                                                  1. Applied rewrites56.0%

                                                    \[\leadsto \mathsf{max}\left(-30 \cdot z - 25, \left|30 \cdot y\right| - 0.2\right) \]
                                                  2. Add Preprocessing

                                                  Reproduce

                                                  ?
                                                  herbie shell --seed 2026070 
                                                  (FPCore (x y z)
                                                    :name "Gyroid sphere"
                                                    :precision binary64
                                                    (fmax (- (sqrt (+ (+ (pow (* x 30.0) 2.0) (pow (* y 30.0) 2.0)) (pow (* z 30.0) 2.0))) 25.0) (- (fabs (+ (+ (* (sin (* x 30.0)) (cos (* y 30.0))) (* (sin (* y 30.0)) (cos (* z 30.0)))) (* (sin (* z 30.0)) (cos (* x 30.0))))) 0.2)))