
(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 (/ (* (- y x) z) t)))) (if (<= t_1 (- INFINITY)) (+ x (* z (/ (- y x) t))) t_1)))
double code(double x, double y, double z, double t) {
double t_1 = x + (((y - x) * z) / t);
double tmp;
if (t_1 <= -((double) INFINITY)) {
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 + (((y - x) * z) / t);
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = x + (z * ((y - x) / t));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (((y - x) * z) / t) tmp = 0 if t_1 <= -math.inf: tmp = x + (z * ((y - x) / t)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(Float64(y - x) * z) / t)) tmp = 0.0 if (t_1 <= Float64(-Inf)) 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 + (((y - x) * z) / t); tmp = 0.0; if (t_1 <= -Inf) 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[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], 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{\left(y - x\right) \cdot z}{t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;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.0Initial program 71.7%
associate-*l/99.9%
Simplified99.9%
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) z) t)) Initial program 97.9%
Final simplification98.3%
(FPCore (x y z t) :precision binary64 (if (<= y -1e-108) (+ x (* y (/ z t))) (if (<= y 2.4e-48) (+ x (/ x (/ (- t) z))) (+ x (/ y (/ t z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1e-108) {
tmp = x + (y * (z / t));
} else if (y <= 2.4e-48) {
tmp = x + (x / (-t / z));
} else {
tmp = x + (y / (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 <= (-1d-108)) then
tmp = x + (y * (z / t))
else if (y <= 2.4d-48) then
tmp = x + (x / (-t / z))
else
tmp = x + (y / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1e-108) {
tmp = x + (y * (z / t));
} else if (y <= 2.4e-48) {
tmp = x + (x / (-t / z));
} else {
tmp = x + (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1e-108: tmp = x + (y * (z / t)) elif y <= 2.4e-48: tmp = x + (x / (-t / z)) else: tmp = x + (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1e-108) tmp = Float64(x + Float64(y * Float64(z / t))); elseif (y <= 2.4e-48) tmp = Float64(x + Float64(x / Float64(Float64(-t) / z))); else tmp = Float64(x + Float64(y / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1e-108) tmp = x + (y * (z / t)); elseif (y <= 2.4e-48) tmp = x + (x / (-t / z)); else tmp = x + (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1e-108], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.4e-48], N[(x + N[(x / N[((-t) / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-108}:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-48}:\\
\;\;\;\;x + \frac{x}{\frac{-t}{z}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if y < -1.00000000000000004e-108Initial program 92.6%
associate-*l/95.0%
Simplified95.0%
Taylor expanded in y around inf 87.8%
associate-*r/92.5%
Simplified92.5%
if -1.00000000000000004e-108 < y < 2.4e-48Initial program 94.8%
associate-*l/93.6%
Simplified93.6%
Taylor expanded in y around 0 83.2%
neg-mul-183.2%
distribute-neg-frac83.2%
Simplified83.2%
*-commutative83.2%
frac-2neg83.2%
remove-double-neg83.2%
associate-*r/83.9%
Applied egg-rr83.9%
*-commutative83.9%
associate-/l*88.6%
distribute-frac-neg88.6%
Simplified88.6%
if 2.4e-48 < y Initial program 92.7%
associate-*l/92.6%
Simplified92.6%
Taylor expanded in y around inf 87.3%
associate-*r/92.0%
Simplified92.0%
clear-num92.0%
un-div-inv92.1%
Applied egg-rr92.1%
Final simplification90.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -4e-108) (not (<= y 4.3e-49))) (+ x (* y (/ z t))) (* x (- 1.0 (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -4e-108) || !(y <= 4.3e-49)) {
tmp = x + (y * (z / t));
} else {
tmp = x * (1.0 - (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 <= (-4d-108)) .or. (.not. (y <= 4.3d-49))) then
tmp = x + (y * (z / t))
else
tmp = x * (1.0d0 - (z / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -4e-108) || !(y <= 4.3e-49)) {
tmp = x + (y * (z / t));
} else {
tmp = x * (1.0 - (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -4e-108) or not (y <= 4.3e-49): tmp = x + (y * (z / t)) else: tmp = x * (1.0 - (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -4e-108) || !(y <= 4.3e-49)) tmp = Float64(x + Float64(y * Float64(z / t))); else tmp = Float64(x * Float64(1.0 - Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -4e-108) || ~((y <= 4.3e-49))) tmp = x + (y * (z / t)); else tmp = x * (1.0 - (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -4e-108], N[Not[LessEqual[y, 4.3e-49]], $MachinePrecision]], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-108} \lor \neg \left(y \leq 4.3 \cdot 10^{-49}\right):\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\
\end{array}
\end{array}
if y < -4.00000000000000016e-108 or 4.30000000000000016e-49 < y Initial program 92.6%
associate-*l/93.8%
Simplified93.8%
Taylor expanded in y around inf 87.5%
associate-*r/92.3%
Simplified92.3%
if -4.00000000000000016e-108 < y < 4.30000000000000016e-49Initial program 94.8%
+-commutative94.8%
remove-double-neg94.8%
unsub-neg94.8%
associate-*r/97.1%
fma-neg97.1%
remove-double-neg97.1%
Simplified97.1%
Taylor expanded in y around 0 83.9%
mul-1-neg83.9%
associate-*r/88.6%
*-rgt-identity88.6%
distribute-rgt-neg-in88.6%
mul-1-neg88.6%
distribute-lft-in88.6%
mul-1-neg88.6%
unsub-neg88.6%
Simplified88.6%
Final simplification90.8%
(FPCore (x y z t) :precision binary64 (if (<= y -1.32e-107) (+ x (* y (/ z t))) (if (<= y 1.26e-48) (* x (- 1.0 (/ z t))) (+ x (/ y (/ t z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.32e-107) {
tmp = x + (y * (z / t));
} else if (y <= 1.26e-48) {
tmp = x * (1.0 - (z / t));
} else {
tmp = x + (y / (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.32d-107)) then
tmp = x + (y * (z / t))
else if (y <= 1.26d-48) then
tmp = x * (1.0d0 - (z / t))
else
tmp = x + (y / (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.32e-107) {
tmp = x + (y * (z / t));
} else if (y <= 1.26e-48) {
tmp = x * (1.0 - (z / t));
} else {
tmp = x + (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.32e-107: tmp = x + (y * (z / t)) elif y <= 1.26e-48: tmp = x * (1.0 - (z / t)) else: tmp = x + (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.32e-107) tmp = Float64(x + Float64(y * Float64(z / t))); elseif (y <= 1.26e-48) tmp = Float64(x * Float64(1.0 - Float64(z / t))); else tmp = Float64(x + Float64(y / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.32e-107) tmp = x + (y * (z / t)); elseif (y <= 1.26e-48) tmp = x * (1.0 - (z / t)); else tmp = x + (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.32e-107], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.26e-48], N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.32 \cdot 10^{-107}:\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{elif}\;y \leq 1.26 \cdot 10^{-48}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if y < -1.3200000000000001e-107Initial program 92.6%
associate-*l/95.0%
Simplified95.0%
Taylor expanded in y around inf 87.8%
associate-*r/92.5%
Simplified92.5%
if -1.3200000000000001e-107 < y < 1.2599999999999999e-48Initial program 94.8%
+-commutative94.8%
remove-double-neg94.8%
unsub-neg94.8%
associate-*r/97.1%
fma-neg97.1%
remove-double-neg97.1%
Simplified97.1%
Taylor expanded in y around 0 83.9%
mul-1-neg83.9%
associate-*r/88.6%
*-rgt-identity88.6%
distribute-rgt-neg-in88.6%
mul-1-neg88.6%
distribute-lft-in88.6%
mul-1-neg88.6%
unsub-neg88.6%
Simplified88.6%
if 1.2599999999999999e-48 < y Initial program 92.7%
associate-*l/92.6%
Simplified92.6%
Taylor expanded in y around inf 87.3%
associate-*r/92.0%
Simplified92.0%
clear-num92.0%
un-div-inv92.1%
Applied egg-rr92.1%
Final simplification90.8%
(FPCore (x y z t) :precision binary64 (if (<= t -3.8e-44) x (if (<= t 2.35e-32) (* z (/ (- x) t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -3.8e-44) {
tmp = x;
} else if (t <= 2.35e-32) {
tmp = z * (-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 (t <= (-3.8d-44)) then
tmp = x
else if (t <= 2.35d-32) then
tmp = z * (-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 (t <= -3.8e-44) {
tmp = x;
} else if (t <= 2.35e-32) {
tmp = z * (-x / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -3.8e-44: tmp = x elif t <= 2.35e-32: tmp = z * (-x / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -3.8e-44) tmp = x; elseif (t <= 2.35e-32) tmp = Float64(z * Float64(Float64(-x) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -3.8e-44) tmp = x; elseif (t <= 2.35e-32) tmp = z * (-x / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -3.8e-44], x, If[LessEqual[t, 2.35e-32], N[(z * N[((-x) / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.8 \cdot 10^{-44}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 2.35 \cdot 10^{-32}:\\
\;\;\;\;z \cdot \frac{-x}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -3.8000000000000001e-44 or 2.3500000000000001e-32 < t Initial program 89.9%
+-commutative89.9%
remove-double-neg89.9%
unsub-neg89.9%
associate-*r/98.5%
fma-neg98.5%
remove-double-neg98.5%
Simplified98.5%
Taylor expanded in z around 0 63.6%
if -3.8000000000000001e-44 < t < 2.3500000000000001e-32Initial program 98.1%
+-commutative98.1%
remove-double-neg98.1%
unsub-neg98.1%
associate-*r/97.3%
fma-neg97.4%
remove-double-neg97.4%
Simplified97.4%
Taylor expanded in y around 0 46.6%
mul-1-neg46.6%
associate-*r/50.7%
*-rgt-identity50.7%
distribute-rgt-neg-in50.7%
mul-1-neg50.7%
distribute-lft-in50.7%
mul-1-neg50.7%
unsub-neg50.7%
Simplified50.7%
Taylor expanded in z around inf 39.0%
mul-1-neg39.0%
*-commutative39.0%
associate-*r/36.6%
distribute-rgt-neg-in36.6%
distribute-neg-frac36.6%
Simplified36.6%
Final simplification51.7%
(FPCore (x y z t) :precision binary64 (if (<= t -1.05e-43) x (if (<= t 1.55e-33) (* x (/ (- z) t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.05e-43) {
tmp = x;
} else if (t <= 1.55e-33) {
tmp = x * (-z / 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 (t <= (-1.05d-43)) then
tmp = x
else if (t <= 1.55d-33) then
tmp = x * (-z / 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 (t <= -1.05e-43) {
tmp = x;
} else if (t <= 1.55e-33) {
tmp = x * (-z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.05e-43: tmp = x elif t <= 1.55e-33: tmp = x * (-z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.05e-43) tmp = x; elseif (t <= 1.55e-33) tmp = Float64(x * Float64(Float64(-z) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.05e-43) tmp = x; elseif (t <= 1.55e-33) tmp = x * (-z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.05e-43], x, If[LessEqual[t, 1.55e-33], N[(x * N[((-z) / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.05 \cdot 10^{-43}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 1.55 \cdot 10^{-33}:\\
\;\;\;\;x \cdot \frac{-z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.05e-43 or 1.54999999999999998e-33 < t Initial program 89.9%
+-commutative89.9%
remove-double-neg89.9%
unsub-neg89.9%
associate-*r/98.5%
fma-neg98.5%
remove-double-neg98.5%
Simplified98.5%
Taylor expanded in z around 0 63.6%
if -1.05e-43 < t < 1.54999999999999998e-33Initial program 98.1%
+-commutative98.1%
remove-double-neg98.1%
unsub-neg98.1%
associate-*r/97.3%
fma-neg97.4%
remove-double-neg97.4%
Simplified97.4%
Taylor expanded in y around 0 46.6%
mul-1-neg46.6%
associate-*r/50.7%
*-rgt-identity50.7%
distribute-rgt-neg-in50.7%
mul-1-neg50.7%
distribute-lft-in50.7%
mul-1-neg50.7%
unsub-neg50.7%
Simplified50.7%
Taylor expanded in z around inf 39.0%
associate-*r/39.0%
*-commutative39.0%
neg-mul-139.0%
distribute-neg-frac39.0%
associate-/l*36.6%
associate-/r/43.2%
distribute-rgt-neg-in43.2%
Simplified43.2%
Final simplification54.6%
(FPCore (x y z t) :precision binary64 (+ x (* z (/ (- y x) t))))
double code(double x, double y, double z, double t) {
return x + (z * ((y - x) / 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 + (z * ((y - x) / t))
end function
public static double code(double x, double y, double z, double t) {
return x + (z * ((y - x) / t));
}
def code(x, y, z, t): return x + (z * ((y - x) / t))
function code(x, y, z, t) return Float64(x + Float64(z * Float64(Float64(y - x) / t))) end
function tmp = code(x, y, z, t) tmp = x + (z * ((y - x) / t)); end
code[x_, y_, z_, t_] := N[(x + N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + z \cdot \frac{y - x}{t}
\end{array}
Initial program 93.5%
associate-*l/93.7%
Simplified93.7%
Final simplification93.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 93.5%
associate-/l*98.2%
Simplified98.2%
Final simplification98.2%
(FPCore (x y z t) :precision binary64 (* x (- 1.0 (/ z t))))
double code(double x, double y, double z, double t) {
return x * (1.0 - (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 * (1.0d0 - (z / t))
end function
public static double code(double x, double y, double z, double t) {
return x * (1.0 - (z / t));
}
def code(x, y, z, t): return x * (1.0 - (z / t))
function code(x, y, z, t) return Float64(x * Float64(1.0 - Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x * (1.0 - (z / t)); end
code[x_, y_, z_, t_] := N[(x * N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \frac{z}{t}\right)
\end{array}
Initial program 93.5%
+-commutative93.5%
remove-double-neg93.5%
unsub-neg93.5%
associate-*r/98.0%
fma-neg98.0%
remove-double-neg98.0%
Simplified98.0%
Taylor expanded in y around 0 59.1%
mul-1-neg59.1%
associate-*r/62.7%
*-rgt-identity62.7%
distribute-rgt-neg-in62.7%
mul-1-neg62.7%
distribute-lft-in62.8%
mul-1-neg62.8%
unsub-neg62.8%
Simplified62.8%
Final simplification62.8%
(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 93.5%
+-commutative93.5%
remove-double-neg93.5%
unsub-neg93.5%
associate-*r/98.0%
fma-neg98.0%
remove-double-neg98.0%
Simplified98.0%
Taylor expanded in z around 0 39.9%
Final simplification39.9%
(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 2023336
(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)))