
(FPCore (x y z) :precision binary64 (/ (- x y) (- z y)))
double code(double x, double y, double z) {
return (x - y) / (z - y);
}
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 - y)
end function
public static double code(double x, double y, double z) {
return (x - y) / (z - y);
}
def code(x, y, z): return (x - y) / (z - y)
function code(x, y, z) return Float64(Float64(x - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- x y) (- z y)))
double code(double x, double y, double z) {
return (x - y) / (z - y);
}
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 - y)
end function
public static double code(double x, double y, double z) {
return (x - y) / (z - y);
}
def code(x, y, z): return (x - y) / (z - y)
function code(x, y, z) return Float64(Float64(x - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y}
\end{array}
(FPCore (x y z) :precision binary64 (+ (/ x (- z y)) (/ y (- y z))))
double code(double x, double y, double z) {
return (x / (z - y)) + (y / (y - 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 / (z - y)) + (y / (y - z))
end function
public static double code(double x, double y, double z) {
return (x / (z - y)) + (y / (y - z));
}
def code(x, y, z): return (x / (z - y)) + (y / (y - z))
function code(x, y, z) return Float64(Float64(x / Float64(z - y)) + Float64(y / Float64(y - z))) end
function tmp = code(x, y, z) tmp = (x / (z - y)) + (y / (y - z)); end
code[x_, y_, z_] := N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] + N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z - y} + \frac{y}{y - z}
\end{array}
Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -4.5e+127)
t_0
(if (<= y -1.8e+15)
(/ y (- y z))
(if (<= y -8.6e-165)
(/ x (- z y))
(if (<= y 1e-42) (- (/ x z) (/ y z)) t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -4.5e+127) {
tmp = t_0;
} else if (y <= -1.8e+15) {
tmp = y / (y - z);
} else if (y <= -8.6e-165) {
tmp = x / (z - y);
} else if (y <= 1e-42) {
tmp = (x / z) - (y / 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 - (x / y)
if (y <= (-4.5d+127)) then
tmp = t_0
else if (y <= (-1.8d+15)) then
tmp = y / (y - z)
else if (y <= (-8.6d-165)) then
tmp = x / (z - y)
else if (y <= 1d-42) then
tmp = (x / z) - (y / 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 - (x / y);
double tmp;
if (y <= -4.5e+127) {
tmp = t_0;
} else if (y <= -1.8e+15) {
tmp = y / (y - z);
} else if (y <= -8.6e-165) {
tmp = x / (z - y);
} else if (y <= 1e-42) {
tmp = (x / z) - (y / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -4.5e+127: tmp = t_0 elif y <= -1.8e+15: tmp = y / (y - z) elif y <= -8.6e-165: tmp = x / (z - y) elif y <= 1e-42: tmp = (x / z) - (y / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -4.5e+127) tmp = t_0; elseif (y <= -1.8e+15) tmp = Float64(y / Float64(y - z)); elseif (y <= -8.6e-165) tmp = Float64(x / Float64(z - y)); elseif (y <= 1e-42) tmp = Float64(Float64(x / z) - Float64(y / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -4.5e+127) tmp = t_0; elseif (y <= -1.8e+15) tmp = y / (y - z); elseif (y <= -8.6e-165) tmp = x / (z - y); elseif (y <= 1e-42) tmp = (x / z) - (y / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.5e+127], t$95$0, If[LessEqual[y, -1.8e+15], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -8.6e-165], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e-42], N[(N[(x / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -4.5 \cdot 10^{+127}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.8 \cdot 10^{+15}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq -8.6 \cdot 10^{-165}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 10^{-42}:\\
\;\;\;\;\frac{x}{z} - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.50000000000000034e127 or 1.00000000000000004e-42 < y Initial program 100.0%
Taylor expanded in z around 0 83.1%
div-sub83.1%
sub-neg83.1%
*-inverses83.1%
metadata-eval83.1%
distribute-lft-in83.1%
metadata-eval83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
if -4.50000000000000034e127 < y < -1.8e15Initial program 100.0%
Taylor expanded in x around 0 91.9%
neg-mul-191.9%
distribute-neg-frac91.9%
Simplified91.9%
frac-2neg91.9%
div-inv91.3%
remove-double-neg91.3%
sub-neg91.3%
distribute-neg-in91.3%
remove-double-neg91.3%
Applied egg-rr91.3%
associate-*r/91.9%
*-rgt-identity91.9%
+-commutative91.9%
unsub-neg91.9%
Simplified91.9%
if -1.8e15 < y < -8.60000000000000013e-165Initial program 99.9%
Taylor expanded in x around inf 82.4%
if -8.60000000000000013e-165 < y < 1.00000000000000004e-42Initial program 99.9%
Taylor expanded in z around inf 90.6%
div-sub90.6%
Applied egg-rr90.6%
Final simplification86.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -2.4e+124)
t_0
(if (<= y -1.26e+82)
(/ y (- z))
(if (or (<= y -1.4e-106) (not (<= y 1.45e-48))) t_0 (/ x z))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -2.4e+124) {
tmp = t_0;
} else if (y <= -1.26e+82) {
tmp = y / -z;
} else if ((y <= -1.4e-106) || !(y <= 1.45e-48)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-2.4d+124)) then
tmp = t_0
else if (y <= (-1.26d+82)) then
tmp = y / -z
else if ((y <= (-1.4d-106)) .or. (.not. (y <= 1.45d-48))) then
tmp = t_0
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -2.4e+124) {
tmp = t_0;
} else if (y <= -1.26e+82) {
tmp = y / -z;
} else if ((y <= -1.4e-106) || !(y <= 1.45e-48)) {
tmp = t_0;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -2.4e+124: tmp = t_0 elif y <= -1.26e+82: tmp = y / -z elif (y <= -1.4e-106) or not (y <= 1.45e-48): tmp = t_0 else: tmp = x / z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -2.4e+124) tmp = t_0; elseif (y <= -1.26e+82) tmp = Float64(y / Float64(-z)); elseif ((y <= -1.4e-106) || !(y <= 1.45e-48)) tmp = t_0; else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -2.4e+124) tmp = t_0; elseif (y <= -1.26e+82) tmp = y / -z; elseif ((y <= -1.4e-106) || ~((y <= 1.45e-48))) tmp = t_0; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.4e+124], t$95$0, If[LessEqual[y, -1.26e+82], N[(y / (-z)), $MachinePrecision], If[Or[LessEqual[y, -1.4e-106], N[Not[LessEqual[y, 1.45e-48]], $MachinePrecision]], t$95$0, N[(x / z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -2.4 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.26 \cdot 10^{+82}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{elif}\;y \leq -1.4 \cdot 10^{-106} \lor \neg \left(y \leq 1.45 \cdot 10^{-48}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.40000000000000006e124 or -1.2600000000000001e82 < y < -1.39999999999999994e-106 or 1.4500000000000001e-48 < y Initial program 100.0%
Taylor expanded in z around 0 76.5%
div-sub76.5%
sub-neg76.5%
*-inverses76.5%
metadata-eval76.5%
distribute-lft-in76.5%
metadata-eval76.5%
+-commutative76.5%
mul-1-neg76.5%
unsub-neg76.5%
Simplified76.5%
if -2.40000000000000006e124 < y < -1.2600000000000001e82Initial program 100.0%
Taylor expanded in z around inf 77.9%
Taylor expanded in x around 0 77.9%
neg-mul-177.9%
distribute-neg-frac277.9%
Simplified77.9%
if -1.39999999999999994e-106 < y < 1.4500000000000001e-48Initial program 100.0%
Taylor expanded in y around 0 79.2%
Final simplification77.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -3.75e+124)
t_0
(if (<= y -1.26e+82)
(/ y (- z))
(if (or (<= y -4.4e-7) (not (<= y 7e-46))) t_0 (/ x (- z y)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -3.75e+124) {
tmp = t_0;
} else if (y <= -1.26e+82) {
tmp = y / -z;
} else if ((y <= -4.4e-7) || !(y <= 7e-46)) {
tmp = t_0;
} else {
tmp = x / (z - y);
}
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 - (x / y)
if (y <= (-3.75d+124)) then
tmp = t_0
else if (y <= (-1.26d+82)) then
tmp = y / -z
else if ((y <= (-4.4d-7)) .or. (.not. (y <= 7d-46))) then
tmp = t_0
else
tmp = x / (z - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -3.75e+124) {
tmp = t_0;
} else if (y <= -1.26e+82) {
tmp = y / -z;
} else if ((y <= -4.4e-7) || !(y <= 7e-46)) {
tmp = t_0;
} else {
tmp = x / (z - y);
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -3.75e+124: tmp = t_0 elif y <= -1.26e+82: tmp = y / -z elif (y <= -4.4e-7) or not (y <= 7e-46): tmp = t_0 else: tmp = x / (z - y) return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -3.75e+124) tmp = t_0; elseif (y <= -1.26e+82) tmp = Float64(y / Float64(-z)); elseif ((y <= -4.4e-7) || !(y <= 7e-46)) tmp = t_0; else tmp = Float64(x / Float64(z - y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -3.75e+124) tmp = t_0; elseif (y <= -1.26e+82) tmp = y / -z; elseif ((y <= -4.4e-7) || ~((y <= 7e-46))) tmp = t_0; else tmp = x / (z - y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.75e+124], t$95$0, If[LessEqual[y, -1.26e+82], N[(y / (-z)), $MachinePrecision], If[Or[LessEqual[y, -4.4e-7], N[Not[LessEqual[y, 7e-46]], $MachinePrecision]], t$95$0, N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -3.75 \cdot 10^{+124}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.26 \cdot 10^{+82}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{elif}\;y \leq -4.4 \cdot 10^{-7} \lor \neg \left(y \leq 7 \cdot 10^{-46}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y}\\
\end{array}
\end{array}
if y < -3.75000000000000019e124 or -1.2600000000000001e82 < y < -4.4000000000000002e-7 or 7.0000000000000004e-46 < y Initial program 100.0%
Taylor expanded in z around 0 79.6%
div-sub79.6%
sub-neg79.6%
*-inverses79.6%
metadata-eval79.6%
distribute-lft-in79.6%
metadata-eval79.6%
+-commutative79.6%
mul-1-neg79.6%
unsub-neg79.6%
Simplified79.6%
if -3.75000000000000019e124 < y < -1.2600000000000001e82Initial program 100.0%
Taylor expanded in z around inf 77.9%
Taylor expanded in x around 0 77.9%
neg-mul-177.9%
distribute-neg-frac277.9%
Simplified77.9%
if -4.4000000000000002e-7 < y < 7.0000000000000004e-46Initial program 99.9%
Taylor expanded in x around inf 84.9%
Final simplification82.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -1.65e+128)
t_0
(if (<= y -900000000000.0)
(/ y (- y z))
(if (<= y -2.4e-165)
(/ x (- z y))
(if (<= y 1.25e-42) (/ (- x y) z) t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -1.65e+128) {
tmp = t_0;
} else if (y <= -900000000000.0) {
tmp = y / (y - z);
} else if (y <= -2.4e-165) {
tmp = x / (z - y);
} else if (y <= 1.25e-42) {
tmp = (x - y) / 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 - (x / y)
if (y <= (-1.65d+128)) then
tmp = t_0
else if (y <= (-900000000000.0d0)) then
tmp = y / (y - z)
else if (y <= (-2.4d-165)) then
tmp = x / (z - y)
else if (y <= 1.25d-42) then
tmp = (x - y) / 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 - (x / y);
double tmp;
if (y <= -1.65e+128) {
tmp = t_0;
} else if (y <= -900000000000.0) {
tmp = y / (y - z);
} else if (y <= -2.4e-165) {
tmp = x / (z - y);
} else if (y <= 1.25e-42) {
tmp = (x - y) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -1.65e+128: tmp = t_0 elif y <= -900000000000.0: tmp = y / (y - z) elif y <= -2.4e-165: tmp = x / (z - y) elif y <= 1.25e-42: tmp = (x - y) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -1.65e+128) tmp = t_0; elseif (y <= -900000000000.0) tmp = Float64(y / Float64(y - z)); elseif (y <= -2.4e-165) tmp = Float64(x / Float64(z - y)); elseif (y <= 1.25e-42) tmp = Float64(Float64(x - y) / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -1.65e+128) tmp = t_0; elseif (y <= -900000000000.0) tmp = y / (y - z); elseif (y <= -2.4e-165) tmp = x / (z - y); elseif (y <= 1.25e-42) tmp = (x - y) / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.65e+128], t$95$0, If[LessEqual[y, -900000000000.0], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -2.4e-165], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.25e-42], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -1.65 \cdot 10^{+128}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -900000000000:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq -2.4 \cdot 10^{-165}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-42}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.65e128 or 1.25000000000000001e-42 < y Initial program 100.0%
Taylor expanded in z around 0 83.1%
div-sub83.1%
sub-neg83.1%
*-inverses83.1%
metadata-eval83.1%
distribute-lft-in83.1%
metadata-eval83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
if -1.65e128 < y < -9e11Initial program 100.0%
Taylor expanded in x around 0 91.9%
neg-mul-191.9%
distribute-neg-frac91.9%
Simplified91.9%
frac-2neg91.9%
div-inv91.3%
remove-double-neg91.3%
sub-neg91.3%
distribute-neg-in91.3%
remove-double-neg91.3%
Applied egg-rr91.3%
associate-*r/91.9%
*-rgt-identity91.9%
+-commutative91.9%
unsub-neg91.9%
Simplified91.9%
if -9e11 < y < -2.4000000000000002e-165Initial program 99.9%
Taylor expanded in x around inf 82.4%
if -2.4000000000000002e-165 < y < 1.25000000000000001e-42Initial program 99.9%
Taylor expanded in z around inf 90.6%
Final simplification86.3%
(FPCore (x y z)
:precision binary64
(if (<= y -2.4e+124)
1.0
(if (<= y -1.26e+82)
(/ y (- z))
(if (<= y -3.6e-7) 1.0 (if (<= y 4e-48) (/ x z) 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e+124) {
tmp = 1.0;
} else if (y <= -1.26e+82) {
tmp = y / -z;
} else if (y <= -3.6e-7) {
tmp = 1.0;
} else if (y <= 4e-48) {
tmp = x / z;
} else {
tmp = 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 (y <= (-2.4d+124)) then
tmp = 1.0d0
else if (y <= (-1.26d+82)) then
tmp = y / -z
else if (y <= (-3.6d-7)) then
tmp = 1.0d0
else if (y <= 4d-48) then
tmp = x / z
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e+124) {
tmp = 1.0;
} else if (y <= -1.26e+82) {
tmp = y / -z;
} else if (y <= -3.6e-7) {
tmp = 1.0;
} else if (y <= 4e-48) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.4e+124: tmp = 1.0 elif y <= -1.26e+82: tmp = y / -z elif y <= -3.6e-7: tmp = 1.0 elif y <= 4e-48: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.4e+124) tmp = 1.0; elseif (y <= -1.26e+82) tmp = Float64(y / Float64(-z)); elseif (y <= -3.6e-7) tmp = 1.0; elseif (y <= 4e-48) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.4e+124) tmp = 1.0; elseif (y <= -1.26e+82) tmp = y / -z; elseif (y <= -3.6e-7) tmp = 1.0; elseif (y <= 4e-48) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.4e+124], 1.0, If[LessEqual[y, -1.26e+82], N[(y / (-z)), $MachinePrecision], If[LessEqual[y, -3.6e-7], 1.0, If[LessEqual[y, 4e-48], N[(x / z), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+124}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.26 \cdot 10^{+82}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{elif}\;y \leq -3.6 \cdot 10^{-7}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-48}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.40000000000000006e124 or -1.2600000000000001e82 < y < -3.59999999999999994e-7 or 3.9999999999999999e-48 < y Initial program 100.0%
Taylor expanded in y around inf 62.1%
if -2.40000000000000006e124 < y < -1.2600000000000001e82Initial program 100.0%
Taylor expanded in z around inf 77.9%
Taylor expanded in x around 0 77.9%
neg-mul-177.9%
distribute-neg-frac277.9%
Simplified77.9%
if -3.59999999999999994e-7 < y < 3.9999999999999999e-48Initial program 99.9%
Taylor expanded in y around 0 71.5%
Final simplification66.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -3.1e+127)
t_0
(if (<= y -21000000000000.0)
(/ y (- y z))
(if (<= y 2.1e-50) (/ x (- z y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -3.1e+127) {
tmp = t_0;
} else if (y <= -21000000000000.0) {
tmp = y / (y - z);
} else if (y <= 2.1e-50) {
tmp = x / (z - y);
} 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 - (x / y)
if (y <= (-3.1d+127)) then
tmp = t_0
else if (y <= (-21000000000000.0d0)) then
tmp = y / (y - z)
else if (y <= 2.1d-50) then
tmp = x / (z - y)
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 - (x / y);
double tmp;
if (y <= -3.1e+127) {
tmp = t_0;
} else if (y <= -21000000000000.0) {
tmp = y / (y - z);
} else if (y <= 2.1e-50) {
tmp = x / (z - y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -3.1e+127: tmp = t_0 elif y <= -21000000000000.0: tmp = y / (y - z) elif y <= 2.1e-50: tmp = x / (z - y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -3.1e+127) tmp = t_0; elseif (y <= -21000000000000.0) tmp = Float64(y / Float64(y - z)); elseif (y <= 2.1e-50) tmp = Float64(x / Float64(z - y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -3.1e+127) tmp = t_0; elseif (y <= -21000000000000.0) tmp = y / (y - z); elseif (y <= 2.1e-50) tmp = x / (z - y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.1e+127], t$95$0, If[LessEqual[y, -21000000000000.0], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.1e-50], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -3.1 \cdot 10^{+127}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -21000000000000:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-50}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.1000000000000002e127 or 2.1000000000000001e-50 < y Initial program 100.0%
Taylor expanded in z around 0 82.4%
div-sub82.4%
sub-neg82.4%
*-inverses82.4%
metadata-eval82.4%
distribute-lft-in82.4%
metadata-eval82.4%
+-commutative82.4%
mul-1-neg82.4%
unsub-neg82.4%
Simplified82.4%
if -3.1000000000000002e127 < y < -2.1e13Initial program 100.0%
Taylor expanded in x around 0 91.9%
neg-mul-191.9%
distribute-neg-frac91.9%
Simplified91.9%
frac-2neg91.9%
div-inv91.3%
remove-double-neg91.3%
sub-neg91.3%
distribute-neg-in91.3%
remove-double-neg91.3%
Applied egg-rr91.3%
associate-*r/91.9%
*-rgt-identity91.9%
+-commutative91.9%
unsub-neg91.9%
Simplified91.9%
if -2.1e13 < y < 2.1000000000000001e-50Initial program 99.9%
Taylor expanded in x around inf 83.3%
Final simplification83.7%
(FPCore (x y z) :precision binary64 (if (<= y -6.5e-7) 1.0 (if (<= y 1.9e-46) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e-7) {
tmp = 1.0;
} else if (y <= 1.9e-46) {
tmp = x / z;
} else {
tmp = 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 (y <= (-6.5d-7)) then
tmp = 1.0d0
else if (y <= 1.9d-46) then
tmp = x / z
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e-7) {
tmp = 1.0;
} else if (y <= 1.9e-46) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.5e-7: tmp = 1.0 elif y <= 1.9e-46: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.5e-7) tmp = 1.0; elseif (y <= 1.9e-46) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.5e-7) tmp = 1.0; elseif (y <= 1.9e-46) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.5e-7], 1.0, If[LessEqual[y, 1.9e-46], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{-7}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-46}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -6.50000000000000024e-7 or 1.8999999999999998e-46 < y Initial program 100.0%
Taylor expanded in y around inf 59.0%
if -6.50000000000000024e-7 < y < 1.8999999999999998e-46Initial program 99.9%
Taylor expanded in y around 0 71.5%
Final simplification64.7%
(FPCore (x y z) :precision binary64 (/ (- y x) (- y z)))
double code(double x, double y, double z) {
return (y - x) / (y - z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y - x) / (y - z)
end function
public static double code(double x, double y, double z) {
return (y - x) / (y - z);
}
def code(x, y, z): return (y - x) / (y - z)
function code(x, y, z) return Float64(Float64(y - x) / Float64(y - z)) end
function tmp = code(x, y, z) tmp = (y - x) / (y - z); end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y - x}{y - z}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in y around inf 35.7%
Final simplification35.7%
(FPCore (x y z) :precision binary64 (- (/ x (- z y)) (/ y (- z y))))
double code(double x, double y, double z) {
return (x / (z - y)) - (y / (z - y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x / (z - y)) - (y / (z - y))
end function
public static double code(double x, double y, double z) {
return (x / (z - y)) - (y / (z - y));
}
def code(x, y, z): return (x / (z - y)) - (y / (z - y))
function code(x, y, z) return Float64(Float64(x / Float64(z - y)) - Float64(y / Float64(z - y))) end
function tmp = code(x, y, z) tmp = (x / (z - y)) - (y / (z - y)); end
code[x_, y_, z_] := N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z - y} - \frac{y}{z - y}
\end{array}
herbie shell --seed 2024115
(FPCore (x y z)
:name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
:precision binary64
:alt
(- (/ x (- z y)) (/ y (- z y)))
(/ (- x y) (- z y)))