
(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 9 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 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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= y -3.4e+93)
1.0
(if (<= y -2.5e+32)
(/ x (- y))
(if (<= y -3.6e-22)
1.0
(if (<= y 1e-49)
(/ x z)
(if (or (<= y 950000000000.0)
(and (not (<= y 3.5e+79)) (<= y 1.55e+152)))
(/ y (- z))
1.0))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+93) {
tmp = 1.0;
} else if (y <= -2.5e+32) {
tmp = x / -y;
} else if (y <= -3.6e-22) {
tmp = 1.0;
} else if (y <= 1e-49) {
tmp = x / z;
} else if ((y <= 950000000000.0) || (!(y <= 3.5e+79) && (y <= 1.55e+152))) {
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 <= (-3.4d+93)) then
tmp = 1.0d0
else if (y <= (-2.5d+32)) then
tmp = x / -y
else if (y <= (-3.6d-22)) then
tmp = 1.0d0
else if (y <= 1d-49) then
tmp = x / z
else if ((y <= 950000000000.0d0) .or. (.not. (y <= 3.5d+79)) .and. (y <= 1.55d+152)) 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 <= -3.4e+93) {
tmp = 1.0;
} else if (y <= -2.5e+32) {
tmp = x / -y;
} else if (y <= -3.6e-22) {
tmp = 1.0;
} else if (y <= 1e-49) {
tmp = x / z;
} else if ((y <= 950000000000.0) || (!(y <= 3.5e+79) && (y <= 1.55e+152))) {
tmp = y / -z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.4e+93: tmp = 1.0 elif y <= -2.5e+32: tmp = x / -y elif y <= -3.6e-22: tmp = 1.0 elif y <= 1e-49: tmp = x / z elif (y <= 950000000000.0) or (not (y <= 3.5e+79) and (y <= 1.55e+152)): tmp = y / -z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.4e+93) tmp = 1.0; elseif (y <= -2.5e+32) tmp = Float64(x / Float64(-y)); elseif (y <= -3.6e-22) tmp = 1.0; elseif (y <= 1e-49) tmp = Float64(x / z); elseif ((y <= 950000000000.0) || (!(y <= 3.5e+79) && (y <= 1.55e+152))) 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 <= -3.4e+93) tmp = 1.0; elseif (y <= -2.5e+32) tmp = x / -y; elseif (y <= -3.6e-22) tmp = 1.0; elseif (y <= 1e-49) tmp = x / z; elseif ((y <= 950000000000.0) || (~((y <= 3.5e+79)) && (y <= 1.55e+152))) tmp = y / -z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.4e+93], 1.0, If[LessEqual[y, -2.5e+32], N[(x / (-y)), $MachinePrecision], If[LessEqual[y, -3.6e-22], 1.0, If[LessEqual[y, 1e-49], N[(x / z), $MachinePrecision], If[Or[LessEqual[y, 950000000000.0], And[N[Not[LessEqual[y, 3.5e+79]], $MachinePrecision], LessEqual[y, 1.55e+152]]], N[(y / (-z)), $MachinePrecision], 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+93}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.5 \cdot 10^{+32}:\\
\;\;\;\;\frac{x}{-y}\\
\mathbf{elif}\;y \leq -3.6 \cdot 10^{-22}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 10^{-49}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 950000000000 \lor \neg \left(y \leq 3.5 \cdot 10^{+79}\right) \land y \leq 1.55 \cdot 10^{+152}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.4e93 or -2.4999999999999999e32 < y < -3.5999999999999998e-22 or 9.5e11 < y < 3.4999999999999998e79 or 1.55e152 < y Initial program 100.0%
Taylor expanded in y around inf 73.3%
if -3.4e93 < y < -2.4999999999999999e32Initial program 100.0%
Taylor expanded in x around inf 87.7%
Taylor expanded in z around 0 72.9%
associate-*r/72.9%
neg-mul-172.9%
Simplified72.9%
if -3.5999999999999998e-22 < y < 9.99999999999999936e-50Initial program 100.0%
Taylor expanded in y around 0 76.7%
if 9.99999999999999936e-50 < y < 9.5e11 or 3.4999999999999998e79 < y < 1.55e152Initial program 100.0%
clear-num99.7%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in z around inf 63.0%
Taylor expanded in x around 0 55.1%
neg-mul-155.1%
distribute-neg-frac55.1%
Simplified55.1%
Final simplification72.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (- y))))
(if (<= y -3.4e+93)
1.0
(if (<= y -1.25e+33)
t_0
(if (<= y -2.55e-22)
1.0
(if (<= y 1.65e-49)
(/ x z)
(if (<= y 44000.0) t_0 (if (<= y 1.2e+26) (/ x z) 1.0))))))))
double code(double x, double y, double z) {
double t_0 = x / -y;
double tmp;
if (y <= -3.4e+93) {
tmp = 1.0;
} else if (y <= -1.25e+33) {
tmp = t_0;
} else if (y <= -2.55e-22) {
tmp = 1.0;
} else if (y <= 1.65e-49) {
tmp = x / z;
} else if (y <= 44000.0) {
tmp = t_0;
} else if (y <= 1.2e+26) {
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) :: t_0
real(8) :: tmp
t_0 = x / -y
if (y <= (-3.4d+93)) then
tmp = 1.0d0
else if (y <= (-1.25d+33)) then
tmp = t_0
else if (y <= (-2.55d-22)) then
tmp = 1.0d0
else if (y <= 1.65d-49) then
tmp = x / z
else if (y <= 44000.0d0) then
tmp = t_0
else if (y <= 1.2d+26) 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 t_0 = x / -y;
double tmp;
if (y <= -3.4e+93) {
tmp = 1.0;
} else if (y <= -1.25e+33) {
tmp = t_0;
} else if (y <= -2.55e-22) {
tmp = 1.0;
} else if (y <= 1.65e-49) {
tmp = x / z;
} else if (y <= 44000.0) {
tmp = t_0;
} else if (y <= 1.2e+26) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): t_0 = x / -y tmp = 0 if y <= -3.4e+93: tmp = 1.0 elif y <= -1.25e+33: tmp = t_0 elif y <= -2.55e-22: tmp = 1.0 elif y <= 1.65e-49: tmp = x / z elif y <= 44000.0: tmp = t_0 elif y <= 1.2e+26: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) t_0 = Float64(x / Float64(-y)) tmp = 0.0 if (y <= -3.4e+93) tmp = 1.0; elseif (y <= -1.25e+33) tmp = t_0; elseif (y <= -2.55e-22) tmp = 1.0; elseif (y <= 1.65e-49) tmp = Float64(x / z); elseif (y <= 44000.0) tmp = t_0; elseif (y <= 1.2e+26) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / -y; tmp = 0.0; if (y <= -3.4e+93) tmp = 1.0; elseif (y <= -1.25e+33) tmp = t_0; elseif (y <= -2.55e-22) tmp = 1.0; elseif (y <= 1.65e-49) tmp = x / z; elseif (y <= 44000.0) tmp = t_0; elseif (y <= 1.2e+26) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / (-y)), $MachinePrecision]}, If[LessEqual[y, -3.4e+93], 1.0, If[LessEqual[y, -1.25e+33], t$95$0, If[LessEqual[y, -2.55e-22], 1.0, If[LessEqual[y, 1.65e-49], N[(x / z), $MachinePrecision], If[LessEqual[y, 44000.0], t$95$0, If[LessEqual[y, 1.2e+26], N[(x / z), $MachinePrecision], 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{-y}\\
\mathbf{if}\;y \leq -3.4 \cdot 10^{+93}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.25 \cdot 10^{+33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -2.55 \cdot 10^{-22}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{-49}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 44000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+26}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.4e93 or -1.24999999999999993e33 < y < -2.55000000000000011e-22 or 1.20000000000000002e26 < y Initial program 100.0%
Taylor expanded in y around inf 66.6%
if -3.4e93 < y < -1.24999999999999993e33 or 1.65e-49 < y < 44000Initial program 100.0%
Taylor expanded in x around inf 60.3%
Taylor expanded in z around 0 52.6%
associate-*r/52.6%
neg-mul-152.6%
Simplified52.6%
if -2.55000000000000011e-22 < y < 1.65e-49 or 44000 < y < 1.20000000000000002e26Initial program 100.0%
Taylor expanded in y around 0 75.1%
Final simplification69.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -1.12e-23)
t_0
(if (<= y 3.5e-56)
(/ x z)
(if (or (<= y 6e+79) (not (<= y 1.35e+152))) t_0 (/ y (- z)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -1.12e-23) {
tmp = t_0;
} else if (y <= 3.5e-56) {
tmp = x / z;
} else if ((y <= 6e+79) || !(y <= 1.35e+152)) {
tmp = t_0;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-1.12d-23)) then
tmp = t_0
else if (y <= 3.5d-56) then
tmp = x / z
else if ((y <= 6d+79) .or. (.not. (y <= 1.35d+152))) then
tmp = t_0
else
tmp = y / -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 <= -1.12e-23) {
tmp = t_0;
} else if (y <= 3.5e-56) {
tmp = x / z;
} else if ((y <= 6e+79) || !(y <= 1.35e+152)) {
tmp = t_0;
} else {
tmp = y / -z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -1.12e-23: tmp = t_0 elif y <= 3.5e-56: tmp = x / z elif (y <= 6e+79) or not (y <= 1.35e+152): tmp = t_0 else: tmp = y / -z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -1.12e-23) tmp = t_0; elseif (y <= 3.5e-56) tmp = Float64(x / z); elseif ((y <= 6e+79) || !(y <= 1.35e+152)) tmp = t_0; else tmp = Float64(y / Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -1.12e-23) tmp = t_0; elseif (y <= 3.5e-56) tmp = x / z; elseif ((y <= 6e+79) || ~((y <= 1.35e+152))) tmp = t_0; else tmp = y / -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, -1.12e-23], t$95$0, If[LessEqual[y, 3.5e-56], N[(x / z), $MachinePrecision], If[Or[LessEqual[y, 6e+79], N[Not[LessEqual[y, 1.35e+152]], $MachinePrecision]], t$95$0, N[(y / (-z)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -1.12 \cdot 10^{-23}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{-56}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+79} \lor \neg \left(y \leq 1.35 \cdot 10^{+152}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{-z}\\
\end{array}
\end{array}
if y < -1.1200000000000001e-23 or 3.4999999999999998e-56 < y < 5.99999999999999948e79 or 1.35000000000000007e152 < y Initial program 100.0%
Taylor expanded in z around 0 82.2%
div-sub82.2%
sub-neg82.2%
*-inverses82.2%
metadata-eval82.2%
distribute-lft-in82.2%
metadata-eval82.2%
+-commutative82.2%
mul-1-neg82.2%
unsub-neg82.2%
Simplified82.2%
if -1.1200000000000001e-23 < y < 3.4999999999999998e-56Initial program 100.0%
Taylor expanded in y around 0 77.3%
if 5.99999999999999948e79 < y < 1.35000000000000007e152Initial program 100.0%
clear-num99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 71.1%
Taylor expanded in x around 0 65.2%
neg-mul-165.2%
distribute-neg-frac65.2%
Simplified65.2%
Final simplification78.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -8e-19)
t_0
(if (<= y 2.45e-51)
(/ x (- z y))
(if (or (<= y 6e+79) (not (<= y 1.35e+152))) t_0 (/ y (- z)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -8e-19) {
tmp = t_0;
} else if (y <= 2.45e-51) {
tmp = x / (z - y);
} else if ((y <= 6e+79) || !(y <= 1.35e+152)) {
tmp = t_0;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-8d-19)) then
tmp = t_0
else if (y <= 2.45d-51) then
tmp = x / (z - y)
else if ((y <= 6d+79) .or. (.not. (y <= 1.35d+152))) then
tmp = t_0
else
tmp = y / -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 <= -8e-19) {
tmp = t_0;
} else if (y <= 2.45e-51) {
tmp = x / (z - y);
} else if ((y <= 6e+79) || !(y <= 1.35e+152)) {
tmp = t_0;
} else {
tmp = y / -z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -8e-19: tmp = t_0 elif y <= 2.45e-51: tmp = x / (z - y) elif (y <= 6e+79) or not (y <= 1.35e+152): tmp = t_0 else: tmp = y / -z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -8e-19) tmp = t_0; elseif (y <= 2.45e-51) tmp = Float64(x / Float64(z - y)); elseif ((y <= 6e+79) || !(y <= 1.35e+152)) tmp = t_0; else tmp = Float64(y / Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -8e-19) tmp = t_0; elseif (y <= 2.45e-51) tmp = x / (z - y); elseif ((y <= 6e+79) || ~((y <= 1.35e+152))) tmp = t_0; else tmp = y / -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, -8e-19], t$95$0, If[LessEqual[y, 2.45e-51], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 6e+79], N[Not[LessEqual[y, 1.35e+152]], $MachinePrecision]], t$95$0, N[(y / (-z)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -8 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{-51}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+79} \lor \neg \left(y \leq 1.35 \cdot 10^{+152}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{-z}\\
\end{array}
\end{array}
if y < -7.9999999999999998e-19 or 2.44999999999999987e-51 < y < 5.99999999999999948e79 or 1.35000000000000007e152 < y Initial program 100.0%
Taylor expanded in z around 0 82.0%
div-sub82.1%
sub-neg82.1%
*-inverses82.1%
metadata-eval82.1%
distribute-lft-in82.1%
metadata-eval82.1%
+-commutative82.1%
mul-1-neg82.1%
unsub-neg82.1%
Simplified82.1%
if -7.9999999999999998e-19 < y < 2.44999999999999987e-51Initial program 100.0%
Taylor expanded in x around inf 84.6%
if 5.99999999999999948e79 < y < 1.35000000000000007e152Initial program 100.0%
clear-num99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 71.1%
Taylor expanded in x around 0 65.2%
neg-mul-165.2%
distribute-neg-frac65.2%
Simplified65.2%
Final simplification82.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -3e-19)
t_0
(if (<= y 5.6e-99)
(/ x (- z y))
(if (<= y 2.5e+152) (/ y (- y z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -3e-19) {
tmp = t_0;
} else if (y <= 5.6e-99) {
tmp = x / (z - y);
} else if (y <= 2.5e+152) {
tmp = y / (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 <= (-3d-19)) then
tmp = t_0
else if (y <= 5.6d-99) then
tmp = x / (z - y)
else if (y <= 2.5d+152) then
tmp = y / (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 <= -3e-19) {
tmp = t_0;
} else if (y <= 5.6e-99) {
tmp = x / (z - y);
} else if (y <= 2.5e+152) {
tmp = y / (y - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -3e-19: tmp = t_0 elif y <= 5.6e-99: tmp = x / (z - y) elif y <= 2.5e+152: tmp = y / (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 <= -3e-19) tmp = t_0; elseif (y <= 5.6e-99) tmp = Float64(x / Float64(z - y)); elseif (y <= 2.5e+152) tmp = Float64(y / 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 <= -3e-19) tmp = t_0; elseif (y <= 5.6e-99) tmp = x / (z - y); elseif (y <= 2.5e+152) tmp = y / (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, -3e-19], t$95$0, If[LessEqual[y, 5.6e-99], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e+152], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -3 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{-99}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+152}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.99999999999999993e-19 or 2.5e152 < y Initial program 100.0%
Taylor expanded in z around 0 87.8%
div-sub87.8%
sub-neg87.8%
*-inverses87.8%
metadata-eval87.8%
distribute-lft-in87.8%
metadata-eval87.8%
+-commutative87.8%
mul-1-neg87.8%
unsub-neg87.8%
Simplified87.8%
if -2.99999999999999993e-19 < y < 5.6000000000000001e-99Initial program 100.0%
Taylor expanded in x around inf 87.0%
if 5.6000000000000001e-99 < y < 2.5e152Initial program 100.0%
Taylor expanded in x around 0 70.2%
neg-mul-170.2%
distribute-neg-frac70.2%
Simplified70.2%
frac-2neg70.2%
div-inv69.9%
remove-double-neg69.9%
sub-neg69.9%
distribute-neg-in69.9%
remove-double-neg69.9%
Applied egg-rr69.9%
associate-*r/70.2%
*-rgt-identity70.2%
+-commutative70.2%
unsub-neg70.2%
Simplified70.2%
Final simplification83.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -2.35e-23)
t_0
(if (<= y 1.22e-51)
(/ (- x y) z)
(if (<= y 2.4e+152) (/ y (- y z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -2.35e-23) {
tmp = t_0;
} else if (y <= 1.22e-51) {
tmp = (x - y) / z;
} else if (y <= 2.4e+152) {
tmp = y / (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 <= (-2.35d-23)) then
tmp = t_0
else if (y <= 1.22d-51) then
tmp = (x - y) / z
else if (y <= 2.4d+152) then
tmp = y / (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 <= -2.35e-23) {
tmp = t_0;
} else if (y <= 1.22e-51) {
tmp = (x - y) / z;
} else if (y <= 2.4e+152) {
tmp = y / (y - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -2.35e-23: tmp = t_0 elif y <= 1.22e-51: tmp = (x - y) / z elif y <= 2.4e+152: tmp = y / (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 <= -2.35e-23) tmp = t_0; elseif (y <= 1.22e-51) tmp = Float64(Float64(x - y) / z); elseif (y <= 2.4e+152) tmp = Float64(y / 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 <= -2.35e-23) tmp = t_0; elseif (y <= 1.22e-51) tmp = (x - y) / z; elseif (y <= 2.4e+152) tmp = y / (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, -2.35e-23], t$95$0, If[LessEqual[y, 1.22e-51], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 2.4e+152], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -2.35 \cdot 10^{-23}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.22 \cdot 10^{-51}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+152}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.35e-23 or 2.3999999999999999e152 < y Initial program 100.0%
Taylor expanded in z around 0 87.9%
div-sub87.9%
sub-neg87.9%
*-inverses87.9%
metadata-eval87.9%
distribute-lft-in87.9%
metadata-eval87.9%
+-commutative87.9%
mul-1-neg87.9%
unsub-neg87.9%
Simplified87.9%
if -2.35e-23 < y < 1.21999999999999998e-51Initial program 100.0%
Taylor expanded in z around inf 87.5%
if 1.21999999999999998e-51 < y < 2.3999999999999999e152Initial program 100.0%
Taylor expanded in x around 0 71.2%
neg-mul-171.2%
distribute-neg-frac71.2%
Simplified71.2%
frac-2neg71.2%
div-inv70.9%
remove-double-neg70.9%
sub-neg70.9%
distribute-neg-in70.9%
remove-double-neg70.9%
Applied egg-rr70.9%
associate-*r/71.2%
*-rgt-identity71.2%
+-commutative71.2%
unsub-neg71.2%
Simplified71.2%
Final simplification84.2%
(FPCore (x y z) :precision binary64 (if (<= y -3.95e-22) 1.0 (if (<= y 2.1e-51) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.95e-22) {
tmp = 1.0;
} else if (y <= 2.1e-51) {
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.95d-22)) then
tmp = 1.0d0
else if (y <= 2.1d-51) 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.95e-22) {
tmp = 1.0;
} else if (y <= 2.1e-51) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.95e-22: tmp = 1.0 elif y <= 2.1e-51: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.95e-22) tmp = 1.0; elseif (y <= 2.1e-51) 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.95e-22) tmp = 1.0; elseif (y <= 2.1e-51) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.95e-22], 1.0, If[LessEqual[y, 2.1e-51], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.95 \cdot 10^{-22}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-51}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.9499999999999999e-22 or 2.10000000000000002e-51 < y Initial program 100.0%
Taylor expanded in y around inf 56.3%
if -3.9499999999999999e-22 < y < 2.10000000000000002e-51Initial program 100.0%
Taylor expanded in y around 0 77.3%
Final simplification65.4%
(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.6%
Final simplification35.6%
(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 2024078
(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)))