
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (((y - x) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
def code(x, y, z, t): return x + (((y - x) * z) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(y - x) * z) / t)) end
function tmp = code(x, y, z, t) tmp = x + (((y - x) * z) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot z}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* (- y x) z) t)))
double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (((y - x) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + (((y - x) * z) / t);
}
def code(x, y, z, t): return x + (((y - x) * z) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(Float64(y - x) * z) / t)) end
function tmp = code(x, y, z, t) tmp = x + (((y - x) * z) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot z}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (if (<= z 1.06e+108) (fma (/ z t) (- y x) x) (* (/ (- y x) t) z)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 1.06e+108) {
tmp = fma((z / t), (y - x), x);
} else {
tmp = ((y - x) / t) * z;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (z <= 1.06e+108) tmp = fma(Float64(z / t), Float64(y - x), x); else tmp = Float64(Float64(Float64(y - x) / t) * z); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, 1.06e+108], N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.06 \cdot 10^{+108}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{t} \cdot z\\
\end{array}
\end{array}
if z < 1.06e108Initial program 94.5%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6498.3
Applied rewrites98.3%
if 1.06e108 < z Initial program 94.7%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6499.5
Applied rewrites99.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- 1.0 (/ z t)) x)) (t_2 (* (/ z t) (- y x))))
(if (<= z -2.2e-28)
t_2
(if (<= z 2.1e-145)
t_1
(if (<= z 3.2e-70) t_2 (if (<= z 4.2e-16) t_1 (* (/ (- y x) t) z)))))))
double code(double x, double y, double z, double t) {
double t_1 = (1.0 - (z / t)) * x;
double t_2 = (z / t) * (y - x);
double tmp;
if (z <= -2.2e-28) {
tmp = t_2;
} else if (z <= 2.1e-145) {
tmp = t_1;
} else if (z <= 3.2e-70) {
tmp = t_2;
} else if (z <= 4.2e-16) {
tmp = t_1;
} else {
tmp = ((y - x) / t) * z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (1.0d0 - (z / t)) * x
t_2 = (z / t) * (y - x)
if (z <= (-2.2d-28)) then
tmp = t_2
else if (z <= 2.1d-145) then
tmp = t_1
else if (z <= 3.2d-70) then
tmp = t_2
else if (z <= 4.2d-16) then
tmp = t_1
else
tmp = ((y - x) / t) * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (1.0 - (z / t)) * x;
double t_2 = (z / t) * (y - x);
double tmp;
if (z <= -2.2e-28) {
tmp = t_2;
} else if (z <= 2.1e-145) {
tmp = t_1;
} else if (z <= 3.2e-70) {
tmp = t_2;
} else if (z <= 4.2e-16) {
tmp = t_1;
} else {
tmp = ((y - x) / t) * z;
}
return tmp;
}
def code(x, y, z, t): t_1 = (1.0 - (z / t)) * x t_2 = (z / t) * (y - x) tmp = 0 if z <= -2.2e-28: tmp = t_2 elif z <= 2.1e-145: tmp = t_1 elif z <= 3.2e-70: tmp = t_2 elif z <= 4.2e-16: tmp = t_1 else: tmp = ((y - x) / t) * z return tmp
function code(x, y, z, t) t_1 = Float64(Float64(1.0 - Float64(z / t)) * x) t_2 = Float64(Float64(z / t) * Float64(y - x)) tmp = 0.0 if (z <= -2.2e-28) tmp = t_2; elseif (z <= 2.1e-145) tmp = t_1; elseif (z <= 3.2e-70) tmp = t_2; elseif (z <= 4.2e-16) tmp = t_1; else tmp = Float64(Float64(Float64(y - x) / t) * z); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (1.0 - (z / t)) * x; t_2 = (z / t) * (y - x); tmp = 0.0; if (z <= -2.2e-28) tmp = t_2; elseif (z <= 2.1e-145) tmp = t_1; elseif (z <= 3.2e-70) tmp = t_2; elseif (z <= 4.2e-16) tmp = t_1; else tmp = ((y - x) / t) * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.2e-28], t$95$2, If[LessEqual[z, 2.1e-145], t$95$1, If[LessEqual[z, 3.2e-70], t$95$2, If[LessEqual[z, 4.2e-16], t$95$1, N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(1 - \frac{z}{t}\right) \cdot x\\
t_2 := \frac{z}{t} \cdot \left(y - x\right)\\
\mathbf{if}\;z \leq -2.2 \cdot 10^{-28}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-145}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-70}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{t} \cdot z\\
\end{array}
\end{array}
if z < -2.19999999999999996e-28 or 2.09999999999999991e-145 < z < 3.1999999999999997e-70Initial program 87.5%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6478.2
Applied rewrites78.2%
Applied rewrites82.5%
if -2.19999999999999996e-28 < z < 2.09999999999999991e-145 or 3.1999999999999997e-70 < z < 4.2000000000000002e-16Initial program 98.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6480.1
Applied rewrites80.1%
if 4.2000000000000002e-16 < z Initial program 96.0%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6491.3
Applied rewrites91.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.2e-28) (not (<= z 2.1e-145))) (* (/ z t) (- y x)) (* (- 1.0 (/ z t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.2e-28) || !(z <= 2.1e-145)) {
tmp = (z / t) * (y - x);
} else {
tmp = (1.0 - (z / t)) * x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-2.2d-28)) .or. (.not. (z <= 2.1d-145))) then
tmp = (z / t) * (y - x)
else
tmp = (1.0d0 - (z / t)) * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.2e-28) || !(z <= 2.1e-145)) {
tmp = (z / t) * (y - x);
} else {
tmp = (1.0 - (z / t)) * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.2e-28) or not (z <= 2.1e-145): tmp = (z / t) * (y - x) else: tmp = (1.0 - (z / t)) * x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.2e-28) || !(z <= 2.1e-145)) tmp = Float64(Float64(z / t) * Float64(y - x)); else tmp = Float64(Float64(1.0 - Float64(z / t)) * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.2e-28) || ~((z <= 2.1e-145))) tmp = (z / t) * (y - x); else tmp = (1.0 - (z / t)) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.2e-28], N[Not[LessEqual[z, 2.1e-145]], $MachinePrecision]], N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{-28} \lor \neg \left(z \leq 2.1 \cdot 10^{-145}\right):\\
\;\;\;\;\frac{z}{t} \cdot \left(y - x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{z}{t}\right) \cdot x\\
\end{array}
\end{array}
if z < -2.19999999999999996e-28 or 2.09999999999999991e-145 < z Initial program 91.5%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6478.9
Applied rewrites78.9%
Applied rewrites79.3%
if -2.19999999999999996e-28 < z < 2.09999999999999991e-145Initial program 98.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6479.5
Applied rewrites79.5%
Final simplification79.4%
(FPCore (x y z t) :precision binary64 (if (or (<= y -4e+42) (not (<= y 1.05e+27))) (* y (/ z t)) (* (- 1.0 (/ z t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -4e+42) || !(y <= 1.05e+27)) {
tmp = y * (z / t);
} else {
tmp = (1.0 - (z / t)) * x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-4d+42)) .or. (.not. (y <= 1.05d+27))) then
tmp = y * (z / t)
else
tmp = (1.0d0 - (z / t)) * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -4e+42) || !(y <= 1.05e+27)) {
tmp = y * (z / t);
} else {
tmp = (1.0 - (z / t)) * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -4e+42) or not (y <= 1.05e+27): tmp = y * (z / t) else: tmp = (1.0 - (z / t)) * x return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -4e+42) || !(y <= 1.05e+27)) tmp = Float64(y * Float64(z / t)); else tmp = Float64(Float64(1.0 - Float64(z / t)) * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -4e+42) || ~((y <= 1.05e+27))) tmp = y * (z / t); else tmp = (1.0 - (z / t)) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -4e+42], N[Not[LessEqual[y, 1.05e+27]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+42} \lor \neg \left(y \leq 1.05 \cdot 10^{+27}\right):\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{z}{t}\right) \cdot x\\
\end{array}
\end{array}
if y < -4.00000000000000018e42 or 1.04999999999999997e27 < y Initial program 93.2%
Taylor expanded in x around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6462.4
Applied rewrites62.4%
Applied rewrites67.8%
if -4.00000000000000018e42 < y < 1.04999999999999997e27Initial program 95.7%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6483.4
Applied rewrites83.4%
Final simplification76.3%
(FPCore (x y z t) :precision binary64 (if (<= z -5.5e-28) (* (/ z t) (- y x)) (if (<= z 1.6e+78) (+ x (/ (* z y) t)) (* (/ (- y x) t) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.5e-28) {
tmp = (z / t) * (y - x);
} else if (z <= 1.6e+78) {
tmp = x + ((z * y) / t);
} else {
tmp = ((y - x) / t) * z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-5.5d-28)) then
tmp = (z / t) * (y - x)
else if (z <= 1.6d+78) then
tmp = x + ((z * y) / t)
else
tmp = ((y - x) / t) * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.5e-28) {
tmp = (z / t) * (y - x);
} else if (z <= 1.6e+78) {
tmp = x + ((z * y) / t);
} else {
tmp = ((y - x) / t) * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.5e-28: tmp = (z / t) * (y - x) elif z <= 1.6e+78: tmp = x + ((z * y) / t) else: tmp = ((y - x) / t) * z return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.5e-28) tmp = Float64(Float64(z / t) * Float64(y - x)); elseif (z <= 1.6e+78) tmp = Float64(x + Float64(Float64(z * y) / t)); else tmp = Float64(Float64(Float64(y - x) / t) * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5.5e-28) tmp = (z / t) * (y - x); elseif (z <= 1.6e+78) tmp = x + ((z * y) / t); else tmp = ((y - x) / t) * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.5e-28], N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.6e+78], N[(x + N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{-28}:\\
\;\;\;\;\frac{z}{t} \cdot \left(y - x\right)\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{+78}:\\
\;\;\;\;x + \frac{z \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{t} \cdot z\\
\end{array}
\end{array}
if z < -5.49999999999999967e-28Initial program 84.7%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6482.8
Applied rewrites82.8%
Applied rewrites82.9%
if -5.49999999999999967e-28 < z < 1.59999999999999997e78Initial program 99.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f6488.1
Applied rewrites88.1%
if 1.59999999999999997e78 < z Initial program 95.0%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6497.6
Applied rewrites97.6%
(FPCore (x y z t) :precision binary64 (if (<= z -2.2e-28) (* (/ z t) (- y x)) (if (<= z 2.1e-145) (* (- 1.0 (/ z t)) x) (/ (* (- y x) z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.2e-28) {
tmp = (z / t) * (y - x);
} else if (z <= 2.1e-145) {
tmp = (1.0 - (z / t)) * x;
} else {
tmp = ((y - x) * z) / t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-2.2d-28)) then
tmp = (z / t) * (y - x)
else if (z <= 2.1d-145) then
tmp = (1.0d0 - (z / t)) * x
else
tmp = ((y - x) * z) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.2e-28) {
tmp = (z / t) * (y - x);
} else if (z <= 2.1e-145) {
tmp = (1.0 - (z / t)) * x;
} else {
tmp = ((y - x) * z) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.2e-28: tmp = (z / t) * (y - x) elif z <= 2.1e-145: tmp = (1.0 - (z / t)) * x else: tmp = ((y - x) * z) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.2e-28) tmp = Float64(Float64(z / t) * Float64(y - x)); elseif (z <= 2.1e-145) tmp = Float64(Float64(1.0 - Float64(z / t)) * x); else tmp = Float64(Float64(Float64(y - x) * z) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.2e-28) tmp = (z / t) * (y - x); elseif (z <= 2.1e-145) tmp = (1.0 - (z / t)) * x; else tmp = ((y - x) * z) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.2e-28], N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.1e-145], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{-28}:\\
\;\;\;\;\frac{z}{t} \cdot \left(y - x\right)\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-145}:\\
\;\;\;\;\left(1 - \frac{z}{t}\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(y - x\right) \cdot z}{t}\\
\end{array}
\end{array}
if z < -2.19999999999999996e-28Initial program 84.7%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6482.8
Applied rewrites82.8%
Applied rewrites82.9%
if -2.19999999999999996e-28 < z < 2.09999999999999991e-145Initial program 98.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f6479.5
Applied rewrites79.5%
if 2.09999999999999991e-145 < z Initial program 97.3%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6475.4
Applied rewrites75.4%
Applied rewrites79.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.85e-5) (not (<= y 14500000000000.0))) (* y (/ z t)) (/ (* (- x) z) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.85e-5) || !(y <= 14500000000000.0)) {
tmp = y * (z / t);
} else {
tmp = (-x * z) / t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-1.85d-5)) .or. (.not. (y <= 14500000000000.0d0))) then
tmp = y * (z / t)
else
tmp = (-x * z) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.85e-5) || !(y <= 14500000000000.0)) {
tmp = y * (z / t);
} else {
tmp = (-x * z) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.85e-5) or not (y <= 14500000000000.0): tmp = y * (z / t) else: tmp = (-x * z) / t return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.85e-5) || !(y <= 14500000000000.0)) tmp = Float64(y * Float64(z / t)); else tmp = Float64(Float64(Float64(-x) * z) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.85e-5) || ~((y <= 14500000000000.0))) tmp = y * (z / t); else tmp = (-x * z) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.85e-5], N[Not[LessEqual[y, 14500000000000.0]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(N[((-x) * z), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{-5} \lor \neg \left(y \leq 14500000000000\right):\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-x\right) \cdot z}{t}\\
\end{array}
\end{array}
if y < -1.84999999999999991e-5 or 1.45e13 < y Initial program 92.8%
Taylor expanded in x around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6458.7
Applied rewrites58.7%
Applied rewrites63.3%
if -1.84999999999999991e-5 < y < 1.45e13Initial program 96.5%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6446.8
Applied rewrites46.8%
Taylor expanded in x around inf
Applied rewrites37.9%
Applied rewrites38.4%
Final simplification51.5%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.85e-5) (not (<= y 14500000000000.0))) (* y (/ z t)) (* (/ (- x) t) z)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.85e-5) || !(y <= 14500000000000.0)) {
tmp = y * (z / t);
} else {
tmp = (-x / t) * z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-1.85d-5)) .or. (.not. (y <= 14500000000000.0d0))) then
tmp = y * (z / t)
else
tmp = (-x / t) * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.85e-5) || !(y <= 14500000000000.0)) {
tmp = y * (z / t);
} else {
tmp = (-x / t) * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.85e-5) or not (y <= 14500000000000.0): tmp = y * (z / t) else: tmp = (-x / t) * z return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.85e-5) || !(y <= 14500000000000.0)) tmp = Float64(y * Float64(z / t)); else tmp = Float64(Float64(Float64(-x) / t) * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.85e-5) || ~((y <= 14500000000000.0))) tmp = y * (z / t); else tmp = (-x / t) * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.85e-5], N[Not[LessEqual[y, 14500000000000.0]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(N[((-x) / t), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{-5} \lor \neg \left(y \leq 14500000000000\right):\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{t} \cdot z\\
\end{array}
\end{array}
if y < -1.84999999999999991e-5 or 1.45e13 < y Initial program 92.8%
Taylor expanded in x around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6458.7
Applied rewrites58.7%
Applied rewrites63.3%
if -1.84999999999999991e-5 < y < 1.45e13Initial program 96.5%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6446.8
Applied rewrites46.8%
Taylor expanded in x around inf
Applied rewrites37.9%
Final simplification51.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2e-5) (not (<= y 14500000000000.0))) (* y (/ z t)) (* (- x) (/ z t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2e-5) || !(y <= 14500000000000.0)) {
tmp = y * (z / t);
} else {
tmp = -x * (z / t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-2d-5)) .or. (.not. (y <= 14500000000000.0d0))) then
tmp = y * (z / t)
else
tmp = -x * (z / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2e-5) || !(y <= 14500000000000.0)) {
tmp = y * (z / t);
} else {
tmp = -x * (z / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2e-5) or not (y <= 14500000000000.0): tmp = y * (z / t) else: tmp = -x * (z / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2e-5) || !(y <= 14500000000000.0)) tmp = Float64(y * Float64(z / t)); else tmp = Float64(Float64(-x) * Float64(z / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2e-5) || ~((y <= 14500000000000.0))) tmp = y * (z / t); else tmp = -x * (z / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2e-5], N[Not[LessEqual[y, 14500000000000.0]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], N[((-x) * N[(z / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-5} \lor \neg \left(y \leq 14500000000000\right):\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \frac{z}{t}\\
\end{array}
\end{array}
if y < -2.00000000000000016e-5 or 1.45e13 < y Initial program 92.8%
Taylor expanded in x around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6458.7
Applied rewrites58.7%
Applied rewrites63.3%
if -2.00000000000000016e-5 < y < 1.45e13Initial program 96.5%
Taylor expanded in z around inf
div-subN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6446.8
Applied rewrites46.8%
Taylor expanded in x around inf
Applied rewrites37.9%
Applied rewrites36.5%
Final simplification50.6%
(FPCore (x y z t) :precision binary64 (* y (/ z t)))
double code(double x, double y, double z, double t) {
return y * (z / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = y * (z / t)
end function
public static double code(double x, double y, double z, double t) {
return y * (z / t);
}
def code(x, y, z, t): return y * (z / t)
function code(x, y, z, t) return Float64(y * Float64(z / t)) end
function tmp = code(x, y, z, t) tmp = y * (z / t); end
code[x_, y_, z_, t_] := N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \frac{z}{t}
\end{array}
Initial program 94.6%
Taylor expanded in x around 0
associate-*l/N/A
lower-*.f64N/A
lower-/.f6438.2
Applied rewrites38.2%
Applied rewrites41.4%
(FPCore (x y z t)
:precision binary64
(if (< x -9.025511195533005e-135)
(- x (* (/ z t) (- x y)))
(if (< x 4.275032163700715e-250)
(+ x (* (/ (- y x) t) z))
(+ x (/ (- y x) (/ t z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (x < -9.025511195533005e-135) {
tmp = x - ((z / t) * (x - y));
} else if (x < 4.275032163700715e-250) {
tmp = x + (((y - x) / t) * z);
} else {
tmp = x + ((y - x) / (t / z));
}
return tmp;
}
real(8) function code(x, y, z, t)
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 < (-9.025511195533005d-135)) then
tmp = x - ((z / t) * (x - y))
else if (x < 4.275032163700715d-250) then
tmp = x + (((y - x) / t) * z)
else
tmp = x + ((y - x) / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x < -9.025511195533005e-135) {
tmp = x - ((z / t) * (x - y));
} else if (x < 4.275032163700715e-250) {
tmp = x + (((y - x) / t) * z);
} else {
tmp = x + ((y - x) / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x < -9.025511195533005e-135: tmp = x - ((z / t) * (x - y)) elif x < 4.275032163700715e-250: tmp = x + (((y - x) / t) * z) else: tmp = x + ((y - x) / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (x < -9.025511195533005e-135) tmp = Float64(x - Float64(Float64(z / t) * Float64(x - y))); elseif (x < 4.275032163700715e-250) tmp = Float64(x + Float64(Float64(Float64(y - x) / t) * z)); else tmp = Float64(x + Float64(Float64(y - x) / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x < -9.025511195533005e-135) tmp = x - ((z / t) * (x - y)); elseif (x < 4.275032163700715e-250) tmp = x + (((y - x) / t) * z); else tmp = x + ((y - x) / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Less[x, -9.025511195533005e-135], N[(x - N[(N[(z / t), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Less[x, 4.275032163700715e-250], N[(x + N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x < -9.025511195533005 \cdot 10^{-135}:\\
\;\;\;\;x - \frac{z}{t} \cdot \left(x - y\right)\\
\mathbf{elif}\;x < 4.275032163700715 \cdot 10^{-250}:\\
\;\;\;\;x + \frac{y - x}{t} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\
\end{array}
\end{array}
herbie shell --seed 2024326
(FPCore (x y z t)
:name "Numeric.Histogram:binBounds from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (if (< x -1805102239106601/200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- x (* (/ z t) (- x y))) (if (< x 855006432740143/2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ x (* (/ (- y x) t) z)) (+ x (/ (- y x) (/ t z))))))
(+ x (/ (* (- y x) z) t)))