
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y * (z - t)) / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) a)))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y * (z - t)) / a)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / a);
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / a)
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / a)) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / a); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (<= (- z t) -5e+143) (+ x (* (- z t) (/ y a))) (+ x (/ (* (- z t) y) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z - t) <= -5e+143) {
tmp = x + ((z - t) * (y / a));
} else {
tmp = x + (((z - t) * y) / a);
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((z - t) <= (-5d+143)) then
tmp = x + ((z - t) * (y / a))
else
tmp = x + (((z - t) * y) / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z - t) <= -5e+143) {
tmp = x + ((z - t) * (y / a));
} else {
tmp = x + (((z - t) * y) / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z - t) <= -5e+143: tmp = x + ((z - t) * (y / a)) else: tmp = x + (((z - t) * y) / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(z - t) <= -5e+143) tmp = Float64(x + Float64(Float64(z - t) * Float64(y / a))); else tmp = Float64(x + Float64(Float64(Float64(z - t) * y) / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z - t) <= -5e+143) tmp = x + ((z - t) * (y / a)); else tmp = x + (((z - t) * y) / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(z - t), $MachinePrecision], -5e+143], N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z - t \leq -5 \cdot 10^{+143}:\\
\;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\left(z - t\right) \cdot y}{a}\\
\end{array}
\end{array}
if (-.f64 z t) < -5.00000000000000012e143Initial program 84.0%
associate-*l/98.3%
Simplified98.3%
if -5.00000000000000012e143 < (-.f64 z t) Initial program 99.2%
Final simplification99.0%
(FPCore (x y z t a)
:precision binary64
(if (<= x -1.85e+54)
x
(if (or (<= x -50000.0) (and (not (<= x -2.8e-29)) (<= x 2.3e-99)))
(* t (/ (- y) a))
x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -1.85e+54) {
tmp = x;
} else if ((x <= -50000.0) || (!(x <= -2.8e-29) && (x <= 2.3e-99))) {
tmp = t * (-y / a);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (x <= (-1.85d+54)) then
tmp = x
else if ((x <= (-50000.0d0)) .or. (.not. (x <= (-2.8d-29))) .and. (x <= 2.3d-99)) then
tmp = t * (-y / a)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -1.85e+54) {
tmp = x;
} else if ((x <= -50000.0) || (!(x <= -2.8e-29) && (x <= 2.3e-99))) {
tmp = t * (-y / a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if x <= -1.85e+54: tmp = x elif (x <= -50000.0) or (not (x <= -2.8e-29) and (x <= 2.3e-99)): tmp = t * (-y / a) else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (x <= -1.85e+54) tmp = x; elseif ((x <= -50000.0) || (!(x <= -2.8e-29) && (x <= 2.3e-99))) tmp = Float64(t * Float64(Float64(-y) / a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (x <= -1.85e+54) tmp = x; elseif ((x <= -50000.0) || (~((x <= -2.8e-29)) && (x <= 2.3e-99))) tmp = t * (-y / a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[x, -1.85e+54], x, If[Or[LessEqual[x, -50000.0], And[N[Not[LessEqual[x, -2.8e-29]], $MachinePrecision], LessEqual[x, 2.3e-99]]], N[(t * N[((-y) / a), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.85 \cdot 10^{+54}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -50000 \lor \neg \left(x \leq -2.8 \cdot 10^{-29}\right) \land x \leq 2.3 \cdot 10^{-99}:\\
\;\;\;\;t \cdot \frac{-y}{a}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.8500000000000001e54 or -5e4 < x < -2.8000000000000002e-29 or 2.2999999999999998e-99 < x Initial program 97.4%
+-commutative97.4%
associate-*r/94.8%
fma-def94.8%
Simplified94.8%
Taylor expanded in y around 0 60.9%
if -1.8500000000000001e54 < x < -5e4 or -2.8000000000000002e-29 < x < 2.2999999999999998e-99Initial program 93.5%
+-commutative93.5%
associate-*r/91.1%
fma-def91.1%
Simplified91.1%
Taylor expanded in z around 0 66.0%
+-commutative66.0%
mul-1-neg66.0%
unsub-neg66.0%
*-commutative66.0%
associate-*r/67.1%
Simplified67.1%
clear-num67.0%
div-inv66.3%
Applied egg-rr66.3%
Taylor expanded in x around 0 54.1%
mul-1-neg54.1%
associate-*r/53.3%
distribute-lft-neg-in53.3%
*-commutative53.3%
Simplified53.3%
Taylor expanded in t around 0 54.1%
associate-*l/55.5%
*-commutative55.5%
neg-mul-155.5%
distribute-rgt-neg-in55.5%
distribute-neg-frac55.5%
Simplified55.5%
Final simplification58.6%
(FPCore (x y z t a)
:precision binary64
(if (<= x -8.8e+52)
x
(if (<= x -0.118)
(/ (- t) (/ a y))
(if (<= x -2.3e-29) x (if (<= x 1.75e-99) (* t (/ (- y) a)) x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -8.8e+52) {
tmp = x;
} else if (x <= -0.118) {
tmp = -t / (a / y);
} else if (x <= -2.3e-29) {
tmp = x;
} else if (x <= 1.75e-99) {
tmp = t * (-y / a);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (x <= (-8.8d+52)) then
tmp = x
else if (x <= (-0.118d0)) then
tmp = -t / (a / y)
else if (x <= (-2.3d-29)) then
tmp = x
else if (x <= 1.75d-99) then
tmp = t * (-y / a)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -8.8e+52) {
tmp = x;
} else if (x <= -0.118) {
tmp = -t / (a / y);
} else if (x <= -2.3e-29) {
tmp = x;
} else if (x <= 1.75e-99) {
tmp = t * (-y / a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if x <= -8.8e+52: tmp = x elif x <= -0.118: tmp = -t / (a / y) elif x <= -2.3e-29: tmp = x elif x <= 1.75e-99: tmp = t * (-y / a) else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (x <= -8.8e+52) tmp = x; elseif (x <= -0.118) tmp = Float64(Float64(-t) / Float64(a / y)); elseif (x <= -2.3e-29) tmp = x; elseif (x <= 1.75e-99) tmp = Float64(t * Float64(Float64(-y) / a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (x <= -8.8e+52) tmp = x; elseif (x <= -0.118) tmp = -t / (a / y); elseif (x <= -2.3e-29) tmp = x; elseif (x <= 1.75e-99) tmp = t * (-y / a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[x, -8.8e+52], x, If[LessEqual[x, -0.118], N[((-t) / N[(a / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.3e-29], x, If[LessEqual[x, 1.75e-99], N[(t * N[((-y) / a), $MachinePrecision]), $MachinePrecision], x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.8 \cdot 10^{+52}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -0.118:\\
\;\;\;\;\frac{-t}{\frac{a}{y}}\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-29}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-99}:\\
\;\;\;\;t \cdot \frac{-y}{a}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -8.7999999999999999e52 or -0.11799999999999999 < x < -2.29999999999999991e-29 or 1.7499999999999999e-99 < x Initial program 97.4%
+-commutative97.4%
associate-*r/94.8%
fma-def94.8%
Simplified94.8%
Taylor expanded in y around 0 60.9%
if -8.7999999999999999e52 < x < -0.11799999999999999Initial program 100.0%
+-commutative100.0%
associate-*r/89.2%
fma-def89.2%
Simplified89.2%
Taylor expanded in z around 0 79.8%
+-commutative79.8%
mul-1-neg79.8%
unsub-neg79.8%
*-commutative79.8%
associate-*r/74.4%
Simplified74.4%
clear-num74.4%
div-inv74.5%
Applied egg-rr74.5%
Taylor expanded in x around 0 57.6%
mul-1-neg57.6%
associate-*r/50.6%
distribute-lft-neg-in50.6%
*-commutative50.6%
Simplified50.6%
associate-/r/52.3%
frac-2neg52.3%
distribute-frac-neg52.3%
frac-2neg52.3%
Applied egg-rr52.3%
if -2.29999999999999991e-29 < x < 1.7499999999999999e-99Initial program 92.2%
+-commutative92.2%
associate-*r/91.5%
fma-def91.5%
Simplified91.5%
Taylor expanded in z around 0 63.3%
+-commutative63.3%
mul-1-neg63.3%
unsub-neg63.3%
*-commutative63.3%
associate-*r/65.6%
Simplified65.6%
clear-num65.5%
div-inv64.6%
Applied egg-rr64.6%
Taylor expanded in x around 0 53.5%
mul-1-neg53.5%
associate-*r/53.8%
distribute-lft-neg-in53.8%
*-commutative53.8%
Simplified53.8%
Taylor expanded in t around 0 53.5%
associate-*l/56.2%
*-commutative56.2%
neg-mul-156.2%
distribute-rgt-neg-in56.2%
distribute-neg-frac56.2%
Simplified56.2%
Final simplification58.6%
(FPCore (x y z t a)
:precision binary64
(if (<= x -6.8e+54)
x
(if (<= x -128000.0)
(/ (* t (- y)) a)
(if (<= x -2.5e-29) x (if (<= x 2.3e-99) (* t (/ (- y) a)) x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -6.8e+54) {
tmp = x;
} else if (x <= -128000.0) {
tmp = (t * -y) / a;
} else if (x <= -2.5e-29) {
tmp = x;
} else if (x <= 2.3e-99) {
tmp = t * (-y / a);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (x <= (-6.8d+54)) then
tmp = x
else if (x <= (-128000.0d0)) then
tmp = (t * -y) / a
else if (x <= (-2.5d-29)) then
tmp = x
else if (x <= 2.3d-99) then
tmp = t * (-y / a)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -6.8e+54) {
tmp = x;
} else if (x <= -128000.0) {
tmp = (t * -y) / a;
} else if (x <= -2.5e-29) {
tmp = x;
} else if (x <= 2.3e-99) {
tmp = t * (-y / a);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if x <= -6.8e+54: tmp = x elif x <= -128000.0: tmp = (t * -y) / a elif x <= -2.5e-29: tmp = x elif x <= 2.3e-99: tmp = t * (-y / a) else: tmp = x return tmp
function code(x, y, z, t, a) tmp = 0.0 if (x <= -6.8e+54) tmp = x; elseif (x <= -128000.0) tmp = Float64(Float64(t * Float64(-y)) / a); elseif (x <= -2.5e-29) tmp = x; elseif (x <= 2.3e-99) tmp = Float64(t * Float64(Float64(-y) / a)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (x <= -6.8e+54) tmp = x; elseif (x <= -128000.0) tmp = (t * -y) / a; elseif (x <= -2.5e-29) tmp = x; elseif (x <= 2.3e-99) tmp = t * (-y / a); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[x, -6.8e+54], x, If[LessEqual[x, -128000.0], N[(N[(t * (-y)), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[x, -2.5e-29], x, If[LessEqual[x, 2.3e-99], N[(t * N[((-y) / a), $MachinePrecision]), $MachinePrecision], x]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{+54}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -128000:\\
\;\;\;\;\frac{t \cdot \left(-y\right)}{a}\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-29}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-99}:\\
\;\;\;\;t \cdot \frac{-y}{a}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -6.8000000000000001e54 or -128000 < x < -2.49999999999999993e-29 or 2.2999999999999998e-99 < x Initial program 97.4%
+-commutative97.4%
associate-*r/94.8%
fma-def94.8%
Simplified94.8%
Taylor expanded in y around 0 60.9%
if -6.8000000000000001e54 < x < -128000Initial program 100.0%
+-commutative100.0%
associate-*r/89.2%
fma-def89.2%
Simplified89.2%
Taylor expanded in z around 0 79.8%
+-commutative79.8%
mul-1-neg79.8%
unsub-neg79.8%
*-commutative79.8%
associate-*r/74.4%
Simplified74.4%
clear-num74.4%
div-inv74.5%
Applied egg-rr74.5%
Taylor expanded in x around 0 57.6%
associate-*r/57.6%
*-commutative57.6%
neg-mul-157.6%
distribute-rgt-neg-in57.6%
Simplified57.6%
if -2.49999999999999993e-29 < x < 2.2999999999999998e-99Initial program 92.2%
+-commutative92.2%
associate-*r/91.5%
fma-def91.5%
Simplified91.5%
Taylor expanded in z around 0 63.3%
+-commutative63.3%
mul-1-neg63.3%
unsub-neg63.3%
*-commutative63.3%
associate-*r/65.6%
Simplified65.6%
clear-num65.5%
div-inv64.6%
Applied egg-rr64.6%
Taylor expanded in x around 0 53.5%
mul-1-neg53.5%
associate-*r/53.8%
distribute-lft-neg-in53.8%
*-commutative53.8%
Simplified53.8%
Taylor expanded in t around 0 53.5%
associate-*l/56.2%
*-commutative56.2%
neg-mul-156.2%
distribute-rgt-neg-in56.2%
distribute-neg-frac56.2%
Simplified56.2%
Final simplification59.0%
(FPCore (x y z t a)
:precision binary64
(if (<= t -1.86e+136)
(/ (- t) (/ a y))
(if (or (<= t 1.18e+119) (not (<= t 5.4e+178)))
(+ x (* z (/ y a)))
(* y (/ (- t) a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.86e+136) {
tmp = -t / (a / y);
} else if ((t <= 1.18e+119) || !(t <= 5.4e+178)) {
tmp = x + (z * (y / a));
} else {
tmp = y * (-t / a);
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (t <= (-1.86d+136)) then
tmp = -t / (a / y)
else if ((t <= 1.18d+119) .or. (.not. (t <= 5.4d+178))) then
tmp = x + (z * (y / a))
else
tmp = y * (-t / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.86e+136) {
tmp = -t / (a / y);
} else if ((t <= 1.18e+119) || !(t <= 5.4e+178)) {
tmp = x + (z * (y / a));
} else {
tmp = y * (-t / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= -1.86e+136: tmp = -t / (a / y) elif (t <= 1.18e+119) or not (t <= 5.4e+178): tmp = x + (z * (y / a)) else: tmp = y * (-t / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.86e+136) tmp = Float64(Float64(-t) / Float64(a / y)); elseif ((t <= 1.18e+119) || !(t <= 5.4e+178)) tmp = Float64(x + Float64(z * Float64(y / a))); else tmp = Float64(y * Float64(Float64(-t) / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -1.86e+136) tmp = -t / (a / y); elseif ((t <= 1.18e+119) || ~((t <= 5.4e+178))) tmp = x + (z * (y / a)); else tmp = y * (-t / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.86e+136], N[((-t) / N[(a / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t, 1.18e+119], N[Not[LessEqual[t, 5.4e+178]], $MachinePrecision]], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[((-t) / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.86 \cdot 10^{+136}:\\
\;\;\;\;\frac{-t}{\frac{a}{y}}\\
\mathbf{elif}\;t \leq 1.18 \cdot 10^{+119} \lor \neg \left(t \leq 5.4 \cdot 10^{+178}\right):\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{-t}{a}\\
\end{array}
\end{array}
if t < -1.86e136Initial program 99.8%
+-commutative99.8%
associate-*r/85.9%
fma-def85.9%
Simplified85.9%
Taylor expanded in z around 0 93.0%
+-commutative93.0%
mul-1-neg93.0%
unsub-neg93.0%
*-commutative93.0%
associate-*r/93.0%
Simplified93.0%
clear-num93.0%
div-inv93.1%
Applied egg-rr93.1%
Taylor expanded in x around 0 76.1%
mul-1-neg76.1%
associate-*r/63.8%
distribute-lft-neg-in63.8%
*-commutative63.8%
Simplified63.8%
associate-/r/76.1%
frac-2neg76.1%
distribute-frac-neg76.1%
frac-2neg76.1%
Applied egg-rr76.1%
if -1.86e136 < t < 1.1799999999999999e119 or 5.40000000000000036e178 < t Initial program 95.6%
+-commutative95.6%
associate-*r/94.3%
fma-def94.3%
Simplified94.3%
Taylor expanded in t around 0 78.4%
associate-*l/79.9%
*-commutative79.9%
Simplified79.9%
if 1.1799999999999999e119 < t < 5.40000000000000036e178Initial program 83.9%
+-commutative83.9%
associate-*r/99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around 0 83.9%
+-commutative83.9%
mul-1-neg83.9%
unsub-neg83.9%
*-commutative83.9%
associate-*r/92.0%
Simplified92.0%
clear-num91.8%
div-inv92.1%
Applied egg-rr92.1%
Taylor expanded in x around 0 59.7%
mul-1-neg59.7%
associate-*r/75.5%
distribute-lft-neg-in75.5%
*-commutative75.5%
Simplified75.5%
Final simplification79.1%
(FPCore (x y z t a) :precision binary64 (if (<= z -4.8e+23) (+ x (* z (/ y a))) (if (<= z 7.4e+68) (- x (* t (/ y a))) (+ x (/ z (/ a y))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.8e+23) {
tmp = x + (z * (y / a));
} else if (z <= 7.4e+68) {
tmp = x - (t * (y / a));
} else {
tmp = x + (z / (a / y));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (z <= (-4.8d+23)) then
tmp = x + (z * (y / a))
else if (z <= 7.4d+68) then
tmp = x - (t * (y / a))
else
tmp = x + (z / (a / y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.8e+23) {
tmp = x + (z * (y / a));
} else if (z <= 7.4e+68) {
tmp = x - (t * (y / a));
} else {
tmp = x + (z / (a / y));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -4.8e+23: tmp = x + (z * (y / a)) elif z <= 7.4e+68: tmp = x - (t * (y / a)) else: tmp = x + (z / (a / y)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4.8e+23) tmp = Float64(x + Float64(z * Float64(y / a))); elseif (z <= 7.4e+68) tmp = Float64(x - Float64(t * Float64(y / a))); else tmp = Float64(x + Float64(z / Float64(a / y))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -4.8e+23) tmp = x + (z * (y / a)); elseif (z <= 7.4e+68) tmp = x - (t * (y / a)); else tmp = x + (z / (a / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.8e+23], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.4e+68], N[(x - N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{+23}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{+68}:\\
\;\;\;\;x - t \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{z}{\frac{a}{y}}\\
\end{array}
\end{array}
if z < -4.8e23Initial program 93.4%
+-commutative93.4%
associate-*r/91.7%
fma-def91.7%
Simplified91.7%
Taylor expanded in t around 0 84.6%
associate-*l/91.2%
*-commutative91.2%
Simplified91.2%
if -4.8e23 < z < 7.39999999999999996e68Initial program 96.5%
+-commutative96.5%
associate-*r/94.8%
fma-def94.8%
Simplified94.8%
Taylor expanded in z around 0 88.0%
+-commutative88.0%
mul-1-neg88.0%
unsub-neg88.0%
*-commutative88.0%
associate-*r/90.0%
Simplified90.0%
if 7.39999999999999996e68 < z Initial program 96.0%
+-commutative96.0%
associate-*r/90.0%
fma-def90.0%
Simplified90.0%
Taylor expanded in t around 0 88.5%
associate-*l/90.5%
*-commutative90.5%
Simplified90.5%
clear-num90.5%
div-inv90.5%
Applied egg-rr90.5%
Final simplification90.4%
(FPCore (x y z t a) :precision binary64 (+ x (* (- z t) (/ y a))))
double code(double x, double y, double z, double t, double a) {
return x + ((z - t) * (y / a));
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((z - t) * (y / a))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((z - t) * (y / a));
}
def code(x, y, z, t, a): return x + ((z - t) * (y / a))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(z - t) * Float64(y / a))) end
function tmp = code(x, y, z, t, a) tmp = x + ((z - t) * (y / a)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(z - t\right) \cdot \frac{y}{a}
\end{array}
Initial program 95.7%
associate-*l/97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
return x;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 95.7%
+-commutative95.7%
associate-*r/93.2%
fma-def93.2%
Simplified93.2%
Taylor expanded in y around 0 41.1%
Final simplification41.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ a (- z t))))
(if (< y -1.0761266216389975e-10)
(+ x (/ 1.0 (/ t_1 y)))
(if (< y 2.894426862792089e-49)
(+ x (/ (* y (- z t)) a))
(+ x (/ y t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = a / (z - t);
double tmp;
if (y < -1.0761266216389975e-10) {
tmp = x + (1.0 / (t_1 / y));
} else if (y < 2.894426862792089e-49) {
tmp = x + ((y * (z - t)) / a);
} else {
tmp = x + (y / t_1);
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = a / (z - t)
if (y < (-1.0761266216389975d-10)) then
tmp = x + (1.0d0 / (t_1 / y))
else if (y < 2.894426862792089d-49) then
tmp = x + ((y * (z - t)) / a)
else
tmp = x + (y / t_1)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = a / (z - t);
double tmp;
if (y < -1.0761266216389975e-10) {
tmp = x + (1.0 / (t_1 / y));
} else if (y < 2.894426862792089e-49) {
tmp = x + ((y * (z - t)) / a);
} else {
tmp = x + (y / t_1);
}
return tmp;
}
def code(x, y, z, t, a): t_1 = a / (z - t) tmp = 0 if y < -1.0761266216389975e-10: tmp = x + (1.0 / (t_1 / y)) elif y < 2.894426862792089e-49: tmp = x + ((y * (z - t)) / a) else: tmp = x + (y / t_1) return tmp
function code(x, y, z, t, a) t_1 = Float64(a / Float64(z - t)) tmp = 0.0 if (y < -1.0761266216389975e-10) tmp = Float64(x + Float64(1.0 / Float64(t_1 / y))); elseif (y < 2.894426862792089e-49) tmp = Float64(x + Float64(Float64(y * Float64(z - t)) / a)); else tmp = Float64(x + Float64(y / t_1)); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = a / (z - t); tmp = 0.0; if (y < -1.0761266216389975e-10) tmp = x + (1.0 / (t_1 / y)); elseif (y < 2.894426862792089e-49) tmp = x + ((y * (z - t)) / a); else tmp = x + (y / t_1); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(a / N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[Less[y, -1.0761266216389975e-10], N[(x + N[(1.0 / N[(t$95$1 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Less[y, 2.894426862792089e-49], N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{a}{z - t}\\
\mathbf{if}\;y < -1.0761266216389975 \cdot 10^{-10}:\\
\;\;\;\;x + \frac{1}{\frac{t_1}{y}}\\
\mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{t_1}\\
\end{array}
\end{array}
herbie shell --seed 2023224
(FPCore (x y z t a)
:name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, E"
:precision binary64
:herbie-target
(if (< y -1.0761266216389975e-10) (+ x (/ 1.0 (/ (/ a (- z t)) y))) (if (< y 2.894426862792089e-49) (+ x (/ (* y (- z t)) a)) (+ x (/ y (/ a (- z t))))))
(+ x (/ (* y (- z t)) a)))