
(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}
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
(let* ((t_0 (sin (* 30.0 x))))
(if (<= z -4.4e+80)
(fmax (* -30.0 z) (- (fabs (fma y 30.0 t_0)) 0.2))
(if (<= z 2.6e+135)
(fmax (* (- 30.0 (/ 25.0 y)) y) (- (fabs (* 30.0 (+ x y))) 0.2))
(fmax
(fma z 30.0 -25.0)
(- (fabs (fma t_0 (cos (* y 30.0)) (sin (* y 30.0)))) 0.2))))))
double code(double x, double y, double z) {
double t_0 = sin((30.0 * x));
double tmp;
if (z <= -4.4e+80) {
tmp = fmax((-30.0 * z), (fabs(fma(y, 30.0, t_0)) - 0.2));
} else if (z <= 2.6e+135) {
tmp = fmax(((30.0 - (25.0 / y)) * y), (fabs((30.0 * (x + y))) - 0.2));
} else {
tmp = fmax(fma(z, 30.0, -25.0), (fabs(fma(t_0, cos((y * 30.0)), sin((y * 30.0)))) - 0.2));
}
return tmp;
}
function code(x, y, z) t_0 = sin(Float64(30.0 * x)) tmp = 0.0 if (z <= -4.4e+80) tmp = fmax(Float64(-30.0 * z), Float64(abs(fma(y, 30.0, t_0)) - 0.2)); elseif (z <= 2.6e+135) tmp = fmax(Float64(Float64(30.0 - Float64(25.0 / y)) * y), Float64(abs(Float64(30.0 * Float64(x + y))) - 0.2)); else tmp = fmax(fma(z, 30.0, -25.0), Float64(abs(fma(t_0, cos(Float64(y * 30.0)), sin(Float64(y * 30.0)))) - 0.2)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Sin[N[(30.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -4.4e+80], N[Max[N[(-30.0 * z), $MachinePrecision], N[(N[Abs[N[(y * 30.0 + t$95$0), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 2.6e+135], N[Max[N[(N[(30.0 - N[(25.0 / y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Abs[N[(30.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(z * 30.0 + -25.0), $MachinePrecision], N[(N[Abs[N[(t$95$0 * N[Cos[N[(y * 30.0), $MachinePrecision]], $MachinePrecision] + N[Sin[N[(y * 30.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(30 \cdot x\right)\\
\mathbf{if}\;z \leq -4.4 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot z, \left|\mathsf{fma}\left(y, 30, t\_0\right)\right| - 0.2\right)\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+135}:\\
\;\;\;\;\mathsf{max}\left(\left(30 - \frac{25}{y}\right) \cdot y, \left|30 \cdot \left(x + y\right)\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(\mathsf{fma}\left(z, 30, -25\right), \left|\mathsf{fma}\left(t\_0, \cos \left(y \cdot 30\right), \sin \left(y \cdot 30\right)\right)\right| - 0.2\right)\\
\end{array}
\end{array}
if z < -4.40000000000000005e80Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in z around -inf
lower-*.f6445.8
Applied rewrites45.8%
if -4.40000000000000005e80 < z < 2.6e135Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6470.5
Applied rewrites70.5%
if 2.6e135 < z Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f6429.5
Applied rewrites29.5%
Taylor expanded in z around 0
sub-flipN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f6429.5
Applied rewrites29.5%
(FPCore (x y z)
:precision binary64
(if (<= z -4.4e+80)
(fmax (* -30.0 z) (- (fabs (fma y 30.0 (sin (* 30.0 x)))) 0.2))
(if (<= z 2.6e+135)
(fmax (* (- 30.0 (/ 25.0 y)) y) (- (fabs (* 30.0 (+ x y))) 0.2))
(fmax (* (- 30.0 (/ 25.0 z)) z) (- (fabs (sin (* y 30.0))) 0.2)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.4e+80) {
tmp = fmax((-30.0 * z), (fabs(fma(y, 30.0, sin((30.0 * x)))) - 0.2));
} else if (z <= 2.6e+135) {
tmp = fmax(((30.0 - (25.0 / y)) * y), (fabs((30.0 * (x + y))) - 0.2));
} else {
tmp = fmax(((30.0 - (25.0 / z)) * z), (fabs(sin((y * 30.0))) - 0.2));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -4.4e+80) tmp = fmax(Float64(-30.0 * z), Float64(abs(fma(y, 30.0, sin(Float64(30.0 * x)))) - 0.2)); elseif (z <= 2.6e+135) tmp = fmax(Float64(Float64(30.0 - Float64(25.0 / y)) * y), Float64(abs(Float64(30.0 * Float64(x + y))) - 0.2)); else tmp = fmax(Float64(Float64(30.0 - Float64(25.0 / z)) * z), Float64(abs(sin(Float64(y * 30.0))) - 0.2)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -4.4e+80], N[Max[N[(-30.0 * z), $MachinePrecision], N[(N[Abs[N[(y * 30.0 + N[Sin[N[(30.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 2.6e+135], N[Max[N[(N[(30.0 - N[(25.0 / y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Abs[N[(30.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(N[(30.0 - N[(25.0 / z), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[Abs[N[Sin[N[(y * 30.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot z, \left|\mathsf{fma}\left(y, 30, \sin \left(30 \cdot x\right)\right)\right| - 0.2\right)\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{+135}:\\
\;\;\;\;\mathsf{max}\left(\left(30 - \frac{25}{y}\right) \cdot y, \left|30 \cdot \left(x + y\right)\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(\left(30 - \frac{25}{z}\right) \cdot z, \left|\sin \left(y \cdot 30\right)\right| - 0.2\right)\\
\end{array}
\end{array}
if z < -4.40000000000000005e80Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in z around -inf
lower-*.f6445.8
Applied rewrites45.8%
if -4.40000000000000005e80 < z < 2.6e135Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6470.5
Applied rewrites70.5%
if 2.6e135 < z Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.5
Applied rewrites45.5%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
unpow2N/A
unpow2N/A
swap-sqrN/A
pow2N/A
metadata-evalN/A
*-commutativeN/A
swap-sqrN/A
pow2N/A
metadata-evalN/A
*-commutativeN/A
Applied rewrites45.4%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f6428.5
Applied rewrites28.5%
(FPCore (x y z)
:precision binary64
(if (<= z -4.4e+80)
(fmax (* -30.0 z) (- (fabs (fma y 30.0 (sin (* 30.0 x)))) 0.2))
(if (<= z 3.3e+135)
(fmax (* (- 30.0 (/ 25.0 y)) y) (- (fabs (* 30.0 (+ x y))) 0.2))
(fmax
(-
(*
(fma (/ (* 900.0 (fma x x (* y y))) (* z z)) 0.016666666666666666 30.0)
z)
25.0)
(- (fabs (* (fma -4500.0 (* y y) 30.0) y)) 0.2)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.4e+80) {
tmp = fmax((-30.0 * z), (fabs(fma(y, 30.0, sin((30.0 * x)))) - 0.2));
} else if (z <= 3.3e+135) {
tmp = fmax(((30.0 - (25.0 / y)) * y), (fabs((30.0 * (x + y))) - 0.2));
} else {
tmp = fmax(((fma(((900.0 * fma(x, x, (y * y))) / (z * z)), 0.016666666666666666, 30.0) * z) - 25.0), (fabs((fma(-4500.0, (y * y), 30.0) * y)) - 0.2));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -4.4e+80) tmp = fmax(Float64(-30.0 * z), Float64(abs(fma(y, 30.0, sin(Float64(30.0 * x)))) - 0.2)); elseif (z <= 3.3e+135) tmp = fmax(Float64(Float64(30.0 - Float64(25.0 / y)) * y), Float64(abs(Float64(30.0 * Float64(x + y))) - 0.2)); else tmp = fmax(Float64(Float64(fma(Float64(Float64(900.0 * fma(x, x, Float64(y * y))) / Float64(z * z)), 0.016666666666666666, 30.0) * z) - 25.0), Float64(abs(Float64(fma(-4500.0, Float64(y * y), 30.0) * y)) - 0.2)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -4.4e+80], N[Max[N[(-30.0 * z), $MachinePrecision], N[(N[Abs[N[(y * 30.0 + N[Sin[N[(30.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 3.3e+135], N[Max[N[(N[(30.0 - N[(25.0 / y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Abs[N[(30.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(N[(N[(N[(N[(900.0 * N[(x * x + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * z), $MachinePrecision]), $MachinePrecision] * 0.016666666666666666 + 30.0), $MachinePrecision] * z), $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(N[(-4500.0 * N[(y * y), $MachinePrecision] + 30.0), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.4 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot z, \left|\mathsf{fma}\left(y, 30, \sin \left(30 \cdot x\right)\right)\right| - 0.2\right)\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{+135}:\\
\;\;\;\;\mathsf{max}\left(\left(30 - \frac{25}{y}\right) \cdot y, \left|30 \cdot \left(x + y\right)\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(\mathsf{fma}\left(\frac{900 \cdot \mathsf{fma}\left(x, x, y \cdot y\right)}{z \cdot z}, 0.016666666666666666, 30\right) \cdot z - 25, \left|\mathsf{fma}\left(-4500, y \cdot y, 30\right) \cdot y\right| - 0.2\right)\\
\end{array}
\end{array}
if z < -4.40000000000000005e80Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in z around -inf
lower-*.f6445.8
Applied rewrites45.8%
if -4.40000000000000005e80 < z < 3.2999999999999999e135Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6470.5
Applied rewrites70.5%
if 3.2999999999999999e135 < z Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.5
Applied rewrites45.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites24.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6423.5
Applied rewrites23.5%
(FPCore (x y z)
:precision binary64
(if (<= z -9.2e+86)
(fmax (* -30.0 z) (- (fabs (sin (* y 30.0))) 0.2))
(if (<= z 3.3e+135)
(fmax (* (- 30.0 (/ 25.0 y)) y) (- (fabs (* 30.0 (+ x y))) 0.2))
(fmax
(-
(*
(fma (/ (* 900.0 (fma x x (* y y))) (* z z)) 0.016666666666666666 30.0)
z)
25.0)
(- (fabs (* (fma -4500.0 (* y y) 30.0) y)) 0.2)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9.2e+86) {
tmp = fmax((-30.0 * z), (fabs(sin((y * 30.0))) - 0.2));
} else if (z <= 3.3e+135) {
tmp = fmax(((30.0 - (25.0 / y)) * y), (fabs((30.0 * (x + y))) - 0.2));
} else {
tmp = fmax(((fma(((900.0 * fma(x, x, (y * y))) / (z * z)), 0.016666666666666666, 30.0) * z) - 25.0), (fabs((fma(-4500.0, (y * y), 30.0) * y)) - 0.2));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -9.2e+86) tmp = fmax(Float64(-30.0 * z), Float64(abs(sin(Float64(y * 30.0))) - 0.2)); elseif (z <= 3.3e+135) tmp = fmax(Float64(Float64(30.0 - Float64(25.0 / y)) * y), Float64(abs(Float64(30.0 * Float64(x + y))) - 0.2)); else tmp = fmax(Float64(Float64(fma(Float64(Float64(900.0 * fma(x, x, Float64(y * y))) / Float64(z * z)), 0.016666666666666666, 30.0) * z) - 25.0), Float64(abs(Float64(fma(-4500.0, Float64(y * y), 30.0) * y)) - 0.2)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -9.2e+86], N[Max[N[(-30.0 * z), $MachinePrecision], N[(N[Abs[N[Sin[N[(y * 30.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 3.3e+135], N[Max[N[(N[(30.0 - N[(25.0 / y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Abs[N[(30.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(N[(N[(N[(N[(900.0 * N[(x * x + N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * z), $MachinePrecision]), $MachinePrecision] * 0.016666666666666666 + 30.0), $MachinePrecision] * z), $MachinePrecision] - 25.0), $MachinePrecision], N[(N[Abs[N[(N[(-4500.0 * N[(y * y), $MachinePrecision] + 30.0), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.2 \cdot 10^{+86}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot z, \left|\sin \left(y \cdot 30\right)\right| - 0.2\right)\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{+135}:\\
\;\;\;\;\mathsf{max}\left(\left(30 - \frac{25}{y}\right) \cdot y, \left|30 \cdot \left(x + y\right)\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(\mathsf{fma}\left(\frac{900 \cdot \mathsf{fma}\left(x, x, y \cdot y\right)}{z \cdot z}, 0.016666666666666666, 30\right) \cdot z - 25, \left|\mathsf{fma}\left(-4500, y \cdot y, 30\right) \cdot y\right| - 0.2\right)\\
\end{array}
\end{array}
if z < -9.19999999999999958e86Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.5
Applied rewrites45.5%
Taylor expanded in z around -inf
lower-*.f6417.2
Applied rewrites17.2%
if -9.19999999999999958e86 < z < 3.2999999999999999e135Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6470.5
Applied rewrites70.5%
if 3.2999999999999999e135 < z Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.5
Applied rewrites45.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites24.0%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6423.5
Applied rewrites23.5%
(FPCore (x y z) :precision binary64 (if (<= z -9.2e+86) (fmax (* -30.0 z) (- (fabs (sin (* y 30.0))) 0.2)) (fmax (* (- 30.0 (/ 25.0 y)) y) (- (fabs (* 30.0 (+ x y))) 0.2))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9.2e+86) {
tmp = fmax((-30.0 * z), (fabs(sin((y * 30.0))) - 0.2));
} else {
tmp = fmax(((30.0 - (25.0 / y)) * y), (fabs((30.0 * (x + y))) - 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 (z <= (-9.2d+86)) then
tmp = fmax(((-30.0d0) * z), (abs(sin((y * 30.0d0))) - 0.2d0))
else
tmp = fmax(((30.0d0 - (25.0d0 / y)) * y), (abs((30.0d0 * (x + y))) - 0.2d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9.2e+86) {
tmp = fmax((-30.0 * z), (Math.abs(Math.sin((y * 30.0))) - 0.2));
} else {
tmp = fmax(((30.0 - (25.0 / y)) * y), (Math.abs((30.0 * (x + y))) - 0.2));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9.2e+86: tmp = fmax((-30.0 * z), (math.fabs(math.sin((y * 30.0))) - 0.2)) else: tmp = fmax(((30.0 - (25.0 / y)) * y), (math.fabs((30.0 * (x + y))) - 0.2)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9.2e+86) tmp = fmax(Float64(-30.0 * z), Float64(abs(sin(Float64(y * 30.0))) - 0.2)); else tmp = fmax(Float64(Float64(30.0 - Float64(25.0 / y)) * y), Float64(abs(Float64(30.0 * Float64(x + y))) - 0.2)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -9.2e+86) tmp = max((-30.0 * z), (abs(sin((y * 30.0))) - 0.2)); else tmp = max(((30.0 - (25.0 / y)) * y), (abs((30.0 * (x + y))) - 0.2)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9.2e+86], N[Max[N[(-30.0 * z), $MachinePrecision], N[(N[Abs[N[Sin[N[(y * 30.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(N[(30.0 - N[(25.0 / y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Abs[N[(30.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.2 \cdot 10^{+86}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot z, \left|\sin \left(y \cdot 30\right)\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(\left(30 - \frac{25}{y}\right) \cdot y, \left|30 \cdot \left(x + y\right)\right| - 0.2\right)\\
\end{array}
\end{array}
if z < -9.19999999999999958e86Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.5
Applied rewrites45.5%
Taylor expanded in z around -inf
lower-*.f6417.2
Applied rewrites17.2%
if -9.19999999999999958e86 < z Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6470.5
Applied rewrites70.5%
(FPCore (x y z) :precision binary64 (fmax (* (- 30.0 (/ 25.0 y)) y) (- (fabs (* 30.0 (+ x y))) 0.2)))
double code(double x, double y, double z) {
return fmax(((30.0 - (25.0 / y)) * y), (fabs((30.0 * (x + y))) - 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 - (25.0d0 / y)) * y), (abs((30.0d0 * (x + y))) - 0.2d0))
end function
public static double code(double x, double y, double z) {
return fmax(((30.0 - (25.0 / y)) * y), (Math.abs((30.0 * (x + y))) - 0.2));
}
def code(x, y, z): return fmax(((30.0 - (25.0 / y)) * y), (math.fabs((30.0 * (x + y))) - 0.2))
function code(x, y, z) return fmax(Float64(Float64(30.0 - Float64(25.0 / y)) * y), Float64(abs(Float64(30.0 * Float64(x + y))) - 0.2)) end
function tmp = code(x, y, z) tmp = max(((30.0 - (25.0 / y)) * y), (abs((30.0 * (x + y))) - 0.2)); end
code[x_, y_, z_] := N[Max[N[(N[(30.0 - N[(25.0 / y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Abs[N[(30.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\left(30 - \frac{25}{y}\right) \cdot y, \left|30 \cdot \left(x + y\right)\right| - 0.2\right)
\end{array}
Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in x around 0
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6470.5
Applied rewrites70.5%
(FPCore (x y z) :precision binary64 (if (<= x -2.7e+69) (fmax (* -30.0 x) (- (fabs (* (fma -4500.0 (* y y) 30.0) y)) 0.2)) (fmax (* (- 30.0 (/ 25.0 y)) y) (- (fabs (* y 30.0)) 0.2))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.7e+69) {
tmp = fmax((-30.0 * x), (fabs((fma(-4500.0, (y * y), 30.0) * y)) - 0.2));
} else {
tmp = fmax(((30.0 - (25.0 / y)) * y), (fabs((y * 30.0)) - 0.2));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -2.7e+69) tmp = fmax(Float64(-30.0 * x), Float64(abs(Float64(fma(-4500.0, Float64(y * y), 30.0) * y)) - 0.2)); else tmp = fmax(Float64(Float64(30.0 - Float64(25.0 / y)) * y), Float64(abs(Float64(y * 30.0)) - 0.2)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -2.7e+69], N[Max[N[(-30.0 * x), $MachinePrecision], N[(N[Abs[N[(N[(-4500.0 * N[(y * y), $MachinePrecision] + 30.0), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision], N[Max[N[(N[(30.0 - N[(25.0 / y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Abs[N[(y * 30.0), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{max}\left(-30 \cdot x, \left|\mathsf{fma}\left(-4500, y \cdot y, 30\right) \cdot y\right| - 0.2\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(\left(30 - \frac{25}{y}\right) \cdot y, \left|y \cdot 30\right| - 0.2\right)\\
\end{array}
\end{array}
if x < -2.6999999999999998e69Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.5
Applied rewrites45.5%
Taylor expanded in x around -inf
lower-*.f6417.4
Applied rewrites17.4%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6415.4
Applied rewrites15.4%
if -2.6999999999999998e69 < x Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in x around 0
*-commutativeN/A
lift-*.f6442.8
Applied rewrites42.8%
(FPCore (x y z) :precision binary64 (fmax (* (- 30.0 (/ 25.0 y)) y) (- (fabs (* y 30.0)) 0.2)))
double code(double x, double y, double z) {
return fmax(((30.0 - (25.0 / y)) * y), (fabs((y * 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 - (25.0d0 / y)) * y), (abs((y * 30.0d0)) - 0.2d0))
end function
public static double code(double x, double y, double z) {
return fmax(((30.0 - (25.0 / y)) * y), (Math.abs((y * 30.0)) - 0.2));
}
def code(x, y, z): return fmax(((30.0 - (25.0 / y)) * y), (math.fabs((y * 30.0)) - 0.2))
function code(x, y, z) return fmax(Float64(Float64(30.0 - Float64(25.0 / y)) * y), Float64(abs(Float64(y * 30.0)) - 0.2)) end
function tmp = code(x, y, z) tmp = max(((30.0 - (25.0 / y)) * y), (abs((y * 30.0)) - 0.2)); end
code[x_, y_, z_] := N[Max[N[(N[(30.0 - N[(25.0 / y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[Abs[N[(y * 30.0), $MachinePrecision]], $MachinePrecision] - 0.2), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{max}\left(\left(30 - \frac{25}{y}\right) \cdot y, \left|y \cdot 30\right| - 0.2\right)
\end{array}
Initial program 46.1%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6445.8
Applied rewrites45.8%
Taylor expanded in y around 0
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lift-/.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in x around 0
*-commutativeN/A
lift-*.f6442.8
Applied rewrites42.8%
herbie shell --seed 2025129
(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)))