
(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 12 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 (hypot y z)) (* 30.0 x)) 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((hypot((30.0 * hypot(y, z)), (30.0 * x)) - 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));
}
public static double code(double x, double y, double z) {
return fmax((Math.hypot((30.0 * Math.hypot(y, z)), (30.0 * x)) - 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((math.hypot((30.0 * math.hypot(y, z)), (30.0 * x)) - 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(hypot(Float64(30.0 * hypot(y, z)), Float64(30.0 * x)) - 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((hypot((30.0 * hypot(y, z)), (30.0 * x)) - 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[Sqrt[N[(30.0 * N[Sqrt[y ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(30.0 * x), $MachinePrecision] ^ 2], $MachinePrecision] - 25.0), $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(\mathsf{hypot}\left(30 \cdot \mathsf{hypot}\left(y, z\right), 30 \cdot x\right) - 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 49.3%
associate-+l+N/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (fmax (- (hypot (* 30.0 (hypot y z)) (* 30.0 x)) 25.0) (- (fabs (fma (sin (* z 30.0)) (cos (* x 30.0)) (sin (* x 30.0)))) 0.2)))
double code(double x, double y, double z) {
return fmax((hypot((30.0 * hypot(y, z)), (30.0 * x)) - 25.0), (fabs(fma(sin((z * 30.0)), cos((x * 30.0)), sin((x * 30.0)))) - 0.2));
}
function code(x, y, z) return fmax(Float64(hypot(Float64(30.0 * hypot(y, z)), Float64(30.0 * x)) - 25.0), Float64(abs(fma(sin(Float64(z * 30.0)), cos(Float64(x * 30.0)), sin(Float64(x * 30.0)))) - 0.2)) end
code[x_, y_, z_] := N[Max[N[(N[Sqrt[N[(30.0 * N[Sqrt[y ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(30.0 * x), $MachinePrecision] ^ 2], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(x * 30.0), $MachinePrecision]], $MachinePrecision] + N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\mathsf{hypot}\left(30 \cdot \mathsf{hypot}\left(y, z\right), 30 \cdot x\right) - 25, \left|\mathsf{fma}\left(\sin \left(z \cdot 30\right), \cos \left(x \cdot 30\right), \sin \left(x \cdot 30\right)\right)\right| - 0.2\right)
\end{array}
Initial program 49.3%
associate-+l+N/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (x y z) :precision binary64 (fmax (- (hypot (* 30.0 (hypot y z)) (* 30.0 x)) 25.0) (- (fabs (fma x 30.0 (sin (* z 30.0)))) 0.2)))
double code(double x, double y, double z) {
return fmax((hypot((30.0 * hypot(y, z)), (30.0 * x)) - 25.0), (fabs(fma(x, 30.0, sin((z * 30.0)))) - 0.2));
}
function code(x, y, z) return fmax(Float64(hypot(Float64(30.0 * hypot(y, z)), Float64(30.0 * x)) - 25.0), Float64(abs(fma(x, 30.0, sin(Float64(z * 30.0)))) - 0.2)) end
code[x_, y_, z_] := N[Max[N[(N[Sqrt[N[(30.0 * N[Sqrt[y ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(30.0 * x), $MachinePrecision] ^ 2], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(x * 30.0 + N[Sin[N[(z * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\mathsf{hypot}\left(30 \cdot \mathsf{hypot}\left(y, z\right), 30 \cdot x\right) - 25, \left|\mathsf{fma}\left(x, 30, \sin \left(z \cdot 30\right)\right)\right| - 0.2\right)
\end{array}
Initial program 49.3%
associate-+l+N/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.3
Applied rewrites99.3%
(FPCore (x y z) :precision binary64 (fmax (- (hypot (* 30.0 (hypot y z)) (* 30.0 x)) 25.0) (- (fabs (sin (* x 30.0))) 0.2)))
double code(double x, double y, double z) {
return fmax((hypot((30.0 * hypot(y, z)), (30.0 * x)) - 25.0), (fabs(sin((x * 30.0))) - 0.2));
}
public static double code(double x, double y, double z) {
return fmax((Math.hypot((30.0 * Math.hypot(y, z)), (30.0 * x)) - 25.0), (Math.abs(Math.sin((x * 30.0))) - 0.2));
}
def code(x, y, z): return fmax((math.hypot((30.0 * math.hypot(y, z)), (30.0 * x)) - 25.0), (math.fabs(math.sin((x * 30.0))) - 0.2))
function code(x, y, z) return fmax(Float64(hypot(Float64(30.0 * hypot(y, z)), Float64(30.0 * x)) - 25.0), Float64(abs(sin(Float64(x * 30.0))) - 0.2)) end
function tmp = code(x, y, z) tmp = max((hypot((30.0 * hypot(y, z)), (30.0 * x)) - 25.0), (abs(sin((x * 30.0))) - 0.2)); end
code[x_, y_, z_] := N[Max[N[(N[Sqrt[N[(30.0 * N[Sqrt[y ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] ^ 2 + N[(30.0 * x), $MachinePrecision] ^ 2], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\mathsf{hypot}\left(30 \cdot \mathsf{hypot}\left(y, z\right), 30 \cdot x\right) - 25, \left|\sin \left(x \cdot 30\right)\right| - 0.2\right)
\end{array}
Initial program 49.3%
associate-+l+N/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in z around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.3
Applied rewrites99.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (fabs (sin (* x 30.0))) 0.2)))
(if (or (<= x -3900000000000.0) (not (<= x 7.6e+34)))
(fmax (- (hypot (* 30.0 y) (* 30.0 x)) 25.0) t_0)
(fmax (- (* 30.0 (hypot y z)) 25.0) t_0))))
double code(double x, double y, double z) {
double t_0 = fabs(sin((x * 30.0))) - 0.2;
double tmp;
if ((x <= -3900000000000.0) || !(x <= 7.6e+34)) {
tmp = fmax((hypot((30.0 * y), (30.0 * x)) - 25.0), t_0);
} else {
tmp = fmax(((30.0 * hypot(y, z)) - 25.0), t_0);
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = Math.abs(Math.sin((x * 30.0))) - 0.2;
double tmp;
if ((x <= -3900000000000.0) || !(x <= 7.6e+34)) {
tmp = fmax((Math.hypot((30.0 * y), (30.0 * x)) - 25.0), t_0);
} else {
tmp = fmax(((30.0 * Math.hypot(y, z)) - 25.0), t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs(math.sin((x * 30.0))) - 0.2 tmp = 0 if (x <= -3900000000000.0) or not (x <= 7.6e+34): tmp = fmax((math.hypot((30.0 * y), (30.0 * x)) - 25.0), t_0) else: tmp = fmax(((30.0 * math.hypot(y, z)) - 25.0), t_0) return tmp
function code(x, y, z) t_0 = Float64(abs(sin(Float64(x * 30.0))) - 0.2) tmp = 0.0 if ((x <= -3900000000000.0) || !(x <= 7.6e+34)) tmp = fmax(Float64(hypot(Float64(30.0 * y), Float64(30.0 * x)) - 25.0), t_0); else tmp = fmax(Float64(Float64(30.0 * hypot(y, z)) - 25.0), t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs(sin((x * 30.0))) - 0.2; tmp = 0.0; if ((x <= -3900000000000.0) || ~((x <= 7.6e+34))) tmp = max((hypot((30.0 * y), (30.0 * x)) - 25.0), t_0); else tmp = max(((30.0 * hypot(y, z)) - 25.0), t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Abs[N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]}, If[Or[LessEqual[x, -3900000000000.0], N[Not[LessEqual[x, 7.6e+34]], $MachinePrecision]], N[Max[N[(N[Sqrt[N[(30.0 * y), $MachinePrecision] ^ 2 + N[(30.0 * x), $MachinePrecision] ^ 2], $MachinePrecision] - 25.0), $MachinePrecision], t$95$0], $MachinePrecision], N[Max[N[(N[(30.0 * N[Sqrt[y ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] - 25.0), $MachinePrecision], t$95$0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\sin \left(x \cdot 30\right)\right| - 0.2\\
\mathbf{if}\;x \leq -3900000000000 \lor \neg \left(x \leq 7.6 \cdot 10^{+34}\right):\\
\;\;\;\;\mathsf{max}\left(\mathsf{hypot}\left(30 \cdot y, 30 \cdot x\right) - 25, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(30 \cdot \mathsf{hypot}\left(y, z\right) - 25, t\_0\right)\\
\end{array}
\end{array}
if x < -3.9e12 or 7.6000000000000003e34 < x Initial program 29.6%
associate-+l+N/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in y around inf
Applied rewrites88.9%
if -3.9e12 < x < 7.6000000000000003e34Initial program 64.9%
associate-+l+N/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in z around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
Taylor expanded in x around 0
pow2N/A
pow2N/A
lower-*.f64N/A
lower-hypot.f6497.6
Applied rewrites97.6%
Final simplification93.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (sin (* x 30.0))))
(if (<= x -3900000000000.0)
(fmax (* -30.0 x) (- (fabs (fma y 30.0 t_0)) 0.2))
(if (<= x 3.4e+40)
(fmax (- (* 30.0 (hypot y z)) 25.0) (- (fabs t_0) 0.2))
(fmax (* -30.0 x) (- (fabs (* 30.0 x)) 0.2))))))
double code(double x, double y, double z) {
double t_0 = sin((x * 30.0));
double tmp;
if (x <= -3900000000000.0) {
tmp = fmax((-30.0 * x), (fabs(fma(y, 30.0, t_0)) - 0.2));
} else if (x <= 3.4e+40) {
tmp = fmax(((30.0 * hypot(y, z)) - 25.0), (fabs(t_0) - 0.2));
} else {
tmp = fmax((-30.0 * x), (fabs((30.0 * x)) - 0.2));
}
return tmp;
}
function code(x, y, z) t_0 = sin(Float64(x * 30.0)) tmp = 0.0 if (x <= -3900000000000.0) tmp = fmax(Float64(-30.0 * x), Float64(abs(fma(y, 30.0, t_0)) - 0.2)); elseif (x <= 3.4e+40) tmp = fmax(Float64(Float64(30.0 * hypot(y, z)) - 25.0), Float64(abs(t_0) - 0.2)); else tmp = fmax(Float64(-30.0 * x), Float64(abs(Float64(30.0 * x)) - 0.2)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3900000000000.0], N[Max[N[(-30.0 * x), $MachinePrecision], N[(N[Abs[N[(y * 30.0 + t$95$0), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 3.4e+40], N[Max[N[(N[(30.0 * N[Sqrt[y ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[t$95$0], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(-30.0 * x), $MachinePrecision], N[(N[Abs[N[(30.0 * x), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 30\right)\\
\mathbf{if}\;x \leq -3900000000000:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x, \left|\mathsf{fma}\left(y, 30, t\_0\right)\right| - 0.2\right)\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+40}:\\
\;\;\;\;\mathsf{max}\left(30 \cdot \mathsf{hypot}\left(y, z\right) - 25, \left|t\_0\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x, \left|30 \cdot x\right| - 0.2\right)\\
\end{array}
\end{array}
if x < -3.9e12Initial program 29.4%
Taylor expanded in x around -inf
lower-*.f6469.2
Applied rewrites69.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6469.2
Applied rewrites69.2%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6487.4
Applied rewrites87.4%
if -3.9e12 < x < 3.39999999999999989e40Initial program 64.9%
associate-+l+N/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in z around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
Taylor expanded in x around 0
pow2N/A
pow2N/A
lower-*.f64N/A
lower-hypot.f6497.6
Applied rewrites97.6%
if 3.39999999999999989e40 < x Initial program 29.8%
Taylor expanded in x around -inf
lower-*.f643.8
Applied rewrites3.8%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f643.6
Applied rewrites3.6%
Taylor expanded in y around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f643.7
Applied rewrites3.7%
Taylor expanded in x around 0
lower-*.f6475.7
Applied rewrites75.7%
(FPCore (x y z)
:precision binary64
(if (or (<= y -6.8e-10) (not (<= y 25.0)))
(fmax (* -30.0 x) (- (fabs (fma y 30.0 (sin (* x 30.0)))) 0.2))
(fmax
(- (sqrt (* (* x x) 900.0)) 25.0)
(- (fabs (fma z 30.0 (sin (* y 30.0)))) 0.2))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.8e-10) || !(y <= 25.0)) {
tmp = fmax((-30.0 * x), (fabs(fma(y, 30.0, sin((x * 30.0)))) - 0.2));
} else {
tmp = fmax((sqrt(((x * x) * 900.0)) - 25.0), (fabs(fma(z, 30.0, sin((y * 30.0)))) - 0.2));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -6.8e-10) || !(y <= 25.0)) tmp = fmax(Float64(-30.0 * x), Float64(abs(fma(y, 30.0, sin(Float64(x * 30.0)))) - 0.2)); else tmp = fmax(Float64(sqrt(Float64(Float64(x * x) * 900.0)) - 25.0), Float64(abs(fma(z, 30.0, sin(Float64(y * 30.0)))) - 0.2)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.8e-10], N[Not[LessEqual[y, 25.0]], $MachinePrecision]], N[Max[N[(-30.0 * x), $MachinePrecision], N[(N[Abs[N[(y * 30.0 + N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(N[Sqrt[N[(N[(x * x), $MachinePrecision] * 900.0), $MachinePrecision]], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(z * 30.0 + N[Sin[N[(y * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{-10} \lor \neg \left(y \leq 25\right):\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x, \left|\mathsf{fma}\left(y, 30, \sin \left(x \cdot 30\right)\right)\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(\sqrt{\left(x \cdot x\right) \cdot 900} - 25, \left|\mathsf{fma}\left(z, 30, \sin \left(y \cdot 30\right)\right)\right| - 0.2\right)\\
\end{array}
\end{array}
if y < -6.8000000000000003e-10 or 25 < y Initial program 36.1%
Taylor expanded in x around -inf
lower-*.f6416.1
Applied rewrites16.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6416.1
Applied rewrites16.1%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6472.9
Applied rewrites72.9%
if -6.8000000000000003e-10 < y < 25Initial program 63.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6452.7
Applied rewrites52.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6452.7
Applied rewrites52.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6474.5
Applied rewrites74.5%
Final simplification73.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.8e-10) (not (<= y 21.5))) (fmax (* -30.0 x) (- (fabs (fma y 30.0 (sin (* x 30.0)))) 0.2)) (fmax (- (sqrt (* (* x x) 900.0)) 25.0) (- (fabs (* 30.0 z)) 0.2))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.8e-10) || !(y <= 21.5)) {
tmp = fmax((-30.0 * x), (fabs(fma(y, 30.0, sin((x * 30.0)))) - 0.2));
} else {
tmp = fmax((sqrt(((x * x) * 900.0)) - 25.0), (fabs((30.0 * z)) - 0.2));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -6.8e-10) || !(y <= 21.5)) tmp = fmax(Float64(-30.0 * x), Float64(abs(fma(y, 30.0, sin(Float64(x * 30.0)))) - 0.2)); else tmp = fmax(Float64(sqrt(Float64(Float64(x * x) * 900.0)) - 25.0), Float64(abs(Float64(30.0 * z)) - 0.2)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.8e-10], N[Not[LessEqual[y, 21.5]], $MachinePrecision]], N[Max[N[(-30.0 * x), $MachinePrecision], N[(N[Abs[N[(y * 30.0 + N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(N[Sqrt[N[(N[(x * x), $MachinePrecision] * 900.0), $MachinePrecision]], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(30.0 * z), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{-10} \lor \neg \left(y \leq 21.5\right):\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x, \left|\mathsf{fma}\left(y, 30, \sin \left(x \cdot 30\right)\right)\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(\sqrt{\left(x \cdot x\right) \cdot 900} - 25, \left|30 \cdot z\right| - 0.2\right)\\
\end{array}
\end{array}
if y < -6.8000000000000003e-10 or 21.5 < y Initial program 36.1%
Taylor expanded in x around -inf
lower-*.f6416.1
Applied rewrites16.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6416.1
Applied rewrites16.1%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6472.9
Applied rewrites72.9%
if -6.8000000000000003e-10 < y < 21.5Initial program 63.6%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6452.7
Applied rewrites52.7%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6452.7
Applied rewrites52.7%
Taylor expanded in y around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6452.4
Applied rewrites52.4%
Taylor expanded in z around 0
lower-*.f6474.3
Applied rewrites74.3%
Final simplification73.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (fabs (sin (* x 30.0))) 0.2)))
(if (<= y -5200000000000.0)
(fmax (- (* -30.0 y) 25.0) t_0)
(if (<= y 1.6e+71)
(fmax (- (sqrt (* (* x x) 900.0)) 25.0) (- (fabs (* 30.0 z)) 0.2))
(fmax (* 30.0 y) t_0)))))
double code(double x, double y, double z) {
double t_0 = fabs(sin((x * 30.0))) - 0.2;
double tmp;
if (y <= -5200000000000.0) {
tmp = fmax(((-30.0 * y) - 25.0), t_0);
} else if (y <= 1.6e+71) {
tmp = fmax((sqrt(((x * x) * 900.0)) - 25.0), (fabs((30.0 * z)) - 0.2));
} else {
tmp = fmax((30.0 * y), 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((x * 30.0d0))) - 0.2d0
if (y <= (-5200000000000.0d0)) then
tmp = fmax((((-30.0d0) * y) - 25.0d0), t_0)
else if (y <= 1.6d+71) then
tmp = fmax((sqrt(((x * x) * 900.0d0)) - 25.0d0), (abs((30.0d0 * z)) - 0.2d0))
else
tmp = fmax((30.0d0 * y), 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((x * 30.0))) - 0.2;
double tmp;
if (y <= -5200000000000.0) {
tmp = fmax(((-30.0 * y) - 25.0), t_0);
} else if (y <= 1.6e+71) {
tmp = fmax((Math.sqrt(((x * x) * 900.0)) - 25.0), (Math.abs((30.0 * z)) - 0.2));
} else {
tmp = fmax((30.0 * y), t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs(math.sin((x * 30.0))) - 0.2 tmp = 0 if y <= -5200000000000.0: tmp = fmax(((-30.0 * y) - 25.0), t_0) elif y <= 1.6e+71: tmp = fmax((math.sqrt(((x * x) * 900.0)) - 25.0), (math.fabs((30.0 * z)) - 0.2)) else: tmp = fmax((30.0 * y), t_0) return tmp
function code(x, y, z) t_0 = Float64(abs(sin(Float64(x * 30.0))) - 0.2) tmp = 0.0 if (y <= -5200000000000.0) tmp = fmax(Float64(Float64(-30.0 * y) - 25.0), t_0); elseif (y <= 1.6e+71) tmp = fmax(Float64(sqrt(Float64(Float64(x * x) * 900.0)) - 25.0), Float64(abs(Float64(30.0 * z)) - 0.2)); else tmp = fmax(Float64(30.0 * y), t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs(sin((x * 30.0))) - 0.2; tmp = 0.0; if (y <= -5200000000000.0) tmp = max(((-30.0 * y) - 25.0), t_0); elseif (y <= 1.6e+71) tmp = max((sqrt(((x * x) * 900.0)) - 25.0), (abs((30.0 * z)) - 0.2)); else tmp = max((30.0 * y), t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Abs[N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]}, If[LessEqual[y, -5200000000000.0], N[Max[N[(N[(-30.0 * y), $MachinePrecision] - 25.0), $MachinePrecision], t$95$0], $MachinePrecision], If[LessEqual[y, 1.6e+71], N[Max[N[(N[Sqrt[N[(N[(x * x), $MachinePrecision] * 900.0), $MachinePrecision]], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(30.0 * z), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(30.0 * y), $MachinePrecision], t$95$0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\sin \left(x \cdot 30\right)\right| - 0.2\\
\mathbf{if}\;y \leq -5200000000000:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot y - 25, t\_0\right)\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{max}\left(\sqrt{\left(x \cdot x\right) \cdot 900} - 25, \left|30 \cdot z\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(30 \cdot y, t\_0\right)\\
\end{array}
\end{array}
if y < -5.2e12Initial program 28.4%
associate-+l+N/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
unpow-prod-downN/A
metadata-evalN/A
*-commutativeN/A
+-commutativeN/A
Applied rewrites99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in z around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in y around -inf
lower-*.f6461.9
Applied rewrites61.9%
if -5.2e12 < y < 1.60000000000000012e71Initial program 62.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6447.6
Applied rewrites47.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6447.5
Applied rewrites47.5%
Taylor expanded in y around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6447.2
Applied rewrites47.2%
Taylor expanded in z around 0
lower-*.f6468.3
Applied rewrites68.3%
if 1.60000000000000012e71 < y Initial program 35.9%
Taylor expanded in x around -inf
lower-*.f6410.2
Applied rewrites10.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6410.1
Applied rewrites10.1%
Taylor expanded in y around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f649.0
Applied rewrites9.0%
Taylor expanded in y around inf
lower-*.f6477.9
Applied rewrites77.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (fabs (sin (* x 30.0))) 0.2)))
(if (<= y -6200000000000.0)
(fmax (* -30.0 y) t_0)
(if (<= y 1.6e+71)
(fmax (- (sqrt (* (* x x) 900.0)) 25.0) (- (fabs (* 30.0 z)) 0.2))
(fmax (* 30.0 y) t_0)))))
double code(double x, double y, double z) {
double t_0 = fabs(sin((x * 30.0))) - 0.2;
double tmp;
if (y <= -6200000000000.0) {
tmp = fmax((-30.0 * y), t_0);
} else if (y <= 1.6e+71) {
tmp = fmax((sqrt(((x * x) * 900.0)) - 25.0), (fabs((30.0 * z)) - 0.2));
} else {
tmp = fmax((30.0 * y), 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((x * 30.0d0))) - 0.2d0
if (y <= (-6200000000000.0d0)) then
tmp = fmax(((-30.0d0) * y), t_0)
else if (y <= 1.6d+71) then
tmp = fmax((sqrt(((x * x) * 900.0d0)) - 25.0d0), (abs((30.0d0 * z)) - 0.2d0))
else
tmp = fmax((30.0d0 * y), 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((x * 30.0))) - 0.2;
double tmp;
if (y <= -6200000000000.0) {
tmp = fmax((-30.0 * y), t_0);
} else if (y <= 1.6e+71) {
tmp = fmax((Math.sqrt(((x * x) * 900.0)) - 25.0), (Math.abs((30.0 * z)) - 0.2));
} else {
tmp = fmax((30.0 * y), t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.fabs(math.sin((x * 30.0))) - 0.2 tmp = 0 if y <= -6200000000000.0: tmp = fmax((-30.0 * y), t_0) elif y <= 1.6e+71: tmp = fmax((math.sqrt(((x * x) * 900.0)) - 25.0), (math.fabs((30.0 * z)) - 0.2)) else: tmp = fmax((30.0 * y), t_0) return tmp
function code(x, y, z) t_0 = Float64(abs(sin(Float64(x * 30.0))) - 0.2) tmp = 0.0 if (y <= -6200000000000.0) tmp = fmax(Float64(-30.0 * y), t_0); elseif (y <= 1.6e+71) tmp = fmax(Float64(sqrt(Float64(Float64(x * x) * 900.0)) - 25.0), Float64(abs(Float64(30.0 * z)) - 0.2)); else tmp = fmax(Float64(30.0 * y), t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = abs(sin((x * 30.0))) - 0.2; tmp = 0.0; if (y <= -6200000000000.0) tmp = max((-30.0 * y), t_0); elseif (y <= 1.6e+71) tmp = max((sqrt(((x * x) * 900.0)) - 25.0), (abs((30.0 * z)) - 0.2)); else tmp = max((30.0 * y), t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Abs[N[Sin[N[(x * 30.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]}, If[LessEqual[y, -6200000000000.0], N[Max[N[(-30.0 * y), $MachinePrecision], t$95$0], $MachinePrecision], If[LessEqual[y, 1.6e+71], N[Max[N[(N[Sqrt[N[(N[(x * x), $MachinePrecision] * 900.0), $MachinePrecision]], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(30.0 * z), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(30.0 * y), $MachinePrecision], t$95$0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\sin \left(x \cdot 30\right)\right| - 0.2\\
\mathbf{if}\;y \leq -6200000000000:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot y, t\_0\right)\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+71}:\\
\;\;\;\;\mathsf{max}\left(\sqrt{\left(x \cdot x\right) \cdot 900} - 25, \left|30 \cdot z\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(30 \cdot y, t\_0\right)\\
\end{array}
\end{array}
if y < -6.2e12Initial program 28.4%
Taylor expanded in x around -inf
lower-*.f6413.8
Applied rewrites13.8%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6413.8
Applied rewrites13.8%
Taylor expanded in y around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6412.7
Applied rewrites12.7%
Taylor expanded in y around -inf
lower-*.f6461.7
Applied rewrites61.7%
if -6.2e12 < y < 1.60000000000000012e71Initial program 62.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6447.6
Applied rewrites47.6%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6447.5
Applied rewrites47.5%
Taylor expanded in y around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6447.2
Applied rewrites47.2%
Taylor expanded in z around 0
lower-*.f6468.3
Applied rewrites68.3%
if 1.60000000000000012e71 < y Initial program 35.9%
Taylor expanded in x around -inf
lower-*.f6410.2
Applied rewrites10.2%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6410.1
Applied rewrites10.1%
Taylor expanded in y around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f649.0
Applied rewrites9.0%
Taylor expanded in y around inf
lower-*.f6477.9
Applied rewrites77.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -4e+152) (not (<= x 2.15e+156))) (fmax (* -30.0 x) (- (fabs (* 30.0 x)) 0.2)) (fmax (- (sqrt (* (* x x) 900.0)) 25.0) (- (fabs (* 30.0 z)) 0.2))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4e+152) || !(x <= 2.15e+156)) {
tmp = fmax((-30.0 * x), (fabs((30.0 * x)) - 0.2));
} else {
tmp = fmax((sqrt(((x * x) * 900.0)) - 25.0), (fabs((30.0 * z)) - 0.2));
}
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) :: tmp
if ((x <= (-4d+152)) .or. (.not. (x <= 2.15d+156))) then
tmp = fmax(((-30.0d0) * x), (abs((30.0d0 * x)) - 0.2d0))
else
tmp = fmax((sqrt(((x * x) * 900.0d0)) - 25.0d0), (abs((30.0d0 * z)) - 0.2d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -4e+152) || !(x <= 2.15e+156)) {
tmp = fmax((-30.0 * x), (Math.abs((30.0 * x)) - 0.2));
} else {
tmp = fmax((Math.sqrt(((x * x) * 900.0)) - 25.0), (Math.abs((30.0 * z)) - 0.2));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4e+152) or not (x <= 2.15e+156): tmp = fmax((-30.0 * x), (math.fabs((30.0 * x)) - 0.2)) else: tmp = fmax((math.sqrt(((x * x) * 900.0)) - 25.0), (math.fabs((30.0 * z)) - 0.2)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4e+152) || !(x <= 2.15e+156)) tmp = fmax(Float64(-30.0 * x), Float64(abs(Float64(30.0 * x)) - 0.2)); else tmp = fmax(Float64(sqrt(Float64(Float64(x * x) * 900.0)) - 25.0), Float64(abs(Float64(30.0 * z)) - 0.2)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -4e+152) || ~((x <= 2.15e+156))) tmp = max((-30.0 * x), (abs((30.0 * x)) - 0.2)); else tmp = max((sqrt(((x * x) * 900.0)) - 25.0), (abs((30.0 * z)) - 0.2)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4e+152], N[Not[LessEqual[x, 2.15e+156]], $MachinePrecision]], N[Max[N[(-30.0 * x), $MachinePrecision], N[(N[Abs[N[(30.0 * x), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(N[Sqrt[N[(N[(x * x), $MachinePrecision] * 900.0), $MachinePrecision]], $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(30.0 * z), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+152} \lor \neg \left(x \leq 2.15 \cdot 10^{+156}\right):\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x, \left|30 \cdot x\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(\sqrt{\left(x \cdot x\right) \cdot 900} - 25, \left|30 \cdot z\right| - 0.2\right)\\
\end{array}
\end{array}
if x < -4.0000000000000002e152 or 2.14999999999999993e156 < x Initial program 9.1%
Taylor expanded in x around -inf
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6446.3
Applied rewrites46.3%
Taylor expanded in y around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6446.4
Applied rewrites46.4%
Taylor expanded in x around 0
lower-*.f6483.6
Applied rewrites83.6%
if -4.0000000000000002e152 < x < 2.14999999999999993e156Initial program 63.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6437.4
Applied rewrites37.4%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6437.3
Applied rewrites37.3%
Taylor expanded in y around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6436.4
Applied rewrites36.4%
Taylor expanded in z around 0
lower-*.f6459.4
Applied rewrites59.4%
Final simplification65.8%
(FPCore (x y z) :precision binary64 (fmax (* -30.0 x) (- (fabs (* 30.0 x)) 0.2)))
double code(double x, double y, double z) {
return fmax((-30.0 * x), (fabs((30.0 * x)) - 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), (abs((30.0d0 * x)) - 0.2d0))
end function
public static double code(double x, double y, double z) {
return fmax((-30.0 * x), (Math.abs((30.0 * x)) - 0.2));
}
def code(x, y, z): return fmax((-30.0 * x), (math.fabs((30.0 * x)) - 0.2))
function code(x, y, z) return fmax(Float64(-30.0 * x), Float64(abs(Float64(30.0 * x)) - 0.2)) end
function tmp = code(x, y, z) tmp = max((-30.0 * x), (abs((30.0 * x)) - 0.2)); end
code[x_, y_, z_] := N[Max[N[(-30.0 * x), $MachinePrecision], N[(N[Abs[N[(30.0 * x), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(-30 \cdot x, \left|30 \cdot x\right| - 0.2\right)
\end{array}
Initial program 49.3%
Taylor expanded in x around -inf
lower-*.f6420.7
Applied rewrites20.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6420.4
Applied rewrites20.4%
Taylor expanded in y around 0
lower-sin.f64N/A
*-commutativeN/A
lower-*.f6419.8
Applied rewrites19.8%
Taylor expanded in x around 0
lower-*.f6433.8
Applied rewrites33.8%
herbie shell --seed 2025043
(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)))