
(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 (/ (- z x) (* t -2.0))))
(if (<= (+ x y) 1e-123)
t_1
(if (<= (+ x y) 5e-53)
(* 0.5 (/ (+ x y) t))
(if (<= (+ x y) 1e+39) t_1 (* 0.5 (/ y t)))))))
double code(double x, double y, double z, double t) {
double t_1 = (z - x) / (t * -2.0);
double tmp;
if ((x + y) <= 1e-123) {
tmp = t_1;
} else if ((x + y) <= 5e-53) {
tmp = 0.5 * ((x + y) / t);
} else if ((x + y) <= 1e+39) {
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) :: tmp
t_1 = (z - x) / (t * (-2.0d0))
if ((x + y) <= 1d-123) then
tmp = t_1
else if ((x + y) <= 5d-53) then
tmp = 0.5d0 * ((x + y) / t)
else if ((x + y) <= 1d+39) 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 = (z - x) / (t * -2.0);
double tmp;
if ((x + y) <= 1e-123) {
tmp = t_1;
} else if ((x + y) <= 5e-53) {
tmp = 0.5 * ((x + y) / t);
} else if ((x + y) <= 1e+39) {
tmp = t_1;
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = (z - x) / (t * -2.0) tmp = 0 if (x + y) <= 1e-123: tmp = t_1 elif (x + y) <= 5e-53: tmp = 0.5 * ((x + y) / t) elif (x + y) <= 1e+39: tmp = t_1 else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(z - x) / Float64(t * -2.0)) tmp = 0.0 if (Float64(x + y) <= 1e-123) tmp = t_1; elseif (Float64(x + y) <= 5e-53) tmp = Float64(0.5 * Float64(Float64(x + y) / t)); elseif (Float64(x + y) <= 1e+39) 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 = (z - x) / (t * -2.0); tmp = 0.0; if ((x + y) <= 1e-123) tmp = t_1; elseif ((x + y) <= 5e-53) tmp = 0.5 * ((x + y) / t); elseif ((x + y) <= 1e+39) tmp = t_1; else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z - x), $MachinePrecision] / N[(t * -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + y), $MachinePrecision], 1e-123], t$95$1, If[LessEqual[N[(x + y), $MachinePrecision], 5e-53], N[(0.5 * N[(N[(x + y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 1e+39], t$95$1, N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - x}{t \cdot -2}\\
\mathbf{if}\;x + y \leq 10^{-123}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x + y \leq 5 \cdot 10^{-53}:\\
\;\;\;\;0.5 \cdot \frac{x + y}{t}\\
\mathbf{elif}\;x + y \leq 10^{+39}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if (+.f64 x y) < 1.0000000000000001e-123 or 5e-53 < (+.f64 x y) < 9.9999999999999994e38Initial 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 79.6%
if 1.0000000000000001e-123 < (+.f64 x y) < 5e-53Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.4%
remove-double-neg99.4%
sub0-neg99.4%
div-sub99.4%
metadata-eval99.4%
neg-mul-199.4%
*-commutative99.4%
associate-/l*99.4%
metadata-eval99.4%
/-rgt-identity99.4%
associate--r-99.4%
neg-sub099.4%
+-commutative99.4%
sub-neg99.4%
+-commutative99.4%
associate--r+99.4%
*-commutative99.4%
associate-/r*99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 73.9%
if 9.9999999999999994e38 < (+.f64 x y) Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.8%
remove-double-neg99.8%
sub0-neg99.8%
div-sub99.8%
metadata-eval99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/l*99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
*-commutative99.8%
associate-/r*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 46.3%
Final simplification66.4%
(FPCore (x y z t)
:precision binary64
(if (<= (+ x y) 1e-123)
(/ -0.5 (/ t (- z x)))
(if (<= (+ x y) 5e-53)
(* 0.5 (/ (+ x y) t))
(if (<= (+ x y) 1e+39) (/ z (* t -2.0)) (* 0.5 (/ y t))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= 1e-123) {
tmp = -0.5 / (t / (z - x));
} else if ((x + y) <= 5e-53) {
tmp = 0.5 * ((x + y) / t);
} else if ((x + y) <= 1e+39) {
tmp = z / (t * -2.0);
} 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) :: tmp
if ((x + y) <= 1d-123) then
tmp = (-0.5d0) / (t / (z - x))
else if ((x + y) <= 5d-53) then
tmp = 0.5d0 * ((x + y) / t)
else if ((x + y) <= 1d+39) then
tmp = z / (t * (-2.0d0))
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 tmp;
if ((x + y) <= 1e-123) {
tmp = -0.5 / (t / (z - x));
} else if ((x + y) <= 5e-53) {
tmp = 0.5 * ((x + y) / t);
} else if ((x + y) <= 1e+39) {
tmp = z / (t * -2.0);
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= 1e-123: tmp = -0.5 / (t / (z - x)) elif (x + y) <= 5e-53: tmp = 0.5 * ((x + y) / t) elif (x + y) <= 1e+39: tmp = z / (t * -2.0) else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= 1e-123) tmp = Float64(-0.5 / Float64(t / Float64(z - x))); elseif (Float64(x + y) <= 5e-53) tmp = Float64(0.5 * Float64(Float64(x + y) / t)); elseif (Float64(x + y) <= 1e+39) tmp = Float64(z / Float64(t * -2.0)); else tmp = Float64(0.5 * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= 1e-123) tmp = -0.5 / (t / (z - x)); elseif ((x + y) <= 5e-53) tmp = 0.5 * ((x + y) / t); elseif ((x + y) <= 1e+39) tmp = z / (t * -2.0); else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], 1e-123], N[(-0.5 / N[(t / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 5e-53], N[(0.5 * N[(N[(x + y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x + y), $MachinePrecision], 1e+39], N[(z / N[(t * -2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq 10^{-123}:\\
\;\;\;\;\frac{-0.5}{\frac{t}{z - x}}\\
\mathbf{elif}\;x + y \leq 5 \cdot 10^{-53}:\\
\;\;\;\;0.5 \cdot \frac{x + y}{t}\\
\mathbf{elif}\;x + y \leq 10^{+39}:\\
\;\;\;\;\frac{z}{t \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if (+.f64 x y) < 1.0000000000000001e-123Initial 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%
associate-*r/100.0%
clear-num99.2%
associate--l-99.2%
Applied egg-rr99.2%
Taylor expanded in y around 0 79.1%
associate-*r/79.1%
associate-/l*78.4%
Simplified78.4%
if 1.0000000000000001e-123 < (+.f64 x y) < 5e-53Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.4%
remove-double-neg99.4%
sub0-neg99.4%
div-sub99.4%
metadata-eval99.4%
neg-mul-199.4%
*-commutative99.4%
associate-/l*99.4%
metadata-eval99.4%
/-rgt-identity99.4%
associate--r-99.4%
neg-sub099.4%
+-commutative99.4%
sub-neg99.4%
+-commutative99.4%
associate--r+99.4%
*-commutative99.4%
associate-/r*99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 73.9%
if 5e-53 < (+.f64 x y) < 9.9999999999999994e38Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
times-frac99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
sub-neg99.9%
+-commutative99.9%
associate--r+99.9%
neg-mul-199.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 70.2%
if 9.9999999999999994e38 < (+.f64 x y) Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.8%
remove-double-neg99.8%
sub0-neg99.8%
div-sub99.8%
metadata-eval99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/l*99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
*-commutative99.8%
associate-/r*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 46.3%
Final simplification65.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -5e+152) (not (<= z 9e+152))) (/ z (* t -2.0)) (* 0.5 (/ (+ x y) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5e+152) || !(z <= 9e+152)) {
tmp = z / (t * -2.0);
} else {
tmp = 0.5 * ((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 ((z <= (-5d+152)) .or. (.not. (z <= 9d+152))) then
tmp = z / (t * (-2.0d0))
else
tmp = 0.5d0 * ((x + y) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -5e+152) || !(z <= 9e+152)) {
tmp = z / (t * -2.0);
} else {
tmp = 0.5 * ((x + y) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -5e+152) or not (z <= 9e+152): tmp = z / (t * -2.0) else: tmp = 0.5 * ((x + y) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -5e+152) || !(z <= 9e+152)) tmp = Float64(z / Float64(t * -2.0)); else tmp = Float64(0.5 * Float64(Float64(x + y) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -5e+152) || ~((z <= 9e+152))) tmp = z / (t * -2.0); else tmp = 0.5 * ((x + y) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5e+152], N[Not[LessEqual[z, 9e+152]], $MachinePrecision]], N[(z / N[(t * -2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x + y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+152} \lor \neg \left(z \leq 9 \cdot 10^{+152}\right):\\
\;\;\;\;\frac{z}{t \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x + y}{t}\\
\end{array}
\end{array}
if z < -5e152 or 9.0000000000000002e152 < z 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 86.0%
if -5e152 < z < 9.0000000000000002e152Initial 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 0 85.1%
Final simplification85.3%
(FPCore (x y z t) :precision binary64 (if (<= x -9.5e+64) (* 0.5 (/ x t)) (if (<= x -1e-136) (/ z (* t -2.0)) (* 0.5 (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -9.5e+64) {
tmp = 0.5 * (x / t);
} else if (x <= -1e-136) {
tmp = z / (t * -2.0);
} 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) :: tmp
if (x <= (-9.5d+64)) then
tmp = 0.5d0 * (x / t)
else if (x <= (-1d-136)) then
tmp = z / (t * (-2.0d0))
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 tmp;
if (x <= -9.5e+64) {
tmp = 0.5 * (x / t);
} else if (x <= -1e-136) {
tmp = z / (t * -2.0);
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -9.5e+64: tmp = 0.5 * (x / t) elif x <= -1e-136: tmp = z / (t * -2.0) else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -9.5e+64) tmp = Float64(0.5 * Float64(x / t)); elseif (x <= -1e-136) tmp = Float64(z / Float64(t * -2.0)); else tmp = Float64(0.5 * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -9.5e+64) tmp = 0.5 * (x / t); elseif (x <= -1e-136) tmp = z / (t * -2.0); else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -9.5e+64], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-136], N[(z / N[(t * -2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+64}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-136}:\\
\;\;\;\;\frac{z}{t \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if x < -9.50000000000000028e64Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
times-frac99.9%
*-commutative99.9%
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 66.4%
if -9.50000000000000028e64 < x < -1e-136Initial 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 40.3%
if -1e-136 < x Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.8%
remove-double-neg99.8%
sub0-neg99.8%
div-sub99.8%
metadata-eval99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/l*99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
*-commutative99.8%
associate-/r*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 41.3%
Final simplification46.3%
(FPCore (x y z t) :precision binary64 (if (<= (+ x y) -5e-80) (/ (- z x) (* t -2.0)) (/ (- z y) (* t -2.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e-80) {
tmp = (z - x) / (t * -2.0);
} else {
tmp = (z - y) / (t * -2.0);
}
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) <= (-5d-80)) then
tmp = (z - x) / (t * (-2.0d0))
else
tmp = (z - y) / (t * (-2.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x + y) <= -5e-80) {
tmp = (z - x) / (t * -2.0);
} else {
tmp = (z - y) / (t * -2.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x + y) <= -5e-80: tmp = (z - x) / (t * -2.0) else: tmp = (z - y) / (t * -2.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x + y) <= -5e-80) tmp = Float64(Float64(z - x) / Float64(t * -2.0)); else tmp = Float64(Float64(z - y) / Float64(t * -2.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x + y) <= -5e-80) tmp = (z - x) / (t * -2.0); else tmp = (z - y) / (t * -2.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x + y), $MachinePrecision], -5e-80], N[(N[(z - x), $MachinePrecision] / N[(t * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(z - y), $MachinePrecision] / N[(t * -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + y \leq -5 \cdot 10^{-80}:\\
\;\;\;\;\frac{z - x}{t \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{z - y}{t \cdot -2}\\
\end{array}
\end{array}
if (+.f64 x y) < -5e-80Initial 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 74.1%
if -5e-80 < (+.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 71.3%
Final simplification72.4%
(FPCore (x y z t) :precision binary64 (if (<= x -1.42e-11) (* 0.5 (/ x t)) (* 0.5 (/ y t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.42e-11) {
tmp = 0.5 * (x / t);
} 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) :: tmp
if (x <= (-1.42d-11)) then
tmp = 0.5d0 * (x / t)
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 tmp;
if (x <= -1.42e-11) {
tmp = 0.5 * (x / t);
} else {
tmp = 0.5 * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.42e-11: tmp = 0.5 * (x / t) else: tmp = 0.5 * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.42e-11) tmp = Float64(0.5 * Float64(x / t)); else tmp = Float64(0.5 * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.42e-11) tmp = 0.5 * (x / t); else tmp = 0.5 * (y / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.42e-11], N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.42 \cdot 10^{-11}:\\
\;\;\;\;0.5 \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{t}\\
\end{array}
\end{array}
if x < -1.42e-11Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
times-frac99.9%
*-commutative99.9%
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 55.9%
if -1.42e-11 < x Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
times-frac100.0%
*-commutative100.0%
times-frac99.8%
remove-double-neg99.8%
sub0-neg99.8%
div-sub99.8%
metadata-eval99.8%
neg-mul-199.8%
*-commutative99.8%
associate-/l*99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
+-commutative99.8%
associate--r+99.8%
*-commutative99.8%
associate-/r*99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 41.6%
Final simplification45.7%
(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 (/ x t)))
double code(double x, double y, double z, double t) {
return 0.5 * (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 = 0.5d0 * (x / t)
end function
public static double code(double x, double y, double z, double t) {
return 0.5 * (x / t);
}
def code(x, y, z, t): return 0.5 * (x / t)
function code(x, y, z, t) return Float64(0.5 * Float64(x / t)) end
function tmp = code(x, y, z, t) tmp = 0.5 * (x / t); end
code[x_, y_, z_, t_] := N[(0.5 * N[(x / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \frac{x}{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 x around inf 39.2%
Final simplification39.2%
herbie shell --seed 2024019
(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)))