
(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]
\begin{array}{l}
\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}
Herbie found 4 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]
\begin{array}{l}
\\
\left(x \cdot y - z \cdot y\right) \cdot t
\end{array}
y_m = (fabs.f64 y) t_m = (fabs.f64 t) NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. (FPCore (x y_m z t_m) :precision binary64 (if (<= (- (* x y_m) (* z y_m)) -4e+272) (* (* (* (+ z x) (- x z)) (/ t_m z)) y_m) (* (* (- x z) y_m) t_m)))
y_m = fabs(y);
t_m = fabs(t);
assert(x < y_m && y_m < z && z < t_m);
double code(double x, double y_m, double z, double t_m) {
double tmp;
if (((x * y_m) - (z * y_m)) <= -4e+272) {
tmp = (((z + x) * (x - z)) * (t_m / z)) * y_m;
} else {
tmp = ((x - z) * y_m) * t_m;
}
return tmp;
}
y_m = private
t_m = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
real(8) :: tmp
if (((x * y_m) - (z * y_m)) <= (-4d+272)) then
tmp = (((z + x) * (x - z)) * (t_m / z)) * y_m
else
tmp = ((x - z) * y_m) * t_m
end if
code = tmp
end function
y_m = Math.abs(y);
t_m = Math.abs(t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double x, double y_m, double z, double t_m) {
double tmp;
if (((x * y_m) - (z * y_m)) <= -4e+272) {
tmp = (((z + x) * (x - z)) * (t_m / z)) * y_m;
} else {
tmp = ((x - z) * y_m) * t_m;
}
return tmp;
}
y_m = math.fabs(y) t_m = math.fabs(t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(x, y_m, z, t_m): tmp = 0 if ((x * y_m) - (z * y_m)) <= -4e+272: tmp = (((z + x) * (x - z)) * (t_m / z)) * y_m else: tmp = ((x - z) * y_m) * t_m return tmp
y_m = abs(y) t_m = abs(t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(x, y_m, z, t_m) tmp = 0.0 if (Float64(Float64(x * y_m) - Float64(z * y_m)) <= -4e+272) tmp = Float64(Float64(Float64(Float64(z + x) * Float64(x - z)) * Float64(t_m / z)) * y_m); else tmp = Float64(Float64(Float64(x - z) * y_m) * t_m); end return tmp end
y_m = abs(y);
t_m = abs(t);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(x, y_m, z, t_m)
tmp = 0.0;
if (((x * y_m) - (z * y_m)) <= -4e+272)
tmp = (((z + x) * (x - z)) * (t_m / z)) * y_m;
else
tmp = ((x - z) * y_m) * t_m;
end
tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision] t_m = N[Abs[t], $MachinePrecision] NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. code[x_, y$95$m_, z_, t$95$m_] := If[LessEqual[N[(N[(x * y$95$m), $MachinePrecision] - N[(z * y$95$m), $MachinePrecision]), $MachinePrecision], -4e+272], N[(N[(N[(N[(z + x), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision] * N[(t$95$m / z), $MachinePrecision]), $MachinePrecision] * y$95$m), $MachinePrecision], N[(N[(N[(x - z), $MachinePrecision] * y$95$m), $MachinePrecision] * t$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
t_m = \left|t\right|
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y\_m - z \cdot y\_m \leq -4 \cdot 10^{+272}:\\
\;\;\;\;\left(\left(\left(z + x\right) \cdot \left(x - z\right)\right) \cdot \frac{t\_m}{z}\right) \cdot y\_m\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x - z\right) \cdot y\_m\right) \cdot t\_m\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 z y)) < -4.0000000000000003e272Initial program 52.7%
Applied rewrites47.6%
Applied rewrites36.0%
Taylor expanded in x around 0
Applied rewrites26.6%
if -4.0000000000000003e272 < (-.f64 (*.f64 x y) (*.f64 z y)) Initial program 52.7%
Applied rewrites52.9%
y_m = (fabs.f64 y) t_m = (fabs.f64 t) NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. (FPCore (x y_m z t_m) :precision binary64 (* (* (- x z) y_m) t_m))
y_m = fabs(y);
t_m = fabs(t);
assert(x < y_m && y_m < z && z < t_m);
double code(double x, double y_m, double z, double t_m) {
return ((x - z) * y_m) * t_m;
}
y_m = private
t_m = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
code = ((x - z) * y_m) * t_m
end function
y_m = Math.abs(y);
t_m = Math.abs(t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double x, double y_m, double z, double t_m) {
return ((x - z) * y_m) * t_m;
}
y_m = math.fabs(y) t_m = math.fabs(t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(x, y_m, z, t_m): return ((x - z) * y_m) * t_m
y_m = abs(y) t_m = abs(t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(x, y_m, z, t_m) return Float64(Float64(Float64(x - z) * y_m) * t_m) end
y_m = abs(y);
t_m = abs(t);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp = code(x, y_m, z, t_m)
tmp = ((x - z) * y_m) * t_m;
end
y_m = N[Abs[y], $MachinePrecision] t_m = N[Abs[t], $MachinePrecision] NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. code[x_, y$95$m_, z_, t$95$m_] := N[(N[(N[(x - z), $MachinePrecision] * y$95$m), $MachinePrecision] * t$95$m), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
t_m = \left|t\right|
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
\left(\left(x - z\right) \cdot y\_m\right) \cdot t\_m
\end{array}
Initial program 52.7%
Applied rewrites52.9%
y_m = (fabs.f64 y) t_m = (fabs.f64 t) NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. (FPCore (x y_m z t_m) :precision binary64 (if (<= x -1.26e+116) (* t_m (* x y_m)) (* (* (- x z) t_m) y_m)))
y_m = fabs(y);
t_m = fabs(t);
assert(x < y_m && y_m < z && z < t_m);
double code(double x, double y_m, double z, double t_m) {
double tmp;
if (x <= -1.26e+116) {
tmp = t_m * (x * y_m);
} else {
tmp = ((x - z) * t_m) * y_m;
}
return tmp;
}
y_m = private
t_m = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
real(8) :: tmp
if (x <= (-1.26d+116)) then
tmp = t_m * (x * y_m)
else
tmp = ((x - z) * t_m) * y_m
end if
code = tmp
end function
y_m = Math.abs(y);
t_m = Math.abs(t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double x, double y_m, double z, double t_m) {
double tmp;
if (x <= -1.26e+116) {
tmp = t_m * (x * y_m);
} else {
tmp = ((x - z) * t_m) * y_m;
}
return tmp;
}
y_m = math.fabs(y) t_m = math.fabs(t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(x, y_m, z, t_m): tmp = 0 if x <= -1.26e+116: tmp = t_m * (x * y_m) else: tmp = ((x - z) * t_m) * y_m return tmp
y_m = abs(y) t_m = abs(t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(x, y_m, z, t_m) tmp = 0.0 if (x <= -1.26e+116) tmp = Float64(t_m * Float64(x * y_m)); else tmp = Float64(Float64(Float64(x - z) * t_m) * y_m); end return tmp end
y_m = abs(y);
t_m = abs(t);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp_2 = code(x, y_m, z, t_m)
tmp = 0.0;
if (x <= -1.26e+116)
tmp = t_m * (x * y_m);
else
tmp = ((x - z) * t_m) * y_m;
end
tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision] t_m = N[Abs[t], $MachinePrecision] NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. code[x_, y$95$m_, z_, t$95$m_] := If[LessEqual[x, -1.26e+116], N[(t$95$m * N[(x * y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x - z), $MachinePrecision] * t$95$m), $MachinePrecision] * y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
t_m = \left|t\right|
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.26 \cdot 10^{+116}:\\
\;\;\;\;t\_m \cdot \left(x \cdot y\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x - z\right) \cdot t\_m\right) \cdot y\_m\\
\end{array}
\end{array}
if x < -1.2599999999999999e116Initial program 52.7%
Taylor expanded in x around inf
Applied rewrites34.2%
if -1.2599999999999999e116 < x Initial program 52.7%
Applied rewrites47.6%
y_m = (fabs.f64 y) t_m = (fabs.f64 t) NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. (FPCore (x y_m z t_m) :precision binary64 (* t_m (* x y_m)))
y_m = fabs(y);
t_m = fabs(t);
assert(x < y_m && y_m < z && z < t_m);
double code(double x, double y_m, double z, double t_m) {
return t_m * (x * y_m);
}
y_m = private
t_m = private
NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function.
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_m, z, t_m)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t_m
code = t_m * (x * y_m)
end function
y_m = Math.abs(y);
t_m = Math.abs(t);
assert x < y_m && y_m < z && z < t_m;
public static double code(double x, double y_m, double z, double t_m) {
return t_m * (x * y_m);
}
y_m = math.fabs(y) t_m = math.fabs(t) [x, y_m, z, t_m] = sort([x, y_m, z, t_m]) def code(x, y_m, z, t_m): return t_m * (x * y_m)
y_m = abs(y) t_m = abs(t) x, y_m, z, t_m = sort([x, y_m, z, t_m]) function code(x, y_m, z, t_m) return Float64(t_m * Float64(x * y_m)) end
y_m = abs(y);
t_m = abs(t);
x, y_m, z, t_m = num2cell(sort([x, y_m, z, t_m])){:}
function tmp = code(x, y_m, z, t_m)
tmp = t_m * (x * y_m);
end
y_m = N[Abs[y], $MachinePrecision] t_m = N[Abs[t], $MachinePrecision] NOTE: x, y_m, z, and t_m should be sorted in increasing order before calling this function. code[x_, y$95$m_, z_, t$95$m_] := N[(t$95$m * N[(x * y$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
t_m = \left|t\right|
\\
[x, y_m, z, t_m] = \mathsf{sort}([x, y_m, z, t_m])\\
\\
t\_m \cdot \left(x \cdot y\_m\right)
\end{array}
Initial program 52.7%
Taylor expanded in x around inf
Applied rewrites34.2%
herbie shell --seed 2025159
(FPCore (x y z t)
:name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
:precision binary64
(* (- (* x y) (* z y)) t))