
(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 8 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 (hypot (pow (* 30.0 y) 1.0) (pow (* 30.0 x) 1.0)) (* z 30.0))
(* -1.0 25.0))
(-
(fabs
(fma
(sin (* 30.0 x))
(sin (fma y 30.0 (/ PI 2.0)))
(fma
(sin (* y 30.0))
(sin (fma z 30.0 (/ PI 2.0)))
(* (sin (* z 30.0)) (sin (fma 30.0 x (/ PI 2.0)))))))
0.2)))
double code(double x, double y, double z) {
return fmax((hypot(hypot(pow((30.0 * y), 1.0), pow((30.0 * x), 1.0)), (z * 30.0)) + (-1.0 * 25.0)), (fabs(fma(sin((30.0 * x)), sin(fma(y, 30.0, (((double) M_PI) / 2.0))), fma(sin((y * 30.0)), sin(fma(z, 30.0, (((double) M_PI) / 2.0))), (sin((z * 30.0)) * sin(fma(30.0, x, (((double) M_PI) / 2.0))))))) - 0.2));
}
function code(x, y, z) return fmax(Float64(hypot(hypot((Float64(30.0 * y) ^ 1.0), (Float64(30.0 * x) ^ 1.0)), Float64(z * 30.0)) + Float64(-1.0 * 25.0)), Float64(abs(fma(sin(Float64(30.0 * x)), sin(fma(y, 30.0, Float64(pi / 2.0))), fma(sin(Float64(y * 30.0)), sin(fma(z, 30.0, Float64(pi / 2.0))), Float64(sin(Float64(z * 30.0)) * sin(fma(30.0, x, Float64(pi / 2.0))))))) - 0.2)) end
code[x_, y_, z_] := N[Max[N[(N[Sqrt[N[Sqrt[N[Power[N[(30.0 * y), $MachinePrecision], 1.0], $MachinePrecision] ^ 2 + N[Power[N[(30.0 * x), $MachinePrecision], 1.0], $MachinePrecision] ^ 2], $MachinePrecision] ^ 2 + N[(z * 30.0), $MachinePrecision] ^ 2], $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(N[Sin[N[(30.0 * x), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(y * 30.0 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(y * 30.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(z * 30.0 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(30.0 * x + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\mathsf{hypot}\left(\mathsf{hypot}\left({\left(30 \cdot y\right)}^{1}, {\left(30 \cdot x\right)}^{1}\right), z \cdot 30\right) + -1 \cdot 25, \left|\mathsf{fma}\left(\sin \left(30 \cdot x\right), \sin \left(\mathsf{fma}\left(y, 30, \frac{\pi}{2}\right)\right), \mathsf{fma}\left(\sin \left(y \cdot 30\right), \sin \left(\mathsf{fma}\left(z, 30, \frac{\pi}{2}\right)\right), \sin \left(z \cdot 30\right) \cdot \sin \left(\mathsf{fma}\left(30, x, \frac{\pi}{2}\right)\right)\right)\right)\right| - 0.2\right)
\end{array}
Initial program 42.0%
Applied rewrites54.3%
lift-pow.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unpow1/2N/A
pow2N/A
metadata-evalN/A
unpow-prod-downN/A
pow2N/A
metadata-evalN/A
unpow-prod-downN/A
sqr-powN/A
sqr-powN/A
lower-hypot.f64N/A
*-commutativeN/A
metadata-evalN/A
lower-pow.f64N/A
lower-*.f64N/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(fmax
(+
(hypot (hypot (pow (* 30.0 y) 1.0) (pow (* 30.0 x) 1.0)) (* z 30.0))
(* -1.0 25.0))
(-
(fabs
(fma
(sin (* 30.0 x))
(sin (fma y 30.0 (/ PI 2.0)))
(fma
30.0
(* y (sin (fma 0.5 PI (* 30.0 z))))
(* (sin (* 30.0 z)) (sin (fma 0.5 PI (* 30.0 x)))))))
0.2)))
double code(double x, double y, double z) {
return fmax((hypot(hypot(pow((30.0 * y), 1.0), pow((30.0 * x), 1.0)), (z * 30.0)) + (-1.0 * 25.0)), (fabs(fma(sin((30.0 * x)), sin(fma(y, 30.0, (((double) M_PI) / 2.0))), fma(30.0, (y * sin(fma(0.5, ((double) M_PI), (30.0 * z)))), (sin((30.0 * z)) * sin(fma(0.5, ((double) M_PI), (30.0 * x))))))) - 0.2));
}
function code(x, y, z) return fmax(Float64(hypot(hypot((Float64(30.0 * y) ^ 1.0), (Float64(30.0 * x) ^ 1.0)), Float64(z * 30.0)) + Float64(-1.0 * 25.0)), Float64(abs(fma(sin(Float64(30.0 * x)), sin(fma(y, 30.0, Float64(pi / 2.0))), fma(30.0, Float64(y * sin(fma(0.5, pi, Float64(30.0 * z)))), Float64(sin(Float64(30.0 * z)) * sin(fma(0.5, pi, Float64(30.0 * x))))))) - 0.2)) end
code[x_, y_, z_] := N[Max[N[(N[Sqrt[N[Sqrt[N[Power[N[(30.0 * y), $MachinePrecision], 1.0], $MachinePrecision] ^ 2 + N[Power[N[(30.0 * x), $MachinePrecision], 1.0], $MachinePrecision] ^ 2], $MachinePrecision] ^ 2 + N[(z * 30.0), $MachinePrecision] ^ 2], $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(N[Sin[N[(30.0 * x), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(y * 30.0 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(30.0 * N[(y * N[Sin[N[(0.5 * Pi + N[(30.0 * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[N[(30.0 * z), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * Pi + N[(30.0 * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\mathsf{hypot}\left(\mathsf{hypot}\left({\left(30 \cdot y\right)}^{1}, {\left(30 \cdot x\right)}^{1}\right), z \cdot 30\right) + -1 \cdot 25, \left|\mathsf{fma}\left(\sin \left(30 \cdot x\right), \sin \left(\mathsf{fma}\left(y, 30, \frac{\pi}{2}\right)\right), \mathsf{fma}\left(30, y \cdot \sin \left(\mathsf{fma}\left(0.5, \pi, 30 \cdot z\right)\right), \sin \left(30 \cdot z\right) \cdot \sin \left(\mathsf{fma}\left(0.5, \pi, 30 \cdot x\right)\right)\right)\right)\right| - 0.2\right)
\end{array}
Initial program 42.0%
Applied rewrites54.3%
lift-pow.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
unpow1/2N/A
pow2N/A
metadata-evalN/A
unpow-prod-downN/A
pow2N/A
metadata-evalN/A
unpow-prod-downN/A
sqr-powN/A
sqr-powN/A
lower-hypot.f64N/A
*-commutativeN/A
metadata-evalN/A
lower-pow.f64N/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-fma.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lower-sin.f64N/A
lower-fma.f64N/A
Applied rewrites99.6%
Final simplification99.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (sin (* z 30.0)))
(t_1 (sin (* y 30.0)))
(t_2
(fma
(sin (* 30.0 x))
(sin (fma y 30.0 (/ PI 2.0)))
(fma
t_1
(sin (fma z 30.0 (/ PI 2.0)))
(* t_0 (sin (fma 30.0 x (/ PI 2.0)))))))
(t_3 (fabs t_2))
(t_4
(-
(fabs
(+
(* t_0 (cos (* x 30.0)))
(+
(* (sin (* x 30.0)) (cos (* y 30.0)))
(* t_1 (cos (* z 30.0))))))
0.2)))
(if (<= x -1.15e+112)
(fmax (+ (* -30.0 x) (* -1.0 25.0)) t_4)
(if (<= x -2.1e-131)
(fmax (+ (* -30.0 y) (* -1.0 25.0)) t_4)
(if (<= x 6.5e+148)
(fmax
(-
(sqrt
(+
(+ (pow (* x 30.0) 2.0) (pow (* y 30.0) 2.0))
(pow (* z 30.0) 2.0)))
25.0)
(/ (- (pow t_3 3.0) 0.008) (+ (* t_2 t_2) (+ 0.04 (* t_3 0.2)))))
(fmax (+ (* 30.0 x) (* -1.0 25.0)) t_4))))))
double code(double x, double y, double z) {
double t_0 = sin((z * 30.0));
double t_1 = sin((y * 30.0));
double t_2 = fma(sin((30.0 * x)), sin(fma(y, 30.0, (((double) M_PI) / 2.0))), fma(t_1, sin(fma(z, 30.0, (((double) M_PI) / 2.0))), (t_0 * sin(fma(30.0, x, (((double) M_PI) / 2.0))))));
double t_3 = fabs(t_2);
double t_4 = fabs(((t_0 * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (t_1 * cos((z * 30.0)))))) - 0.2;
double tmp;
if (x <= -1.15e+112) {
tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_4);
} else if (x <= -2.1e-131) {
tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_4);
} else if (x <= 6.5e+148) {
tmp = fmax((sqrt(((pow((x * 30.0), 2.0) + pow((y * 30.0), 2.0)) + pow((z * 30.0), 2.0))) - 25.0), ((pow(t_3, 3.0) - 0.008) / ((t_2 * t_2) + (0.04 + (t_3 * 0.2)))));
} else {
tmp = fmax(((30.0 * x) + (-1.0 * 25.0)), t_4);
}
return tmp;
}
function code(x, y, z) t_0 = sin(Float64(z * 30.0)) t_1 = sin(Float64(y * 30.0)) t_2 = fma(sin(Float64(30.0 * x)), sin(fma(y, 30.0, Float64(pi / 2.0))), fma(t_1, sin(fma(z, 30.0, Float64(pi / 2.0))), Float64(t_0 * sin(fma(30.0, x, Float64(pi / 2.0)))))) t_3 = abs(t_2) t_4 = Float64(abs(Float64(Float64(t_0 * cos(Float64(x * 30.0))) + Float64(Float64(sin(Float64(x * 30.0)) * cos(Float64(y * 30.0))) + Float64(t_1 * cos(Float64(z * 30.0)))))) - 0.2) tmp = 0.0 if (x <= -1.15e+112) tmp = fmax(Float64(Float64(-30.0 * x) + Float64(-1.0 * 25.0)), t_4); elseif (x <= -2.1e-131) tmp = fmax(Float64(Float64(-30.0 * y) + Float64(-1.0 * 25.0)), t_4); elseif (x <= 6.5e+148) tmp = 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(Float64((t_3 ^ 3.0) - 0.008) / Float64(Float64(t_2 * t_2) + Float64(0.04 + Float64(t_3 * 0.2))))); else tmp = fmax(Float64(Float64(30.0 * x) + Float64(-1.0 * 25.0)), t_4); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(y * 30.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[N[(30.0 * x), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(y * 30.0 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(t$95$1 * N[Sin[N[(z * 30.0 + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(t$95$0 * N[Sin[N[(30.0 * x + N[(Pi / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Abs[t$95$2], $MachinePrecision]}, Block[{t$95$4 = N[(N[Abs[N[(N[(t$95$0 * N[Cos[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(y * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[Cos[N[(z * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]}, If[LessEqual[x, -1.15e+112], N[Max[N[(N[(-30.0 * x), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$4], $MachinePrecision], If[LessEqual[x, -2.1e-131], N[Max[N[(N[(-30.0 * y), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$4], $MachinePrecision], If[LessEqual[x, 6.5e+148], 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[(N[Power[t$95$3, 3.0], $MachinePrecision] - 0.008), $MachinePrecision] / N[(N[(t$95$2 * t$95$2), $MachinePrecision] + N[(0.04 + N[(t$95$3 * 0.2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Max[N[(N[(30.0 * x), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$4], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(z \cdot 30\right)\\
t_1 := \sin \left(y \cdot 30\right)\\
t_2 := \mathsf{fma}\left(\sin \left(30 \cdot x\right), \sin \left(\mathsf{fma}\left(y, 30, \frac{\pi}{2}\right)\right), \mathsf{fma}\left(t\_1, \sin \left(\mathsf{fma}\left(z, 30, \frac{\pi}{2}\right)\right), t\_0 \cdot \sin \left(\mathsf{fma}\left(30, x, \frac{\pi}{2}\right)\right)\right)\right)\\
t_3 := \left|t\_2\right|\\
t_4 := \left|t\_0 \cdot \cos \left(x \cdot 30\right) + \left(\sin \left(x \cdot 30\right) \cdot \cos \left(y \cdot 30\right) + t\_1 \cdot \cos \left(z \cdot 30\right)\right)\right| - 0.2\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{+112}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x + -1 \cdot 25, t\_4\right)\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{-131}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot y + -1 \cdot 25, t\_4\right)\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+148}:\\
\;\;\;\;\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, \frac{{t\_3}^{3} - 0.008}{t\_2 \cdot t\_2 + \left(0.04 + t\_3 \cdot 0.2\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(30 \cdot x + -1 \cdot 25, t\_4\right)\\
\end{array}
\end{array}
if x < -1.15e112Initial program 12.3%
Taylor expanded in x around -inf
lower-*.f6479.5
Applied rewrites79.5%
if -1.15e112 < x < -2.09999999999999997e-131Initial program 45.5%
Taylor expanded in y around -inf
lower-*.f6456.7
Applied rewrites56.7%
if -2.09999999999999997e-131 < x < 6.49999999999999947e148Initial program 59.6%
Applied rewrites59.6%
if 6.49999999999999947e148 < x Initial program 11.7%
Taylor expanded in x around inf
lower-*.f6478.6
Applied rewrites78.6%
Final simplification65.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(-
(fabs
(+
(* (sin (* z 30.0)) (cos (* x 30.0)))
(+
(* (sin (* x 30.0)) (cos (* y 30.0)))
(* (sin (* y 30.0)) (cos (* z 30.0))))))
0.2)))
(if (<= x -1.15e+112)
(fmax (+ (* -30.0 x) (* -1.0 25.0)) t_0)
(if (<= x -2.1e-131)
(fmax (+ (* -30.0 y) (* -1.0 25.0)) t_0)
(if (<= x 6.5e+148)
(fmax
(-
(sqrt
(+
(+ (pow (* x 30.0) 2.0) (pow (* y 30.0) 2.0))
(pow (* z 30.0) 2.0)))
25.0)
t_0)
(fmax (+ (* 30.0 x) (* -1.0 25.0)) t_0))))))
double code(double x, double y, double z) {
double t_0 = fabs(((sin((z * 30.0)) * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))))) - 0.2;
double tmp;
if (x <= -1.15e+112) {
tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0);
} else if (x <= -2.1e-131) {
tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0);
} else if (x <= 6.5e+148) {
tmp = fmax((sqrt(((pow((x * 30.0), 2.0) + pow((y * 30.0), 2.0)) + pow((z * 30.0), 2.0))) - 25.0), t_0);
} else {
tmp = fmax(((30.0 * x) + (-1.0 * 25.0)), t_0);
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = abs(((sin((z * 30.0d0)) * cos((x * 30.0d0))) + ((sin((x * 30.0d0)) * cos((y * 30.0d0))) + (sin((y * 30.0d0)) * cos((z * 30.0d0)))))) - 0.2d0
if (x <= (-1.15d+112)) then
tmp = fmax((((-30.0d0) * x) + ((-1.0d0) * 25.0d0)), t_0)
else if (x <= (-2.1d-131)) then
tmp = fmax((((-30.0d0) * y) + ((-1.0d0) * 25.0d0)), t_0)
else if (x <= 6.5d+148) then
tmp = fmax((sqrt(((((x * 30.0d0) ** 2.0d0) + ((y * 30.0d0) ** 2.0d0)) + ((z * 30.0d0) ** 2.0d0))) - 25.0d0), t_0)
else
tmp = fmax(((30.0d0 * x) + ((-1.0d0) * 25.0d0)), t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs(((Math.sin((z * 30.0)) * Math.cos((x * 30.0))) + ((Math.sin((x * 30.0)) * Math.cos((y * 30.0))) + (Math.sin((y * 30.0)) * Math.cos((z * 30.0)))))) - 0.2;
double tmp;
if (x <= -1.15e+112) {
tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0);
} else if (x <= -2.1e-131) {
tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0);
} else if (x <= 6.5e+148) {
tmp = 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), t_0);
} else {
tmp = fmax(((30.0 * x) + (-1.0 * 25.0)), t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs(((math.sin((z * 30.0)) * math.cos((x * 30.0))) + ((math.sin((x * 30.0)) * math.cos((y * 30.0))) + (math.sin((y * 30.0)) * math.cos((z * 30.0)))))) - 0.2 tmp = 0 if x <= -1.15e+112: tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0) elif x <= -2.1e-131: tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0) elif x <= 6.5e+148: tmp = 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), t_0) else: tmp = fmax(((30.0 * x) + (-1.0 * 25.0)), t_0) return tmp
function code(x, y, z) t_0 = Float64(abs(Float64(Float64(sin(Float64(z * 30.0)) * cos(Float64(x * 30.0))) + Float64(Float64(sin(Float64(x * 30.0)) * cos(Float64(y * 30.0))) + Float64(sin(Float64(y * 30.0)) * cos(Float64(z * 30.0)))))) - 0.2) tmp = 0.0 if (x <= -1.15e+112) tmp = fmax(Float64(Float64(-30.0 * x) + Float64(-1.0 * 25.0)), t_0); elseif (x <= -2.1e-131) tmp = fmax(Float64(Float64(-30.0 * y) + Float64(-1.0 * 25.0)), t_0); elseif (x <= 6.5e+148) tmp = 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), t_0); else tmp = fmax(Float64(Float64(30.0 * x) + Float64(-1.0 * 25.0)), t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs(((sin((z * 30.0)) * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))))) - 0.2; tmp = 0.0; if (x <= -1.15e+112) tmp = max(((-30.0 * x) + (-1.0 * 25.0)), t_0); elseif (x <= -2.1e-131) tmp = max(((-30.0 * y) + (-1.0 * 25.0)), t_0); elseif (x <= 6.5e+148) tmp = max((sqrt(((((x * 30.0) ^ 2.0) + ((y * 30.0) ^ 2.0)) + ((z * 30.0) ^ 2.0))) - 25.0), t_0); else tmp = max(((30.0 * x) + (-1.0 * 25.0)), t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Abs[N[(N[(N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 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]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]}, If[LessEqual[x, -1.15e+112], N[Max[N[(N[(-30.0 * x), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision], If[LessEqual[x, -2.1e-131], N[Max[N[(N[(-30.0 * y), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision], If[LessEqual[x, 6.5e+148], 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], t$95$0], $MachinePrecision], N[Max[N[(N[(30.0 * x), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right) + \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)\right| - 0.2\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{+112}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x + -1 \cdot 25, t\_0\right)\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{-131}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot y + -1 \cdot 25, t\_0\right)\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{+148}:\\
\;\;\;\;\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, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(30 \cdot x + -1 \cdot 25, t\_0\right)\\
\end{array}
\end{array}
if x < -1.15e112Initial program 12.3%
Taylor expanded in x around -inf
lower-*.f6479.5
Applied rewrites79.5%
if -1.15e112 < x < -2.09999999999999997e-131Initial program 45.5%
Taylor expanded in y around -inf
lower-*.f6456.7
Applied rewrites56.7%
if -2.09999999999999997e-131 < x < 6.49999999999999947e148Initial program 59.6%
if 6.49999999999999947e148 < x Initial program 11.7%
Taylor expanded in x around inf
lower-*.f6478.6
Applied rewrites78.6%
Final simplification65.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(-
(fabs
(+
(* (sin (* z 30.0)) (cos (* x 30.0)))
(+
(* (sin (* x 30.0)) (cos (* y 30.0)))
(* (sin (* y 30.0)) (cos (* z 30.0))))))
0.2)))
(if (<= x -1.15e+112)
(fmax (+ (* -30.0 x) (* -1.0 25.0)) t_0)
(if (<= x -3.5e-220)
(fmax (+ (* -30.0 y) (* -1.0 25.0)) t_0)
(if (<= x 1.3e+68)
(fmax (+ (* -30.0 z) (* -1.0 25.0)) t_0)
(fmax (+ (* 30.0 x) (* -1.0 25.0)) t_0))))))
double code(double x, double y, double z) {
double t_0 = fabs(((sin((z * 30.0)) * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))))) - 0.2;
double tmp;
if (x <= -1.15e+112) {
tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0);
} else if (x <= -3.5e-220) {
tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0);
} else if (x <= 1.3e+68) {
tmp = fmax(((-30.0 * z) + (-1.0 * 25.0)), t_0);
} else {
tmp = fmax(((30.0 * x) + (-1.0 * 25.0)), t_0);
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = abs(((sin((z * 30.0d0)) * cos((x * 30.0d0))) + ((sin((x * 30.0d0)) * cos((y * 30.0d0))) + (sin((y * 30.0d0)) * cos((z * 30.0d0)))))) - 0.2d0
if (x <= (-1.15d+112)) then
tmp = fmax((((-30.0d0) * x) + ((-1.0d0) * 25.0d0)), t_0)
else if (x <= (-3.5d-220)) then
tmp = fmax((((-30.0d0) * y) + ((-1.0d0) * 25.0d0)), t_0)
else if (x <= 1.3d+68) then
tmp = fmax((((-30.0d0) * z) + ((-1.0d0) * 25.0d0)), t_0)
else
tmp = fmax(((30.0d0 * x) + ((-1.0d0) * 25.0d0)), t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs(((Math.sin((z * 30.0)) * Math.cos((x * 30.0))) + ((Math.sin((x * 30.0)) * Math.cos((y * 30.0))) + (Math.sin((y * 30.0)) * Math.cos((z * 30.0)))))) - 0.2;
double tmp;
if (x <= -1.15e+112) {
tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0);
} else if (x <= -3.5e-220) {
tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0);
} else if (x <= 1.3e+68) {
tmp = fmax(((-30.0 * z) + (-1.0 * 25.0)), t_0);
} else {
tmp = fmax(((30.0 * x) + (-1.0 * 25.0)), t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs(((math.sin((z * 30.0)) * math.cos((x * 30.0))) + ((math.sin((x * 30.0)) * math.cos((y * 30.0))) + (math.sin((y * 30.0)) * math.cos((z * 30.0)))))) - 0.2 tmp = 0 if x <= -1.15e+112: tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0) elif x <= -3.5e-220: tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0) elif x <= 1.3e+68: tmp = fmax(((-30.0 * z) + (-1.0 * 25.0)), t_0) else: tmp = fmax(((30.0 * x) + (-1.0 * 25.0)), t_0) return tmp
function code(x, y, z) t_0 = Float64(abs(Float64(Float64(sin(Float64(z * 30.0)) * cos(Float64(x * 30.0))) + Float64(Float64(sin(Float64(x * 30.0)) * cos(Float64(y * 30.0))) + Float64(sin(Float64(y * 30.0)) * cos(Float64(z * 30.0)))))) - 0.2) tmp = 0.0 if (x <= -1.15e+112) tmp = fmax(Float64(Float64(-30.0 * x) + Float64(-1.0 * 25.0)), t_0); elseif (x <= -3.5e-220) tmp = fmax(Float64(Float64(-30.0 * y) + Float64(-1.0 * 25.0)), t_0); elseif (x <= 1.3e+68) tmp = fmax(Float64(Float64(-30.0 * z) + Float64(-1.0 * 25.0)), t_0); else tmp = fmax(Float64(Float64(30.0 * x) + Float64(-1.0 * 25.0)), t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs(((sin((z * 30.0)) * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))))) - 0.2; tmp = 0.0; if (x <= -1.15e+112) tmp = max(((-30.0 * x) + (-1.0 * 25.0)), t_0); elseif (x <= -3.5e-220) tmp = max(((-30.0 * y) + (-1.0 * 25.0)), t_0); elseif (x <= 1.3e+68) tmp = max(((-30.0 * z) + (-1.0 * 25.0)), t_0); else tmp = max(((30.0 * x) + (-1.0 * 25.0)), t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Abs[N[(N[(N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 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]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]}, If[LessEqual[x, -1.15e+112], N[Max[N[(N[(-30.0 * x), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision], If[LessEqual[x, -3.5e-220], N[Max[N[(N[(-30.0 * y), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision], If[LessEqual[x, 1.3e+68], N[Max[N[(N[(-30.0 * z), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision], N[Max[N[(N[(30.0 * x), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right) + \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)\right| - 0.2\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{+112}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x + -1 \cdot 25, t\_0\right)\\
\mathbf{elif}\;x \leq -3.5 \cdot 10^{-220}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot y + -1 \cdot 25, t\_0\right)\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot z + -1 \cdot 25, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(30 \cdot x + -1 \cdot 25, t\_0\right)\\
\end{array}
\end{array}
if x < -1.15e112Initial program 12.3%
Taylor expanded in x around -inf
lower-*.f6479.5
Applied rewrites79.5%
if -1.15e112 < x < -3.49999999999999988e-220Initial program 48.9%
Taylor expanded in y around -inf
lower-*.f6454.5
Applied rewrites54.5%
if -3.49999999999999988e-220 < x < 1.2999999999999999e68Initial program 58.4%
Taylor expanded in z around -inf
lower-*.f6450.8
Applied rewrites50.8%
if 1.2999999999999999e68 < x Initial program 27.5%
Taylor expanded in x around inf
lower-*.f6473.7
Applied rewrites73.7%
Final simplification61.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(-
(fabs
(+
(* (sin (* z 30.0)) (cos (* x 30.0)))
(+
(* (sin (* x 30.0)) (cos (* y 30.0)))
(* (sin (* y 30.0)) (cos (* z 30.0))))))
0.2)))
(if (<= x -1.15e+112)
(fmax (+ (* -30.0 x) (* -1.0 25.0)) t_0)
(if (<= x -3.5e-220)
(fmax (+ (* -30.0 y) (* -1.0 25.0)) t_0)
(fmax (+ (* -30.0 z) (* -1.0 25.0)) t_0)))))
double code(double x, double y, double z) {
double t_0 = fabs(((sin((z * 30.0)) * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))))) - 0.2;
double tmp;
if (x <= -1.15e+112) {
tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0);
} else if (x <= -3.5e-220) {
tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0);
} else {
tmp = fmax(((-30.0 * z) + (-1.0 * 25.0)), t_0);
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = abs(((sin((z * 30.0d0)) * cos((x * 30.0d0))) + ((sin((x * 30.0d0)) * cos((y * 30.0d0))) + (sin((y * 30.0d0)) * cos((z * 30.0d0)))))) - 0.2d0
if (x <= (-1.15d+112)) then
tmp = fmax((((-30.0d0) * x) + ((-1.0d0) * 25.0d0)), t_0)
else if (x <= (-3.5d-220)) then
tmp = fmax((((-30.0d0) * y) + ((-1.0d0) * 25.0d0)), t_0)
else
tmp = fmax((((-30.0d0) * z) + ((-1.0d0) * 25.0d0)), t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs(((Math.sin((z * 30.0)) * Math.cos((x * 30.0))) + ((Math.sin((x * 30.0)) * Math.cos((y * 30.0))) + (Math.sin((y * 30.0)) * Math.cos((z * 30.0)))))) - 0.2;
double tmp;
if (x <= -1.15e+112) {
tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0);
} else if (x <= -3.5e-220) {
tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0);
} else {
tmp = fmax(((-30.0 * z) + (-1.0 * 25.0)), t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs(((math.sin((z * 30.0)) * math.cos((x * 30.0))) + ((math.sin((x * 30.0)) * math.cos((y * 30.0))) + (math.sin((y * 30.0)) * math.cos((z * 30.0)))))) - 0.2 tmp = 0 if x <= -1.15e+112: tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0) elif x <= -3.5e-220: tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0) else: tmp = fmax(((-30.0 * z) + (-1.0 * 25.0)), t_0) return tmp
function code(x, y, z) t_0 = Float64(abs(Float64(Float64(sin(Float64(z * 30.0)) * cos(Float64(x * 30.0))) + Float64(Float64(sin(Float64(x * 30.0)) * cos(Float64(y * 30.0))) + Float64(sin(Float64(y * 30.0)) * cos(Float64(z * 30.0)))))) - 0.2) tmp = 0.0 if (x <= -1.15e+112) tmp = fmax(Float64(Float64(-30.0 * x) + Float64(-1.0 * 25.0)), t_0); elseif (x <= -3.5e-220) tmp = fmax(Float64(Float64(-30.0 * y) + Float64(-1.0 * 25.0)), t_0); else tmp = fmax(Float64(Float64(-30.0 * z) + Float64(-1.0 * 25.0)), t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs(((sin((z * 30.0)) * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))))) - 0.2; tmp = 0.0; if (x <= -1.15e+112) tmp = max(((-30.0 * x) + (-1.0 * 25.0)), t_0); elseif (x <= -3.5e-220) tmp = max(((-30.0 * y) + (-1.0 * 25.0)), t_0); else tmp = max(((-30.0 * z) + (-1.0 * 25.0)), t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Abs[N[(N[(N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 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]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]}, If[LessEqual[x, -1.15e+112], N[Max[N[(N[(-30.0 * x), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision], If[LessEqual[x, -3.5e-220], N[Max[N[(N[(-30.0 * y), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision], N[Max[N[(N[(-30.0 * z), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right) + \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)\right| - 0.2\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{+112}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x + -1 \cdot 25, t\_0\right)\\
\mathbf{elif}\;x \leq -3.5 \cdot 10^{-220}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot y + -1 \cdot 25, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot z + -1 \cdot 25, t\_0\right)\\
\end{array}
\end{array}
if x < -1.15e112Initial program 12.3%
Taylor expanded in x around -inf
lower-*.f6479.5
Applied rewrites79.5%
if -1.15e112 < x < -3.49999999999999988e-220Initial program 48.9%
Taylor expanded in y around -inf
lower-*.f6454.5
Applied rewrites54.5%
if -3.49999999999999988e-220 < x Initial program 45.8%
Taylor expanded in z around -inf
lower-*.f6435.7
Applied rewrites35.7%
Final simplification47.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(-
(fabs
(+
(* (sin (* z 30.0)) (cos (* x 30.0)))
(+
(* (sin (* x 30.0)) (cos (* y 30.0)))
(* (sin (* y 30.0)) (cos (* z 30.0))))))
0.2)))
(if (<= x -1.15e+112)
(fmax (+ (* -30.0 x) (* -1.0 25.0)) t_0)
(fmax (+ (* -30.0 y) (* -1.0 25.0)) t_0))))
double code(double x, double y, double z) {
double t_0 = fabs(((sin((z * 30.0)) * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))))) - 0.2;
double tmp;
if (x <= -1.15e+112) {
tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0);
} else {
tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0);
}
return tmp;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = abs(((sin((z * 30.0d0)) * cos((x * 30.0d0))) + ((sin((x * 30.0d0)) * cos((y * 30.0d0))) + (sin((y * 30.0d0)) * cos((z * 30.0d0)))))) - 0.2d0
if (x <= (-1.15d+112)) then
tmp = fmax((((-30.0d0) * x) + ((-1.0d0) * 25.0d0)), t_0)
else
tmp = fmax((((-30.0d0) * y) + ((-1.0d0) * 25.0d0)), t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.abs(((Math.sin((z * 30.0)) * Math.cos((x * 30.0))) + ((Math.sin((x * 30.0)) * Math.cos((y * 30.0))) + (Math.sin((y * 30.0)) * Math.cos((z * 30.0)))))) - 0.2;
double tmp;
if (x <= -1.15e+112) {
tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0);
} else {
tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs(((math.sin((z * 30.0)) * math.cos((x * 30.0))) + ((math.sin((x * 30.0)) * math.cos((y * 30.0))) + (math.sin((y * 30.0)) * math.cos((z * 30.0)))))) - 0.2 tmp = 0 if x <= -1.15e+112: tmp = fmax(((-30.0 * x) + (-1.0 * 25.0)), t_0) else: tmp = fmax(((-30.0 * y) + (-1.0 * 25.0)), t_0) return tmp
function code(x, y, z) t_0 = Float64(abs(Float64(Float64(sin(Float64(z * 30.0)) * cos(Float64(x * 30.0))) + Float64(Float64(sin(Float64(x * 30.0)) * cos(Float64(y * 30.0))) + Float64(sin(Float64(y * 30.0)) * cos(Float64(z * 30.0)))))) - 0.2) tmp = 0.0 if (x <= -1.15e+112) tmp = fmax(Float64(Float64(-30.0 * x) + Float64(-1.0 * 25.0)), t_0); else tmp = fmax(Float64(Float64(-30.0 * y) + Float64(-1.0 * 25.0)), t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs(((sin((z * 30.0)) * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))))) - 0.2; tmp = 0.0; if (x <= -1.15e+112) tmp = max(((-30.0 * x) + (-1.0 * 25.0)), t_0); else tmp = max(((-30.0 * y) + (-1.0 * 25.0)), t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Abs[N[(N[(N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 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]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]}, If[LessEqual[x, -1.15e+112], N[Max[N[(N[(-30.0 * x), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision], N[Max[N[(N[(-30.0 * y), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right) + \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)\right| - 0.2\\
\mathbf{if}\;x \leq -1.15 \cdot 10^{+112}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x + -1 \cdot 25, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot y + -1 \cdot 25, t\_0\right)\\
\end{array}
\end{array}
if x < -1.15e112Initial program 12.3%
Taylor expanded in x around -inf
lower-*.f6479.5
Applied rewrites79.5%
if -1.15e112 < x Initial program 46.8%
Taylor expanded in y around -inf
lower-*.f6435.4
Applied rewrites35.4%
Final simplification41.6%
(FPCore (x y z)
:precision binary64
(fmax
(+ (* -30.0 x) (* -1.0 25.0))
(-
(fabs
(+
(* (sin (* z 30.0)) (cos (* x 30.0)))
(+
(* (sin (* x 30.0)) (cos (* y 30.0)))
(* (sin (* y 30.0)) (cos (* z 30.0))))))
0.2)))
double code(double x, double y, double z) {
return fmax(((-30.0 * x) + (-1.0 * 25.0)), (fabs(((sin((z * 30.0)) * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 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((((-30.0d0) * x) + ((-1.0d0) * 25.0d0)), (abs(((sin((z * 30.0d0)) * cos((x * 30.0d0))) + ((sin((x * 30.0d0)) * cos((y * 30.0d0))) + (sin((y * 30.0d0)) * cos((z * 30.0d0)))))) - 0.2d0))
end function
public static double code(double x, double y, double z) {
return fmax(((-30.0 * x) + (-1.0 * 25.0)), (Math.abs(((Math.sin((z * 30.0)) * Math.cos((x * 30.0))) + ((Math.sin((x * 30.0)) * Math.cos((y * 30.0))) + (Math.sin((y * 30.0)) * Math.cos((z * 30.0)))))) - 0.2));
}
def code(x, y, z): return fmax(((-30.0 * x) + (-1.0 * 25.0)), (math.fabs(((math.sin((z * 30.0)) * math.cos((x * 30.0))) + ((math.sin((x * 30.0)) * math.cos((y * 30.0))) + (math.sin((y * 30.0)) * math.cos((z * 30.0)))))) - 0.2))
function code(x, y, z) return fmax(Float64(Float64(-30.0 * x) + Float64(-1.0 * 25.0)), Float64(abs(Float64(Float64(sin(Float64(z * 30.0)) * cos(Float64(x * 30.0))) + Float64(Float64(sin(Float64(x * 30.0)) * cos(Float64(y * 30.0))) + Float64(sin(Float64(y * 30.0)) * cos(Float64(z * 30.0)))))) - 0.2)) end
function tmp = code(x, y, z) tmp = max(((-30.0 * x) + (-1.0 * 25.0)), (abs(((sin((z * 30.0)) * cos((x * 30.0))) + ((sin((x * 30.0)) * cos((y * 30.0))) + (sin((y * 30.0)) * cos((z * 30.0)))))) - 0.2)); end
code[x_, y_, z_] := N[Max[N[(N[(-30.0 * x), $MachinePrecision] + N[(-1.0 * 25.0), $MachinePrecision]), $MachinePrecision], N[(N[Abs[N[(N[(N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 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]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(-30 \cdot x + -1 \cdot 25, \left|\sin \left(z \cdot 30\right) \cdot \cos \left(x \cdot 30\right) + \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)\right| - 0.2\right)
\end{array}
Initial program 42.0%
Taylor expanded in x around -inf
lower-*.f6427.4
Applied rewrites27.4%
Final simplification27.4%
herbie shell --seed 2025065
(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)))