
(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
(let* ((t_1 (+ x (/ (* z (- y x)) t))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+291)))
(+ x (* z (/ (- y x) t)))
t_1)))
double code(double x, double y, double z, double t) {
double t_1 = x + ((z * (y - x)) / t);
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+291)) {
tmp = x + (z * ((y - x) / t));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((z * (y - x)) / t);
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e+291)) {
tmp = x + (z * ((y - x) / t));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((z * (y - x)) / t) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 5e+291): tmp = x + (z * ((y - x) / t)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(z * Float64(y - x)) / t)) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+291)) tmp = Float64(x + Float64(z * Float64(Float64(y - x) / t))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((z * (y - x)) / t); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 5e+291))) tmp = x + (z * ((y - x) / t)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+291]], $MachinePrecision]], N[(x + N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{z \cdot \left(y - x\right)}{t}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+291}\right):\\
\;\;\;\;x + z \cdot \frac{y - x}{t}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < -inf.0 or 5.0000000000000001e291 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) Initial program 77.8%
associate-*l/100.0%
Applied egg-rr100.0%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) < 5.0000000000000001e291Initial program 98.6%
Final simplification99.1%
(FPCore (x y z t) :precision binary64 (fma (/ z t) (- y x) x))
double code(double x, double y, double z, double t) {
return fma((z / t), (y - x), x);
}
function code(x, y, z, t) return fma(Float64(z / t), Float64(y - x), x) end
code[x_, y_, z_, t_] := N[(N[(z / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z}{t}, y - x, x\right)
\end{array}
Initial program 91.3%
+-commutative91.3%
*-commutative91.3%
associate-*l/97.6%
fma-def97.6%
Simplified97.6%
Final simplification97.6%
(FPCore (x y z t)
:precision binary64
(if (<= t -6e+48)
x
(if (<= t -6.1e-112)
(/ (* z y) t)
(if (<= t -5.6e-219)
(* (/ z t) (- x))
(if (<= t 1.7e+26) (* (/ z t) y) x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -6e+48) {
tmp = x;
} else if (t <= -6.1e-112) {
tmp = (z * y) / t;
} else if (t <= -5.6e-219) {
tmp = (z / t) * -x;
} else if (t <= 1.7e+26) {
tmp = (z / t) * y;
} else {
tmp = 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 (t <= (-6d+48)) then
tmp = x
else if (t <= (-6.1d-112)) then
tmp = (z * y) / t
else if (t <= (-5.6d-219)) then
tmp = (z / t) * -x
else if (t <= 1.7d+26) then
tmp = (z / t) * y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -6e+48) {
tmp = x;
} else if (t <= -6.1e-112) {
tmp = (z * y) / t;
} else if (t <= -5.6e-219) {
tmp = (z / t) * -x;
} else if (t <= 1.7e+26) {
tmp = (z / t) * y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -6e+48: tmp = x elif t <= -6.1e-112: tmp = (z * y) / t elif t <= -5.6e-219: tmp = (z / t) * -x elif t <= 1.7e+26: tmp = (z / t) * y else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -6e+48) tmp = x; elseif (t <= -6.1e-112) tmp = Float64(Float64(z * y) / t); elseif (t <= -5.6e-219) tmp = Float64(Float64(z / t) * Float64(-x)); elseif (t <= 1.7e+26) tmp = Float64(Float64(z / t) * y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -6e+48) tmp = x; elseif (t <= -6.1e-112) tmp = (z * y) / t; elseif (t <= -5.6e-219) tmp = (z / t) * -x; elseif (t <= 1.7e+26) tmp = (z / t) * y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -6e+48], x, If[LessEqual[t, -6.1e-112], N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[t, -5.6e-219], N[(N[(z / t), $MachinePrecision] * (-x)), $MachinePrecision], If[LessEqual[t, 1.7e+26], N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision], x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6 \cdot 10^{+48}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq -6.1 \cdot 10^{-112}:\\
\;\;\;\;\frac{z \cdot y}{t}\\
\mathbf{elif}\;t \leq -5.6 \cdot 10^{-219}:\\
\;\;\;\;\frac{z}{t} \cdot \left(-x\right)\\
\mathbf{elif}\;t \leq 1.7 \cdot 10^{+26}:\\
\;\;\;\;\frac{z}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -5.9999999999999999e48 or 1.7000000000000001e26 < t Initial program 82.1%
Taylor expanded in z around 0 68.5%
if -5.9999999999999999e48 < t < -6.0999999999999999e-112Initial program 99.9%
Taylor expanded in t around 0 81.5%
Taylor expanded in y around inf 59.2%
*-commutative59.2%
Simplified59.2%
if -6.0999999999999999e-112 < t < -5.5999999999999998e-219Initial program 99.9%
Taylor expanded in t around 0 83.1%
Taylor expanded in y around 0 58.8%
associate-*r/58.8%
mul-1-neg58.8%
distribute-rgt-neg-out58.8%
associate-*l/63.5%
Simplified63.5%
if -5.5999999999999998e-219 < t < 1.7000000000000001e26Initial program 97.4%
Taylor expanded in t around 0 80.4%
Taylor expanded in y around inf 57.4%
associate-*r/59.7%
Simplified59.7%
Final simplification63.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.3e-83) (not (<= z 4.7e-126))) (* z (/ (- y x) t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.3e-83) || !(z <= 4.7e-126)) {
tmp = z * ((y - x) / t);
} else {
tmp = 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 <= (-1.3d-83)) .or. (.not. (z <= 4.7d-126))) then
tmp = z * ((y - x) / t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.3e-83) || !(z <= 4.7e-126)) {
tmp = z * ((y - x) / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.3e-83) or not (z <= 4.7e-126): tmp = z * ((y - x) / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.3e-83) || !(z <= 4.7e-126)) tmp = Float64(z * Float64(Float64(y - x) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.3e-83) || ~((z <= 4.7e-126))) tmp = z * ((y - x) / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.3e-83], N[Not[LessEqual[z, 4.7e-126]], $MachinePrecision]], N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{-83} \lor \neg \left(z \leq 4.7 \cdot 10^{-126}\right):\\
\;\;\;\;z \cdot \frac{y - x}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.30000000000000004e-83 or 4.70000000000000017e-126 < z Initial program 88.3%
Taylor expanded in t around 0 70.9%
associate-*l/96.9%
Applied egg-rr75.0%
if -1.30000000000000004e-83 < z < 4.70000000000000017e-126Initial program 97.3%
Taylor expanded in z around 0 72.9%
Final simplification74.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.6e+157) (not (<= z 8.2e+114))) (* z (/ (- y x) t)) (+ x (* (/ z t) y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.6e+157) || !(z <= 8.2e+114)) {
tmp = z * ((y - x) / t);
} else {
tmp = x + ((z / t) * y);
}
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.6d+157)) .or. (.not. (z <= 8.2d+114))) then
tmp = z * ((y - x) / t)
else
tmp = x + ((z / t) * y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.6e+157) || !(z <= 8.2e+114)) {
tmp = z * ((y - x) / t);
} else {
tmp = x + ((z / t) * y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.6e+157) or not (z <= 8.2e+114): tmp = z * ((y - x) / t) else: tmp = x + ((z / t) * y) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.6e+157) || !(z <= 8.2e+114)) tmp = Float64(z * Float64(Float64(y - x) / t)); else tmp = Float64(x + Float64(Float64(z / t) * y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.6e+157) || ~((z <= 8.2e+114))) tmp = z * ((y - x) / t); else tmp = x + ((z / t) * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.6e+157], N[Not[LessEqual[z, 8.2e+114]], $MachinePrecision]], N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{+157} \lor \neg \left(z \leq 8.2 \cdot 10^{+114}\right):\\
\;\;\;\;z \cdot \frac{y - x}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{z}{t} \cdot y\\
\end{array}
\end{array}
if z < -2.60000000000000011e157 or 8.2000000000000001e114 < z Initial program 85.3%
Taylor expanded in t around 0 82.9%
associate-*l/96.9%
Applied egg-rr91.6%
if -2.60000000000000011e157 < z < 8.2000000000000001e114Initial program 93.9%
Taylor expanded in y around inf 83.7%
associate-*r/35.6%
Simplified87.3%
Final simplification88.6%
(FPCore (x y z t) :precision binary64 (if (or (<= y -9.6e-76) (not (<= y 1.75e-107))) (+ x (* (/ z t) y)) (- x (* (/ z t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -9.6e-76) || !(y <= 1.75e-107)) {
tmp = x + ((z / t) * y);
} else {
tmp = x - ((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 <= (-9.6d-76)) .or. (.not. (y <= 1.75d-107))) then
tmp = x + ((z / t) * y)
else
tmp = x - ((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 <= -9.6e-76) || !(y <= 1.75e-107)) {
tmp = x + ((z / t) * y);
} else {
tmp = x - ((z / t) * x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -9.6e-76) or not (y <= 1.75e-107): tmp = x + ((z / t) * y) else: tmp = x - ((z / t) * x) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -9.6e-76) || !(y <= 1.75e-107)) tmp = Float64(x + Float64(Float64(z / t) * y)); else tmp = Float64(x - Float64(Float64(z / t) * x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -9.6e-76) || ~((y <= 1.75e-107))) tmp = x + ((z / t) * y); else tmp = x - ((z / t) * x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -9.6e-76], N[Not[LessEqual[y, 1.75e-107]], $MachinePrecision]], N[(x + N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(z / t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.6 \cdot 10^{-76} \lor \neg \left(y \leq 1.75 \cdot 10^{-107}\right):\\
\;\;\;\;x + \frac{z}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z}{t} \cdot x\\
\end{array}
\end{array}
if y < -9.60000000000000053e-76 or 1.74999999999999993e-107 < y Initial program 90.8%
Taylor expanded in y around inf 83.7%
associate-*r/55.9%
Simplified90.3%
if -9.60000000000000053e-76 < y < 1.74999999999999993e-107Initial program 92.1%
Taylor expanded in x around inf 90.0%
*-commutative90.0%
distribute-lft-in90.0%
*-rgt-identity90.0%
mul-1-neg90.0%
distribute-rgt-neg-in90.0%
unsub-neg90.0%
Simplified90.0%
Final simplification90.2%
(FPCore (x y z t) :precision binary64 (if (<= x -8.4e+40) (- x (* (/ z t) x)) (+ x (* z (/ (- y x) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -8.4e+40) {
tmp = x - ((z / t) * x);
} else {
tmp = x + (z * ((y - x) / 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 (x <= (-8.4d+40)) then
tmp = x - ((z / t) * x)
else
tmp = x + (z * ((y - x) / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -8.4e+40) {
tmp = x - ((z / t) * x);
} else {
tmp = x + (z * ((y - x) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -8.4e+40: tmp = x - ((z / t) * x) else: tmp = x + (z * ((y - x) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -8.4e+40) tmp = Float64(x - Float64(Float64(z / t) * x)); else tmp = Float64(x + Float64(z * Float64(Float64(y - x) / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -8.4e+40) tmp = x - ((z / t) * x); else tmp = x + (z * ((y - x) / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -8.4e+40], N[(x - N[(N[(z / t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.4 \cdot 10^{+40}:\\
\;\;\;\;x - \frac{z}{t} \cdot x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y - x}{t}\\
\end{array}
\end{array}
if x < -8.4000000000000004e40Initial program 86.1%
Taylor expanded in x around inf 98.5%
*-commutative98.5%
distribute-lft-in98.5%
*-rgt-identity98.5%
mul-1-neg98.5%
distribute-rgt-neg-in98.5%
unsub-neg98.5%
Simplified98.5%
if -8.4000000000000004e40 < x Initial program 93.2%
associate-*l/93.7%
Applied egg-rr93.7%
Final simplification95.0%
(FPCore (x y z t) :precision binary64 (if (<= t -5.6e+39) x (if (<= t 6e+25) (* (/ z t) y) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -5.6e+39) {
tmp = x;
} else if (t <= 6e+25) {
tmp = (z / t) * y;
} else {
tmp = 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 (t <= (-5.6d+39)) then
tmp = x
else if (t <= 6d+25) then
tmp = (z / t) * y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -5.6e+39) {
tmp = x;
} else if (t <= 6e+25) {
tmp = (z / t) * y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -5.6e+39: tmp = x elif t <= 6e+25: tmp = (z / t) * y else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -5.6e+39) tmp = x; elseif (t <= 6e+25) tmp = Float64(Float64(z / t) * y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -5.6e+39) tmp = x; elseif (t <= 6e+25) tmp = (z / t) * y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -5.6e+39], x, If[LessEqual[t, 6e+25], N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.6 \cdot 10^{+39}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 6 \cdot 10^{+25}:\\
\;\;\;\;\frac{z}{t} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -5.60000000000000003e39 or 6.00000000000000011e25 < t Initial program 82.6%
Taylor expanded in z around 0 67.6%
if -5.60000000000000003e39 < t < 6.00000000000000011e25Initial program 98.3%
Taylor expanded in t around 0 81.3%
Taylor expanded in y around inf 55.3%
associate-*r/56.8%
Simplified56.8%
Final simplification61.7%
(FPCore (x y z t) :precision binary64 (+ x (/ (- y x) (/ t z))))
double code(double x, double y, double z, double t) {
return x + ((y - x) / (t / z));
}
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) / (t / z))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - x) / (t / z));
}
def code(x, y, z, t): return x + ((y - x) / (t / z))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) / Float64(t / z))) end
function tmp = code(x, y, z, t) tmp = x + ((y - x) / (t / z)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y - x}{\frac{t}{z}}
\end{array}
Initial program 91.3%
associate-/l*97.6%
Simplified97.6%
Final simplification97.6%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 91.3%
Taylor expanded in z around 0 40.4%
Final simplification40.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 2023200
(FPCore (x y z t)
:name "Numeric.Histogram:binBounds from Chart-1.5.3"
:precision binary64
:herbie-target
(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)))))
(+ x (/ (* (- y x) z) t)))