
(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 (<= z -1e-15) (not (<= z 2e-6))) (+ (/ x z) (* y (- 1.0 (/ x z)))) (/ (fma y (- z x) x) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-15) || !(z <= 2e-6)) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else {
tmp = fma(y, (z - x), x) / z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -1e-15) || !(z <= 2e-6)) tmp = Float64(Float64(x / z) + Float64(y * Float64(1.0 - Float64(x / z)))); else tmp = Float64(fma(y, Float64(z - x), x) / z); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-15], N[Not[LessEqual[z, 2e-6]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(z - x), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-15} \lor \neg \left(z \leq 2 \cdot 10^{-6}\right):\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, z - x, x\right)}{z}\\
\end{array}
\end{array}
if z < -1.0000000000000001e-15 or 1.99999999999999991e-6 < z Initial program 79.5%
Taylor expanded in y around 0 99.9%
if -1.0000000000000001e-15 < z < 1.99999999999999991e-6Initial program 99.9%
+-commutative99.9%
fma-define100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= y -1.05e+204)
(/ (* y x) x)
(if (or (<= y -8.8e+135) (not (<= y 1.11e+167)))
(* y (/ (- x) z))
(+ y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.05e+204) {
tmp = (y * x) / x;
} else if ((y <= -8.8e+135) || !(y <= 1.11e+167)) {
tmp = y * (-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 <= (-1.05d+204)) then
tmp = (y * x) / x
else if ((y <= (-8.8d+135)) .or. (.not. (y <= 1.11d+167))) then
tmp = y * (-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 <= -1.05e+204) {
tmp = (y * x) / x;
} else if ((y <= -8.8e+135) || !(y <= 1.11e+167)) {
tmp = y * (-x / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.05e+204: tmp = (y * x) / x elif (y <= -8.8e+135) or not (y <= 1.11e+167): tmp = y * (-x / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.05e+204) tmp = Float64(Float64(y * x) / x); elseif ((y <= -8.8e+135) || !(y <= 1.11e+167)) tmp = Float64(y * Float64(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 <= -1.05e+204) tmp = (y * x) / x; elseif ((y <= -8.8e+135) || ~((y <= 1.11e+167))) tmp = y * (-x / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.05e+204], N[(N[(y * x), $MachinePrecision] / x), $MachinePrecision], If[Or[LessEqual[y, -8.8e+135], N[Not[LessEqual[y, 1.11e+167]], $MachinePrecision]], N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+204}:\\
\;\;\;\;\frac{y \cdot x}{x}\\
\mathbf{elif}\;y \leq -8.8 \cdot 10^{+135} \lor \neg \left(y \leq 1.11 \cdot 10^{+167}\right):\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1.05e204Initial program 76.6%
Taylor expanded in x around inf 58.1%
associate-+r+58.1%
+-commutative58.1%
mul-1-neg58.1%
unsub-neg58.1%
div-sub58.1%
Simplified58.1%
Taylor expanded in z around inf 30.1%
*-commutative30.1%
associate-*l/71.3%
Applied egg-rr71.3%
if -1.05e204 < y < -8.7999999999999998e135 or 1.11e167 < y Initial program 76.9%
Taylor expanded in x around inf 65.7%
associate-/l*62.5%
mul-1-neg62.5%
unsub-neg62.5%
Simplified62.5%
Taylor expanded in y around inf 62.5%
neg-mul-162.5%
distribute-neg-frac262.5%
Simplified62.5%
associate-*r/65.7%
distribute-frac-neg265.7%
*-commutative65.7%
associate-*r/74.9%
Applied egg-rr74.9%
if -8.7999999999999998e135 < y < 1.11e167Initial program 93.9%
Taylor expanded in y around 0 94.2%
Taylor expanded in x around 0 87.2%
Final simplification83.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -5e-14) (not (<= z 6.5e-77))) (+ (/ x z) (* y (- 1.0 (/ x z)))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5e-14) || !(z <= 6.5e-77)) {
tmp = (x / z) + (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 ((z <= (-5d-14)) .or. (.not. (z <= 6.5d-77))) then
tmp = (x / z) + (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 ((z <= -5e-14) || !(z <= 6.5e-77)) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5e-14) or not (z <= 6.5e-77): tmp = (x / z) + (y * (1.0 - (x / z))) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5e-14) || !(z <= 6.5e-77)) tmp = Float64(Float64(x / z) + 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 ((z <= -5e-14) || ~((z <= 6.5e-77))) tmp = (x / z) + (y * (1.0 - (x / z))); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5e-14], N[Not[LessEqual[z, 6.5e-77]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-14} \lor \neg \left(z \leq 6.5 \cdot 10^{-77}\right):\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if z < -5.0000000000000002e-14 or 6.4999999999999999e-77 < z Initial program 82.2%
Taylor expanded in y around 0 99.9%
if -5.0000000000000002e-14 < z < 6.4999999999999999e-77Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= y -1.15e+21)
(* y (/ (- z x) z))
(if (<= y 2000000000000.0)
(/ (+ x (* y (- z x))) z)
(* y (- 1.0 (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+21) {
tmp = y * ((z - x) / z);
} else if (y <= 2000000000000.0) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y * (1.0 - (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 <= (-1.15d+21)) then
tmp = y * ((z - x) / z)
else if (y <= 2000000000000.0d0) then
tmp = (x + (y * (z - x))) / z
else
tmp = y * (1.0d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+21) {
tmp = y * ((z - x) / z);
} else if (y <= 2000000000000.0) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.15e+21: tmp = y * ((z - x) / z) elif y <= 2000000000000.0: tmp = (x + (y * (z - x))) / z else: tmp = y * (1.0 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.15e+21) tmp = Float64(y * Float64(Float64(z - x) / z)); elseif (y <= 2000000000000.0) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); else tmp = Float64(y * Float64(1.0 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.15e+21) tmp = y * ((z - x) / z); elseif (y <= 2000000000000.0) tmp = (x + (y * (z - x))) / z; else tmp = y * (1.0 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.15e+21], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2000000000000.0], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+21}:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\mathbf{elif}\;y \leq 2000000000000:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1.15e21Initial program 82.4%
Taylor expanded in y around inf 82.4%
associate-/l*99.9%
*-commutative99.9%
Applied egg-rr99.9%
if -1.15e21 < y < 2e12Initial program 99.9%
if 2e12 < y Initial program 74.8%
Taylor expanded in y around inf 74.8%
associate-/l*99.8%
div-sub99.8%
*-inverses99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -3e-56) (not (<= x 3e+76))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3e-56) || !(x <= 3e+76)) {
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 <= (-3d-56)) .or. (.not. (x <= 3d+76))) 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 <= -3e-56) || !(x <= 3e+76)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3e-56) or not (x <= 3e+76): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3e-56) || !(x <= 3e+76)) 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 <= -3e-56) || ~((x <= 3e+76))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3e-56], N[Not[LessEqual[x, 3e+76]], $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 -3 \cdot 10^{-56} \lor \neg \left(x \leq 3 \cdot 10^{+76}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -2.99999999999999989e-56 or 2.9999999999999998e76 < x Initial program 87.6%
Taylor expanded in x around inf 83.4%
associate-/l*89.1%
mul-1-neg89.1%
unsub-neg89.1%
Simplified89.1%
if -2.99999999999999989e-56 < x < 2.9999999999999998e76Initial program 91.4%
Taylor expanded in y around 0 99.9%
Taylor expanded in x around 0 81.4%
Final simplification85.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
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 <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) 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 <= -1.0) || !(y <= 1.0)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) 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 <= -1.0) || ~((y <= 1.0))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $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 -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 79.5%
Taylor expanded in y around inf 78.6%
associate-/l*98.9%
div-sub98.9%
*-inverses98.9%
Simplified98.9%
if -1 < y < 1Initial program 99.9%
Taylor expanded in y around 0 92.1%
Taylor expanded in x around 0 98.3%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (<= y -1.0) (* y (/ (- z x) z)) (if (<= y 1.0) (+ y (/ x z)) (* y (- 1.0 (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = y * ((z - x) / z);
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y * (1.0 - (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 <= (-1.0d0)) then
tmp = y * ((z - x) / z)
else if (y <= 1.0d0) then
tmp = y + (x / z)
else
tmp = y * (1.0d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = y * ((z - x) / z);
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.0: tmp = y * ((z - x) / z) elif y <= 1.0: tmp = y + (x / z) else: tmp = y * (1.0 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.0) tmp = Float64(y * Float64(Float64(z - x) / z)); elseif (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y * Float64(1.0 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.0) tmp = y * ((z - x) / z); elseif (y <= 1.0) tmp = y + (x / z); else tmp = y * (1.0 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.0], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1Initial program 83.6%
Taylor expanded in y around inf 81.9%
associate-/l*98.1%
*-commutative98.1%
Applied egg-rr98.1%
if -1 < y < 1Initial program 99.9%
Taylor expanded in y around 0 92.1%
Taylor expanded in x around 0 98.3%
if 1 < y Initial program 74.8%
Taylor expanded in y around inf 74.8%
associate-/l*99.8%
div-sub99.8%
*-inverses99.8%
Simplified99.8%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.1e-50) (not (<= x 7.5e+76))) (/ x z) y))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.1e-50) || !(x <= 7.5e+76)) {
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 ((x <= (-2.1d-50)) .or. (.not. (x <= 7.5d+76))) 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 ((x <= -2.1e-50) || !(x <= 7.5e+76)) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.1e-50) or not (x <= 7.5e+76): tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.1e-50) || !(x <= 7.5e+76)) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.1e-50) || ~((x <= 7.5e+76))) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.1e-50], N[Not[LessEqual[x, 7.5e+76]], $MachinePrecision]], N[(x / z), $MachinePrecision], y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-50} \lor \neg \left(x \leq 7.5 \cdot 10^{+76}\right):\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -2.1000000000000001e-50 or 7.4999999999999995e76 < x Initial program 87.4%
Taylor expanded in y around 0 62.7%
if -2.1000000000000001e-50 < x < 7.4999999999999995e76Initial program 91.6%
Taylor expanded in x around 0 59.0%
Final simplification60.8%
(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 89.6%
Taylor expanded in y around 0 95.2%
Taylor expanded in x around 0 76.2%
Final simplification76.2%
(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 89.6%
Taylor expanded in x around 0 36.6%
Final simplification36.6%
(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 2024055
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:alt
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))