
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * y) - (z * y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\left(x \cdot y - z \cdot y\right) \cdot t
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * y) - (z * y)) * t
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
\left(x \cdot y - z \cdot y\right) \cdot t
(FPCore (x y z t) :precision binary64 (134-z0z1z2z3z4 y x t z t))
\mathsf{134\_z0z1z2z3z4}\left(y, x, t, z, t\right)
Initial program 89.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-out--N/A
sub-flip-reverseN/A
distribute-rgt-neg-outN/A
distribute-lft-inN/A
sub-flipN/A
distribute-rgt-out--N/A
lower-134-z0z1z2z3z4100.0%
Applied rewrites100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fmin (fabs y) (fabs t)))
(t_2 (fmax (fabs y) (fabs t)))
(t_3 (* (* (- x z) t_1) t_2))
(t_4 (* (- (* x t_1) (* z t_1)) t_2)))
(*
(copysign 1 y)
(*
(copysign 1 t)
(if (<=
t_4
-6090821257124999/609082125712499942522086399242199269429764178599687970429244153575809293172901631404100941617625641201581557264463041761466198116575193377911124206019540838720704856247279564366924353468128353022049974592451148679605349870337179684109147725966810350801733675194017346692614286874494631936)
t_3
(if (<=
t_4
554533938824163/2772669694120814859578414184143083703436437075375816575170479580614621307805625623039974406104139578097391210961403571828974157824)
(* (* (- x z) t_2) t_1)
t_3))))))double code(double x, double y, double z, double t) {
double t_1 = fmin(fabs(y), fabs(t));
double t_2 = fmax(fabs(y), fabs(t));
double t_3 = ((x - z) * t_1) * t_2;
double t_4 = ((x * t_1) - (z * t_1)) * t_2;
double tmp;
if (t_4 <= -1e-272) {
tmp = t_3;
} else if (t_4 <= 2e-115) {
tmp = ((x - z) * t_2) * t_1;
} else {
tmp = t_3;
}
return copysign(1.0, y) * (copysign(1.0, t) * tmp);
}
public static double code(double x, double y, double z, double t) {
double t_1 = fmin(Math.abs(y), Math.abs(t));
double t_2 = fmax(Math.abs(y), Math.abs(t));
double t_3 = ((x - z) * t_1) * t_2;
double t_4 = ((x * t_1) - (z * t_1)) * t_2;
double tmp;
if (t_4 <= -1e-272) {
tmp = t_3;
} else if (t_4 <= 2e-115) {
tmp = ((x - z) * t_2) * t_1;
} else {
tmp = t_3;
}
return Math.copySign(1.0, y) * (Math.copySign(1.0, t) * tmp);
}
def code(x, y, z, t): t_1 = fmin(math.fabs(y), math.fabs(t)) t_2 = fmax(math.fabs(y), math.fabs(t)) t_3 = ((x - z) * t_1) * t_2 t_4 = ((x * t_1) - (z * t_1)) * t_2 tmp = 0 if t_4 <= -1e-272: tmp = t_3 elif t_4 <= 2e-115: tmp = ((x - z) * t_2) * t_1 else: tmp = t_3 return math.copysign(1.0, y) * (math.copysign(1.0, t) * tmp)
function code(x, y, z, t) t_1 = fmin(abs(y), abs(t)) t_2 = fmax(abs(y), abs(t)) t_3 = Float64(Float64(Float64(x - z) * t_1) * t_2) t_4 = Float64(Float64(Float64(x * t_1) - Float64(z * t_1)) * t_2) tmp = 0.0 if (t_4 <= -1e-272) tmp = t_3; elseif (t_4 <= 2e-115) tmp = Float64(Float64(Float64(x - z) * t_2) * t_1); else tmp = t_3; end return Float64(copysign(1.0, y) * Float64(copysign(1.0, t) * tmp)) end
function tmp_2 = code(x, y, z, t) t_1 = min(abs(y), abs(t)); t_2 = max(abs(y), abs(t)); t_3 = ((x - z) * t_1) * t_2; t_4 = ((x * t_1) - (z * t_1)) * t_2; tmp = 0.0; if (t_4 <= -1e-272) tmp = t_3; elseif (t_4 <= 2e-115) tmp = ((x - z) * t_2) * t_1; else tmp = t_3; end tmp_2 = (sign(y) * abs(1.0)) * ((sign(t) * abs(1.0)) * tmp); end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Min[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(x - z), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(x * t$95$1), $MachinePrecision] - N[(z * t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$4, -6090821257124999/609082125712499942522086399242199269429764178599687970429244153575809293172901631404100941617625641201581557264463041761466198116575193377911124206019540838720704856247279564366924353468128353022049974592451148679605349870337179684109147725966810350801733675194017346692614286874494631936], t$95$3, If[LessEqual[t$95$4, 554533938824163/2772669694120814859578414184143083703436437075375816575170479580614621307805625623039974406104139578097391210961403571828974157824], N[(N[(N[(x - z), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision], t$95$3]]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_1 := \mathsf{min}\left(\left|y\right|, \left|t\right|\right)\\
t_2 := \mathsf{max}\left(\left|y\right|, \left|t\right|\right)\\
t_3 := \left(\left(x - z\right) \cdot t\_1\right) \cdot t\_2\\
t_4 := \left(x \cdot t\_1 - z \cdot t\_1\right) \cdot t\_2\\
\mathsf{copysign}\left(1, y\right) \cdot \left(\mathsf{copysign}\left(1, t\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_4 \leq \frac{-6090821257124999}{609082125712499942522086399242199269429764178599687970429244153575809293172901631404100941617625641201581557264463041761466198116575193377911124206019540838720704856247279564366924353468128353022049974592451148679605349870337179684109147725966810350801733675194017346692614286874494631936}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_4 \leq \frac{554533938824163}{2772669694120814859578414184143083703436437075375816575170479580614621307805625623039974406104139578097391210961403571828974157824}:\\
\;\;\;\;\left(\left(x - z\right) \cdot t\_2\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}\right)
\end{array}
if (*.f64 (-.f64 (*.f64 x y) (*.f64 z y)) t) < -9.9999999999999993e-273 or 2.0000000000000001e-115 < (*.f64 (-.f64 (*.f64 x y) (*.f64 z y)) t) Initial program 89.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.7%
Applied rewrites91.7%
if -9.9999999999999993e-273 < (*.f64 (-.f64 (*.f64 x y) (*.f64 z y)) t) < 2.0000000000000001e-115Initial program 89.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6491.7%
Applied rewrites91.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fmin (fabs y) (fabs t))) (t_2 (fmax (fabs y) (fabs t))))
(*
(copysign 1 y)
(*
(copysign 1 t)
(if (<=
t_2
7423025276069149/11972621413014756705924586149611790497021399392059392)
(* (- (* x t_1) (* z t_1)) t_2)
(* (- x z) (* t_2 t_1)))))))double code(double x, double y, double z, double t) {
double t_1 = fmin(fabs(y), fabs(t));
double t_2 = fmax(fabs(y), fabs(t));
double tmp;
if (t_2 <= 6.2e-37) {
tmp = ((x * t_1) - (z * t_1)) * t_2;
} else {
tmp = (x - z) * (t_2 * t_1);
}
return copysign(1.0, y) * (copysign(1.0, t) * tmp);
}
public static double code(double x, double y, double z, double t) {
double t_1 = fmin(Math.abs(y), Math.abs(t));
double t_2 = fmax(Math.abs(y), Math.abs(t));
double tmp;
if (t_2 <= 6.2e-37) {
tmp = ((x * t_1) - (z * t_1)) * t_2;
} else {
tmp = (x - z) * (t_2 * t_1);
}
return Math.copySign(1.0, y) * (Math.copySign(1.0, t) * tmp);
}
def code(x, y, z, t): t_1 = fmin(math.fabs(y), math.fabs(t)) t_2 = fmax(math.fabs(y), math.fabs(t)) tmp = 0 if t_2 <= 6.2e-37: tmp = ((x * t_1) - (z * t_1)) * t_2 else: tmp = (x - z) * (t_2 * t_1) return math.copysign(1.0, y) * (math.copysign(1.0, t) * tmp)
function code(x, y, z, t) t_1 = fmin(abs(y), abs(t)) t_2 = fmax(abs(y), abs(t)) tmp = 0.0 if (t_2 <= 6.2e-37) tmp = Float64(Float64(Float64(x * t_1) - Float64(z * t_1)) * t_2); else tmp = Float64(Float64(x - z) * Float64(t_2 * t_1)); end return Float64(copysign(1.0, y) * Float64(copysign(1.0, t) * tmp)) end
function tmp_2 = code(x, y, z, t) t_1 = min(abs(y), abs(t)); t_2 = max(abs(y), abs(t)); tmp = 0.0; if (t_2 <= 6.2e-37) tmp = ((x * t_1) - (z * t_1)) * t_2; else tmp = (x - z) * (t_2 * t_1); end tmp_2 = (sign(y) * abs(1.0)) * ((sign(t) * abs(1.0)) * tmp); end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Min[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, 7423025276069149/11972621413014756705924586149611790497021399392059392], N[(N[(N[(x * t$95$1), $MachinePrecision] - N[(z * t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \mathsf{min}\left(\left|y\right|, \left|t\right|\right)\\
t_2 := \mathsf{max}\left(\left|y\right|, \left|t\right|\right)\\
\mathsf{copysign}\left(1, y\right) \cdot \left(\mathsf{copysign}\left(1, t\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq \frac{7423025276069149}{11972621413014756705924586149611790497021399392059392}:\\
\;\;\;\;\left(x \cdot t\_1 - z \cdot t\_1\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \left(t\_2 \cdot t\_1\right)\\
\end{array}\right)
\end{array}
if t < 6.1999999999999999e-37Initial program 89.7%
if 6.1999999999999999e-37 < t Initial program 89.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6492.1%
Applied rewrites92.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fmin (fabs y) (fabs t))) (t_2 (fmax (fabs y) (fabs t))))
(*
(copysign 1 y)
(*
(copysign 1 t)
(if (<=
t_2
2993155353253689/5986310706507378352962293074805895248510699696029696)
(* (* (- x z) t_2) t_1)
(* (- x z) (* t_2 t_1)))))))double code(double x, double y, double z, double t) {
double t_1 = fmin(fabs(y), fabs(t));
double t_2 = fmax(fabs(y), fabs(t));
double tmp;
if (t_2 <= 5e-37) {
tmp = ((x - z) * t_2) * t_1;
} else {
tmp = (x - z) * (t_2 * t_1);
}
return copysign(1.0, y) * (copysign(1.0, t) * tmp);
}
public static double code(double x, double y, double z, double t) {
double t_1 = fmin(Math.abs(y), Math.abs(t));
double t_2 = fmax(Math.abs(y), Math.abs(t));
double tmp;
if (t_2 <= 5e-37) {
tmp = ((x - z) * t_2) * t_1;
} else {
tmp = (x - z) * (t_2 * t_1);
}
return Math.copySign(1.0, y) * (Math.copySign(1.0, t) * tmp);
}
def code(x, y, z, t): t_1 = fmin(math.fabs(y), math.fabs(t)) t_2 = fmax(math.fabs(y), math.fabs(t)) tmp = 0 if t_2 <= 5e-37: tmp = ((x - z) * t_2) * t_1 else: tmp = (x - z) * (t_2 * t_1) return math.copysign(1.0, y) * (math.copysign(1.0, t) * tmp)
function code(x, y, z, t) t_1 = fmin(abs(y), abs(t)) t_2 = fmax(abs(y), abs(t)) tmp = 0.0 if (t_2 <= 5e-37) tmp = Float64(Float64(Float64(x - z) * t_2) * t_1); else tmp = Float64(Float64(x - z) * Float64(t_2 * t_1)); end return Float64(copysign(1.0, y) * Float64(copysign(1.0, t) * tmp)) end
function tmp_2 = code(x, y, z, t) t_1 = min(abs(y), abs(t)); t_2 = max(abs(y), abs(t)); tmp = 0.0; if (t_2 <= 5e-37) tmp = ((x - z) * t_2) * t_1; else tmp = (x - z) * (t_2 * t_1); end tmp_2 = (sign(y) * abs(1.0)) * ((sign(t) * abs(1.0)) * tmp); end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Min[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, 2993155353253689/5986310706507378352962293074805895248510699696029696], N[(N[(N[(x - z), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \mathsf{min}\left(\left|y\right|, \left|t\right|\right)\\
t_2 := \mathsf{max}\left(\left|y\right|, \left|t\right|\right)\\
\mathsf{copysign}\left(1, y\right) \cdot \left(\mathsf{copysign}\left(1, t\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq \frac{2993155353253689}{5986310706507378352962293074805895248510699696029696}:\\
\;\;\;\;\left(\left(x - z\right) \cdot t\_2\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \left(t\_2 \cdot t\_1\right)\\
\end{array}\right)
\end{array}
if t < 4.9999999999999997e-37Initial program 89.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6491.7%
Applied rewrites91.7%
if 4.9999999999999997e-37 < t Initial program 89.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6492.1%
Applied rewrites92.1%
(FPCore (x y z t) :precision binary64 (* (* (- x z) t) y))
double code(double x, double y, double z, double t) {
return ((x - z) * t) * 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, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x - z) * t) * y
end function
public static double code(double x, double y, double z, double t) {
return ((x - z) * t) * y;
}
def code(x, y, z, t): return ((x - z) * t) * y
function code(x, y, z, t) return Float64(Float64(Float64(x - z) * t) * y) end
function tmp = code(x, y, z, t) tmp = ((x - z) * t) * y; end
code[x_, y_, z_, t_] := N[(N[(N[(x - z), $MachinePrecision] * t), $MachinePrecision] * y), $MachinePrecision]
\left(\left(x - z\right) \cdot t\right) \cdot y
Initial program 89.7%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6491.7%
Applied rewrites91.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fmin (fabs y) (fabs t))) (t_2 (fmax (fabs y) (fabs t))))
(*
(copysign 1 y)
(*
(copysign 1 t)
(if (<=
t_2
1915619426082361/95780971304118053647396689196894323976171195136475136)
(* t_2 (* x t_1))
(* (* t_2 t_1) x))))))double code(double x, double y, double z, double t) {
double t_1 = fmin(fabs(y), fabs(t));
double t_2 = fmax(fabs(y), fabs(t));
double tmp;
if (t_2 <= 2e-38) {
tmp = t_2 * (x * t_1);
} else {
tmp = (t_2 * t_1) * x;
}
return copysign(1.0, y) * (copysign(1.0, t) * tmp);
}
public static double code(double x, double y, double z, double t) {
double t_1 = fmin(Math.abs(y), Math.abs(t));
double t_2 = fmax(Math.abs(y), Math.abs(t));
double tmp;
if (t_2 <= 2e-38) {
tmp = t_2 * (x * t_1);
} else {
tmp = (t_2 * t_1) * x;
}
return Math.copySign(1.0, y) * (Math.copySign(1.0, t) * tmp);
}
def code(x, y, z, t): t_1 = fmin(math.fabs(y), math.fabs(t)) t_2 = fmax(math.fabs(y), math.fabs(t)) tmp = 0 if t_2 <= 2e-38: tmp = t_2 * (x * t_1) else: tmp = (t_2 * t_1) * x return math.copysign(1.0, y) * (math.copysign(1.0, t) * tmp)
function code(x, y, z, t) t_1 = fmin(abs(y), abs(t)) t_2 = fmax(abs(y), abs(t)) tmp = 0.0 if (t_2 <= 2e-38) tmp = Float64(t_2 * Float64(x * t_1)); else tmp = Float64(Float64(t_2 * t_1) * x); end return Float64(copysign(1.0, y) * Float64(copysign(1.0, t) * tmp)) end
function tmp_2 = code(x, y, z, t) t_1 = min(abs(y), abs(t)); t_2 = max(abs(y), abs(t)); tmp = 0.0; if (t_2 <= 2e-38) tmp = t_2 * (x * t_1); else tmp = (t_2 * t_1) * x; end tmp_2 = (sign(y) * abs(1.0)) * ((sign(t) * abs(1.0)) * tmp); end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Min[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, 1915619426082361/95780971304118053647396689196894323976171195136475136], N[(t$95$2 * N[(x * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 * t$95$1), $MachinePrecision] * x), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_1 := \mathsf{min}\left(\left|y\right|, \left|t\right|\right)\\
t_2 := \mathsf{max}\left(\left|y\right|, \left|t\right|\right)\\
\mathsf{copysign}\left(1, y\right) \cdot \left(\mathsf{copysign}\left(1, t\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_2 \leq \frac{1915619426082361}{95780971304118053647396689196894323976171195136475136}:\\
\;\;\;\;t\_2 \cdot \left(x \cdot t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 \cdot t\_1\right) \cdot x\\
\end{array}\right)
\end{array}
if t < 1.9999999999999999e-38Initial program 89.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6453.4%
Applied rewrites53.4%
if 1.9999999999999999e-38 < t Initial program 89.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6453.4%
Applied rewrites53.4%
lift-*.f64N/A
remove-double-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-outN/A
associate-*r*N/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-outN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lift-*.f6455.0%
Applied rewrites55.0%
(FPCore (x y z t) :precision binary64 (* (copysign 1 t) (* (fmax y (fabs t)) (* x (fmin y (fabs t))))))
double code(double x, double y, double z, double t) {
return copysign(1.0, t) * (fmax(y, fabs(t)) * (x * fmin(y, fabs(t))));
}
public static double code(double x, double y, double z, double t) {
return Math.copySign(1.0, t) * (fmax(y, Math.abs(t)) * (x * fmin(y, Math.abs(t))));
}
def code(x, y, z, t): return math.copysign(1.0, t) * (fmax(y, math.fabs(t)) * (x * fmin(y, math.fabs(t))))
function code(x, y, z, t) return Float64(copysign(1.0, t) * Float64(fmax(y, abs(t)) * Float64(x * fmin(y, abs(t))))) end
function tmp = code(x, y, z, t) tmp = (sign(t) * abs(1.0)) * (max(y, abs(t)) * (x * min(y, abs(t)))); end
code[x_, y_, z_, t_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[Max[y, N[Abs[t], $MachinePrecision]], $MachinePrecision] * N[(x * N[Min[y, N[Abs[t], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{copysign}\left(1, t\right) \cdot \left(\mathsf{max}\left(y, \left|t\right|\right) \cdot \left(x \cdot \mathsf{min}\left(y, \left|t\right|\right)\right)\right)
Initial program 89.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6453.4%
Applied rewrites53.4%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y z t)
:name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
:precision binary64
(* (- (* x y) (* z y)) t))