
(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 10 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 (if (or (<= z -3.7e-27) (not (<= z 1.8e-58))) (* x (+ (/ (+ y 1.0) z) -1.0)) (/ (+ x (* x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.7e-27) || !(z <= 1.8e-58)) {
tmp = x * (((y + 1.0) / z) + -1.0);
} else {
tmp = (x + (x * y)) / 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 <= (-3.7d-27)) .or. (.not. (z <= 1.8d-58))) then
tmp = x * (((y + 1.0d0) / z) + (-1.0d0))
else
tmp = (x + (x * y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.7e-27) || !(z <= 1.8e-58)) {
tmp = x * (((y + 1.0) / z) + -1.0);
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.7e-27) or not (z <= 1.8e-58): tmp = x * (((y + 1.0) / z) + -1.0) else: tmp = (x + (x * y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.7e-27) || !(z <= 1.8e-58)) tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); else tmp = Float64(Float64(x + Float64(x * y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.7e-27) || ~((z <= 1.8e-58))) tmp = x * (((y + 1.0) / z) + -1.0); else tmp = (x + (x * y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.7e-27], N[Not[LessEqual[z, 1.8e-58]], $MachinePrecision]], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{-27} \lor \neg \left(z \leq 1.8 \cdot 10^{-58}\right):\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\end{array}
\end{array}
if z < -3.70000000000000029e-27 or 1.80000000000000005e-58 < z Initial program 74.7%
Taylor expanded in x around 0 74.7%
associate--l+74.7%
+-commutative74.7%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
if -3.70000000000000029e-27 < z < 1.80000000000000005e-58Initial program 99.9%
distribute-lft-in99.9%
fma-def99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x 4e-100) (/ (fma x (- y z) x) z) (* x (+ (/ (+ y 1.0) z) -1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= 4e-100) {
tmp = fma(x, (y - z), x) / z;
} else {
tmp = x * (((y + 1.0) / z) + -1.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 4e-100) tmp = Float64(fma(x, Float64(y - z), x) / z); else tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 4e-100], N[(N[(x * N[(y - z), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4 \cdot 10^{-100}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\end{array}
\end{array}
if x < 4.0000000000000001e-100Initial program 89.5%
distribute-lft-in89.5%
fma-def89.5%
*-rgt-identity89.5%
Simplified89.5%
if 4.0000000000000001e-100 < x Initial program 77.9%
Taylor expanded in x around 0 77.9%
associate--l+77.9%
+-commutative77.9%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification93.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -210.0)
(- x)
(if (<= z -2.9e-82)
t_0
(if (<= z -3.7e-193)
(/ x z)
(if (<= z 2.8e-102)
t_0
(if (<= z 2.3e-17) (/ x z) (if (<= z 1.35e+20) t_0 (- x)))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -210.0) {
tmp = -x;
} else if (z <= -2.9e-82) {
tmp = t_0;
} else if (z <= -3.7e-193) {
tmp = x / z;
} else if (z <= 2.8e-102) {
tmp = t_0;
} else if (z <= 2.3e-17) {
tmp = x / z;
} else if (z <= 1.35e+20) {
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 <= (-210.0d0)) then
tmp = -x
else if (z <= (-2.9d-82)) then
tmp = t_0
else if (z <= (-3.7d-193)) then
tmp = x / z
else if (z <= 2.8d-102) then
tmp = t_0
else if (z <= 2.3d-17) then
tmp = x / z
else if (z <= 1.35d+20) 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 <= -210.0) {
tmp = -x;
} else if (z <= -2.9e-82) {
tmp = t_0;
} else if (z <= -3.7e-193) {
tmp = x / z;
} else if (z <= 2.8e-102) {
tmp = t_0;
} else if (z <= 2.3e-17) {
tmp = x / z;
} else if (z <= 1.35e+20) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -210.0: tmp = -x elif z <= -2.9e-82: tmp = t_0 elif z <= -3.7e-193: tmp = x / z elif z <= 2.8e-102: tmp = t_0 elif z <= 2.3e-17: tmp = x / z elif z <= 1.35e+20: 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 <= -210.0) tmp = Float64(-x); elseif (z <= -2.9e-82) tmp = t_0; elseif (z <= -3.7e-193) tmp = Float64(x / z); elseif (z <= 2.8e-102) tmp = t_0; elseif (z <= 2.3e-17) tmp = Float64(x / z); elseif (z <= 1.35e+20) 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 <= -210.0) tmp = -x; elseif (z <= -2.9e-82) tmp = t_0; elseif (z <= -3.7e-193) tmp = x / z; elseif (z <= 2.8e-102) tmp = t_0; elseif (z <= 2.3e-17) tmp = x / z; elseif (z <= 1.35e+20) 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, -210.0], (-x), If[LessEqual[z, -2.9e-82], t$95$0, If[LessEqual[z, -3.7e-193], N[(x / z), $MachinePrecision], If[LessEqual[z, 2.8e-102], t$95$0, If[LessEqual[z, 2.3e-17], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.35e+20], t$95$0, (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -210:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -2.9 \cdot 10^{-82}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{-193}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-102}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{-17}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{+20}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -210 or 1.35e20 < z Initial program 69.7%
Taylor expanded in z around inf 74.8%
mul-1-neg74.8%
Simplified74.8%
if -210 < z < -2.89999999999999977e-82 or -3.7000000000000002e-193 < z < 2.80000000000000013e-102 or 2.30000000000000009e-17 < z < 1.35e20Initial program 99.9%
Taylor expanded in y around inf 63.5%
associate-/l*53.6%
associate-/r/70.4%
Simplified70.4%
if -2.89999999999999977e-82 < z < -3.7000000000000002e-193 or 2.80000000000000013e-102 < z < 2.30000000000000009e-17Initial program 99.9%
Taylor expanded in y around 0 82.0%
Taylor expanded in z around 0 82.0%
Final simplification74.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -210.0)
(- x)
(if (<= z -2.4e-81)
t_0
(if (<= z -5e-194)
(/ x z)
(if (<= z 8.4e-103)
t_0
(if (<= z 7.6e-18)
(/ x z)
(if (<= z 4.6e+20) (* x (/ y z)) (- x)))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -210.0) {
tmp = -x;
} else if (z <= -2.4e-81) {
tmp = t_0;
} else if (z <= -5e-194) {
tmp = x / z;
} else if (z <= 8.4e-103) {
tmp = t_0;
} else if (z <= 7.6e-18) {
tmp = x / z;
} else if (z <= 4.6e+20) {
tmp = x * (y / z);
} 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 <= (-210.0d0)) then
tmp = -x
else if (z <= (-2.4d-81)) then
tmp = t_0
else if (z <= (-5d-194)) then
tmp = x / z
else if (z <= 8.4d-103) then
tmp = t_0
else if (z <= 7.6d-18) then
tmp = x / z
else if (z <= 4.6d+20) then
tmp = x * (y / z)
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 <= -210.0) {
tmp = -x;
} else if (z <= -2.4e-81) {
tmp = t_0;
} else if (z <= -5e-194) {
tmp = x / z;
} else if (z <= 8.4e-103) {
tmp = t_0;
} else if (z <= 7.6e-18) {
tmp = x / z;
} else if (z <= 4.6e+20) {
tmp = x * (y / z);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -210.0: tmp = -x elif z <= -2.4e-81: tmp = t_0 elif z <= -5e-194: tmp = x / z elif z <= 8.4e-103: tmp = t_0 elif z <= 7.6e-18: tmp = x / z elif z <= 4.6e+20: tmp = x * (y / z) else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -210.0) tmp = Float64(-x); elseif (z <= -2.4e-81) tmp = t_0; elseif (z <= -5e-194) tmp = Float64(x / z); elseif (z <= 8.4e-103) tmp = t_0; elseif (z <= 7.6e-18) tmp = Float64(x / z); elseif (z <= 4.6e+20) tmp = Float64(x * Float64(y / z)); 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 <= -210.0) tmp = -x; elseif (z <= -2.4e-81) tmp = t_0; elseif (z <= -5e-194) tmp = x / z; elseif (z <= 8.4e-103) tmp = t_0; elseif (z <= 7.6e-18) tmp = x / z; elseif (z <= 4.6e+20) tmp = x * (y / z); 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, -210.0], (-x), If[LessEqual[z, -2.4e-81], t$95$0, If[LessEqual[z, -5e-194], N[(x / z), $MachinePrecision], If[LessEqual[z, 8.4e-103], t$95$0, If[LessEqual[z, 7.6e-18], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.6e+20], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -210:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -2.4 \cdot 10^{-81}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -5 \cdot 10^{-194}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 8.4 \cdot 10^{-103}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 7.6 \cdot 10^{-18}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{+20}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -210 or 4.6e20 < z Initial program 69.7%
Taylor expanded in z around inf 74.8%
mul-1-neg74.8%
Simplified74.8%
if -210 < z < -2.3999999999999999e-81 or -5.0000000000000002e-194 < z < 8.40000000000000019e-103Initial program 99.8%
Taylor expanded in y around inf 63.9%
associate-/l*52.6%
associate-/r/71.7%
Simplified71.7%
if -2.3999999999999999e-81 < z < -5.0000000000000002e-194 or 8.40000000000000019e-103 < z < 7.5999999999999996e-18Initial program 99.9%
Taylor expanded in y around 0 82.0%
Taylor expanded in z around 0 82.0%
if 7.5999999999999996e-18 < z < 4.6e20Initial program 100.0%
Taylor expanded in y around inf 60.9%
associate-/l*60.9%
Simplified60.9%
clear-num60.7%
associate-/r/60.7%
clear-num60.9%
Applied egg-rr60.9%
Final simplification74.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= y -1.8e+160)
t_0
(if (<= y -7.2e+110)
(- x)
(if (or (<= y -1e+63) (not (<= y 9.4e+61))) t_0 (- (/ x z) x))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (y <= -1.8e+160) {
tmp = t_0;
} else if (y <= -7.2e+110) {
tmp = -x;
} else if ((y <= -1e+63) || !(y <= 9.4e+61)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (y <= (-1.8d+160)) then
tmp = t_0
else if (y <= (-7.2d+110)) then
tmp = -x
else if ((y <= (-1d+63)) .or. (.not. (y <= 9.4d+61))) then
tmp = t_0
else
tmp = (x / z) - 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 (y <= -1.8e+160) {
tmp = t_0;
} else if (y <= -7.2e+110) {
tmp = -x;
} else if ((y <= -1e+63) || !(y <= 9.4e+61)) {
tmp = t_0;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if y <= -1.8e+160: tmp = t_0 elif y <= -7.2e+110: tmp = -x elif (y <= -1e+63) or not (y <= 9.4e+61): tmp = t_0 else: tmp = (x / z) - x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (y <= -1.8e+160) tmp = t_0; elseif (y <= -7.2e+110) tmp = Float64(-x); elseif ((y <= -1e+63) || !(y <= 9.4e+61)) tmp = t_0; else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (y <= -1.8e+160) tmp = t_0; elseif (y <= -7.2e+110) tmp = -x; elseif ((y <= -1e+63) || ~((y <= 9.4e+61))) tmp = t_0; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.8e+160], t$95$0, If[LessEqual[y, -7.2e+110], (-x), If[Or[LessEqual[y, -1e+63], N[Not[LessEqual[y, 9.4e+61]], $MachinePrecision]], t$95$0, N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -1.8 \cdot 10^{+160}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -7.2 \cdot 10^{+110}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq -1 \cdot 10^{+63} \lor \neg \left(y \leq 9.4 \cdot 10^{+61}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.80000000000000011e160 or -7.1999999999999994e110 < y < -1.00000000000000006e63 or 9.3999999999999997e61 < y Initial program 88.2%
Taylor expanded in y around inf 81.8%
associate-/l*79.2%
associate-/r/83.2%
Simplified83.2%
if -1.80000000000000011e160 < y < -7.1999999999999994e110Initial program 56.9%
Taylor expanded in z around inf 79.1%
mul-1-neg79.1%
Simplified79.1%
if -1.00000000000000006e63 < y < 9.3999999999999997e61Initial program 85.6%
Taylor expanded in x around 0 85.6%
associate--l+85.6%
+-commutative85.6%
associate-*r/99.3%
+-commutative99.3%
associate--l+99.3%
div-sub99.3%
sub-neg99.3%
*-inverses99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 93.5%
sub-neg93.5%
metadata-eval93.5%
distribute-rgt-in93.5%
associate-*l/93.6%
*-lft-identity93.6%
neg-mul-193.6%
unsub-neg93.6%
Simplified93.6%
Final simplification89.4%
(FPCore (x y z)
:precision binary64
(if (<= y -1.8e+160)
(/ y (/ z x))
(if (<= y -7e+110)
(- x)
(if (or (<= y -3e+60) (not (<= y 1.76e+62)))
(* y (/ x z))
(- (/ x z) x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+160) {
tmp = y / (z / x);
} else if (y <= -7e+110) {
tmp = -x;
} else if ((y <= -3e+60) || !(y <= 1.76e+62)) {
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 <= (-1.8d+160)) then
tmp = y / (z / x)
else if (y <= (-7d+110)) then
tmp = -x
else if ((y <= (-3d+60)) .or. (.not. (y <= 1.76d+62))) 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 <= -1.8e+160) {
tmp = y / (z / x);
} else if (y <= -7e+110) {
tmp = -x;
} else if ((y <= -3e+60) || !(y <= 1.76e+62)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.8e+160: tmp = y / (z / x) elif y <= -7e+110: tmp = -x elif (y <= -3e+60) or not (y <= 1.76e+62): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.8e+160) tmp = Float64(y / Float64(z / x)); elseif (y <= -7e+110) tmp = Float64(-x); elseif ((y <= -3e+60) || !(y <= 1.76e+62)) 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 <= -1.8e+160) tmp = y / (z / x); elseif (y <= -7e+110) tmp = -x; elseif ((y <= -3e+60) || ~((y <= 1.76e+62))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.8e+160], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -7e+110], (-x), If[Or[LessEqual[y, -3e+60], N[Not[LessEqual[y, 1.76e+62]], $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 -1.8 \cdot 10^{+160}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\mathbf{elif}\;y \leq -7 \cdot 10^{+110}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq -3 \cdot 10^{+60} \lor \neg \left(y \leq 1.76 \cdot 10^{+62}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.80000000000000011e160Initial program 90.5%
Taylor expanded in y around inf 81.4%
associate-/l*73.9%
associate-/r/82.9%
Simplified82.9%
*-commutative82.9%
clear-num82.8%
un-div-inv83.0%
Applied egg-rr83.0%
if -1.80000000000000011e160 < y < -6.9999999999999998e110Initial program 56.9%
Taylor expanded in z around inf 79.1%
mul-1-neg79.1%
Simplified79.1%
if -6.9999999999999998e110 < y < -2.9999999999999998e60 or 1.76e62 < y Initial program 87.1%
Taylor expanded in y around inf 81.9%
associate-/l*81.9%
associate-/r/83.4%
Simplified83.4%
if -2.9999999999999998e60 < y < 1.76e62Initial program 85.6%
Taylor expanded in x around 0 85.6%
associate--l+85.6%
+-commutative85.6%
associate-*r/99.3%
+-commutative99.3%
associate--l+99.3%
div-sub99.3%
sub-neg99.3%
*-inverses99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 93.5%
sub-neg93.5%
metadata-eval93.5%
distribute-rgt-in93.5%
associate-*l/93.6%
*-lft-identity93.6%
neg-mul-193.6%
unsub-neg93.6%
Simplified93.6%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -170.0) (not (<= z 5.5e-7))) (- (/ x z) x) (/ (+ x (* x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -170.0) || !(z <= 5.5e-7)) {
tmp = (x / z) - x;
} else {
tmp = (x + (x * y)) / 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 <= (-170.0d0)) .or. (.not. (z <= 5.5d-7))) then
tmp = (x / z) - x
else
tmp = (x + (x * y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -170.0) || !(z <= 5.5e-7)) {
tmp = (x / z) - x;
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -170.0) or not (z <= 5.5e-7): tmp = (x / z) - x else: tmp = (x + (x * y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -170.0) || !(z <= 5.5e-7)) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(x + Float64(x * y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -170.0) || ~((z <= 5.5e-7))) tmp = (x / z) - x; else tmp = (x + (x * y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -170.0], N[Not[LessEqual[z, 5.5e-7]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -170 \lor \neg \left(z \leq 5.5 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\end{array}
\end{array}
if z < -170 or 5.5000000000000003e-7 < z Initial program 71.1%
Taylor expanded in x around 0 71.1%
associate--l+71.1%
+-commutative71.1%
associate-*r/99.9%
+-commutative99.9%
associate--l+99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 75.4%
sub-neg75.4%
metadata-eval75.4%
distribute-rgt-in75.3%
associate-*l/75.4%
*-lft-identity75.4%
neg-mul-175.4%
unsub-neg75.4%
Simplified75.4%
if -170 < z < 5.5000000000000003e-7Initial program 99.9%
distribute-lft-in99.9%
fma-def99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 99.7%
Final simplification87.3%
(FPCore (x y z) :precision binary64 (if (<= x 5e-101) (/ (* x (+ (- y z) 1.0)) z) (* x (+ (/ (+ y 1.0) z) -1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= 5e-101) {
tmp = (x * ((y - z) + 1.0)) / z;
} else {
tmp = x * (((y + 1.0) / z) + -1.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) :: tmp
if (x <= 5d-101) then
tmp = (x * ((y - z) + 1.0d0)) / z
else
tmp = x * (((y + 1.0d0) / z) + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 5e-101) {
tmp = (x * ((y - z) + 1.0)) / z;
} else {
tmp = x * (((y + 1.0) / z) + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 5e-101: tmp = (x * ((y - z) + 1.0)) / z else: tmp = x * (((y + 1.0) / z) + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 5e-101) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z); else tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 5e-101) tmp = (x * ((y - z) + 1.0)) / z; else tmp = x * (((y + 1.0) / z) + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 5e-101], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-101}:\\
\;\;\;\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\end{array}
\end{array}
if x < 5.0000000000000001e-101Initial program 89.5%
if 5.0000000000000001e-101 < x Initial program 77.9%
Taylor expanded in x around 0 77.9%
associate--l+77.9%
+-commutative77.9%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification93.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -90.0) (not (<= z 1.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -90.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 <= (-90.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 <= -90.0) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -90.0) or not (z <= 1.0): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -90.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 <= -90.0) || ~((z <= 1.0))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -90.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -90 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -90 or 1 < z Initial program 70.7%
Taylor expanded in z around inf 73.0%
mul-1-neg73.0%
Simplified73.0%
if -90 < z < 1Initial program 99.9%
Taylor expanded in y around 0 61.0%
Taylor expanded in z around 0 59.8%
Final simplification66.4%
(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 85.3%
Taylor expanded in z around inf 38.2%
mul-1-neg38.2%
Simplified38.2%
Final simplification38.2%
(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 2024018
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))