
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (- y z) 1.0)))
(if (or (<= z -2e+73) (not (<= z 8200000000.0)))
(* x (/ t_0 z))
(* t_0 (/ x z)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if ((z <= -2e+73) || !(z <= 8200000000.0)) {
tmp = x * (t_0 / z);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if ((z <= (-2d+73)) .or. (.not. (z <= 8200000000.0d0))) then
tmp = x * (t_0 / z)
else
tmp = t_0 * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if ((z <= -2e+73) || !(z <= 8200000000.0)) {
tmp = x * (t_0 / z);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if (z <= -2e+73) or not (z <= 8200000000.0): tmp = x * (t_0 / z) else: tmp = t_0 * (x / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if ((z <= -2e+73) || !(z <= 8200000000.0)) tmp = Float64(x * Float64(t_0 / z)); else tmp = Float64(t_0 * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if ((z <= -2e+73) || ~((z <= 8200000000.0))) tmp = x * (t_0 / z); else tmp = t_0 * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[Or[LessEqual[z, -2e+73], N[Not[LessEqual[z, 8200000000.0]], $MachinePrecision]], N[(x * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;z \leq -2 \cdot 10^{+73} \lor \neg \left(z \leq 8200000000\right):\\
\;\;\;\;x \cdot \frac{t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -1.99999999999999997e73 or 8.2e9 < z Initial program 67.6%
associate-/l*99.9%
Simplified99.9%
if -1.99999999999999997e73 < z < 8.2e9Initial program 99.9%
associate-/l*91.4%
Simplified91.4%
Taylor expanded in x around 0 99.9%
associate--l+99.9%
+-commutative99.9%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -1.8e+43)
(- x)
(if (<= z -2e-82)
t_0
(if (<= z 1.02e-77) (/ x z) (if (<= z 1.25e+64) t_0 (- x)))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -1.8e+43) {
tmp = -x;
} else if (z <= -2e-82) {
tmp = t_0;
} else if (z <= 1.02e-77) {
tmp = x / z;
} else if (z <= 1.25e+64) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-1.8d+43)) then
tmp = -x
else if (z <= (-2d-82)) then
tmp = t_0
else if (z <= 1.02d-77) then
tmp = x / z
else if (z <= 1.25d+64) then
tmp = t_0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -1.8e+43) {
tmp = -x;
} else if (z <= -2e-82) {
tmp = t_0;
} else if (z <= 1.02e-77) {
tmp = x / z;
} else if (z <= 1.25e+64) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -1.8e+43: tmp = -x elif z <= -2e-82: tmp = t_0 elif z <= 1.02e-77: tmp = x / z elif z <= 1.25e+64: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -1.8e+43) tmp = Float64(-x); elseif (z <= -2e-82) tmp = t_0; elseif (z <= 1.02e-77) tmp = Float64(x / z); elseif (z <= 1.25e+64) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (z <= -1.8e+43) tmp = -x; elseif (z <= -2e-82) tmp = t_0; elseif (z <= 1.02e-77) tmp = x / z; elseif (z <= 1.25e+64) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.8e+43], (-x), If[LessEqual[z, -2e-82], t$95$0, If[LessEqual[z, 1.02e-77], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.25e+64], t$95$0, (-x)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -1.8 \cdot 10^{+43}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -2 \cdot 10^{-82}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.02 \cdot 10^{-77}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.80000000000000005e43 or 1.25e64 < z Initial program 65.9%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around inf 83.6%
neg-mul-183.6%
Simplified83.6%
if -1.80000000000000005e43 < z < -2e-82 or 1.02e-77 < z < 1.25e64Initial program 96.4%
associate-/l*96.2%
Simplified96.2%
Taylor expanded in x around 0 96.4%
associate--l+96.4%
+-commutative96.4%
associate-*l/98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in y around inf 57.1%
if -2e-82 < z < 1.02e-77Initial program 99.9%
associate-/l*89.7%
Simplified89.7%
Taylor expanded in z around 0 99.9%
associate-/l*89.7%
Simplified89.7%
Taylor expanded in y around 0 66.3%
Final simplification71.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y z))))
(if (<= z -2.8e+43)
(- x)
(if (<= z -1.25e-82)
t_0
(if (<= z 4.3e-72) (/ x z) (if (<= z 1.45e+72) t_0 (- x)))))))
double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -2.8e+43) {
tmp = -x;
} else if (z <= -1.25e-82) {
tmp = t_0;
} else if (z <= 4.3e-72) {
tmp = x / z;
} else if (z <= 1.45e+72) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = x * (y / z)
if (z <= (-2.8d+43)) then
tmp = -x
else if (z <= (-1.25d-82)) then
tmp = t_0
else if (z <= 4.3d-72) then
tmp = x / z
else if (z <= 1.45d+72) then
tmp = t_0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (z <= -2.8e+43) {
tmp = -x;
} else if (z <= -1.25e-82) {
tmp = t_0;
} else if (z <= 4.3e-72) {
tmp = x / z;
} else if (z <= 1.45e+72) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / z) tmp = 0 if z <= -2.8e+43: tmp = -x elif z <= -1.25e-82: tmp = t_0 elif z <= 4.3e-72: tmp = x / z elif z <= 1.45e+72: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y / z)) tmp = 0.0 if (z <= -2.8e+43) tmp = Float64(-x); elseif (z <= -1.25e-82) tmp = t_0; elseif (z <= 4.3e-72) tmp = Float64(x / z); elseif (z <= 1.45e+72) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y / z); tmp = 0.0; if (z <= -2.8e+43) tmp = -x; elseif (z <= -1.25e-82) tmp = t_0; elseif (z <= 4.3e-72) tmp = x / z; elseif (z <= 1.45e+72) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.8e+43], (-x), If[LessEqual[z, -1.25e-82], t$95$0, If[LessEqual[z, 4.3e-72], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.45e+72], t$95$0, (-x)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -2.8 \cdot 10^{+43}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.25 \cdot 10^{-82}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{-72}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -2.80000000000000019e43 or 1.45000000000000009e72 < z Initial program 65.2%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around inf 84.2%
neg-mul-184.2%
Simplified84.2%
if -2.80000000000000019e43 < z < -1.25e-82 or 4.2999999999999999e-72 < z < 1.45000000000000009e72Initial program 96.5%
associate-/l*96.3%
Simplified96.3%
Taylor expanded in y around inf 53.8%
associate-/l*53.6%
Simplified53.6%
if -1.25e-82 < z < 4.2999999999999999e-72Initial program 99.9%
associate-/l*89.7%
Simplified89.7%
Taylor expanded in z around 0 99.9%
associate-/l*89.7%
Simplified89.7%
Taylor expanded in y around 0 66.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -1e-29) (not (<= z 7.2e-25))) (* x (/ (+ (- y z) 1.0) z)) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-29) || !(z <= 7.2e-25)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1d-29)) .or. (.not. (z <= 7.2d-25))) then
tmp = x * (((y - z) + 1.0d0) / z)
else
tmp = (x * (y + 1.0d0)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-29) || !(z <= 7.2e-25)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e-29) or not (z <= 7.2e-25): tmp = x * (((y - z) + 1.0) / z) else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e-29) || !(z <= 7.2e-25)) tmp = Float64(x * Float64(Float64(Float64(y - z) + 1.0) / z)); else tmp = Float64(Float64(x * Float64(y + 1.0)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e-29) || ~((z <= 7.2e-25))) tmp = x * (((y - z) + 1.0) / z); else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-29], N[Not[LessEqual[z, 7.2e-25]], $MachinePrecision]], N[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-29} \lor \neg \left(z \leq 7.2 \cdot 10^{-25}\right):\\
\;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -9.99999999999999943e-30 or 7.1999999999999998e-25 < z Initial program 74.3%
associate-/l*99.9%
Simplified99.9%
if -9.99999999999999943e-30 < z < 7.1999999999999998e-25Initial program 99.9%
associate-/l*89.3%
Simplified89.3%
Taylor expanded in z around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -9.4e+51) (not (<= y 3e+42))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9.4e+51) || !(y <= 3e+42)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-9.4d+51)) .or. (.not. (y <= 3d+42))) then
tmp = y * (x / z)
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -9.4e+51) || !(y <= 3e+42)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9.4e+51) or not (y <= 3e+42): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9.4e+51) || !(y <= 3e+42)) tmp = Float64(y * Float64(x / z)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -9.4e+51) || ~((y <= 3e+42))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9.4e+51], N[Not[LessEqual[y, 3e+42]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.4 \cdot 10^{+51} \lor \neg \left(y \leq 3 \cdot 10^{+42}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -9.4000000000000005e51 or 3.00000000000000029e42 < y Initial program 81.7%
associate-/l*89.3%
Simplified89.3%
Taylor expanded in x around 0 81.7%
associate--l+81.7%
+-commutative81.7%
associate-*l/93.0%
+-commutative93.0%
Simplified93.0%
Taylor expanded in y around inf 78.4%
if -9.4000000000000005e51 < y < 3.00000000000000029e42Initial program 88.7%
associate-/l*98.6%
Simplified98.6%
Taylor expanded in x around 0 88.7%
associate--l+88.7%
+-commutative88.7%
associate-*l/89.1%
+-commutative89.1%
Simplified89.1%
*-commutative89.1%
clear-num88.4%
un-div-inv88.6%
associate-+r-88.6%
+-commutative88.6%
associate--l+88.6%
Applied egg-rr88.6%
Taylor expanded in y around 0 82.9%
associate-/l*94.0%
div-sub94.0%
*-inverses94.0%
sub-neg94.0%
metadata-eval94.0%
distribute-lft-out94.0%
*-commutative94.0%
neg-mul-194.0%
associate-*r/94.2%
*-rgt-identity94.2%
unsub-neg94.2%
Simplified94.2%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= x 2e-20) (/ (* x t_0) z) (* x (/ t_0 z)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (x <= 2e-20) {
tmp = (x * t_0) / z;
} else {
tmp = x * (t_0 / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if (x <= 2d-20) then
tmp = (x * t_0) / z
else
tmp = x * (t_0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (x <= 2e-20) {
tmp = (x * t_0) / z;
} else {
tmp = x * (t_0 / z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if x <= 2e-20: tmp = (x * t_0) / z else: tmp = x * (t_0 / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (x <= 2e-20) tmp = Float64(Float64(x * t_0) / z); else tmp = Float64(x * Float64(t_0 / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (x <= 2e-20) tmp = (x * t_0) / z; else tmp = x * (t_0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, 2e-20], N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;x \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\frac{x \cdot t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{t\_0}{z}\\
\end{array}
\end{array}
if x < 1.99999999999999989e-20Initial program 90.4%
if 1.99999999999999989e-20 < x Initial program 71.3%
associate-/l*99.9%
Simplified99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = -x
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 72.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 73.5%
neg-mul-173.5%
Simplified73.5%
if -1 < z < 1Initial program 99.9%
associate-/l*90.1%
Simplified90.1%
Taylor expanded in z around 0 98.2%
associate-/l*88.5%
Simplified88.5%
Taylor expanded in y around 0 60.2%
Final simplification66.9%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 86.0%
associate-/l*95.0%
Simplified95.0%
Taylor expanded in z around inf 38.5%
neg-mul-138.5%
Simplified38.5%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 86.0%
associate-/l*95.0%
Simplified95.0%
Taylor expanded in z around inf 38.5%
neg-mul-138.5%
Simplified38.5%
neg-sub038.5%
sub-neg38.5%
add-sqr-sqrt20.3%
sqrt-unprod18.8%
sqr-neg18.8%
sqrt-unprod1.5%
add-sqr-sqrt2.9%
Applied egg-rr2.9%
Taylor expanded in x around 0 2.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
(if (< x -2.71483106713436e-162)
t_0
(if (< x 3.874108816439546e-197)
(* (* x (+ (- y z) 1.0)) (/ 1.0 z))
t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + y) * (x / z)) - x
if (x < (-2.71483106713436d-162)) then
tmp = t_0
else if (x < 3.874108816439546d-197) then
tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 + y) * (x / z)) - x tmp = 0 if x < -2.71483106713436e-162: tmp = t_0 elif x < 3.874108816439546e-197: tmp = (x * ((y - z) + 1.0)) * (1.0 / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x) tmp = 0.0 if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 + y) * (x / z)) - x; tmp = 0.0; if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = (x * ((y - z) + 1.0)) * (1.0 / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024131
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< x -67870776678359/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (+ 1 y) (/ x z)) x) (if (< x 1937054408219773/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x))))
(/ (* x (+ (- y z) 1.0)) z))