
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - 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 + ((y * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
double code(double x, double y, double z, double t) {
return x + ((y * (z - 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 + ((y * (z - x)) / t)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (z - x)) / t);
}
def code(x, y, z, t): return x + ((y * (z - x)) / t)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(z - x)) / t)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (z - x)) / t); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - x\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ (- z x) (/ t y))))
double code(double x, double y, double z, double t) {
return x + ((z - x) / (t / y));
}
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 - x) / (t / y))
end function
public static double code(double x, double y, double z, double t) {
return x + ((z - x) / (t / y));
}
def code(x, y, z, t): return x + ((z - x) / (t / y))
function code(x, y, z, t) return Float64(x + Float64(Float64(z - x) / Float64(t / y))) end
function tmp = code(x, y, z, t) tmp = x + ((z - x) / (t / y)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(z - x), $MachinePrecision] / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{z - x}{\frac{t}{y}}
\end{array}
Initial program 92.3%
Taylor expanded in z around 0 87.5%
mul-1-neg87.5%
associate-/l*89.1%
distribute-lft-neg-in89.1%
*-commutative89.1%
associate-*r/92.5%
distribute-rgt-in98.4%
+-commutative98.4%
sub-neg98.4%
Simplified98.4%
*-commutative98.4%
clear-num98.4%
un-div-inv98.6%
Applied egg-rr98.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z y) t)))
(if (<= t -4.9e-11)
x
(if (<= t -7.2e-208)
t_1
(if (<= t -3.05e-304) (* x (/ y (- t))) (if (<= t 3.8e+90) t_1 x))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * y) / t;
double tmp;
if (t <= -4.9e-11) {
tmp = x;
} else if (t <= -7.2e-208) {
tmp = t_1;
} else if (t <= -3.05e-304) {
tmp = x * (y / -t);
} else if (t <= 3.8e+90) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = (z * y) / t
if (t <= (-4.9d-11)) then
tmp = x
else if (t <= (-7.2d-208)) then
tmp = t_1
else if (t <= (-3.05d-304)) then
tmp = x * (y / -t)
else if (t <= 3.8d+90) then
tmp = t_1
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (z * y) / t;
double tmp;
if (t <= -4.9e-11) {
tmp = x;
} else if (t <= -7.2e-208) {
tmp = t_1;
} else if (t <= -3.05e-304) {
tmp = x * (y / -t);
} else if (t <= 3.8e+90) {
tmp = t_1;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): t_1 = (z * y) / t tmp = 0 if t <= -4.9e-11: tmp = x elif t <= -7.2e-208: tmp = t_1 elif t <= -3.05e-304: tmp = x * (y / -t) elif t <= 3.8e+90: tmp = t_1 else: tmp = x return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z * y) / t) tmp = 0.0 if (t <= -4.9e-11) tmp = x; elseif (t <= -7.2e-208) tmp = t_1; elseif (t <= -3.05e-304) tmp = Float64(x * Float64(y / Float64(-t))); elseif (t <= 3.8e+90) tmp = t_1; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (z * y) / t; tmp = 0.0; if (t <= -4.9e-11) tmp = x; elseif (t <= -7.2e-208) tmp = t_1; elseif (t <= -3.05e-304) tmp = x * (y / -t); elseif (t <= 3.8e+90) tmp = t_1; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[t, -4.9e-11], x, If[LessEqual[t, -7.2e-208], t$95$1, If[LessEqual[t, -3.05e-304], N[(x * N[(y / (-t)), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 3.8e+90], t$95$1, x]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot y}{t}\\
\mathbf{if}\;t \leq -4.9 \cdot 10^{-11}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq -7.2 \cdot 10^{-208}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq -3.05 \cdot 10^{-304}:\\
\;\;\;\;x \cdot \frac{y}{-t}\\
\mathbf{elif}\;t \leq 3.8 \cdot 10^{+90}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -4.8999999999999999e-11 or 3.8000000000000001e90 < t Initial program 85.1%
Taylor expanded in y around 0 63.6%
if -4.8999999999999999e-11 < t < -7.1999999999999997e-208 or -3.0500000000000002e-304 < t < 3.8000000000000001e90Initial program 98.9%
Taylor expanded in y around -inf 82.3%
Taylor expanded in z around inf 59.0%
if -7.1999999999999997e-208 < t < -3.0500000000000002e-304Initial program 91.5%
Taylor expanded in x around inf 87.5%
mul-1-neg87.5%
unsub-neg87.5%
Simplified87.5%
Taylor expanded in y around inf 87.5%
associate-*r/87.5%
neg-mul-187.5%
Simplified87.5%
Final simplification63.6%
(FPCore (x y z t) :precision binary64 (if (or (<= t -8.5e-88) (not (<= t 2.9e-6))) (+ x (/ y (/ t z))) (* (- z x) (/ y t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8.5e-88) || !(t <= 2.9e-6)) {
tmp = x + (y / (t / z));
} else {
tmp = (z - x) * (y / 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 ((t <= (-8.5d-88)) .or. (.not. (t <= 2.9d-6))) then
tmp = x + (y / (t / z))
else
tmp = (z - x) * (y / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -8.5e-88) || !(t <= 2.9e-6)) {
tmp = x + (y / (t / z));
} else {
tmp = (z - x) * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -8.5e-88) or not (t <= 2.9e-6): tmp = x + (y / (t / z)) else: tmp = (z - x) * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -8.5e-88) || !(t <= 2.9e-6)) tmp = Float64(x + Float64(y / Float64(t / z))); else tmp = Float64(Float64(z - x) * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -8.5e-88) || ~((t <= 2.9e-6))) tmp = x + (y / (t / z)); else tmp = (z - x) * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -8.5e-88], N[Not[LessEqual[t, 2.9e-6]], $MachinePrecision]], N[(x + N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -8.5 \cdot 10^{-88} \lor \neg \left(t \leq 2.9 \cdot 10^{-6}\right):\\
\;\;\;\;x + \frac{y}{\frac{t}{z}}\\
\mathbf{else}:\\
\;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\
\end{array}
\end{array}
if t < -8.4999999999999996e-88 or 2.9000000000000002e-6 < t Initial program 88.4%
Taylor expanded in z around inf 84.5%
associate-/l*91.1%
Simplified91.1%
clear-num91.1%
un-div-inv91.2%
Applied egg-rr91.2%
if -8.4999999999999996e-88 < t < 2.9000000000000002e-6Initial program 97.1%
Taylor expanded in y around -inf 90.3%
Taylor expanded in z around 0 82.3%
mul-1-neg89.2%
associate-/l*85.8%
distribute-lft-neg-in85.8%
*-commutative85.8%
associate-*r/85.8%
distribute-rgt-in97.4%
+-commutative97.4%
sub-neg97.4%
Simplified90.5%
Final simplification90.9%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.25e-89) (not (<= t 1.65e-6))) (+ x (* y (/ z t))) (* (- z x) (/ y t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.25e-89) || !(t <= 1.65e-6)) {
tmp = x + (y * (z / t));
} else {
tmp = (z - x) * (y / 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 ((t <= (-1.25d-89)) .or. (.not. (t <= 1.65d-6))) then
tmp = x + (y * (z / t))
else
tmp = (z - x) * (y / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.25e-89) || !(t <= 1.65e-6)) {
tmp = x + (y * (z / t));
} else {
tmp = (z - x) * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.25e-89) or not (t <= 1.65e-6): tmp = x + (y * (z / t)) else: tmp = (z - x) * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.25e-89) || !(t <= 1.65e-6)) tmp = Float64(x + Float64(y * Float64(z / t))); else tmp = Float64(Float64(z - x) * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.25e-89) || ~((t <= 1.65e-6))) tmp = x + (y * (z / t)); else tmp = (z - x) * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.25e-89], N[Not[LessEqual[t, 1.65e-6]], $MachinePrecision]], N[(x + N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.25 \cdot 10^{-89} \lor \neg \left(t \leq 1.65 \cdot 10^{-6}\right):\\
\;\;\;\;x + y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\
\end{array}
\end{array}
if t < -1.24999999999999992e-89 or 1.65000000000000008e-6 < t Initial program 88.4%
Taylor expanded in z around inf 84.5%
associate-/l*91.1%
Simplified91.1%
if -1.24999999999999992e-89 < t < 1.65000000000000008e-6Initial program 97.1%
Taylor expanded in y around -inf 90.3%
Taylor expanded in z around 0 82.3%
mul-1-neg89.2%
associate-/l*85.8%
distribute-lft-neg-in85.8%
*-commutative85.8%
associate-*r/85.8%
distribute-rgt-in97.4%
+-commutative97.4%
sub-neg97.4%
Simplified90.5%
Final simplification90.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -7.5e-7) (not (<= z 3e+64))) (* (- z x) (/ y t)) (* x (- 1.0 (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -7.5e-7) || !(z <= 3e+64)) {
tmp = (z - x) * (y / t);
} else {
tmp = x * (1.0 - (y / 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 <= (-7.5d-7)) .or. (.not. (z <= 3d+64))) then
tmp = (z - x) * (y / t)
else
tmp = x * (1.0d0 - (y / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -7.5e-7) || !(z <= 3e+64)) {
tmp = (z - x) * (y / t);
} else {
tmp = x * (1.0 - (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -7.5e-7) or not (z <= 3e+64): tmp = (z - x) * (y / t) else: tmp = x * (1.0 - (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -7.5e-7) || !(z <= 3e+64)) tmp = Float64(Float64(z - x) * Float64(y / t)); else tmp = Float64(x * Float64(1.0 - Float64(y / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -7.5e-7) || ~((z <= 3e+64))) tmp = (z - x) * (y / t); else tmp = x * (1.0 - (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -7.5e-7], N[Not[LessEqual[z, 3e+64]], $MachinePrecision]], N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{-7} \lor \neg \left(z \leq 3 \cdot 10^{+64}\right):\\
\;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\
\end{array}
\end{array}
if z < -7.5000000000000002e-7 or 3.0000000000000002e64 < z Initial program 90.1%
Taylor expanded in y around -inf 72.4%
Taylor expanded in z around 0 64.7%
mul-1-neg82.5%
associate-/l*83.4%
distribute-lft-neg-in83.4%
*-commutative83.4%
associate-*r/90.6%
distribute-rgt-in99.0%
+-commutative99.0%
sub-neg99.0%
Simplified77.3%
if -7.5000000000000002e-7 < z < 3.0000000000000002e64Initial program 94.1%
Taylor expanded in x around inf 86.4%
mul-1-neg86.4%
unsub-neg86.4%
Simplified86.4%
Final simplification82.2%
(FPCore (x y z t) :precision binary64 (if (<= z -2.6e+111) (* y (/ z t)) (if (<= z 4e+75) (* x (- 1.0 (/ y t))) (/ (* z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.6e+111) {
tmp = y * (z / t);
} else if (z <= 4e+75) {
tmp = x * (1.0 - (y / t));
} else {
tmp = (z * y) / 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.6d+111)) then
tmp = y * (z / t)
else if (z <= 4d+75) then
tmp = x * (1.0d0 - (y / t))
else
tmp = (z * y) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.6e+111) {
tmp = y * (z / t);
} else if (z <= 4e+75) {
tmp = x * (1.0 - (y / t));
} else {
tmp = (z * y) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.6e+111: tmp = y * (z / t) elif z <= 4e+75: tmp = x * (1.0 - (y / t)) else: tmp = (z * y) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.6e+111) tmp = Float64(y * Float64(z / t)); elseif (z <= 4e+75) tmp = Float64(x * Float64(1.0 - Float64(y / t))); else tmp = Float64(Float64(z * y) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.6e+111) tmp = y * (z / t); elseif (z <= 4e+75) tmp = x * (1.0 - (y / t)); else tmp = (z * y) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.6e+111], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4e+75], N[(x * N[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.6 \cdot 10^{+111}:\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+75}:\\
\;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot y}{t}\\
\end{array}
\end{array}
if z < -2.5999999999999999e111Initial program 88.4%
Taylor expanded in y around -inf 67.1%
Taylor expanded in z around inf 64.7%
associate-/l*91.0%
Simplified66.9%
if -2.5999999999999999e111 < z < 3.99999999999999971e75Initial program 92.9%
Taylor expanded in x around inf 80.9%
mul-1-neg80.9%
unsub-neg80.9%
Simplified80.9%
if 3.99999999999999971e75 < z Initial program 93.6%
Taylor expanded in y around -inf 85.3%
Taylor expanded in z around inf 81.2%
Final simplification78.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -6e-53) (not (<= z 6.5e+20))) (* y (/ z t)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -6e-53) || !(z <= 6.5e+20)) {
tmp = y * (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 ((z <= (-6d-53)) .or. (.not. (z <= 6.5d+20))) then
tmp = y * (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 ((z <= -6e-53) || !(z <= 6.5e+20)) {
tmp = y * (z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -6e-53) or not (z <= 6.5e+20): tmp = y * (z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -6e-53) || !(z <= 6.5e+20)) tmp = Float64(y * Float64(z / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -6e-53) || ~((z <= 6.5e+20))) tmp = y * (z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -6e-53], N[Not[LessEqual[z, 6.5e+20]], $MachinePrecision]], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{-53} \lor \neg \left(z \leq 6.5 \cdot 10^{+20}\right):\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.0000000000000004e-53 or 6.5e20 < z Initial program 91.0%
Taylor expanded in y around -inf 71.3%
Taylor expanded in z around inf 65.3%
associate-/l*89.6%
Simplified66.0%
if -6.0000000000000004e-53 < z < 6.5e20Initial program 93.8%
Taylor expanded in y around 0 51.9%
Final simplification59.7%
(FPCore (x y z t) :precision binary64 (if (<= z -5.8e-52) (* y (/ z t)) (if (<= z 1.12e+21) x (/ (* z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.8e-52) {
tmp = y * (z / t);
} else if (z <= 1.12e+21) {
tmp = x;
} else {
tmp = (z * y) / 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 <= (-5.8d-52)) then
tmp = y * (z / t)
else if (z <= 1.12d+21) then
tmp = x
else
tmp = (z * y) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.8e-52) {
tmp = y * (z / t);
} else if (z <= 1.12e+21) {
tmp = x;
} else {
tmp = (z * y) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.8e-52: tmp = y * (z / t) elif z <= 1.12e+21: tmp = x else: tmp = (z * y) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.8e-52) tmp = Float64(y * Float64(z / t)); elseif (z <= 1.12e+21) tmp = x; else tmp = Float64(Float64(z * y) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5.8e-52) tmp = y * (z / t); elseif (z <= 1.12e+21) tmp = x; else tmp = (z * y) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.8e-52], N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.12e+21], x, N[(N[(z * y), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{-52}:\\
\;\;\;\;y \cdot \frac{z}{t}\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{+21}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot y}{t}\\
\end{array}
\end{array}
if z < -5.8000000000000003e-52Initial program 89.5%
Taylor expanded in y around -inf 64.3%
Taylor expanded in z around inf 57.5%
associate-/l*89.4%
Simplified60.0%
if -5.8000000000000003e-52 < z < 1.12e21Initial program 93.8%
Taylor expanded in y around 0 51.9%
if 1.12e21 < z Initial program 93.2%
Taylor expanded in y around -inf 81.6%
Taylor expanded in z around inf 76.5%
Final simplification60.1%
(FPCore (x y z t) :precision binary64 (+ x (* (- z x) (/ y t))))
double code(double x, double y, double z, double t) {
return x + ((z - x) * (y / 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 - x) * (y / t))
end function
public static double code(double x, double y, double z, double t) {
return x + ((z - x) * (y / t));
}
def code(x, y, z, t): return x + ((z - x) * (y / t))
function code(x, y, z, t) return Float64(x + Float64(Float64(z - x) * Float64(y / t))) end
function tmp = code(x, y, z, t) tmp = x + ((z - x) * (y / t)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(z - x), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(z - x\right) \cdot \frac{y}{t}
\end{array}
Initial program 92.3%
Taylor expanded in z around 0 87.5%
mul-1-neg87.5%
associate-/l*89.1%
distribute-lft-neg-in89.1%
*-commutative89.1%
associate-*r/92.5%
distribute-rgt-in98.4%
+-commutative98.4%
sub-neg98.4%
Simplified98.4%
Final simplification98.4%
(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 92.3%
Taylor expanded in y around 0 37.1%
(FPCore (x y z t) :precision binary64 (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / 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 - ((x * (y / t)) + (-z * (y / t)))
end function
public static double code(double x, double y, double z, double t) {
return x - ((x * (y / t)) + (-z * (y / t)));
}
def code(x, y, z, t): return x - ((x * (y / t)) + (-z * (y / t)))
function code(x, y, z, t) return Float64(x - Float64(Float64(x * Float64(y / t)) + Float64(Float64(-z) * Float64(y / t)))) end
function tmp = code(x, y, z, t) tmp = x - ((x * (y / t)) + (-z * (y / t))); end
code[x_, y_, z_, t_] := N[(x - N[(N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision] + N[((-z) * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right)
\end{array}
herbie shell --seed 2024145
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
:precision binary64
:alt
(! :herbie-platform default (- x (+ (* x (/ y t)) (* (- z) (/ y t)))))
(+ x (/ (* y (- z x)) t)))