
(FPCore (x y z)
: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)))
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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
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]
\begin{array}{l}
\\
\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)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z)
: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)))
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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
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]
\begin{array}{l}
\\
\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)
\end{array}
(FPCore (x y z) :precision binary64 (fmax (- (hypot (* -30.0 y) (* -30.0 x)) 25.0) (- (fabs (fma (sin (* 30.0 y)) 1.0 (* z 30.0))) 0.2)))
double code(double x, double y, double z) {
return fmax((hypot((-30.0 * y), (-30.0 * x)) - 25.0), (fabs(fma(sin((30.0 * y)), 1.0, (z * 30.0))) - 0.2));
}
function code(x, y, z) return fmax(Float64(hypot(Float64(-30.0 * y), Float64(-30.0 * x)) - 25.0), Float64(abs(fma(sin(Float64(30.0 * y)), 1.0, Float64(z * 30.0))) - 0.2)) end
code[x_, y_, z_] := N[Max[N[(N[Sqrt[N[(-30.0 * y), $MachinePrecision] ^ 2 + N[(-30.0 * x), $MachinePrecision] ^ 2], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(N[Sin[N[(30.0 * y), $MachinePrecision]], $MachinePrecision] * 1.0 + N[(z * 30.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\mathsf{hypot}\left(-30 \cdot y, -30 \cdot x\right) - 25, \left|\mathsf{fma}\left(\sin \left(30 \cdot y\right), 1, z \cdot 30\right)\right| - 0.2\right)
\end{array}
Initial program 47.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6447.5
Applied rewrites47.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
metadata-evalN/A
swap-sqrN/A
sqr-neg-revN/A
unpow2N/A
metadata-evalN/A
swap-sqrN/A
sqr-neg-revN/A
lower-hypot.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f6472.6
Applied rewrites72.6%
Taylor expanded in z around 0
Applied rewrites72.6%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6498.2
Applied rewrites98.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (sin (* 30.0 y)))
(t_1 (- (* -30.0 x) 25.0))
(t_2 (fmax t_1 (- (fabs (fma (* y 30.0) 1.0 (sin (* 30.0 z)))) 0.2))))
(if (<= y -4.8e+26)
t_2
(if (<= y 3.4e-296)
(fmax
(- (* 30.0 x) 25.0)
(- (fabs (fma t_0 (cos (* -30.0 z)) (* z 30.0))) 0.2))
(if (<= y 7e+63)
(fmax t_1 (- (fabs (fma t_0 1.0 (* z 30.0))) 0.2))
t_2)))))
double code(double x, double y, double z) {
double t_0 = sin((30.0 * y));
double t_1 = (-30.0 * x) - 25.0;
double t_2 = fmax(t_1, (fabs(fma((y * 30.0), 1.0, sin((30.0 * z)))) - 0.2));
double tmp;
if (y <= -4.8e+26) {
tmp = t_2;
} else if (y <= 3.4e-296) {
tmp = fmax(((30.0 * x) - 25.0), (fabs(fma(t_0, cos((-30.0 * z)), (z * 30.0))) - 0.2));
} else if (y <= 7e+63) {
tmp = fmax(t_1, (fabs(fma(t_0, 1.0, (z * 30.0))) - 0.2));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z) t_0 = sin(Float64(30.0 * y)) t_1 = Float64(Float64(-30.0 * x) - 25.0) t_2 = fmax(t_1, Float64(abs(fma(Float64(y * 30.0), 1.0, sin(Float64(30.0 * z)))) - 0.2)) tmp = 0.0 if (y <= -4.8e+26) tmp = t_2; elseif (y <= 3.4e-296) tmp = fmax(Float64(Float64(30.0 * x) - 25.0), Float64(abs(fma(t_0, cos(Float64(-30.0 * z)), Float64(z * 30.0))) - 0.2)); elseif (y <= 7e+63) tmp = fmax(t_1, Float64(abs(fma(t_0, 1.0, Float64(z * 30.0))) - 0.2)); else tmp = t_2; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Sin[N[(30.0 * y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(-30.0 * x), $MachinePrecision] - 25.0), $MachinePrecision]}, Block[{t$95$2 = N[Max[t$95$1, N[(N[Abs[N[(N[(y * 30.0), $MachinePrecision] * 1.0 + N[Sin[N[(30.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -4.8e+26], t$95$2, If[LessEqual[y, 3.4e-296], N[Max[N[(N[(30.0 * x), $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(t$95$0 * N[Cos[N[(-30.0 * z), $MachinePrecision]], $MachinePrecision] + N[(z * 30.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 7e+63], N[Max[t$95$1, N[(N[Abs[N[(t$95$0 * 1.0 + N[(z * 30.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(30 \cdot y\right)\\
t_1 := -30 \cdot x - 25\\
t_2 := \mathsf{max}\left(t\_1, \left|\mathsf{fma}\left(y \cdot 30, 1, \sin \left(30 \cdot z\right)\right)\right| - 0.2\right)\\
\mathbf{if}\;y \leq -4.8 \cdot 10^{+26}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-296}:\\
\;\;\;\;\mathsf{max}\left(30 \cdot x - 25, \left|\mathsf{fma}\left(t\_0, \cos \left(-30 \cdot z\right), z \cdot 30\right)\right| - 0.2\right)\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+63}:\\
\;\;\;\;\mathsf{max}\left(t\_1, \left|\mathsf{fma}\left(t\_0, 1, z \cdot 30\right)\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if y < -4.80000000000000009e26 or 7.00000000000000059e63 < y Initial program 35.2%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6435.2
Applied rewrites35.2%
Taylor expanded in x around -inf
lower-*.f6413.9
Applied rewrites13.9%
Taylor expanded in z around 0
Applied rewrites13.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6476.5
Applied rewrites76.5%
if -4.80000000000000009e26 < y < 3.39999999999999997e-296Initial program 58.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6458.1
Applied rewrites58.1%
Taylor expanded in x around inf
lower-*.f6453.1
Applied rewrites53.1%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6487.1
Applied rewrites87.1%
if 3.39999999999999997e-296 < y < 7.00000000000000059e63Initial program 55.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6455.7
Applied rewrites55.7%
Taylor expanded in x around -inf
lower-*.f6450.2
Applied rewrites50.2%
Taylor expanded in z around 0
Applied rewrites50.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* -30.0 x) 25.0)))
(if (or (<= y -1.75e+55) (not (<= y 7e+63)))
(fmax t_0 (- (fabs (fma (* y 30.0) 1.0 (sin (* 30.0 z)))) 0.2))
(fmax t_0 (- (fabs (fma (sin (* 30.0 y)) 1.0 (* z 30.0))) 0.2)))))
double code(double x, double y, double z) {
double t_0 = (-30.0 * x) - 25.0;
double tmp;
if ((y <= -1.75e+55) || !(y <= 7e+63)) {
tmp = fmax(t_0, (fabs(fma((y * 30.0), 1.0, sin((30.0 * z)))) - 0.2));
} else {
tmp = fmax(t_0, (fabs(fma(sin((30.0 * y)), 1.0, (z * 30.0))) - 0.2));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-30.0 * x) - 25.0) tmp = 0.0 if ((y <= -1.75e+55) || !(y <= 7e+63)) tmp = fmax(t_0, Float64(abs(fma(Float64(y * 30.0), 1.0, sin(Float64(30.0 * z)))) - 0.2)); else tmp = fmax(t_0, Float64(abs(fma(sin(Float64(30.0 * y)), 1.0, Float64(z * 30.0))) - 0.2)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-30.0 * x), $MachinePrecision] - 25.0), $MachinePrecision]}, If[Or[LessEqual[y, -1.75e+55], N[Not[LessEqual[y, 7e+63]], $MachinePrecision]], N[Max[t$95$0, N[(N[Abs[N[(N[(y * 30.0), $MachinePrecision] * 1.0 + N[Sin[N[(30.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[t$95$0, N[(N[Abs[N[(N[Sin[N[(30.0 * y), $MachinePrecision]], $MachinePrecision] * 1.0 + N[(z * 30.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -30 \cdot x - 25\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{+55} \lor \neg \left(y \leq 7 \cdot 10^{+63}\right):\\
\;\;\;\;\mathsf{max}\left(t\_0, \left|\mathsf{fma}\left(y \cdot 30, 1, \sin \left(30 \cdot z\right)\right)\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(t\_0, \left|\mathsf{fma}\left(\sin \left(30 \cdot y\right), 1, z \cdot 30\right)\right| - 0.2\right)\\
\end{array}
\end{array}
if y < -1.75000000000000005e55 or 7.00000000000000059e63 < y Initial program 35.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6435.1
Applied rewrites35.1%
Taylor expanded in x around -inf
lower-*.f6412.5
Applied rewrites12.5%
Taylor expanded in z around 0
Applied rewrites12.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6477.9
Applied rewrites77.9%
if -1.75000000000000005e55 < y < 7.00000000000000059e63Initial program 56.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6456.0
Applied rewrites56.0%
Taylor expanded in x around -inf
lower-*.f6446.5
Applied rewrites46.5%
Taylor expanded in z around 0
Applied rewrites46.5%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f6482.8
Applied rewrites82.8%
Final simplification80.8%
(FPCore (x y z) :precision binary64 (fmax (- (* -30.0 x) 25.0) (- (fabs (fma (* y 30.0) 1.0 (sin (* 30.0 z)))) 0.2)))
double code(double x, double y, double z) {
return fmax(((-30.0 * x) - 25.0), (fabs(fma((y * 30.0), 1.0, sin((30.0 * z)))) - 0.2));
}
function code(x, y, z) return fmax(Float64(Float64(-30.0 * x) - 25.0), Float64(abs(fma(Float64(y * 30.0), 1.0, sin(Float64(30.0 * z)))) - 0.2)) end
code[x_, y_, z_] := N[Max[N[(N[(-30.0 * x), $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(N[(y * 30.0), $MachinePrecision] * 1.0 + N[Sin[N[(30.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(-30 \cdot x - 25, \left|\mathsf{fma}\left(y \cdot 30, 1, \sin \left(30 \cdot z\right)\right)\right| - 0.2\right)
\end{array}
Initial program 47.5%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f6447.5
Applied rewrites47.5%
Taylor expanded in x around -inf
lower-*.f6432.7
Applied rewrites32.7%
Taylor expanded in z around 0
Applied rewrites32.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f6460.0
Applied rewrites60.0%
herbie shell --seed 2025026
(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)))