
(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 8 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 (* 0.5 (/ x t))))
(if (<= y -3.6e-180)
t_2
(if (<= y -5.4e-287)
t_1
(if (<= y 1.18e-287)
t_2
(if (<= y 4.6e-207)
t_1
(if (<= y 1.42e-126)
t_2
(if (<= y 1.02e-20) 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 = 0.5 * (x / t);
double tmp;
if (y <= -3.6e-180) {
tmp = t_2;
} else if (y <= -5.4e-287) {
tmp = t_1;
} else if (y <= 1.18e-287) {
tmp = t_2;
} else if (y <= 4.6e-207) {
tmp = t_1;
} else if (y <= 1.42e-126) {
tmp = t_2;
} else if (y <= 1.02e-20) {
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 = 0.5d0 * (x / t)
if (y <= (-3.6d-180)) then
tmp = t_2
else if (y <= (-5.4d-287)) then
tmp = t_1
else if (y <= 1.18d-287) then
tmp = t_2
else if (y <= 4.6d-207) then
tmp = t_1
else if (y <= 1.42d-126) then
tmp = t_2
else if (y <= 1.02d-20) 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 = 0.5 * (x / t);
double tmp;
if (y <= -3.6e-180) {
tmp = t_2;
} else if (y <= -5.4e-287) {
tmp = t_1;
} else if (y <= 1.18e-287) {
tmp = t_2;
} else if (y <= 4.6e-207) {
tmp = t_1;
} else if (y <= 1.42e-126) {
tmp = t_2;
} else if (y <= 1.02e-20) {
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 = 0.5 * (x / t) tmp = 0 if y <= -3.6e-180: tmp = t_2 elif y <= -5.4e-287: tmp = t_1 elif y <= 1.18e-287: tmp = t_2 elif y <= 4.6e-207: tmp = t_1 elif y <= 1.42e-126: tmp = t_2 elif y <= 1.02e-20: 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(0.5 * Float64(x / t)) tmp = 0.0 if (y <= -3.6e-180) tmp = t_2; elseif (y <= -5.4e-287) tmp = t_1; elseif (y <= 1.18e-287) tmp = t_2; elseif (y <= 4.6e-207) tmp = t_1; elseif (y <= 1.42e-126) tmp = t_2; elseif (y <= 1.02e-20) 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 = 0.5 * (x / t); tmp = 0.0; if (y <= -3.6e-180) tmp = t_2; elseif (y <= -5.4e-287) tmp = t_1; elseif (y <= 1.18e-287) tmp = t_2; elseif (y <= 4.6e-207) tmp = t_1; elseif (y <= 1.42e-126) tmp = t_2; elseif (y <= 1.02e-20) 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[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.6e-180], t$95$2, If[LessEqual[y, -5.4e-287], t$95$1, If[LessEqual[y, 1.18e-287], t$95$2, If[LessEqual[y, 4.6e-207], t$95$1, If[LessEqual[y, 1.42e-126], t$95$2, If[LessEqual[y, 1.02e-20], 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 := 0.5 \cdot \frac{x}{t}\\
\mathbf{if}\;y \leq -3.6 \cdot 10^{-180}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq -5.4 \cdot 10^{-287}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.18 \cdot 10^{-287}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{-207}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.42 \cdot 10^{-126}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < -3.5999999999999999e-180 or -5.4000000000000002e-287 < y < 1.18000000000000003e-287 or 4.6000000000000001e-207 < y < 1.42e-126Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.6%
remove-double-neg99.6%
sub0-neg99.6%
div-sub99.6%
metadata-eval99.6%
neg-mul-199.6%
*-commutative99.6%
associate-/l*99.6%
metadata-eval99.6%
/-rgt-identity99.6%
associate--r-99.6%
neg-sub099.6%
+-commutative99.6%
sub-neg99.6%
+-commutative99.6%
associate--r+99.6%
*-commutative99.6%
associate-/r*99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 41.5%
if -3.5999999999999999e-180 < y < -5.4000000000000002e-287 or 1.18000000000000003e-287 < y < 4.6000000000000001e-207 or 1.42e-126 < y < 1.02000000000000001e-20Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.7%
remove-double-neg99.7%
sub0-neg99.7%
div-sub99.7%
metadata-eval99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate--r-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 58.3%
if 1.02000000000000001e-20 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.7%
remove-double-neg99.7%
sub0-neg99.7%
div-sub99.7%
metadata-eval99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate--r-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 60.3%
Final simplification50.7%
(FPCore (x y z t) :precision binary64 (if (or (<= x -4.7e+144) (and (not (<= x -1.9e+16)) (<= x -7.4e-9))) (* 0.5 (/ x t)) (* -0.5 (/ (- z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -4.7e+144) || (!(x <= -1.9e+16) && (x <= -7.4e-9))) {
tmp = 0.5 * (x / 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 <= (-4.7d+144)) .or. (.not. (x <= (-1.9d+16))) .and. (x <= (-7.4d-9))) then
tmp = 0.5d0 * (x / 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 <= -4.7e+144) || (!(x <= -1.9e+16) && (x <= -7.4e-9))) {
tmp = 0.5 * (x / t);
} else {
tmp = -0.5 * ((z - y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -4.7e+144) or (not (x <= -1.9e+16) and (x <= -7.4e-9)): tmp = 0.5 * (x / t) else: tmp = -0.5 * ((z - y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -4.7e+144) || (!(x <= -1.9e+16) && (x <= -7.4e-9))) tmp = Float64(0.5 * Float64(x / 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 <= -4.7e+144) || (~((x <= -1.9e+16)) && (x <= -7.4e-9))) tmp = 0.5 * (x / t); else tmp = -0.5 * ((z - y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -4.7e+144], And[N[Not[LessEqual[x, -1.9e+16]], $MachinePrecision], LessEqual[x, -7.4e-9]]], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.7 \cdot 10^{+144} \lor \neg \left(x \leq -1.9 \cdot 10^{+16}\right) \land x \leq -7.4 \cdot 10^{-9}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z - y}{t}\\
\end{array}
\end{array}
if x < -4.7000000000000002e144 or -1.9e16 < x < -7.4e-9Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.7%
remove-double-neg99.7%
sub0-neg99.7%
div-sub99.7%
metadata-eval99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate--r-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 83.7%
if -4.7000000000000002e144 < x < -1.9e16 or -7.4e-9 < x Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.6%
remove-double-neg99.6%
sub0-neg99.6%
div-sub99.6%
metadata-eval99.6%
neg-mul-199.6%
*-commutative99.6%
associate-/l*99.6%
metadata-eval99.6%
/-rgt-identity99.6%
associate--r-99.6%
neg-sub099.6%
+-commutative99.6%
sub-neg99.6%
+-commutative99.6%
associate--r+99.6%
*-commutative99.6%
associate-/r*99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around 0 76.9%
Final simplification78.2%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1.26e+67) (and (not (<= x -7.8e+21)) (<= x -5e-9))) (* 0.5 (/ x t)) (* -0.5 (/ z t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1.26e+67) || (!(x <= -7.8e+21) && (x <= -5e-9))) {
tmp = 0.5 * (x / 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 ((x <= (-1.26d+67)) .or. (.not. (x <= (-7.8d+21))) .and. (x <= (-5d-9))) then
tmp = 0.5d0 * (x / 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 ((x <= -1.26e+67) || (!(x <= -7.8e+21) && (x <= -5e-9))) {
tmp = 0.5 * (x / t);
} else {
tmp = -0.5 * (z / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1.26e+67) or (not (x <= -7.8e+21) and (x <= -5e-9)): tmp = 0.5 * (x / t) else: tmp = -0.5 * (z / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1.26e+67) || (!(x <= -7.8e+21) && (x <= -5e-9))) tmp = Float64(0.5 * Float64(x / 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 ((x <= -1.26e+67) || (~((x <= -7.8e+21)) && (x <= -5e-9))) tmp = 0.5 * (x / t); else tmp = -0.5 * (z / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1.26e+67], And[N[Not[LessEqual[x, -7.8e+21]], $MachinePrecision], LessEqual[x, -5e-9]]], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.26 \cdot 10^{+67} \lor \neg \left(x \leq -7.8 \cdot 10^{+21}\right) \land x \leq -5 \cdot 10^{-9}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z}{t}\\
\end{array}
\end{array}
if x < -1.26e67 or -7.8e21 < x < -5.0000000000000001e-9Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.7%
remove-double-neg99.7%
sub0-neg99.7%
div-sub99.7%
metadata-eval99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate--r-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 76.0%
if -1.26e67 < x < -7.8e21 or -5.0000000000000001e-9 < x Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.6%
remove-double-neg99.6%
sub0-neg99.6%
div-sub99.6%
metadata-eval99.6%
neg-mul-199.6%
*-commutative99.6%
associate-/l*99.6%
metadata-eval99.6%
/-rgt-identity99.6%
associate--r-99.6%
neg-sub099.6%
+-commutative99.6%
sub-neg99.6%
+-commutative99.6%
associate--r+99.6%
*-commutative99.6%
associate-/r*99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 42.1%
Final simplification49.5%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -2e-167) (* (/ -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) <= -2e-167) {
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) <= (-2d-167)) 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) <= -2e-167) {
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) <= -2e-167: 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) <= -2e-167) 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) <= -2e-167) 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], -2e-167], 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 -2 \cdot 10^{-167}:\\
\;\;\;\;\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) < -2e-167Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.6%
remove-double-neg99.6%
sub0-neg99.6%
div-sub99.6%
metadata-eval99.6%
neg-mul-199.6%
*-commutative99.6%
associate-/l*99.6%
metadata-eval99.6%
/-rgt-identity99.6%
associate--r-99.6%
neg-sub099.6%
+-commutative99.6%
sub-neg99.6%
+-commutative99.6%
associate--r+99.6%
*-commutative99.6%
associate-/r*99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 65.1%
associate-*r/65.1%
Simplified65.1%
associate-/l*64.9%
associate-/r/64.9%
Applied egg-rr64.9%
if -2e-167 < (+.f64 x y) Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.7%
remove-double-neg99.7%
sub0-neg99.7%
div-sub99.7%
metadata-eval99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate--r-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 70.4%
Final simplification67.7%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -2e-167) (/ (* -0.5 (- z x)) t) (* -0.5 (/ (- z y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -2e-167) {
tmp = (-0.5 * (z - x)) / 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 + y) <= (-2d-167)) then
tmp = ((-0.5d0) * (z - x)) / 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 + y) <= -2e-167) {
tmp = (-0.5 * (z - x)) / t;
} else {
tmp = -0.5 * ((z - y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -2e-167: tmp = (-0.5 * (z - x)) / t else: tmp = -0.5 * ((z - y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -2e-167) tmp = Float64(Float64(-0.5 * Float64(z - x)) / 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 + y) <= -2e-167) tmp = (-0.5 * (z - x)) / t; else tmp = -0.5 * ((z - y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -2e-167], N[(N[(-0.5 * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], N[(-0.5 * N[(N[(z - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -2 \cdot 10^{-167}:\\
\;\;\;\;\frac{-0.5 \cdot \left(z - x\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{z - y}{t}\\
\end{array}
\end{array}
if (+.f64 x y) < -2e-167Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.6%
remove-double-neg99.6%
sub0-neg99.6%
div-sub99.6%
metadata-eval99.6%
neg-mul-199.6%
*-commutative99.6%
associate-/l*99.6%
metadata-eval99.6%
/-rgt-identity99.6%
associate--r-99.6%
neg-sub099.6%
+-commutative99.6%
sub-neg99.6%
+-commutative99.6%
associate--r+99.6%
*-commutative99.6%
associate-/r*99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around 0 65.1%
associate-*r/65.1%
Simplified65.1%
if -2e-167 < (+.f64 x y) Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.7%
remove-double-neg99.7%
sub0-neg99.7%
div-sub99.7%
metadata-eval99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate--r-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 70.4%
Final simplification67.8%
(FPCore (x y z t) :precision binary64 (* (- (- z y) x) (/ -0.5 t)))
double code(double x, double y, double z, double t) {
return ((z - y) - x) * (-0.5 / 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 = ((z - y) - x) * ((-0.5d0) / t)
end function
public static double code(double x, double y, double z, double t) {
return ((z - y) - x) * (-0.5 / t);
}
def code(x, y, z, t): return ((z - y) - x) * (-0.5 / t)
function code(x, y, z, t) return Float64(Float64(Float64(z - y) - x) * Float64(-0.5 / t)) end
function tmp = code(x, y, z, t) tmp = ((z - y) - x) * (-0.5 / t); end
code[x_, y_, z_, t_] := N[(N[(N[(z - y), $MachinePrecision] - x), $MachinePrecision] * N[(-0.5 / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(z - y\right) - x\right) \cdot \frac{-0.5}{t}
\end{array}
Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.7%
remove-double-neg99.7%
sub0-neg99.7%
div-sub99.7%
metadata-eval99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate--r-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(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%
*-commutative100.0%
times-frac99.7%
remove-double-neg99.7%
sub0-neg99.7%
div-sub99.7%
metadata-eval99.7%
neg-mul-199.7%
*-commutative99.7%
associate-/l*99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate--r-99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
+-commutative99.7%
associate--r+99.7%
*-commutative99.7%
associate-/r*99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 35.8%
Final simplification35.8%
herbie shell --seed 2024027
(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)))