
(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 99.9%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))) (t_1 (/ x (- z y))))
(if (<= y -62000.0)
t_0
(if (<= y -4.8e-99)
t_1
(if (<= y -9.2e-123)
t_0
(if (<= y 2.1e-77)
t_1
(if (or (<= y 85.0) (not (<= y 1.5e+243)))
t_0
(- 1.0 (/ x y)))))))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = x / (z - y);
double tmp;
if (y <= -62000.0) {
tmp = t_0;
} else if (y <= -4.8e-99) {
tmp = t_1;
} else if (y <= -9.2e-123) {
tmp = t_0;
} else if (y <= 2.1e-77) {
tmp = t_1;
} else if ((y <= 85.0) || !(y <= 1.5e+243)) {
tmp = t_0;
} else {
tmp = 1.0 - (x / 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) :: t_1
real(8) :: tmp
t_0 = y / (y - z)
t_1 = x / (z - y)
if (y <= (-62000.0d0)) then
tmp = t_0
else if (y <= (-4.8d-99)) then
tmp = t_1
else if (y <= (-9.2d-123)) then
tmp = t_0
else if (y <= 2.1d-77) then
tmp = t_1
else if ((y <= 85.0d0) .or. (.not. (y <= 1.5d+243))) then
tmp = t_0
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = x / (z - y);
double tmp;
if (y <= -62000.0) {
tmp = t_0;
} else if (y <= -4.8e-99) {
tmp = t_1;
} else if (y <= -9.2e-123) {
tmp = t_0;
} else if (y <= 2.1e-77) {
tmp = t_1;
} else if ((y <= 85.0) || !(y <= 1.5e+243)) {
tmp = t_0;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) t_1 = x / (z - y) tmp = 0 if y <= -62000.0: tmp = t_0 elif y <= -4.8e-99: tmp = t_1 elif y <= -9.2e-123: tmp = t_0 elif y <= 2.1e-77: tmp = t_1 elif (y <= 85.0) or not (y <= 1.5e+243): tmp = t_0 else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) t_1 = Float64(x / Float64(z - y)) tmp = 0.0 if (y <= -62000.0) tmp = t_0; elseif (y <= -4.8e-99) tmp = t_1; elseif (y <= -9.2e-123) tmp = t_0; elseif (y <= 2.1e-77) tmp = t_1; elseif ((y <= 85.0) || !(y <= 1.5e+243)) tmp = t_0; else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); t_1 = x / (z - y); tmp = 0.0; if (y <= -62000.0) tmp = t_0; elseif (y <= -4.8e-99) tmp = t_1; elseif (y <= -9.2e-123) tmp = t_0; elseif (y <= 2.1e-77) tmp = t_1; elseif ((y <= 85.0) || ~((y <= 1.5e+243))) tmp = t_0; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -62000.0], t$95$0, If[LessEqual[y, -4.8e-99], t$95$1, If[LessEqual[y, -9.2e-123], t$95$0, If[LessEqual[y, 2.1e-77], t$95$1, If[Or[LessEqual[y, 85.0], N[Not[LessEqual[y, 1.5e+243]], $MachinePrecision]], t$95$0, N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
t_1 := \frac{x}{z - y}\\
\mathbf{if}\;y \leq -62000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-99}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -9.2 \cdot 10^{-123}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-77}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 85 \lor \neg \left(y \leq 1.5 \cdot 10^{+243}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -62000 or -4.8000000000000001e-99 < y < -9.19999999999999947e-123 or 2.10000000000000015e-77 < y < 85 or 1.49999999999999992e243 < y Initial program 99.9%
Taylor expanded in x around inf 86.0%
+-commutative86.0%
mul-1-neg86.0%
unsub-neg86.0%
*-commutative86.0%
Simplified86.0%
Taylor expanded in x around 0 80.0%
mul-1-neg80.0%
distribute-neg-frac280.0%
neg-sub080.0%
associate-+l-80.0%
neg-sub080.0%
+-commutative80.0%
unsub-neg80.0%
Simplified80.0%
if -62000 < y < -4.8000000000000001e-99 or -9.19999999999999947e-123 < y < 2.10000000000000015e-77Initial program 100.0%
Taylor expanded in x around inf 89.1%
if 85 < y < 1.49999999999999992e243Initial program 99.9%
Taylor expanded in z around 0 82.3%
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%
Final simplification84.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- z))))
(if (<= y -3.7e+56)
1.0
(if (<= y 3.1e-74)
(/ x z)
(if (<= y 3.9e-51)
t_0
(if (<= y 1.4e-15)
(/ x z)
(if (<= y 2.9e+22) (/ x (- y)) (if (<= y 1.45e+51) t_0 1.0))))))))
double code(double x, double y, double z) {
double t_0 = y / -z;
double tmp;
if (y <= -3.7e+56) {
tmp = 1.0;
} else if (y <= 3.1e-74) {
tmp = x / z;
} else if (y <= 3.9e-51) {
tmp = t_0;
} else if (y <= 1.4e-15) {
tmp = x / z;
} else if (y <= 2.9e+22) {
tmp = x / -y;
} else if (y <= 1.45e+51) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y / -z
if (y <= (-3.7d+56)) then
tmp = 1.0d0
else if (y <= 3.1d-74) then
tmp = x / z
else if (y <= 3.9d-51) then
tmp = t_0
else if (y <= 1.4d-15) then
tmp = x / z
else if (y <= 2.9d+22) then
tmp = x / -y
else if (y <= 1.45d+51) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / -z;
double tmp;
if (y <= -3.7e+56) {
tmp = 1.0;
} else if (y <= 3.1e-74) {
tmp = x / z;
} else if (y <= 3.9e-51) {
tmp = t_0;
} else if (y <= 1.4e-15) {
tmp = x / z;
} else if (y <= 2.9e+22) {
tmp = x / -y;
} else if (y <= 1.45e+51) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): t_0 = y / -z tmp = 0 if y <= -3.7e+56: tmp = 1.0 elif y <= 3.1e-74: tmp = x / z elif y <= 3.9e-51: tmp = t_0 elif y <= 1.4e-15: tmp = x / z elif y <= 2.9e+22: tmp = x / -y elif y <= 1.45e+51: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(-z)) tmp = 0.0 if (y <= -3.7e+56) tmp = 1.0; elseif (y <= 3.1e-74) tmp = Float64(x / z); elseif (y <= 3.9e-51) tmp = t_0; elseif (y <= 1.4e-15) tmp = Float64(x / z); elseif (y <= 2.9e+22) tmp = Float64(x / Float64(-y)); elseif (y <= 1.45e+51) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / -z; tmp = 0.0; if (y <= -3.7e+56) tmp = 1.0; elseif (y <= 3.1e-74) tmp = x / z; elseif (y <= 3.9e-51) tmp = t_0; elseif (y <= 1.4e-15) tmp = x / z; elseif (y <= 2.9e+22) tmp = x / -y; elseif (y <= 1.45e+51) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / (-z)), $MachinePrecision]}, If[LessEqual[y, -3.7e+56], 1.0, If[LessEqual[y, 3.1e-74], N[(x / z), $MachinePrecision], If[LessEqual[y, 3.9e-51], t$95$0, If[LessEqual[y, 1.4e-15], N[(x / z), $MachinePrecision], If[LessEqual[y, 2.9e+22], N[(x / (-y)), $MachinePrecision], If[LessEqual[y, 1.45e+51], t$95$0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{-z}\\
\mathbf{if}\;y \leq -3.7 \cdot 10^{+56}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+22}:\\
\;\;\;\;\frac{x}{-y}\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+51}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.69999999999999997e56 or 1.4499999999999999e51 < y Initial program 99.9%
Taylor expanded in y around inf 68.0%
if -3.69999999999999997e56 < y < 3.1000000000000002e-74 or 3.8999999999999997e-51 < y < 1.40000000000000007e-15Initial program 100.0%
Taylor expanded in y around 0 68.6%
if 3.1000000000000002e-74 < y < 3.8999999999999997e-51 or 2.9e22 < y < 1.4499999999999999e51Initial program 100.0%
Taylor expanded in z around inf 86.4%
Taylor expanded in x around 0 86.4%
neg-mul-186.4%
distribute-neg-frac286.4%
Simplified86.4%
if 1.40000000000000007e-15 < y < 2.9e22Initial program 100.0%
Taylor expanded in x around inf 57.0%
Taylor expanded in z around 0 49.4%
associate-*r/49.4%
neg-mul-149.4%
Simplified49.4%
Final simplification67.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ x (- z y))))
(if (<= y -4.8e+56)
t_0
(if (<= y 3.1e-74)
t_1
(if (<= y 5.4e-55) (/ y (- z)) (if (<= y 760000.0) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (z - y);
double tmp;
if (y <= -4.8e+56) {
tmp = t_0;
} else if (y <= 3.1e-74) {
tmp = t_1;
} else if (y <= 5.4e-55) {
tmp = y / -z;
} else if (y <= 760000.0) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
t_1 = x / (z - y)
if (y <= (-4.8d+56)) then
tmp = t_0
else if (y <= 3.1d-74) then
tmp = t_1
else if (y <= 5.4d-55) then
tmp = y / -z
else if (y <= 760000.0d0) then
tmp = t_1
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 t_1 = x / (z - y);
double tmp;
if (y <= -4.8e+56) {
tmp = t_0;
} else if (y <= 3.1e-74) {
tmp = t_1;
} else if (y <= 5.4e-55) {
tmp = y / -z;
} else if (y <= 760000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) t_1 = x / (z - y) tmp = 0 if y <= -4.8e+56: tmp = t_0 elif y <= 3.1e-74: tmp = t_1 elif y <= 5.4e-55: tmp = y / -z elif y <= 760000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) t_1 = Float64(x / Float64(z - y)) tmp = 0.0 if (y <= -4.8e+56) tmp = t_0; elseif (y <= 3.1e-74) tmp = t_1; elseif (y <= 5.4e-55) tmp = Float64(y / Float64(-z)); elseif (y <= 760000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); t_1 = x / (z - y); tmp = 0.0; if (y <= -4.8e+56) tmp = t_0; elseif (y <= 3.1e-74) tmp = t_1; elseif (y <= 5.4e-55) tmp = y / -z; elseif (y <= 760000.0) tmp = t_1; 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]}, Block[{t$95$1 = N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.8e+56], t$95$0, If[LessEqual[y, 3.1e-74], t$95$1, If[LessEqual[y, 5.4e-55], N[(y / (-z)), $MachinePrecision], If[LessEqual[y, 760000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{x}{z - y}\\
\mathbf{if}\;y \leq -4.8 \cdot 10^{+56}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{-55}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{elif}\;y \leq 760000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.80000000000000027e56 or 7.6e5 < y Initial program 99.9%
Taylor expanded in z around 0 80.0%
div-sub80.1%
sub-neg80.1%
*-inverses80.1%
metadata-eval80.1%
distribute-lft-in80.1%
metadata-eval80.1%
+-commutative80.1%
mul-1-neg80.1%
unsub-neg80.1%
Simplified80.1%
if -4.80000000000000027e56 < y < 3.1000000000000002e-74 or 5.40000000000000008e-55 < y < 7.6e5Initial program 100.0%
Taylor expanded in x around inf 78.1%
if 3.1000000000000002e-74 < y < 5.40000000000000008e-55Initial program 100.0%
Taylor expanded in z around inf 84.2%
Taylor expanded in x around 0 84.2%
neg-mul-184.2%
distribute-neg-frac284.2%
Simplified84.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))))
(if (<= y -9.5e+56)
t_0
(if (<= y -9.8e-126)
(/ (- x y) z)
(if (<= y 1.95e-77) (/ x (- z y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -9.5e+56) {
tmp = t_0;
} else if (y <= -9.8e-126) {
tmp = (x - y) / z;
} else if (y <= 1.95e-77) {
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 = y / (y - z)
if (y <= (-9.5d+56)) then
tmp = t_0
else if (y <= (-9.8d-126)) then
tmp = (x - y) / z
else if (y <= 1.95d-77) 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 = y / (y - z);
double tmp;
if (y <= -9.5e+56) {
tmp = t_0;
} else if (y <= -9.8e-126) {
tmp = (x - y) / z;
} else if (y <= 1.95e-77) {
tmp = x / (z - y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) tmp = 0 if y <= -9.5e+56: tmp = t_0 elif y <= -9.8e-126: tmp = (x - y) / z elif y <= 1.95e-77: tmp = x / (z - y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) tmp = 0.0 if (y <= -9.5e+56) tmp = t_0; elseif (y <= -9.8e-126) tmp = Float64(Float64(x - y) / z); elseif (y <= 1.95e-77) tmp = Float64(x / Float64(z - y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); tmp = 0.0; if (y <= -9.5e+56) tmp = t_0; elseif (y <= -9.8e-126) tmp = (x - y) / z; elseif (y <= 1.95e-77) tmp = x / (z - y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.5e+56], t$95$0, If[LessEqual[y, -9.8e-126], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 1.95e-77], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -9.5 \cdot 10^{+56}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -9.8 \cdot 10^{-126}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-77}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.4999999999999997e56 or 1.9499999999999999e-77 < y Initial program 99.9%
Taylor expanded in x around inf 87.2%
+-commutative87.2%
mul-1-neg87.2%
unsub-neg87.2%
*-commutative87.2%
Simplified87.2%
Taylor expanded in x around 0 78.8%
mul-1-neg78.8%
distribute-neg-frac278.8%
neg-sub078.8%
associate-+l-78.8%
neg-sub078.8%
+-commutative78.8%
unsub-neg78.8%
Simplified78.8%
if -9.4999999999999997e56 < y < -9.8000000000000002e-126Initial program 100.0%
Taylor expanded in z around inf 77.0%
if -9.8000000000000002e-126 < y < 1.9499999999999999e-77Initial program 100.0%
Taylor expanded in x around inf 94.8%
(FPCore (x y z) :precision binary64 (if (<= y -4.1e+56) 1.0 (if (<= y 2.5e-74) (/ x z) (if (<= y 3.8e+50) (/ y (- z)) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.1e+56) {
tmp = 1.0;
} else if (y <= 2.5e-74) {
tmp = x / z;
} else if (y <= 3.8e+50) {
tmp = y / -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 <= (-4.1d+56)) then
tmp = 1.0d0
else if (y <= 2.5d-74) then
tmp = x / z
else if (y <= 3.8d+50) then
tmp = y / -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 <= -4.1e+56) {
tmp = 1.0;
} else if (y <= 2.5e-74) {
tmp = x / z;
} else if (y <= 3.8e+50) {
tmp = y / -z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.1e+56: tmp = 1.0 elif y <= 2.5e-74: tmp = x / z elif y <= 3.8e+50: tmp = y / -z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.1e+56) tmp = 1.0; elseif (y <= 2.5e-74) tmp = Float64(x / z); elseif (y <= 3.8e+50) tmp = Float64(y / Float64(-z)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.1e+56) tmp = 1.0; elseif (y <= 2.5e-74) tmp = x / z; elseif (y <= 3.8e+50) tmp = y / -z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.1e+56], 1.0, If[LessEqual[y, 2.5e-74], N[(x / z), $MachinePrecision], If[LessEqual[y, 3.8e+50], N[(y / (-z)), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.1 \cdot 10^{+56}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+50}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.1000000000000004e56 or 3.79999999999999987e50 < y Initial program 99.9%
Taylor expanded in y around inf 68.0%
if -4.1000000000000004e56 < y < 2.49999999999999999e-74Initial program 100.0%
Taylor expanded in y around 0 69.9%
if 2.49999999999999999e-74 < y < 3.79999999999999987e50Initial program 99.9%
Taylor expanded in z around inf 55.8%
Taylor expanded in x around 0 41.4%
neg-mul-141.4%
distribute-neg-frac241.4%
Simplified41.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.000155) (not (<= y 3.9e-81))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.000155) || !(y <= 3.9e-81)) {
tmp = 1.0 - (x / y);
} 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 ((y <= (-0.000155d0)) .or. (.not. (y <= 3.9d-81))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.000155) || !(y <= 3.9e-81)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.000155) or not (y <= 3.9e-81): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.000155) || !(y <= 3.9e-81)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.000155) || ~((y <= 3.9e-81))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.000155], N[Not[LessEqual[y, 3.9e-81]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.000155 \lor \neg \left(y \leq 3.9 \cdot 10^{-81}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -1.55e-4 or 3.89999999999999985e-81 < y Initial program 99.9%
Taylor expanded in z around 0 71.2%
div-sub71.2%
sub-neg71.2%
*-inverses71.2%
metadata-eval71.2%
distribute-lft-in71.2%
metadata-eval71.2%
+-commutative71.2%
mul-1-neg71.2%
unsub-neg71.2%
Simplified71.2%
if -1.55e-4 < y < 3.89999999999999985e-81Initial program 100.0%
Taylor expanded in y around 0 75.1%
Final simplification73.0%
(FPCore (x y z) :precision binary64 (if (<= y -3.8e+56) 1.0 (if (<= y 7.2e-6) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.8e+56) {
tmp = 1.0;
} else if (y <= 7.2e-6) {
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 <= (-3.8d+56)) then
tmp = 1.0d0
else if (y <= 7.2d-6) 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 <= -3.8e+56) {
tmp = 1.0;
} else if (y <= 7.2e-6) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.8e+56: tmp = 1.0 elif y <= 7.2e-6: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.8e+56) tmp = 1.0; elseif (y <= 7.2e-6) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.8e+56) tmp = 1.0; elseif (y <= 7.2e-6) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.8e+56], 1.0, If[LessEqual[y, 7.2e-6], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{+56}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-6}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.79999999999999996e56 or 7.19999999999999967e-6 < y Initial program 99.9%
Taylor expanded in y around inf 62.9%
if -3.79999999999999996e56 < y < 7.19999999999999967e-6Initial program 100.0%
Taylor expanded in y around 0 65.2%
(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 99.9%
Final simplification99.9%
(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 99.9%
Taylor expanded in y around inf 33.2%
(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 2024084
(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)))