
(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 8 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
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ (- x y) z)))
(if (<= y -7.5e-22)
t_0
(if (<= y 9.8e-214)
t_1
(if (<= y 1.25e-99)
(/ x (- z y))
(if (<= y 17500000000.0)
t_1
(if (<= y 5.8e+156) t_0 (/ y (- y z)))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double t_1 = (x - y) / z;
double tmp;
if (y <= -7.5e-22) {
tmp = t_0;
} else if (y <= 9.8e-214) {
tmp = t_1;
} else if (y <= 1.25e-99) {
tmp = x / (z - y);
} else if (y <= 17500000000.0) {
tmp = t_1;
} else if (y <= 5.8e+156) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
t_1 = (x - y) / z
if (y <= (-7.5d-22)) then
tmp = t_0
else if (y <= 9.8d-214) then
tmp = t_1
else if (y <= 1.25d-99) then
tmp = x / (z - y)
else if (y <= 17500000000.0d0) then
tmp = t_1
else if (y <= 5.8d+156) then
tmp = t_0
else
tmp = y / (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 t_1 = (x - y) / z;
double tmp;
if (y <= -7.5e-22) {
tmp = t_0;
} else if (y <= 9.8e-214) {
tmp = t_1;
} else if (y <= 1.25e-99) {
tmp = x / (z - y);
} else if (y <= 17500000000.0) {
tmp = t_1;
} else if (y <= 5.8e+156) {
tmp = t_0;
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) t_1 = (x - y) / z tmp = 0 if y <= -7.5e-22: tmp = t_0 elif y <= 9.8e-214: tmp = t_1 elif y <= 1.25e-99: tmp = x / (z - y) elif y <= 17500000000.0: tmp = t_1 elif y <= 5.8e+156: tmp = t_0 else: tmp = y / (y - z) return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) t_1 = Float64(Float64(x - y) / z) tmp = 0.0 if (y <= -7.5e-22) tmp = t_0; elseif (y <= 9.8e-214) tmp = t_1; elseif (y <= 1.25e-99) tmp = Float64(x / Float64(z - y)); elseif (y <= 17500000000.0) tmp = t_1; elseif (y <= 5.8e+156) tmp = t_0; else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); t_1 = (x - y) / z; tmp = 0.0; if (y <= -7.5e-22) tmp = t_0; elseif (y <= 9.8e-214) tmp = t_1; elseif (y <= 1.25e-99) tmp = x / (z - y); elseif (y <= 17500000000.0) tmp = t_1; elseif (y <= 5.8e+156) tmp = t_0; else tmp = y / (y - z); 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[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -7.5e-22], t$95$0, If[LessEqual[y, 9.8e-214], t$95$1, If[LessEqual[y, 1.25e-99], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 17500000000.0], t$95$1, If[LessEqual[y, 5.8e+156], t$95$0, N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{x - y}{z}\\
\mathbf{if}\;y \leq -7.5 \cdot 10^{-22}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{-214}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-99}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 17500000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+156}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -7.49999999999999978e-22 or 1.75e10 < y < 5.80000000000000021e156Initial 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 -7.49999999999999978e-22 < y < 9.79999999999999935e-214 or 1.24999999999999992e-99 < y < 1.75e10Initial program 99.9%
Taylor expanded in z around inf 82.6%
if 9.79999999999999935e-214 < y < 1.24999999999999992e-99Initial program 100.0%
Taylor expanded in x around inf 96.7%
if 5.80000000000000021e156 < y Initial program 100.0%
Taylor expanded in x around 0 89.2%
neg-mul-189.2%
distribute-neg-frac89.2%
Simplified89.2%
Final simplification85.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -4.6e-25)
t_0
(if (<= y 2.15e-141)
(/ x z)
(if (<= y 8e-105) (/ (- x) y) (if (<= y 2.05e-25) (/ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -4.6e-25) {
tmp = t_0;
} else if (y <= 2.15e-141) {
tmp = x / z;
} else if (y <= 8e-105) {
tmp = -x / y;
} else if (y <= 2.05e-25) {
tmp = x / 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.6d-25)) then
tmp = t_0
else if (y <= 2.15d-141) then
tmp = x / z
else if (y <= 8d-105) then
tmp = -x / y
else if (y <= 2.05d-25) then
tmp = x / 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.6e-25) {
tmp = t_0;
} else if (y <= 2.15e-141) {
tmp = x / z;
} else if (y <= 8e-105) {
tmp = -x / y;
} else if (y <= 2.05e-25) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -4.6e-25: tmp = t_0 elif y <= 2.15e-141: tmp = x / z elif y <= 8e-105: tmp = -x / y elif y <= 2.05e-25: tmp = x / 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.6e-25) tmp = t_0; elseif (y <= 2.15e-141) tmp = Float64(x / z); elseif (y <= 8e-105) tmp = Float64(Float64(-x) / y); elseif (y <= 2.05e-25) tmp = Float64(x / 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.6e-25) tmp = t_0; elseif (y <= 2.15e-141) tmp = x / z; elseif (y <= 8e-105) tmp = -x / y; elseif (y <= 2.05e-25) tmp = x / 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.6e-25], t$95$0, If[LessEqual[y, 2.15e-141], N[(x / z), $MachinePrecision], If[LessEqual[y, 8e-105], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 2.05e-25], N[(x / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{-25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{-141}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-105}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{-25}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.5999999999999998e-25 or 2.04999999999999994e-25 < y Initial program 100.0%
Taylor expanded in z around 0 80.5%
div-sub80.5%
sub-neg80.5%
*-inverses80.5%
metadata-eval80.5%
distribute-lft-in80.5%
metadata-eval80.5%
+-commutative80.5%
mul-1-neg80.5%
unsub-neg80.5%
Simplified80.5%
if -4.5999999999999998e-25 < y < 2.14999999999999987e-141 or 7.99999999999999972e-105 < y < 2.04999999999999994e-25Initial program 100.0%
Taylor expanded in y around 0 67.8%
if 2.14999999999999987e-141 < y < 7.99999999999999972e-105Initial program 100.0%
Taylor expanded in x around inf 92.9%
Taylor expanded in z around 0 71.4%
mul-1-neg71.4%
distribute-frac-neg271.4%
Simplified71.4%
Final simplification74.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ (- x y) z)))
(if (<= y -1.45e-22)
t_0
(if (<= y 5.5e-214)
t_1
(if (<= y 2.9e-100) (/ x (- z y)) (if (<= y 98000000.0) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double t_1 = (x - y) / z;
double tmp;
if (y <= -1.45e-22) {
tmp = t_0;
} else if (y <= 5.5e-214) {
tmp = t_1;
} else if (y <= 2.9e-100) {
tmp = x / (z - y);
} else if (y <= 98000000.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 - y) / z
if (y <= (-1.45d-22)) then
tmp = t_0
else if (y <= 5.5d-214) then
tmp = t_1
else if (y <= 2.9d-100) then
tmp = x / (z - y)
else if (y <= 98000000.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 - y) / z;
double tmp;
if (y <= -1.45e-22) {
tmp = t_0;
} else if (y <= 5.5e-214) {
tmp = t_1;
} else if (y <= 2.9e-100) {
tmp = x / (z - y);
} else if (y <= 98000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) t_1 = (x - y) / z tmp = 0 if y <= -1.45e-22: tmp = t_0 elif y <= 5.5e-214: tmp = t_1 elif y <= 2.9e-100: tmp = x / (z - y) elif y <= 98000000.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(Float64(x - y) / z) tmp = 0.0 if (y <= -1.45e-22) tmp = t_0; elseif (y <= 5.5e-214) tmp = t_1; elseif (y <= 2.9e-100) tmp = Float64(x / Float64(z - y)); elseif (y <= 98000000.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 - y) / z; tmp = 0.0; if (y <= -1.45e-22) tmp = t_0; elseif (y <= 5.5e-214) tmp = t_1; elseif (y <= 2.9e-100) tmp = x / (z - y); elseif (y <= 98000000.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[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -1.45e-22], t$95$0, If[LessEqual[y, 5.5e-214], t$95$1, If[LessEqual[y, 2.9e-100], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 98000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{x - y}{z}\\
\mathbf{if}\;y \leq -1.45 \cdot 10^{-22}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-214}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-100}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 98000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.4500000000000001e-22 or 9.8e7 < 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.4500000000000001e-22 < y < 5.50000000000000024e-214 or 2.89999999999999975e-100 < y < 9.8e7Initial program 99.9%
Taylor expanded in z around inf 82.6%
if 5.50000000000000024e-214 < y < 2.89999999999999975e-100Initial program 100.0%
Taylor expanded in x around inf 96.7%
Final simplification84.3%
(FPCore (x y z)
:precision binary64
(if (<= y -4.6e-9)
1.0
(if (<= y 2.15e-141)
(/ x z)
(if (<= y 1.7e-104) (/ (- x) y) (if (<= y 3.7e-25) (/ x z) 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.6e-9) {
tmp = 1.0;
} else if (y <= 2.15e-141) {
tmp = x / z;
} else if (y <= 1.7e-104) {
tmp = -x / y;
} else if (y <= 3.7e-25) {
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 <= (-4.6d-9)) then
tmp = 1.0d0
else if (y <= 2.15d-141) then
tmp = x / z
else if (y <= 1.7d-104) then
tmp = -x / y
else if (y <= 3.7d-25) 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 <= -4.6e-9) {
tmp = 1.0;
} else if (y <= 2.15e-141) {
tmp = x / z;
} else if (y <= 1.7e-104) {
tmp = -x / y;
} else if (y <= 3.7e-25) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.6e-9: tmp = 1.0 elif y <= 2.15e-141: tmp = x / z elif y <= 1.7e-104: tmp = -x / y elif y <= 3.7e-25: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.6e-9) tmp = 1.0; elseif (y <= 2.15e-141) tmp = Float64(x / z); elseif (y <= 1.7e-104) tmp = Float64(Float64(-x) / y); elseif (y <= 3.7e-25) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.6e-9) tmp = 1.0; elseif (y <= 2.15e-141) tmp = x / z; elseif (y <= 1.7e-104) tmp = -x / y; elseif (y <= 3.7e-25) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.6e-9], 1.0, If[LessEqual[y, 2.15e-141], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.7e-104], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 3.7e-25], N[(x / z), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{-9}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{-141}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-104}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{-25}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.5999999999999998e-9 or 3.70000000000000009e-25 < y Initial program 100.0%
Taylor expanded in y around inf 64.0%
if -4.5999999999999998e-9 < y < 2.14999999999999987e-141 or 1.70000000000000008e-104 < y < 3.70000000000000009e-25Initial program 100.0%
Taylor expanded in y around 0 66.4%
if 2.14999999999999987e-141 < y < 1.70000000000000008e-104Initial program 100.0%
Taylor expanded in x around inf 92.9%
Taylor expanded in z around 0 71.4%
mul-1-neg71.4%
distribute-frac-neg271.4%
Simplified71.4%
Final simplification65.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.5e+20) (not (<= y 3.7e-25))) (- 1.0 (/ x y)) (/ x (- z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.5e+20) || !(y <= 3.7e-25)) {
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 <= (-3.5d+20)) .or. (.not. (y <= 3.7d-25))) 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 <= -3.5e+20) || !(y <= 3.7e-25)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (z - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.5e+20) or not (y <= 3.7e-25): tmp = 1.0 - (x / y) else: tmp = x / (z - y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.5e+20) || !(y <= 3.7e-25)) 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 <= -3.5e+20) || ~((y <= 3.7e-25))) tmp = 1.0 - (x / y); else tmp = x / (z - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.5e+20], N[Not[LessEqual[y, 3.7e-25]], $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 -3.5 \cdot 10^{+20} \lor \neg \left(y \leq 3.7 \cdot 10^{-25}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y}\\
\end{array}
\end{array}
if y < -3.5e20 or 3.70000000000000009e-25 < y Initial program 100.0%
Taylor expanded in z around 0 80.8%
div-sub80.8%
sub-neg80.8%
*-inverses80.8%
metadata-eval80.8%
distribute-lft-in80.8%
metadata-eval80.8%
+-commutative80.8%
mul-1-neg80.8%
unsub-neg80.8%
Simplified80.8%
if -3.5e20 < y < 3.70000000000000009e-25Initial program 100.0%
Taylor expanded in x around inf 79.7%
Final simplification80.2%
(FPCore (x y z) :precision binary64 (if (<= y -4.8e-9) 1.0 (if (<= y 4.2e-25) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.8e-9) {
tmp = 1.0;
} else if (y <= 4.2e-25) {
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 <= (-4.8d-9)) then
tmp = 1.0d0
else if (y <= 4.2d-25) 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 <= -4.8e-9) {
tmp = 1.0;
} else if (y <= 4.2e-25) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.8e-9: tmp = 1.0 elif y <= 4.2e-25: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.8e-9) tmp = 1.0; elseif (y <= 4.2e-25) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.8e-9) tmp = 1.0; elseif (y <= 4.2e-25) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.8e-9], 1.0, If[LessEqual[y, 4.2e-25], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{-9}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{-25}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.8e-9 or 4.20000000000000005e-25 < y Initial program 100.0%
Taylor expanded in y around inf 64.0%
if -4.8e-9 < y < 4.20000000000000005e-25Initial program 100.0%
Taylor expanded in y around 0 63.0%
Final simplification63.5%
(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 37.1%
Final simplification37.1%
(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 2024039
(FPCore (x y z)
:name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
:precision binary64
:herbie-target
(- (/ x (- z y)) (/ y (- z y)))
(/ (- x y) (- z y)))