
(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 11 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 (+ 1.0 (/ z y))))
(if (<= y -2.6e+56)
t_0
(if (<= y -1.42e-130)
(/ x z)
(if (<= y -4.5e-165)
(/ x (- y))
(if (<= y 2.4e-8) (/ x z) (if (<= y 1.48e+141) (/ (- y) z) t_0)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z / y);
double tmp;
if (y <= -2.6e+56) {
tmp = t_0;
} else if (y <= -1.42e-130) {
tmp = x / z;
} else if (y <= -4.5e-165) {
tmp = x / -y;
} else if (y <= 2.4e-8) {
tmp = x / z;
} else if (y <= 1.48e+141) {
tmp = -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 + (z / y)
if (y <= (-2.6d+56)) then
tmp = t_0
else if (y <= (-1.42d-130)) then
tmp = x / z
else if (y <= (-4.5d-165)) then
tmp = x / -y
else if (y <= 2.4d-8) then
tmp = x / z
else if (y <= 1.48d+141) then
tmp = -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 + (z / y);
double tmp;
if (y <= -2.6e+56) {
tmp = t_0;
} else if (y <= -1.42e-130) {
tmp = x / z;
} else if (y <= -4.5e-165) {
tmp = x / -y;
} else if (y <= 2.4e-8) {
tmp = x / z;
} else if (y <= 1.48e+141) {
tmp = -y / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z / y) tmp = 0 if y <= -2.6e+56: tmp = t_0 elif y <= -1.42e-130: tmp = x / z elif y <= -4.5e-165: tmp = x / -y elif y <= 2.4e-8: tmp = x / z elif y <= 1.48e+141: tmp = -y / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z / y)) tmp = 0.0 if (y <= -2.6e+56) tmp = t_0; elseif (y <= -1.42e-130) tmp = Float64(x / z); elseif (y <= -4.5e-165) tmp = Float64(x / Float64(-y)); elseif (y <= 2.4e-8) tmp = Float64(x / z); elseif (y <= 1.48e+141) tmp = Float64(Float64(-y) / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z / y); tmp = 0.0; if (y <= -2.6e+56) tmp = t_0; elseif (y <= -1.42e-130) tmp = x / z; elseif (y <= -4.5e-165) tmp = x / -y; elseif (y <= 2.4e-8) tmp = x / z; elseif (y <= 1.48e+141) tmp = -y / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.6e+56], t$95$0, If[LessEqual[y, -1.42e-130], N[(x / z), $MachinePrecision], If[LessEqual[y, -4.5e-165], N[(x / (-y)), $MachinePrecision], If[LessEqual[y, 2.4e-8], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.48e+141], N[((-y) / z), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z}{y}\\
\mathbf{if}\;y \leq -2.6 \cdot 10^{+56}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.42 \cdot 10^{-130}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{-165}:\\
\;\;\;\;\frac{x}{-y}\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.48 \cdot 10^{+141}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.60000000000000011e56 or 1.48000000000000001e141 < y Initial program 99.9%
Taylor expanded in x around 0 82.3%
neg-mul-182.3%
distribute-neg-frac82.3%
Simplified82.3%
Taylor expanded in y around inf 74.7%
if -2.60000000000000011e56 < y < -1.4199999999999999e-130 or -4.49999999999999992e-165 < y < 2.39999999999999998e-8Initial program 99.9%
Taylor expanded in y around 0 61.6%
if -1.4199999999999999e-130 < y < -4.49999999999999992e-165Initial program 100.0%
Taylor expanded in x around inf 79.5%
Taylor expanded in z around 0 79.1%
mul-1-neg79.1%
distribute-frac-neg79.1%
Simplified79.1%
if 2.39999999999999998e-8 < y < 1.48000000000000001e141Initial program 100.0%
Taylor expanded in z around inf 68.0%
Taylor expanded in x around 0 45.8%
neg-mul-145.8%
distribute-neg-frac245.8%
Simplified45.8%
Final simplification65.7%
(FPCore (x y z)
:precision binary64
(if (<= y -8e+54)
1.0
(if (<= y -2.1e-130)
(/ x z)
(if (<= y -4.5e-165)
(/ x (- y))
(if (<= y 1.8e-7) (/ x z) (if (<= y 2.8e+142) (/ (- y) z) 1.0))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8e+54) {
tmp = 1.0;
} else if (y <= -2.1e-130) {
tmp = x / z;
} else if (y <= -4.5e-165) {
tmp = x / -y;
} else if (y <= 1.8e-7) {
tmp = x / z;
} else if (y <= 2.8e+142) {
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 <= (-8d+54)) then
tmp = 1.0d0
else if (y <= (-2.1d-130)) then
tmp = x / z
else if (y <= (-4.5d-165)) then
tmp = x / -y
else if (y <= 1.8d-7) then
tmp = x / z
else if (y <= 2.8d+142) 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 <= -8e+54) {
tmp = 1.0;
} else if (y <= -2.1e-130) {
tmp = x / z;
} else if (y <= -4.5e-165) {
tmp = x / -y;
} else if (y <= 1.8e-7) {
tmp = x / z;
} else if (y <= 2.8e+142) {
tmp = -y / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8e+54: tmp = 1.0 elif y <= -2.1e-130: tmp = x / z elif y <= -4.5e-165: tmp = x / -y elif y <= 1.8e-7: tmp = x / z elif y <= 2.8e+142: tmp = -y / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8e+54) tmp = 1.0; elseif (y <= -2.1e-130) tmp = Float64(x / z); elseif (y <= -4.5e-165) tmp = Float64(x / Float64(-y)); elseif (y <= 1.8e-7) tmp = Float64(x / z); elseif (y <= 2.8e+142) tmp = Float64(Float64(-y) / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8e+54) tmp = 1.0; elseif (y <= -2.1e-130) tmp = x / z; elseif (y <= -4.5e-165) tmp = x / -y; elseif (y <= 1.8e-7) tmp = x / z; elseif (y <= 2.8e+142) tmp = -y / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8e+54], 1.0, If[LessEqual[y, -2.1e-130], N[(x / z), $MachinePrecision], If[LessEqual[y, -4.5e-165], N[(x / (-y)), $MachinePrecision], If[LessEqual[y, 1.8e-7], N[(x / z), $MachinePrecision], If[LessEqual[y, 2.8e+142], N[((-y) / z), $MachinePrecision], 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{+54}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{-130}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{-165}:\\
\;\;\;\;\frac{x}{-y}\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+142}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -8.0000000000000006e54 or 2.8e142 < y Initial program 99.9%
Taylor expanded in y around inf 73.5%
if -8.0000000000000006e54 < y < -2.10000000000000002e-130 or -4.49999999999999992e-165 < y < 1.79999999999999997e-7Initial program 99.9%
Taylor expanded in y around 0 62.2%
if -2.10000000000000002e-130 < y < -4.49999999999999992e-165Initial program 100.0%
Taylor expanded in x around inf 79.5%
Taylor expanded in z around 0 79.1%
mul-1-neg79.1%
distribute-frac-neg79.1%
Simplified79.1%
if 1.79999999999999997e-7 < y < 2.8e142Initial program 100.0%
Taylor expanded in z around inf 68.0%
Taylor expanded in x around 0 45.8%
neg-mul-145.8%
distribute-neg-frac245.8%
Simplified45.8%
Final simplification65.5%
(FPCore (x y z)
:precision binary64
(if (or (<= y -3.05e+43)
(not
(or (<= y -4.8e-63) (and (not (<= y -4.5e-165)) (<= y 8.5e-36)))))
(- 1.0 (/ x y))
(/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.05e+43) || !((y <= -4.8e-63) || (!(y <= -4.5e-165) && (y <= 8.5e-36)))) {
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 <= (-3.05d+43)) .or. (.not. (y <= (-4.8d-63)) .or. (.not. (y <= (-4.5d-165))) .and. (y <= 8.5d-36))) 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 <= -3.05e+43) || !((y <= -4.8e-63) || (!(y <= -4.5e-165) && (y <= 8.5e-36)))) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.05e+43) or not ((y <= -4.8e-63) or (not (y <= -4.5e-165) and (y <= 8.5e-36))): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.05e+43) || !((y <= -4.8e-63) || (!(y <= -4.5e-165) && (y <= 8.5e-36)))) 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 <= -3.05e+43) || ~(((y <= -4.8e-63) || (~((y <= -4.5e-165)) && (y <= 8.5e-36))))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.05e+43], N[Not[Or[LessEqual[y, -4.8e-63], And[N[Not[LessEqual[y, -4.5e-165]], $MachinePrecision], LessEqual[y, 8.5e-36]]]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.05 \cdot 10^{+43} \lor \neg \left(y \leq -4.8 \cdot 10^{-63} \lor \neg \left(y \leq -4.5 \cdot 10^{-165}\right) \land y \leq 8.5 \cdot 10^{-36}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -3.0499999999999999e43 or -4.8000000000000001e-63 < y < -4.49999999999999992e-165 or 8.5000000000000007e-36 < y Initial program 100.0%
Taylor expanded in z around 0 76.2%
div-sub76.2%
sub-neg76.2%
*-inverses76.2%
metadata-eval76.2%
distribute-lft-in76.2%
metadata-eval76.2%
+-commutative76.2%
mul-1-neg76.2%
unsub-neg76.2%
Simplified76.2%
if -3.0499999999999999e43 < y < -4.8000000000000001e-63 or -4.49999999999999992e-165 < y < 8.5000000000000007e-36Initial program 99.9%
Taylor expanded in y around 0 67.7%
Final simplification73.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -3.2e+43)
t_0
(if (<= y 4400.0)
(/ x (- z y))
(if (<= y 1.42e+141) (/ (- x y) z) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -3.2e+43) {
tmp = t_0;
} else if (y <= 4400.0) {
tmp = x / (z - y);
} else if (y <= 1.42e+141) {
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 <= (-3.2d+43)) then
tmp = t_0
else if (y <= 4400.0d0) then
tmp = x / (z - y)
else if (y <= 1.42d+141) 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 <= -3.2e+43) {
tmp = t_0;
} else if (y <= 4400.0) {
tmp = x / (z - y);
} else if (y <= 1.42e+141) {
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 <= -3.2e+43: tmp = t_0 elif y <= 4400.0: tmp = x / (z - y) elif y <= 1.42e+141: 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 <= -3.2e+43) tmp = t_0; elseif (y <= 4400.0) tmp = Float64(x / Float64(z - y)); elseif (y <= 1.42e+141) 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 <= -3.2e+43) tmp = t_0; elseif (y <= 4400.0) tmp = x / (z - y); elseif (y <= 1.42e+141) 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, -3.2e+43], t$95$0, If[LessEqual[y, 4400.0], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.42e+141], 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 -3.2 \cdot 10^{+43}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4400:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 1.42 \cdot 10^{+141}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.20000000000000014e43 or 1.42000000000000005e141 < y Initial program 99.9%
Taylor expanded in z around 0 90.0%
div-sub90.0%
sub-neg90.0%
*-inverses90.0%
metadata-eval90.0%
distribute-lft-in90.0%
metadata-eval90.0%
+-commutative90.0%
mul-1-neg90.0%
unsub-neg90.0%
Simplified90.0%
if -3.20000000000000014e43 < y < 4400Initial program 99.9%
Taylor expanded in x around inf 77.7%
if 4400 < y < 1.42000000000000005e141Initial program 100.0%
Taylor expanded in z around inf 71.6%
Final simplification82.2%
(FPCore (x y z) :precision binary64 (if (<= y -2.1e+55) 1.0 (if (<= y 1.2e-7) (/ x z) (if (<= y 5.8e+143) (/ (- y) z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e+55) {
tmp = 1.0;
} else if (y <= 1.2e-7) {
tmp = x / z;
} else if (y <= 5.8e+143) {
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 <= (-2.1d+55)) then
tmp = 1.0d0
else if (y <= 1.2d-7) then
tmp = x / z
else if (y <= 5.8d+143) 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 <= -2.1e+55) {
tmp = 1.0;
} else if (y <= 1.2e-7) {
tmp = x / z;
} else if (y <= 5.8e+143) {
tmp = -y / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.1e+55: tmp = 1.0 elif y <= 1.2e-7: tmp = x / z elif y <= 5.8e+143: tmp = -y / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.1e+55) tmp = 1.0; elseif (y <= 1.2e-7) tmp = Float64(x / z); elseif (y <= 5.8e+143) tmp = Float64(Float64(-y) / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.1e+55) tmp = 1.0; elseif (y <= 1.2e-7) tmp = x / z; elseif (y <= 5.8e+143) tmp = -y / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.1e+55], 1.0, If[LessEqual[y, 1.2e-7], N[(x / z), $MachinePrecision], If[LessEqual[y, 5.8e+143], N[((-y) / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+55}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+143}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.1000000000000001e55 or 5.7999999999999996e143 < y Initial program 99.9%
Taylor expanded in y around inf 73.5%
if -2.1000000000000001e55 < y < 1.19999999999999989e-7Initial program 99.9%
Taylor expanded in y around 0 57.8%
if 1.19999999999999989e-7 < y < 5.7999999999999996e143Initial program 100.0%
Taylor expanded in z around inf 68.0%
Taylor expanded in x around 0 45.8%
neg-mul-145.8%
distribute-neg-frac245.8%
Simplified45.8%
Final simplification62.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.65e+44) (not (<= y 6e+67))) (- 1.0 (/ x y)) (/ x (- z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.65e+44) || !(y <= 6e+67)) {
tmp = 1.0 - (x / y);
} 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) :: tmp
if ((y <= (-1.65d+44)) .or. (.not. (y <= 6d+67))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / (z - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.65e+44) || !(y <= 6e+67)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (z - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.65e+44) or not (y <= 6e+67): tmp = 1.0 - (x / y) else: tmp = x / (z - y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.65e+44) || !(y <= 6e+67)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / Float64(z - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.65e+44) || ~((y <= 6e+67))) tmp = 1.0 - (x / y); else tmp = x / (z - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.65e+44], N[Not[LessEqual[y, 6e+67]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+44} \lor \neg \left(y \leq 6 \cdot 10^{+67}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y}\\
\end{array}
\end{array}
if y < -1.65000000000000007e44 or 6.0000000000000002e67 < y Initial program 100.0%
Taylor expanded in z around 0 83.0%
div-sub83.0%
sub-neg83.0%
*-inverses83.0%
metadata-eval83.0%
distribute-lft-in83.0%
metadata-eval83.0%
+-commutative83.0%
mul-1-neg83.0%
unsub-neg83.0%
Simplified83.0%
if -1.65000000000000007e44 < y < 6.0000000000000002e67Initial program 99.9%
Taylor expanded in x around inf 75.8%
Final simplification79.3%
(FPCore (x y z) :precision binary64 (if (<= y -2.3e+44) (- 1.0 (/ x y)) (if (<= y 6.6e+43) (/ x (- z y)) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.3e+44) {
tmp = 1.0 - (x / y);
} else if (y <= 6.6e+43) {
tmp = x / (z - y);
} else {
tmp = y / (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 (y <= (-2.3d+44)) then
tmp = 1.0d0 - (x / y)
else if (y <= 6.6d+43) then
tmp = x / (z - y)
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.3e+44) {
tmp = 1.0 - (x / y);
} else if (y <= 6.6e+43) {
tmp = x / (z - y);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.3e+44: tmp = 1.0 - (x / y) elif y <= 6.6e+43: tmp = x / (z - y) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.3e+44) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 6.6e+43) tmp = Float64(x / Float64(z - y)); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.3e+44) tmp = 1.0 - (x / y); elseif (y <= 6.6e+43) tmp = x / (z - y); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.3e+44], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.6e+43], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{+44}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{+43}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -2.30000000000000004e44Initial program 99.9%
Taylor expanded in z around 0 92.2%
div-sub92.3%
sub-neg92.3%
*-inverses92.3%
metadata-eval92.3%
distribute-lft-in92.3%
metadata-eval92.3%
+-commutative92.3%
mul-1-neg92.3%
unsub-neg92.3%
Simplified92.3%
if -2.30000000000000004e44 < y < 6.6000000000000003e43Initial program 99.9%
Taylor expanded in x around inf 76.7%
if 6.6000000000000003e43 < y Initial program 100.0%
Taylor expanded in x around 0 82.7%
neg-mul-182.7%
distribute-neg-frac82.7%
Simplified82.7%
Final simplification82.0%
(FPCore (x y z) :precision binary64 (if (<= y -7.5e+54) 1.0 (if (<= y 1.55e+67) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.5e+54) {
tmp = 1.0;
} else if (y <= 1.55e+67) {
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 <= (-7.5d+54)) then
tmp = 1.0d0
else if (y <= 1.55d+67) 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 <= -7.5e+54) {
tmp = 1.0;
} else if (y <= 1.55e+67) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.5e+54: tmp = 1.0 elif y <= 1.55e+67: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.5e+54) tmp = 1.0; elseif (y <= 1.55e+67) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.5e+54) tmp = 1.0; elseif (y <= 1.55e+67) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.5e+54], 1.0, If[LessEqual[y, 1.55e+67], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+54}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+67}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -7.50000000000000042e54 or 1.54999999999999998e67 < y Initial program 99.9%
Taylor expanded in y around inf 67.1%
if -7.50000000000000042e54 < y < 1.54999999999999998e67Initial program 99.9%
Taylor expanded in y around 0 55.3%
Final simplification61.0%
(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 38.9%
Final simplification38.9%
(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 2024096
(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)))