
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / 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 + (y * (z - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / 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 + (y * (z - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= y -6.2e+15) (not (<= y 5.8e+15))) (* y (- 1.0 (/ x z))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.2e+15) || !(y <= 5.8e+15)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - 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 <= (-6.2d+15)) .or. (.not. (y <= 5.8d+15))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = (x + (y * (z - x))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.2e+15) || !(y <= 5.8e+15)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.2e+15) or not (y <= 5.8e+15): tmp = y * (1.0 - (x / z)) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.2e+15) || !(y <= 5.8e+15)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.2e+15) || ~((y <= 5.8e+15))) tmp = y * (1.0 - (x / z)); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.2e+15], N[Not[LessEqual[y, 5.8e+15]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+15} \lor \neg \left(y \leq 5.8 \cdot 10^{+15}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if y < -6.2e15 or 5.8e15 < y Initial program 74.7%
Taylor expanded in y around inf 74.7%
associate-/l*99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
sub-neg99.9%
Simplified99.9%
if -6.2e15 < y < 5.8e15Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.5e+15) (not (<= y 7.5e-25))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+15) || !(y <= 7.5e-25)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (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 <= (-5.5d+15)) .or. (.not. (y <= 7.5d-25))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = y + (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+15) || !(y <= 7.5e-25)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.5e+15) or not (y <= 7.5e-25): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.5e+15) || !(y <= 7.5e-25)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.5e+15) || ~((y <= 7.5e-25))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.5e+15], N[Not[LessEqual[y, 7.5e-25]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+15} \lor \neg \left(y \leq 7.5 \cdot 10^{-25}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -5.5e15 or 7.49999999999999989e-25 < y Initial program 75.6%
Taylor expanded in y around inf 75.3%
associate-/l*99.5%
div-sub99.5%
sub-neg99.5%
*-inverses99.5%
sub-neg99.5%
Simplified99.5%
if -5.5e15 < y < 7.49999999999999989e-25Initial program 99.9%
Taylor expanded in z around inf 99.1%
Taylor expanded in x around 0 99.2%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -0.00156) (not (<= x 7.2e+57))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -0.00156) || !(x <= 7.2e+57)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (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 ((x <= (-0.00156d0)) .or. (.not. (x <= 7.2d+57))) then
tmp = x * ((1.0d0 - y) / z)
else
tmp = y + (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -0.00156) || !(x <= 7.2e+57)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -0.00156) or not (x <= 7.2e+57): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -0.00156) || !(x <= 7.2e+57)) tmp = Float64(x * Float64(Float64(1.0 - y) / z)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -0.00156) || ~((x <= 7.2e+57))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -0.00156], N[Not[LessEqual[x, 7.2e+57]], $MachinePrecision]], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00156 \lor \neg \left(x \leq 7.2 \cdot 10^{+57}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -0.00155999999999999997 or 7.2000000000000005e57 < x Initial program 90.2%
Taylor expanded in x around inf 84.5%
associate-/l*88.4%
mul-1-neg88.4%
unsub-neg88.4%
Simplified88.4%
if -0.00155999999999999997 < x < 7.2000000000000005e57Initial program 84.6%
Taylor expanded in z around inf 73.5%
Taylor expanded in x around 0 88.9%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (<= y -5.5e+15) (* y (- 1.0 (/ x z))) (if (<= y 7.5e-25) (+ y (/ x z)) (- y (* y (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e+15) {
tmp = y * (1.0 - (x / z));
} else if (y <= 7.5e-25) {
tmp = y + (x / z);
} else {
tmp = y - (y * (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 <= (-5.5d+15)) then
tmp = y * (1.0d0 - (x / z))
else if (y <= 7.5d-25) then
tmp = y + (x / z)
else
tmp = y - (y * (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e+15) {
tmp = y * (1.0 - (x / z));
} else if (y <= 7.5e-25) {
tmp = y + (x / z);
} else {
tmp = y - (y * (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.5e+15: tmp = y * (1.0 - (x / z)) elif y <= 7.5e-25: tmp = y + (x / z) else: tmp = y - (y * (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.5e+15) tmp = Float64(y * Float64(1.0 - Float64(x / z))); elseif (y <= 7.5e-25) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y - Float64(y * Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.5e+15) tmp = y * (1.0 - (x / z)); elseif (y <= 7.5e-25) tmp = y + (x / z); else tmp = y - (y * (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.5e+15], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e-25], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+15}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-25}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -5.5e15Initial program 77.4%
Taylor expanded in y around inf 77.4%
associate-/l*99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
sub-neg99.9%
Simplified99.9%
if -5.5e15 < y < 7.49999999999999989e-25Initial program 99.9%
Taylor expanded in z around inf 99.1%
Taylor expanded in x around 0 99.2%
if 7.49999999999999989e-25 < y Initial program 73.8%
Taylor expanded in y around inf 73.2%
Taylor expanded in z around inf 95.3%
mul-1-neg95.3%
unsub-neg95.3%
*-commutative95.3%
associate-*r/99.2%
Simplified99.2%
(FPCore (x y z) :precision binary64 (if (<= y -5.5e+233) (* x (/ y (- z))) (if (<= y 7.5e-25) (+ y (/ x z)) (/ (* y x) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e+233) {
tmp = x * (y / -z);
} else if (y <= 7.5e-25) {
tmp = y + (x / z);
} else {
tmp = (y * x) / x;
}
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 <= (-5.5d+233)) then
tmp = x * (y / -z)
else if (y <= 7.5d-25) then
tmp = y + (x / z)
else
tmp = (y * x) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e+233) {
tmp = x * (y / -z);
} else if (y <= 7.5e-25) {
tmp = y + (x / z);
} else {
tmp = (y * x) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.5e+233: tmp = x * (y / -z) elif y <= 7.5e-25: tmp = y + (x / z) else: tmp = (y * x) / x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.5e+233) tmp = Float64(x * Float64(y / Float64(-z))); elseif (y <= 7.5e-25) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(y * x) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.5e+233) tmp = x * (y / -z); elseif (y <= 7.5e-25) tmp = y + (x / z); else tmp = (y * x) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.5e+233], N[(x * N[(y / (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e-25], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+233}:\\
\;\;\;\;x \cdot \frac{y}{-z}\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-25}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{x}\\
\end{array}
\end{array}
if y < -5.50000000000000019e233Initial program 76.9%
Taylor expanded in x around inf 69.2%
associate-/l*69.2%
mul-1-neg69.2%
unsub-neg69.2%
Simplified69.2%
Taylor expanded in y around inf 69.2%
mul-1-neg69.2%
associate-/l*69.2%
distribute-lft-neg-in69.2%
Simplified69.2%
if -5.50000000000000019e233 < y < 7.49999999999999989e-25Initial program 93.3%
Taylor expanded in z around inf 82.7%
Taylor expanded in x around 0 87.7%
if 7.49999999999999989e-25 < y Initial program 73.8%
Taylor expanded in x around inf 66.9%
associate-+r+66.9%
+-commutative66.9%
mul-1-neg66.9%
unsub-neg66.9%
div-sub66.9%
Simplified66.9%
Taylor expanded in z around inf 32.4%
*-commutative32.4%
associate-*l/64.9%
Applied egg-rr64.9%
Final simplification80.5%
(FPCore (x y z) :precision binary64 (if (<= y -6.5e+76) (* z (/ y z)) (if (<= y 1.95e-29) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e+76) {
tmp = z * (y / z);
} else if (y <= 1.95e-29) {
tmp = x / z;
} else {
tmp = 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 <= (-6.5d+76)) then
tmp = z * (y / z)
else if (y <= 1.95d-29) then
tmp = x / z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e+76) {
tmp = z * (y / z);
} else if (y <= 1.95e-29) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.5e+76: tmp = z * (y / z) elif y <= 1.95e-29: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.5e+76) tmp = Float64(z * Float64(y / z)); elseif (y <= 1.95e-29) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.5e+76) tmp = z * (y / z); elseif (y <= 1.95e-29) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.5e+76], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.95e-29], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+76}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-29}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -6.5000000000000005e76Initial program 73.5%
Taylor expanded in x around inf 75.0%
associate-+r+75.0%
+-commutative75.0%
mul-1-neg75.0%
unsub-neg75.0%
div-sub75.0%
Simplified75.0%
Taylor expanded in z around inf 28.5%
*-commutative28.5%
frac-2neg28.5%
associate-*l/53.1%
add-sqr-sqrt23.3%
sqrt-unprod14.3%
sqr-neg14.3%
sqrt-unprod6.3%
add-sqr-sqrt14.0%
Applied egg-rr14.0%
associate-/l*2.6%
*-inverses2.6%
*-rgt-identity2.6%
Simplified2.6%
add-sqr-sqrt2.6%
sqrt-unprod15.5%
sqr-neg15.5%
sqrt-unprod0.0%
add-sqr-sqrt50.0%
*-un-lft-identity50.0%
*-commutative50.0%
*-inverses50.0%
associate-/l*31.9%
*-commutative31.9%
associate-/l*50.0%
Applied egg-rr50.0%
if -6.5000000000000005e76 < y < 1.9499999999999999e-29Initial program 99.9%
Taylor expanded in y around 0 71.6%
if 1.9499999999999999e-29 < y Initial program 73.8%
Taylor expanded in x around 0 56.9%
(FPCore (x y z) :precision binary64 (if (<= y -6.5e+76) y (if (<= y 3.4e-26) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e+76) {
tmp = y;
} else if (y <= 3.4e-26) {
tmp = x / z;
} else {
tmp = 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 <= (-6.5d+76)) then
tmp = y
else if (y <= 3.4d-26) then
tmp = x / z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e+76) {
tmp = y;
} else if (y <= 3.4e-26) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.5e+76: tmp = y elif y <= 3.4e-26: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.5e+76) tmp = y; elseif (y <= 3.4e-26) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.5e+76) tmp = y; elseif (y <= 3.4e-26) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.5e+76], y, If[LessEqual[y, 3.4e-26], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+76}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-26}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -6.5000000000000005e76 or 3.40000000000000013e-26 < y Initial program 73.7%
Taylor expanded in x around 0 53.7%
if -6.5000000000000005e76 < y < 3.40000000000000013e-26Initial program 99.9%
Taylor expanded in y around 0 71.6%
(FPCore (x y z) :precision binary64 (if (<= y 7.5e-25) (+ y (/ x z)) (/ (* y x) x)))
double code(double x, double y, double z) {
double tmp;
if (y <= 7.5e-25) {
tmp = y + (x / z);
} else {
tmp = (y * x) / x;
}
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-25) then
tmp = y + (x / z)
else
tmp = (y * x) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 7.5e-25) {
tmp = y + (x / z);
} else {
tmp = (y * x) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7.5e-25: tmp = y + (x / z) else: tmp = (y * x) / x return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7.5e-25) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(y * x) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 7.5e-25) tmp = y + (x / z); else tmp = (y * x) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7.5e-25], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.5 \cdot 10^{-25}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{x}\\
\end{array}
\end{array}
if y < 7.49999999999999989e-25Initial program 91.9%
Taylor expanded in z around inf 78.1%
Taylor expanded in x around 0 83.6%
if 7.49999999999999989e-25 < y Initial program 73.8%
Taylor expanded in x around inf 66.9%
associate-+r+66.9%
+-commutative66.9%
mul-1-neg66.9%
unsub-neg66.9%
div-sub66.9%
Simplified66.9%
Taylor expanded in z around inf 32.4%
*-commutative32.4%
associate-*l/64.9%
Applied egg-rr64.9%
(FPCore (x y z) :precision binary64 (+ y (/ x z)))
double code(double x, double y, double z) {
return y + (x / 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 / z)
end function
public static double code(double x, double y, double z) {
return y + (x / z);
}
def code(x, y, z): return y + (x / z)
function code(x, y, z) return Float64(y + Float64(x / z)) end
function tmp = code(x, y, z) tmp = y + (x / z); end
code[x_, y_, z_] := N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \frac{x}{z}
\end{array}
Initial program 87.1%
Taylor expanded in z around inf 66.4%
Taylor expanded in x around 0 76.3%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 87.1%
Taylor expanded in x around 0 39.9%
(FPCore (x y z) :precision binary64 (- (+ y (/ x z)) (/ y (/ z x))))
double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
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 / z)) - (y / (z / x))
end function
public static double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
def code(x, y, z): return (y + (x / z)) - (y / (z / x))
function code(x, y, z) return Float64(Float64(y + Float64(x / z)) - Float64(y / Float64(z / x))) end
function tmp = code(x, y, z) tmp = (y + (x / z)) - (y / (z / x)); end
code[x_, y_, z_] := N[(N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}
\end{array}
herbie shell --seed 2024130
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:alt
(! :herbie-platform default (- (+ y (/ x z)) (/ y (/ z x))))
(/ (+ x (* y (- z x))) z))