
(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 6 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
(let* ((t_1 (fmin (fabs y) (fabs t))) (t_2 (fmax (fabs y) (fabs t))))
(*
(copysign 1.0 y)
(*
(copysign 1.0 t)
(if (<= t_2 40000000000.0)
(fma (* (- t_2) z) t_1 (* t_2 (* t_1 x)))
(* (- 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 <= 40000000000.0) {
tmp = fma((-t_2 * z), t_1, (t_2 * (t_1 * x)));
} else {
tmp = (x - z) * (t_2 * t_1);
}
return copysign(1.0, y) * (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 <= 40000000000.0) tmp = fma(Float64(Float64(-t_2) * z), t_1, Float64(t_2 * Float64(t_1 * x))); 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
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.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, 40000000000.0], N[(N[((-t$95$2) * z), $MachinePrecision] * t$95$1 + N[(t$95$2 * N[(t$95$1 * x), $MachinePrecision]), $MachinePrecision]), $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 40000000000:\\
\;\;\;\;\mathsf{fma}\left(\left(-t\_2\right) \cdot z, t\_1, t\_2 \cdot \left(t\_1 \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \left(t\_2 \cdot t\_1\right)\\
\end{array}\right)
\end{array}
if t < 4e10Initial program 90.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
add-flipN/A
distribute-lft-out--N/A
sub-flip-reverseN/A
add-flipN/A
remove-double-negN/A
distribute-rgt-neg-outN/A
distribute-lft-neg-outN/A
remove-double-negN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
Applied rewrites88.6%
if 4e10 < t Initial program 90.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.2%
Applied rewrites92.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fmin (fabs y) (fabs t))) (t_2 (fmax (fabs y) (fabs t))))
(*
(copysign 1.0 y)
(*
(copysign 1.0 t)
(if (<= t_2 2000000000.0)
(* (* (- 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 <= 2000000000.0) {
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 <= 2000000000.0) {
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 <= 2000000000.0: 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 <= 2000000000.0) 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 <= 2000000000.0) 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.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, 2000000000.0], 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 2000000000:\\
\;\;\;\;\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 < 2e9Initial program 90.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--.f6492.4%
Applied rewrites92.4%
if 2e9 < t Initial program 90.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.2%
Applied rewrites92.2%
(FPCore (x y z t) :precision binary64 (* (copysign 1.0 y) (* (copysign 1.0 t) (* (* (- x z) (fmin (fabs y) (fabs t))) (fmax (fabs y) (fabs t))))))
double code(double x, double y, double z, double t) {
return copysign(1.0, y) * (copysign(1.0, t) * (((x - z) * fmin(fabs(y), fabs(t))) * fmax(fabs(y), fabs(t))));
}
public static double code(double x, double y, double z, double t) {
return Math.copySign(1.0, y) * (Math.copySign(1.0, t) * (((x - z) * fmin(Math.abs(y), Math.abs(t))) * fmax(Math.abs(y), Math.abs(t))));
}
def code(x, y, z, t): return math.copysign(1.0, y) * (math.copysign(1.0, t) * (((x - z) * fmin(math.fabs(y), math.fabs(t))) * fmax(math.fabs(y), math.fabs(t))))
function code(x, y, z, t) return Float64(copysign(1.0, y) * Float64(copysign(1.0, t) * Float64(Float64(Float64(x - z) * fmin(abs(y), abs(t))) * fmax(abs(y), abs(t))))) end
function tmp = code(x, y, z, t) tmp = (sign(y) * abs(1.0)) * ((sign(t) * abs(1.0)) * (((x - z) * min(abs(y), abs(t))) * max(abs(y), abs(t)))); end
code[x_, y_, z_, t_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[(N[(x - z), $MachinePrecision] * N[Min[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Max[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{copysign}\left(1, y\right) \cdot \left(\mathsf{copysign}\left(1, t\right) \cdot \left(\left(\left(x - z\right) \cdot \mathsf{min}\left(\left|y\right|, \left|t\right|\right)\right) \cdot \mathsf{max}\left(\left|y\right|, \left|t\right|\right)\right)\right)
Initial program 90.7%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6492.2%
Applied rewrites92.2%
(FPCore (x y z t) :precision binary64 (if (<= x 1.22e+188) (* (* (- x z) (fmax y t)) (fmin y t)) (* (fmax y t) (* x (fmin y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.22e+188) {
tmp = ((x - z) * fmax(y, t)) * fmin(y, t);
} else {
tmp = fmax(y, t) * (x * fmin(y, t));
}
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, 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
real(8) :: tmp
if (x <= 1.22d+188) then
tmp = ((x - z) * fmax(y, t)) * fmin(y, t)
else
tmp = fmax(y, t) * (x * fmin(y, t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.22e+188) {
tmp = ((x - z) * fmax(y, t)) * fmin(y, t);
} else {
tmp = fmax(y, t) * (x * fmin(y, t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 1.22e+188: tmp = ((x - z) * fmax(y, t)) * fmin(y, t) else: tmp = fmax(y, t) * (x * fmin(y, t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 1.22e+188) tmp = Float64(Float64(Float64(x - z) * fmax(y, t)) * fmin(y, t)); else tmp = Float64(fmax(y, t) * Float64(x * fmin(y, t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 1.22e+188) tmp = ((x - z) * max(y, t)) * min(y, t); else tmp = max(y, t) * (x * min(y, t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 1.22e+188], N[(N[(N[(x - z), $MachinePrecision] * N[Max[y, t], $MachinePrecision]), $MachinePrecision] * N[Min[y, t], $MachinePrecision]), $MachinePrecision], N[(N[Max[y, t], $MachinePrecision] * N[(x * N[Min[y, t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 1.22 \cdot 10^{+188}:\\
\;\;\;\;\left(\left(x - z\right) \cdot \mathsf{max}\left(y, t\right)\right) \cdot \mathsf{min}\left(y, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{max}\left(y, t\right) \cdot \left(x \cdot \mathsf{min}\left(y, t\right)\right)\\
\end{array}
if x < 1.2199999999999999e188Initial program 90.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--.f6492.4%
Applied rewrites92.4%
if 1.2199999999999999e188 < x Initial program 90.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6453.0%
Applied rewrites53.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fmin (fabs y) (fabs t))) (t_2 (fmax (fabs y) (fabs t))))
(*
(copysign 1.0 y)
(*
(copysign 1.0 t)
(if (<= t_2 40000000000.0) (* 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 <= 40000000000.0) {
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 <= 40000000000.0) {
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 <= 40000000000.0: 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 <= 40000000000.0) 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 <= 40000000000.0) 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.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$2, 40000000000.0], 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 40000000000:\\
\;\;\;\;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 < 4e10Initial program 90.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6453.0%
Applied rewrites53.0%
if 4e10 < t Initial program 90.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6453.0%
Applied rewrites53.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6454.2%
Applied rewrites54.2%
(FPCore (x y z t) :precision binary64 (* (copysign 1.0 y) (* (copysign 1.0 t) (* (fmax (fabs y) (fabs t)) (* x (fmin (fabs y) (fabs t)))))))
double code(double x, double y, double z, double t) {
return copysign(1.0, y) * (copysign(1.0, t) * (fmax(fabs(y), fabs(t)) * (x * fmin(fabs(y), fabs(t)))));
}
public static double code(double x, double y, double z, double t) {
return Math.copySign(1.0, y) * (Math.copySign(1.0, t) * (fmax(Math.abs(y), Math.abs(t)) * (x * fmin(Math.abs(y), Math.abs(t)))));
}
def code(x, y, z, t): return math.copysign(1.0, y) * (math.copysign(1.0, t) * (fmax(math.fabs(y), math.fabs(t)) * (x * fmin(math.fabs(y), math.fabs(t)))))
function code(x, y, z, t) return Float64(copysign(1.0, y) * Float64(copysign(1.0, t) * Float64(fmax(abs(y), abs(t)) * Float64(x * fmin(abs(y), abs(t)))))) end
function tmp = code(x, y, z, t) tmp = (sign(y) * abs(1.0)) * ((sign(t) * abs(1.0)) * (max(abs(y), abs(t)) * (x * min(abs(y), abs(t))))); end
code[x_, y_, z_, t_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[Max[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision] * N[(x * N[Min[N[Abs[y], $MachinePrecision], N[Abs[t], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{copysign}\left(1, y\right) \cdot \left(\mathsf{copysign}\left(1, t\right) \cdot \left(\mathsf{max}\left(\left|y\right|, \left|t\right|\right) \cdot \left(x \cdot \mathsf{min}\left(\left|y\right|, \left|t\right|\right)\right)\right)\right)
Initial program 90.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6453.0%
Applied rewrites53.0%
herbie shell --seed 2025205
(FPCore (x y z t)
:name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
:precision binary64
(* (- (* x y) (* z y)) t))