
(FPCore (x y z) :precision binary64 (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
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 = (((x * y) + (z * z)) + (z * z)) + (z * z)
end function
public static double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(z * z)) + Float64(z * z)) + Float64(z * z)) end
function tmp = code(x, y, z) tmp = (((x * y) + (z * z)) + (z * z)) + (z * z); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))
double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
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 = (((x * y) + (z * z)) + (z * z)) + (z * z)
end function
public static double code(double x, double y, double z) {
return (((x * y) + (z * z)) + (z * z)) + (z * z);
}
def code(x, y, z): return (((x * y) + (z * z)) + (z * z)) + (z * z)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * y) + Float64(z * z)) + Float64(z * z)) + Float64(z * z)) end
function tmp = code(x, y, z) tmp = (((x * y) + (z * z)) + (z * z)) + (z * z); end
code[x_, y_, z_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision] + N[(z * z), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
(FPCore (x y z)
:precision binary64
(if (<=
(fabs z)
750000000000000046317730608011206303798377969171117713347427225006633117657190568815604258930892461708979279798889728404095828371632160411314266126155776)
(+
(+ (* (fabs z) (fabs z)) (* y x))
(* (+ (fabs z) (fabs z)) (fabs z)))
(* (- x (* (* (/ (fabs z) y) (fabs z)) -3)) y)))double code(double x, double y, double z) {
double tmp;
if (fabs(z) <= 7.5e+152) {
tmp = ((fabs(z) * fabs(z)) + (y * x)) + ((fabs(z) + fabs(z)) * fabs(z));
} else {
tmp = (x - (((fabs(z) / y) * fabs(z)) * -3.0)) * y;
}
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 (abs(z) <= 7.5d+152) then
tmp = ((abs(z) * abs(z)) + (y * x)) + ((abs(z) + abs(z)) * abs(z))
else
tmp = (x - (((abs(z) / y) * abs(z)) * (-3.0d0))) * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs(z) <= 7.5e+152) {
tmp = ((Math.abs(z) * Math.abs(z)) + (y * x)) + ((Math.abs(z) + Math.abs(z)) * Math.abs(z));
} else {
tmp = (x - (((Math.abs(z) / y) * Math.abs(z)) * -3.0)) * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if math.fabs(z) <= 7.5e+152: tmp = ((math.fabs(z) * math.fabs(z)) + (y * x)) + ((math.fabs(z) + math.fabs(z)) * math.fabs(z)) else: tmp = (x - (((math.fabs(z) / y) * math.fabs(z)) * -3.0)) * y return tmp
function code(x, y, z) tmp = 0.0 if (abs(z) <= 7.5e+152) tmp = Float64(Float64(Float64(abs(z) * abs(z)) + Float64(y * x)) + Float64(Float64(abs(z) + abs(z)) * abs(z))); else tmp = Float64(Float64(x - Float64(Float64(Float64(abs(z) / y) * abs(z)) * -3.0)) * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs(z) <= 7.5e+152) tmp = ((abs(z) * abs(z)) + (y * x)) + ((abs(z) + abs(z)) * abs(z)); else tmp = (x - (((abs(z) / y) * abs(z)) * -3.0)) * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[Abs[z], $MachinePrecision], 750000000000000046317730608011206303798377969171117713347427225006633117657190568815604258930892461708979279798889728404095828371632160411314266126155776], N[(N[(N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Abs[z], $MachinePrecision] + N[Abs[z], $MachinePrecision]), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - N[(N[(N[(N[Abs[z], $MachinePrecision] / y), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision] * -3), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 750000000000000046317730608011206303798377969171117713347427225006633117657190568815604258930892461708979279798889728404095828371632160411314266126155776:\\
\;\;\;\;\left(\left|z\right| \cdot \left|z\right| + y \cdot x\right) + \left(\left|z\right| + \left|z\right|\right) \cdot \left|z\right|\\
\mathbf{else}:\\
\;\;\;\;\left(x - \left(\frac{\left|z\right|}{y} \cdot \left|z\right|\right) \cdot -3\right) \cdot y\\
\end{array}
if z < 7.5000000000000005e152Initial program 98.2%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lift-*.f64N/A
associate-*r*N/A
count-2N/A
lower-*.f64N/A
lower-+.f6498.2%
Applied rewrites98.2%
if 7.5000000000000005e152 < z Initial program 98.2%
Taylor expanded in y around inf
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-/.f64N/A
lower-pow.f6493.7%
Applied rewrites93.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6493.7%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6493.7%
lift-+.f64N/A
lift-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f6493.7%
lift-pow.f64N/A
pow2N/A
lift-*.f6493.7%
Applied rewrites93.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft1-inN/A
lift-*.f64N/A
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-+.f64N/A
lift-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
*-commutativeN/A
Applied rewrites94.3%
(FPCore (x y z)
:precision binary64
(if (<=
(fabs z)
20999999999999999892825751366275165687698317249138536736081263792459064345632643659636974437008550542481857618056144623311682081501011268411332755456)
(+
(+ (* (fabs z) (fabs z)) (* y x))
(* (+ (fabs z) (fabs z)) (fabs z)))
(* (* 3 (fabs z)) (fabs z))))double code(double x, double y, double z) {
double tmp;
if (fabs(z) <= 2.1e+148) {
tmp = ((fabs(z) * fabs(z)) + (y * x)) + ((fabs(z) + fabs(z)) * fabs(z));
} else {
tmp = (3.0 * fabs(z)) * fabs(z);
}
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 (abs(z) <= 2.1d+148) then
tmp = ((abs(z) * abs(z)) + (y * x)) + ((abs(z) + abs(z)) * abs(z))
else
tmp = (3.0d0 * abs(z)) * abs(z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs(z) <= 2.1e+148) {
tmp = ((Math.abs(z) * Math.abs(z)) + (y * x)) + ((Math.abs(z) + Math.abs(z)) * Math.abs(z));
} else {
tmp = (3.0 * Math.abs(z)) * Math.abs(z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if math.fabs(z) <= 2.1e+148: tmp = ((math.fabs(z) * math.fabs(z)) + (y * x)) + ((math.fabs(z) + math.fabs(z)) * math.fabs(z)) else: tmp = (3.0 * math.fabs(z)) * math.fabs(z) return tmp
function code(x, y, z) tmp = 0.0 if (abs(z) <= 2.1e+148) tmp = Float64(Float64(Float64(abs(z) * abs(z)) + Float64(y * x)) + Float64(Float64(abs(z) + abs(z)) * abs(z))); else tmp = Float64(Float64(3.0 * abs(z)) * abs(z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs(z) <= 2.1e+148) tmp = ((abs(z) * abs(z)) + (y * x)) + ((abs(z) + abs(z)) * abs(z)); else tmp = (3.0 * abs(z)) * abs(z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[Abs[z], $MachinePrecision], 20999999999999999892825751366275165687698317249138536736081263792459064345632643659636974437008550542481857618056144623311682081501011268411332755456], N[(N[(N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Abs[z], $MachinePrecision] + N[Abs[z], $MachinePrecision]), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3 * N[Abs[z], $MachinePrecision]), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 20999999999999999892825751366275165687698317249138536736081263792459064345632643659636974437008550542481857618056144623311682081501011268411332755456:\\
\;\;\;\;\left(\left|z\right| \cdot \left|z\right| + y \cdot x\right) + \left(\left|z\right| + \left|z\right|\right) \cdot \left|z\right|\\
\mathbf{else}:\\
\;\;\;\;\left(3 \cdot \left|z\right|\right) \cdot \left|z\right|\\
\end{array}
if z < 2.1e148Initial program 98.2%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lower-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
count-2N/A
lift-*.f64N/A
associate-*r*N/A
count-2N/A
lower-*.f64N/A
lower-+.f6498.2%
Applied rewrites98.2%
if 2.1e148 < z Initial program 98.2%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f6453.0%
Applied rewrites53.0%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6453.0%
Applied rewrites53.0%
(FPCore (x y z)
:precision binary64
(if (<=
(fabs z)
230000000000000002604955994574365275989893223205958458682329976627914510867816641310114444373426724732403712)
(- (* y x) (* (* -3 (fabs z)) (fabs z)))
(* (* (fabs z) (fabs z)) 3)))double code(double x, double y, double z) {
double tmp;
if (fabs(z) <= 2.3e+107) {
tmp = (y * x) - ((-3.0 * fabs(z)) * fabs(z));
} else {
tmp = (fabs(z) * fabs(z)) * 3.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) :: tmp
if (abs(z) <= 2.3d+107) then
tmp = (y * x) - (((-3.0d0) * abs(z)) * abs(z))
else
tmp = (abs(z) * abs(z)) * 3.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs(z) <= 2.3e+107) {
tmp = (y * x) - ((-3.0 * Math.abs(z)) * Math.abs(z));
} else {
tmp = (Math.abs(z) * Math.abs(z)) * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if math.fabs(z) <= 2.3e+107: tmp = (y * x) - ((-3.0 * math.fabs(z)) * math.fabs(z)) else: tmp = (math.fabs(z) * math.fabs(z)) * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (abs(z) <= 2.3e+107) tmp = Float64(Float64(y * x) - Float64(Float64(-3.0 * abs(z)) * abs(z))); else tmp = Float64(Float64(abs(z) * abs(z)) * 3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs(z) <= 2.3e+107) tmp = (y * x) - ((-3.0 * abs(z)) * abs(z)); else tmp = (abs(z) * abs(z)) * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[Abs[z], $MachinePrecision], 230000000000000002604955994574365275989893223205958458682329976627914510867816641310114444373426724732403712], N[(N[(y * x), $MachinePrecision] - N[(N[(-3 * N[Abs[z], $MachinePrecision]), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision] * 3), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 230000000000000002604955994574365275989893223205958458682329976627914510867816641310114444373426724732403712:\\
\;\;\;\;y \cdot x - \left(-3 \cdot \left|z\right|\right) \cdot \left|z\right|\\
\mathbf{else}:\\
\;\;\;\;\left(\left|z\right| \cdot \left|z\right|\right) \cdot 3\\
\end{array}
if z < 2.3e107Initial program 98.2%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
associate-+l-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negate-revN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
count-2N/A
distribute-lft1-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval98.2%
Applied rewrites98.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.3%
Applied rewrites98.3%
if 2.3e107 < z Initial program 98.2%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f6453.0%
Applied rewrites53.0%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6453.0%
Applied rewrites53.0%
(FPCore (x y z)
:precision binary64
(if (<=
(fabs z)
20999999999999999892825751366275165687698317249138536736081263792459064345632643659636974437008550542481857618056144623311682081501011268411332755456)
(- (* y x) (* -3 (* (fabs z) (fabs z))))
(* (* 3 (fabs z)) (fabs z))))double code(double x, double y, double z) {
double tmp;
if (fabs(z) <= 2.1e+148) {
tmp = (y * x) - (-3.0 * (fabs(z) * fabs(z)));
} else {
tmp = (3.0 * fabs(z)) * fabs(z);
}
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 (abs(z) <= 2.1d+148) then
tmp = (y * x) - ((-3.0d0) * (abs(z) * abs(z)))
else
tmp = (3.0d0 * abs(z)) * abs(z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs(z) <= 2.1e+148) {
tmp = (y * x) - (-3.0 * (Math.abs(z) * Math.abs(z)));
} else {
tmp = (3.0 * Math.abs(z)) * Math.abs(z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if math.fabs(z) <= 2.1e+148: tmp = (y * x) - (-3.0 * (math.fabs(z) * math.fabs(z))) else: tmp = (3.0 * math.fabs(z)) * math.fabs(z) return tmp
function code(x, y, z) tmp = 0.0 if (abs(z) <= 2.1e+148) tmp = Float64(Float64(y * x) - Float64(-3.0 * Float64(abs(z) * abs(z)))); else tmp = Float64(Float64(3.0 * abs(z)) * abs(z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs(z) <= 2.1e+148) tmp = (y * x) - (-3.0 * (abs(z) * abs(z))); else tmp = (3.0 * abs(z)) * abs(z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[Abs[z], $MachinePrecision], 20999999999999999892825751366275165687698317249138536736081263792459064345632643659636974437008550542481857618056144623311682081501011268411332755456], N[(N[(y * x), $MachinePrecision] - N[(-3 * N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3 * N[Abs[z], $MachinePrecision]), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 20999999999999999892825751366275165687698317249138536736081263792459064345632643659636974437008550542481857618056144623311682081501011268411332755456:\\
\;\;\;\;y \cdot x - -3 \cdot \left(\left|z\right| \cdot \left|z\right|\right)\\
\mathbf{else}:\\
\;\;\;\;\left(3 \cdot \left|z\right|\right) \cdot \left|z\right|\\
\end{array}
if z < 2.1e148Initial program 98.2%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
associate-+l-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negate-revN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
count-2N/A
distribute-lft1-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval98.2%
Applied rewrites98.2%
if 2.1e148 < z Initial program 98.2%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f6453.0%
Applied rewrites53.0%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6453.0%
Applied rewrites53.0%
(FPCore (x y z) :precision binary64 (if (<= (fabs z) 4000) (* x y) (* (* (fabs z) (fabs z)) 3)))
double code(double x, double y, double z) {
double tmp;
if (fabs(z) <= 4000.0) {
tmp = x * y;
} else {
tmp = (fabs(z) * fabs(z)) * 3.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) :: tmp
if (abs(z) <= 4000.0d0) then
tmp = x * y
else
tmp = (abs(z) * abs(z)) * 3.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs(z) <= 4000.0) {
tmp = x * y;
} else {
tmp = (Math.abs(z) * Math.abs(z)) * 3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if math.fabs(z) <= 4000.0: tmp = x * y else: tmp = (math.fabs(z) * math.fabs(z)) * 3.0 return tmp
function code(x, y, z) tmp = 0.0 if (abs(z) <= 4000.0) tmp = Float64(x * y); else tmp = Float64(Float64(abs(z) * abs(z)) * 3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs(z) <= 4000.0) tmp = x * y; else tmp = (abs(z) * abs(z)) * 3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[Abs[z], $MachinePrecision], 4000], N[(x * y), $MachinePrecision], N[(N[(N[Abs[z], $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision] * 3), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 4000:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(\left|z\right| \cdot \left|z\right|\right) \cdot 3\\
\end{array}
if z < 4e3Initial program 98.2%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
associate-+l-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negate-revN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
count-2N/A
distribute-lft1-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval98.2%
Applied rewrites98.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.3%
Applied rewrites98.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6493.5%
Applied rewrites93.5%
Taylor expanded in x around inf
Applied rewrites53.3%
if 4e3 < z Initial program 98.2%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f6453.0%
Applied rewrites53.0%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6453.0%
Applied rewrites53.0%
(FPCore (x y z) :precision binary64 (if (<= (fabs z) 4000) (* x y) (* (* 3 (fabs z)) (fabs z))))
double code(double x, double y, double z) {
double tmp;
if (fabs(z) <= 4000.0) {
tmp = x * y;
} else {
tmp = (3.0 * fabs(z)) * fabs(z);
}
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 (abs(z) <= 4000.0d0) then
tmp = x * y
else
tmp = (3.0d0 * abs(z)) * abs(z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (Math.abs(z) <= 4000.0) {
tmp = x * y;
} else {
tmp = (3.0 * Math.abs(z)) * Math.abs(z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if math.fabs(z) <= 4000.0: tmp = x * y else: tmp = (3.0 * math.fabs(z)) * math.fabs(z) return tmp
function code(x, y, z) tmp = 0.0 if (abs(z) <= 4000.0) tmp = Float64(x * y); else tmp = Float64(Float64(3.0 * abs(z)) * abs(z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (abs(z) <= 4000.0) tmp = x * y; else tmp = (3.0 * abs(z)) * abs(z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[Abs[z], $MachinePrecision], 4000], N[(x * y), $MachinePrecision], N[(N[(3 * N[Abs[z], $MachinePrecision]), $MachinePrecision] * N[Abs[z], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|z\right| \leq 4000:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;\left(3 \cdot \left|z\right|\right) \cdot \left|z\right|\\
\end{array}
if z < 4e3Initial program 98.2%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
associate-+l-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negate-revN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
count-2N/A
distribute-lft1-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval98.2%
Applied rewrites98.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.3%
Applied rewrites98.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6493.5%
Applied rewrites93.5%
Taylor expanded in x around inf
Applied rewrites53.3%
if 4e3 < z Initial program 98.2%
Taylor expanded in z around inf
lower-*.f64N/A
lower-pow.f6453.0%
Applied rewrites53.0%
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6453.0%
Applied rewrites53.0%
(FPCore (x y z) :precision binary64 (* x y))
double code(double x, double y, double z) {
return x * y;
}
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 = x * y
end function
public static double code(double x, double y, double z) {
return x * y;
}
def code(x, y, z): return x * y
function code(x, y, z) return Float64(x * y) end
function tmp = code(x, y, z) tmp = x * y; end
code[x_, y_, z_] := N[(x * y), $MachinePrecision]
x \cdot y
Initial program 98.2%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
associate-+l-N/A
lower--.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negate-revN/A
fp-cancel-sign-sub-invN/A
lift-*.f64N/A
count-2N/A
distribute-lft1-inN/A
metadata-evalN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval98.2%
Applied rewrites98.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6498.3%
Applied rewrites98.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f6493.5%
Applied rewrites93.5%
Taylor expanded in x around inf
Applied rewrites53.3%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y z)
:name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"
:precision binary64
(+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))