
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
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) / (t * 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
def code(x, y, z, t): return ((x + y) - z) / (t * 2.0)
function code(x, y, z, t) return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0)) end
function tmp = code(x, y, z, t) tmp = ((x + y) - z) / (t * 2.0); end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y\right) - z}{t \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
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) / (t * 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
def code(x, y, z, t): return ((x + y) - z) / (t * 2.0)
function code(x, y, z, t) return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0)) end
function tmp = code(x, y, z, t) tmp = ((x + y) - z) / (t * 2.0); end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y\right) - z}{t \cdot 2}
\end{array}
(FPCore (x y z t) :precision binary64 (/ (- (+ x y) z) (* t 2.0)))
double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
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) / (t * 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return ((x + y) - z) / (t * 2.0);
}
def code(x, y, z, t): return ((x + y) - z) / (t * 2.0)
function code(x, y, z, t) return Float64(Float64(Float64(x + y) - z) / Float64(t * 2.0)) end
function tmp = code(x, y, z, t) tmp = ((x + y) - z) / (t * 2.0); end
code[x_, y_, z_, t_] := N[(N[(N[(x + y), $MachinePrecision] - z), $MachinePrecision] / N[(t * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x + y\right) - z}{t \cdot 2}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* -0.5 (/ z t))) (t_2 (/ (* x 0.5) t)))
(if (<= y -5e+17)
t_2
(if (<= y -3.7e-61)
t_1
(if (<= y -6.8e-271)
t_2
(if (<= y 1.4e-230)
t_1
(if (<= y 2.5e-209)
t_2
(if (<= y 8.5e-107)
t_1
(if (<= y 6.8e-90)
t_2
(if (<= y 4.9e+117) t_1 (* 0.5 (/ y t))))))))))))
double code(double x, double y, double z, double t) {
double t_1 = -0.5 * (z / t);
double t_2 = (x * 0.5) / t;
double tmp;
if (y <= -5e+17) {
tmp = t_2;
} else if (y <= -3.7e-61) {
tmp = t_1;
} else if (y <= -6.8e-271) {
tmp = t_2;
} else if (y <= 1.4e-230) {
tmp = t_1;
} else if (y <= 2.5e-209) {
tmp = t_2;
} else if (y <= 8.5e-107) {
tmp = t_1;
} else if (y <= 6.8e-90) {
tmp = t_2;
} else if (y <= 4.9e+117) {
tmp = t_1;
} else {
tmp = 0.5 * (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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (-0.5d0) * (z / t)
t_2 = (x * 0.5d0) / t
if (y <= (-5d+17)) then
tmp = t_2
else if (y <= (-3.7d-61)) then
tmp = t_1
else if (y <= (-6.8d-271)) then
tmp = t_2
else if (y <= 1.4d-230) then
tmp = t_1
else if (y <= 2.5d-209) then
tmp = t_2
else if (y <= 8.5d-107) then
tmp = t_1
else if (y <= 6.8d-90) then
tmp = t_2
else if (y <= 4.9d+117) then
tmp = t_1
else
tmp = 0.5d0 * (y / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -0.5 * (z / t);
double t_2 = (x * 0.5) / t;
double tmp;
if (y <= -5e+17) {
tmp = t_2;
} else if (y <= -3.7e-61) {
tmp = t_1;
} else if (y <= -6.8e-271) {
tmp = t_2;
} else if (y <= 1.4e-230) {
tmp = t_1;
} else if (y <= 2.5e-209) {
tmp = t_2;
} else if (y <= 8.5e-107) {
tmp = t_1;
} else if (y <= 6.8e-90) {
tmp = t_2;
} else if (y <= 4.9e+117) {
tmp = t_1;
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = -0.5 * (z / t) t_2 = (x * 0.5) / t tmp = 0 if y <= -5e+17: tmp = t_2 elif y <= -3.7e-61: tmp = t_1 elif y <= -6.8e-271: tmp = t_2 elif y <= 1.4e-230: tmp = t_1 elif y <= 2.5e-209: tmp = t_2 elif y <= 8.5e-107: tmp = t_1 elif y <= 6.8e-90: tmp = t_2 elif y <= 4.9e+117: tmp = t_1 else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) t_1 = Float64(-0.5 * Float64(z / t)) t_2 = Float64(Float64(x * 0.5) / t) tmp = 0.0 if (y <= -5e+17) tmp = t_2; elseif (y <= -3.7e-61) tmp = t_1; elseif (y <= -6.8e-271) tmp = t_2; elseif (y <= 1.4e-230) tmp = t_1; elseif (y <= 2.5e-209) tmp = t_2; elseif (y <= 8.5e-107) tmp = t_1; elseif (y <= 6.8e-90) tmp = t_2; elseif (y <= 4.9e+117) tmp = t_1; else tmp = Float64(0.5 * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -0.5 * (z / t); t_2 = (x * 0.5) / t; tmp = 0.0; if (y <= -5e+17) tmp = t_2; elseif (y <= -3.7e-61) tmp = t_1; elseif (y <= -6.8e-271) tmp = t_2; elseif (y <= 1.4e-230) tmp = t_1; elseif (y <= 2.5e-209) tmp = t_2; elseif (y <= 8.5e-107) tmp = t_1; elseif (y <= 6.8e-90) tmp = t_2; elseif (y <= 4.9e+117) tmp = t_1; else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[y, -5e+17], t$95$2, If[LessEqual[y, -3.7e-61], t$95$1, If[LessEqual[y, -6.8e-271], t$95$2, If[LessEqual[y, 1.4e-230], t$95$1, If[LessEqual[y, 2.5e-209], t$95$2, If[LessEqual[y, 8.5e-107], t$95$1, If[LessEqual[y, 6.8e-90], t$95$2, If[LessEqual[y, 4.9e+117], t$95$1, N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -0.5 \cdot \frac{z}{t}\\
t_2 := \frac{x \cdot 0.5}{t}\\
\mathbf{if}\;y \leq -5 \cdot 10^{+17}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq -3.7 \cdot 10^{-61}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -6.8 \cdot 10^{-271}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-230}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-209}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-107}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{-90}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 4.9 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < -5e17 or -3.7e-61 < y < -6.8000000000000001e-271 or 1.4e-230 < y < 2.5000000000000002e-209 or 8.49999999999999956e-107 < y < 6.79999999999999988e-90Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 44.8%
associate-*r/44.8%
Simplified44.8%
if -5e17 < y < -3.7e-61 or -6.8000000000000001e-271 < y < 1.4e-230 or 2.5000000000000002e-209 < y < 8.49999999999999956e-107 or 6.79999999999999988e-90 < y < 4.9000000000000001e117Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 57.9%
if 4.9000000000000001e117 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 88.8%
Final simplification55.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* -0.5 (/ z t))) (t_2 (/ (* x 0.5) t)))
(if (<= y -5.5e+17)
t_2
(if (<= y -9e-60)
t_1
(if (<= y -1.12e-281)
t_2
(if (<= y 8.2e-232)
(/ (/ z -2.0) t)
(if (<= y 2e-205)
t_2
(if (<= y 1e-106)
t_1
(if (<= y 5.4e-90)
t_2
(if (<= y 2.7e+117) t_1 (* 0.5 (/ y t))))))))))))
double code(double x, double y, double z, double t) {
double t_1 = -0.5 * (z / t);
double t_2 = (x * 0.5) / t;
double tmp;
if (y <= -5.5e+17) {
tmp = t_2;
} else if (y <= -9e-60) {
tmp = t_1;
} else if (y <= -1.12e-281) {
tmp = t_2;
} else if (y <= 8.2e-232) {
tmp = (z / -2.0) / t;
} else if (y <= 2e-205) {
tmp = t_2;
} else if (y <= 1e-106) {
tmp = t_1;
} else if (y <= 5.4e-90) {
tmp = t_2;
} else if (y <= 2.7e+117) {
tmp = t_1;
} else {
tmp = 0.5 * (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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (-0.5d0) * (z / t)
t_2 = (x * 0.5d0) / t
if (y <= (-5.5d+17)) then
tmp = t_2
else if (y <= (-9d-60)) then
tmp = t_1
else if (y <= (-1.12d-281)) then
tmp = t_2
else if (y <= 8.2d-232) then
tmp = (z / (-2.0d0)) / t
else if (y <= 2d-205) then
tmp = t_2
else if (y <= 1d-106) then
tmp = t_1
else if (y <= 5.4d-90) then
tmp = t_2
else if (y <= 2.7d+117) then
tmp = t_1
else
tmp = 0.5d0 * (y / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -0.5 * (z / t);
double t_2 = (x * 0.5) / t;
double tmp;
if (y <= -5.5e+17) {
tmp = t_2;
} else if (y <= -9e-60) {
tmp = t_1;
} else if (y <= -1.12e-281) {
tmp = t_2;
} else if (y <= 8.2e-232) {
tmp = (z / -2.0) / t;
} else if (y <= 2e-205) {
tmp = t_2;
} else if (y <= 1e-106) {
tmp = t_1;
} else if (y <= 5.4e-90) {
tmp = t_2;
} else if (y <= 2.7e+117) {
tmp = t_1;
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = -0.5 * (z / t) t_2 = (x * 0.5) / t tmp = 0 if y <= -5.5e+17: tmp = t_2 elif y <= -9e-60: tmp = t_1 elif y <= -1.12e-281: tmp = t_2 elif y <= 8.2e-232: tmp = (z / -2.0) / t elif y <= 2e-205: tmp = t_2 elif y <= 1e-106: tmp = t_1 elif y <= 5.4e-90: tmp = t_2 elif y <= 2.7e+117: tmp = t_1 else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) t_1 = Float64(-0.5 * Float64(z / t)) t_2 = Float64(Float64(x * 0.5) / t) tmp = 0.0 if (y <= -5.5e+17) tmp = t_2; elseif (y <= -9e-60) tmp = t_1; elseif (y <= -1.12e-281) tmp = t_2; elseif (y <= 8.2e-232) tmp = Float64(Float64(z / -2.0) / t); elseif (y <= 2e-205) tmp = t_2; elseif (y <= 1e-106) tmp = t_1; elseif (y <= 5.4e-90) tmp = t_2; elseif (y <= 2.7e+117) tmp = t_1; else tmp = Float64(0.5 * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -0.5 * (z / t); t_2 = (x * 0.5) / t; tmp = 0.0; if (y <= -5.5e+17) tmp = t_2; elseif (y <= -9e-60) tmp = t_1; elseif (y <= -1.12e-281) tmp = t_2; elseif (y <= 8.2e-232) tmp = (z / -2.0) / t; elseif (y <= 2e-205) tmp = t_2; elseif (y <= 1e-106) tmp = t_1; elseif (y <= 5.4e-90) tmp = t_2; elseif (y <= 2.7e+117) tmp = t_1; else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[y, -5.5e+17], t$95$2, If[LessEqual[y, -9e-60], t$95$1, If[LessEqual[y, -1.12e-281], t$95$2, If[LessEqual[y, 8.2e-232], N[(N[(z / -2.0), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[y, 2e-205], t$95$2, If[LessEqual[y, 1e-106], t$95$1, If[LessEqual[y, 5.4e-90], t$95$2, If[LessEqual[y, 2.7e+117], t$95$1, N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -0.5 \cdot \frac{z}{t}\\
t_2 := \frac{x \cdot 0.5}{t}\\
\mathbf{if}\;y \leq -5.5 \cdot 10^{+17}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq -9 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.12 \cdot 10^{-281}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{-232}:\\
\;\;\;\;\frac{\frac{z}{-2}}{t}\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-205}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 10^{-106}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{-90}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+117}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < -5.5e17 or -9.00000000000000001e-60 < y < -1.12e-281 or 8.19999999999999945e-232 < y < 2e-205 or 9.99999999999999941e-107 < y < 5.39999999999999993e-90Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 45.4%
associate-*r/45.4%
Simplified45.4%
if -5.5e17 < y < -9.00000000000000001e-60 or 2e-205 < y < 9.99999999999999941e-107 or 5.39999999999999993e-90 < y < 2.7000000000000002e117Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 50.6%
if -1.12e-281 < y < 8.19999999999999945e-232Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 82.1%
metadata-eval82.1%
times-frac82.1%
*-un-lft-identity82.1%
associate-/r*82.1%
Applied egg-rr82.1%
if 2.7000000000000002e117 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 88.8%
Final simplification55.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* -0.5 (/ z t))) (t_2 (* x (/ 0.5 t))))
(if (<= y -9.5e+18)
t_2
(if (<= y -9.4e-60)
t_1
(if (<= y -1.8e-274)
t_2
(if (<= y 4.2e-106)
t_1
(if (<= y 3.5e-90)
t_2
(if (<= y 2.1e+118) t_1 (* 0.5 (/ y t))))))))))
double code(double x, double y, double z, double t) {
double t_1 = -0.5 * (z / t);
double t_2 = x * (0.5 / t);
double tmp;
if (y <= -9.5e+18) {
tmp = t_2;
} else if (y <= -9.4e-60) {
tmp = t_1;
} else if (y <= -1.8e-274) {
tmp = t_2;
} else if (y <= 4.2e-106) {
tmp = t_1;
} else if (y <= 3.5e-90) {
tmp = t_2;
} else if (y <= 2.1e+118) {
tmp = t_1;
} else {
tmp = 0.5 * (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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (-0.5d0) * (z / t)
t_2 = x * (0.5d0 / t)
if (y <= (-9.5d+18)) then
tmp = t_2
else if (y <= (-9.4d-60)) then
tmp = t_1
else if (y <= (-1.8d-274)) then
tmp = t_2
else if (y <= 4.2d-106) then
tmp = t_1
else if (y <= 3.5d-90) then
tmp = t_2
else if (y <= 2.1d+118) then
tmp = t_1
else
tmp = 0.5d0 * (y / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -0.5 * (z / t);
double t_2 = x * (0.5 / t);
double tmp;
if (y <= -9.5e+18) {
tmp = t_2;
} else if (y <= -9.4e-60) {
tmp = t_1;
} else if (y <= -1.8e-274) {
tmp = t_2;
} else if (y <= 4.2e-106) {
tmp = t_1;
} else if (y <= 3.5e-90) {
tmp = t_2;
} else if (y <= 2.1e+118) {
tmp = t_1;
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = -0.5 * (z / t) t_2 = x * (0.5 / t) tmp = 0 if y <= -9.5e+18: tmp = t_2 elif y <= -9.4e-60: tmp = t_1 elif y <= -1.8e-274: tmp = t_2 elif y <= 4.2e-106: tmp = t_1 elif y <= 3.5e-90: tmp = t_2 elif y <= 2.1e+118: tmp = t_1 else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) t_1 = Float64(-0.5 * Float64(z / t)) t_2 = Float64(x * Float64(0.5 / t)) tmp = 0.0 if (y <= -9.5e+18) tmp = t_2; elseif (y <= -9.4e-60) tmp = t_1; elseif (y <= -1.8e-274) tmp = t_2; elseif (y <= 4.2e-106) tmp = t_1; elseif (y <= 3.5e-90) tmp = t_2; elseif (y <= 2.1e+118) tmp = t_1; else tmp = Float64(0.5 * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -0.5 * (z / t); t_2 = x * (0.5 / t); tmp = 0.0; if (y <= -9.5e+18) tmp = t_2; elseif (y <= -9.4e-60) tmp = t_1; elseif (y <= -1.8e-274) tmp = t_2; elseif (y <= 4.2e-106) tmp = t_1; elseif (y <= 3.5e-90) tmp = t_2; elseif (y <= 2.1e+118) tmp = t_1; else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(0.5 / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.5e+18], t$95$2, If[LessEqual[y, -9.4e-60], t$95$1, If[LessEqual[y, -1.8e-274], t$95$2, If[LessEqual[y, 4.2e-106], t$95$1, If[LessEqual[y, 3.5e-90], t$95$2, If[LessEqual[y, 2.1e+118], t$95$1, N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -0.5 \cdot \frac{z}{t}\\
t_2 := x \cdot \frac{0.5}{t}\\
\mathbf{if}\;y \leq -9.5 \cdot 10^{+18}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq -9.4 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.8 \cdot 10^{-274}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-106}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-90}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < -9.5e18 or -9.4e-60 < y < -1.79999999999999991e-274 or 4.20000000000000007e-106 < y < 3.4999999999999999e-90Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 43.6%
associate-*r/43.6%
associate-/l*43.5%
associate-/r/43.6%
Simplified43.6%
if -9.5e18 < y < -9.4e-60 or -1.79999999999999991e-274 < y < 4.20000000000000007e-106 or 3.4999999999999999e-90 < y < 2.1e118Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 56.6%
if 2.1e118 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 88.8%
Final simplification55.0%
(FPCore (x y z t) :precision binary64 (if (or (<= x -8.2e+132) (and (not (<= x -2e+103)) (<= x -4.6e+58))) (/ (* x 0.5) t) (* -0.5 (/ (- z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -8.2e+132) || (!(x <= -2e+103) && (x <= -4.6e+58))) {
tmp = (x * 0.5) / t;
} else {
tmp = -0.5 * ((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 ((x <= (-8.2d+132)) .or. (.not. (x <= (-2d+103))) .and. (x <= (-4.6d+58))) then
tmp = (x * 0.5d0) / t
else
tmp = (-0.5d0) * ((z - y) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -8.2e+132) || (!(x <= -2e+103) && (x <= -4.6e+58))) {
tmp = (x * 0.5) / t;
} else {
tmp = -0.5 * ((z - y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -8.2e+132) or (not (x <= -2e+103) and (x <= -4.6e+58)): tmp = (x * 0.5) / t else: tmp = -0.5 * ((z - y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -8.2e+132) || (!(x <= -2e+103) && (x <= -4.6e+58))) tmp = Float64(Float64(x * 0.5) / t); else tmp = Float64(-0.5 * Float64(Float64(z - y) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -8.2e+132) || (~((x <= -2e+103)) && (x <= -4.6e+58))) tmp = (x * 0.5) / t; else tmp = -0.5 * ((z - y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -8.2e+132], And[N[Not[LessEqual[x, -2e+103]], $MachinePrecision], LessEqual[x, -4.6e+58]]], N[(N[(x * 0.5), $MachinePrecision] / t), $MachinePrecision], N[(-0.5 * N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+132} \lor \neg \left(x \leq -2 \cdot 10^{+103}\right) \land x \leq -4.6 \cdot 10^{+58}:\\
\;\;\;\;\frac{x \cdot 0.5}{t}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z - y}{t}\\
\end{array}
\end{array}
if x < -8.19999999999999983e132 or -2e103 < x < -4.60000000000000005e58Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around inf 82.9%
associate-*r/82.9%
Simplified82.9%
if -8.19999999999999983e132 < x < -2e103 or -4.60000000000000005e58 < x Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 82.2%
Final simplification82.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.75e+19) (not (<= y 2.8e+117))) (* 0.5 (/ y t)) (* -0.5 (/ z t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.75e+19) || !(y <= 2.8e+117)) {
tmp = 0.5 * (y / t);
} else {
tmp = -0.5 * (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.75d+19)) .or. (.not. (y <= 2.8d+117))) then
tmp = 0.5d0 * (y / t)
else
tmp = (-0.5d0) * (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.75e+19) || !(y <= 2.8e+117)) {
tmp = 0.5 * (y / t);
} else {
tmp = -0.5 * (z / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.75e+19) or not (y <= 2.8e+117): tmp = 0.5 * (y / t) else: tmp = -0.5 * (z / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.75e+19) || !(y <= 2.8e+117)) tmp = Float64(0.5 * Float64(y / t)); else tmp = Float64(-0.5 * Float64(z / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.75e+19) || ~((y <= 2.8e+117))) tmp = 0.5 * (y / t); else tmp = -0.5 * (z / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.75e+19], N[Not[LessEqual[y, 2.8e+117]], $MachinePrecision]], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+19} \lor \neg \left(y \leq 2.8 \cdot 10^{+117}\right):\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z}{t}\\
\end{array}
\end{array}
if y < -1.75e19 or 2.79999999999999997e117 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 73.6%
if -1.75e19 < y < 2.79999999999999997e117Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 51.5%
Final simplification60.1%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -1e-170) (* (/ -0.5 t) (- z x)) (* -0.5 (/ (- z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -1e-170) {
tmp = (-0.5 / t) * (z - x);
} else {
tmp = -0.5 * ((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 ((x + y) <= (-1d-170)) then
tmp = ((-0.5d0) / t) * (z - x)
else
tmp = (-0.5d0) * ((z - y) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -1e-170) {
tmp = (-0.5 / t) * (z - x);
} else {
tmp = -0.5 * ((z - y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -1e-170: tmp = (-0.5 / t) * (z - x) else: tmp = -0.5 * ((z - y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -1e-170) tmp = Float64(Float64(-0.5 / t) * Float64(z - x)); else tmp = Float64(-0.5 * Float64(Float64(z - y) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -1e-170) tmp = (-0.5 / t) * (z - x); else tmp = -0.5 * ((z - y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -1e-170], N[(N[(-0.5 / t), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -1 \cdot 10^{-170}:\\
\;\;\;\;\frac{-0.5}{t} \cdot \left(z - x\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z - y}{t}\\
\end{array}
\end{array}
if (+.f64 x y) < -9.99999999999999983e-171Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 69.0%
associate-*r/69.0%
associate-/l*68.8%
associate-/r/68.9%
Simplified68.9%
if -9.99999999999999983e-171 < (+.f64 x y) Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 76.3%
Final simplification72.5%
(FPCore (x y z t) :precision binary64 (if (<= x -2.9e+51) (* 0.5 (/ (+ x y) t)) (* -0.5 (/ (- z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.9e+51) {
tmp = 0.5 * ((x + y) / t);
} else {
tmp = -0.5 * ((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 (x <= (-2.9d+51)) then
tmp = 0.5d0 * ((x + y) / t)
else
tmp = (-0.5d0) * ((z - y) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.9e+51) {
tmp = 0.5 * ((x + y) / t);
} else {
tmp = -0.5 * ((z - y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -2.9e+51: tmp = 0.5 * ((x + y) / t) else: tmp = -0.5 * ((z - y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -2.9e+51) tmp = Float64(0.5 * Float64(Float64(x + y) / t)); else tmp = Float64(-0.5 * Float64(Float64(z - y) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -2.9e+51) tmp = 0.5 * ((x + y) / t); else tmp = -0.5 * ((z - y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.9e+51], N[(0.5 * N[(N[(x + y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{+51}:\\
\;\;\;\;0.5 \cdot \frac{x + y}{t}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z - y}{t}\\
\end{array}
\end{array}
if x < -2.8999999999999998e51Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around 0 87.3%
if -2.8999999999999998e51 < x Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 82.2%
Final simplification83.3%
(FPCore (x y z t) :precision binary64 (* -0.5 (/ z t)))
double code(double x, double y, double z, double t) {
return -0.5 * (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 = (-0.5d0) * (z / t)
end function
public static double code(double x, double y, double z, double t) {
return -0.5 * (z / t);
}
def code(x, y, z, t): return -0.5 * (z / t)
function code(x, y, z, t) return Float64(-0.5 * Float64(z / t)) end
function tmp = code(x, y, z, t) tmp = -0.5 * (z / t); end
code[x_, y_, z_, t_] := N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{z}{t}
\end{array}
Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
sub-neg100.0%
+-commutative100.0%
associate--r+100.0%
neg-mul-1100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 39.8%
Final simplification39.8%
herbie shell --seed 2024040
(FPCore (x y z t)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, B"
:precision binary64
(/ (- (+ x y) z) (* t 2.0)))