
(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
(let* ((t_0 (* y (- 1.0 (/ x z)))))
(if (<= y -2e-63)
(+ (/ x z) t_0)
(if (<= y 5e+16) (/ (fma y (- z x) x) z) t_0))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - (x / z));
double tmp;
if (y <= -2e-63) {
tmp = (x / z) + t_0;
} else if (y <= 5e+16) {
tmp = fma(y, (z - x), x) / z;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - Float64(x / z))) tmp = 0.0 if (y <= -2e-63) tmp = Float64(Float64(x / z) + t_0); elseif (y <= 5e+16) tmp = Float64(fma(y, Float64(z - x), x) / z); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2e-63], N[(N[(x / z), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[y, 5e+16], N[(N[(y * N[(z - x), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{if}\;y \leq -2 \cdot 10^{-63}:\\
\;\;\;\;\frac{x}{z} + t\_0\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+16}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, z - x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.00000000000000013e-63Initial program 79.1%
Taylor expanded in y around 0 99.9%
if -2.00000000000000013e-63 < y < 5e16Initial program 100.0%
+-commutative100.0%
fma-define100.0%
Simplified100.0%
if 5e16 < y Initial program 76.1%
Taylor expanded in y around inf 76.1%
associate-/l*100.0%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (/ x z))))
(if (<= y -1.36e+133)
t_0
(if (<= y -1.08e+73)
(* y (/ x (- z)))
(if (<= y 1.65e-5) t_0 (- y (/ x z)))))))
double code(double x, double y, double z) {
double t_0 = y + (x / z);
double tmp;
if (y <= -1.36e+133) {
tmp = t_0;
} else if (y <= -1.08e+73) {
tmp = y * (x / -z);
} else if (y <= 1.65e-5) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y + (x / z)
if (y <= (-1.36d+133)) then
tmp = t_0
else if (y <= (-1.08d+73)) then
tmp = y * (x / -z)
else if (y <= 1.65d-5) then
tmp = t_0
else
tmp = y - (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y + (x / z);
double tmp;
if (y <= -1.36e+133) {
tmp = t_0;
} else if (y <= -1.08e+73) {
tmp = y * (x / -z);
} else if (y <= 1.65e-5) {
tmp = t_0;
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = y + (x / z) tmp = 0 if y <= -1.36e+133: tmp = t_0 elif y <= -1.08e+73: tmp = y * (x / -z) elif y <= 1.65e-5: tmp = t_0 else: tmp = y - (x / z) return tmp
function code(x, y, z) t_0 = Float64(y + Float64(x / z)) tmp = 0.0 if (y <= -1.36e+133) tmp = t_0; elseif (y <= -1.08e+73) tmp = Float64(y * Float64(x / Float64(-z))); elseif (y <= 1.65e-5) tmp = t_0; else tmp = Float64(y - Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y + (x / z); tmp = 0.0; if (y <= -1.36e+133) tmp = t_0; elseif (y <= -1.08e+73) tmp = y * (x / -z); elseif (y <= 1.65e-5) tmp = t_0; else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.36e+133], t$95$0, If[LessEqual[y, -1.08e+73], N[(y * N[(x / (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.65e-5], t$95$0, N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
\mathbf{if}\;y \leq -1.36 \cdot 10^{+133}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.08 \cdot 10^{+73}:\\
\;\;\;\;y \cdot \frac{x}{-z}\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < -1.3600000000000001e133 or -1.08e73 < y < 1.6500000000000001e-5Initial program 89.9%
Taylor expanded in y around 0 96.3%
Taylor expanded in x around 0 88.7%
Taylor expanded in y around 0 88.7%
+-commutative88.7%
Simplified88.7%
if -1.3600000000000001e133 < y < -1.08e73Initial program 87.2%
Taylor expanded in y around inf 87.2%
Taylor expanded in z around 0 59.7%
mul-1-neg59.7%
distribute-lft-neg-out59.7%
*-commutative59.7%
Simplified59.7%
frac-2neg59.7%
distribute-frac-neg259.7%
distribute-rgt-neg-out59.7%
remove-double-neg59.7%
associate-*r/72.3%
Applied egg-rr72.3%
if 1.6500000000000001e-5 < y Initial program 77.7%
Taylor expanded in y around 0 85.5%
Taylor expanded in x around 0 52.3%
*-rgt-identity52.3%
add-sqr-sqrt19.9%
sqrt-unprod67.9%
sqr-neg67.9%
sqrt-unprod44.7%
add-sqr-sqrt67.7%
distribute-frac-neg67.7%
sub-neg67.7%
add-sqr-sqrt40.2%
cancel-sign-sub-inv40.2%
Applied egg-rr40.2%
distribute-lft-neg-out40.2%
rem-square-sqrt67.7%
sub-neg67.7%
Simplified67.7%
Final simplification81.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.8e+42) (not (<= y 1e+14))) (* y (- 1.0 (/ x z))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.8e+42) || !(y <= 1e+14)) {
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 <= (-4.8d+42)) .or. (.not. (y <= 1d+14))) 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 <= -4.8e+42) || !(y <= 1e+14)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.8e+42) or not (y <= 1e+14): 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 <= -4.8e+42) || !(y <= 1e+14)) 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 <= -4.8e+42) || ~((y <= 1e+14))) 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, -4.8e+42], N[Not[LessEqual[y, 1e+14]], $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 -4.8 \cdot 10^{+42} \lor \neg \left(y \leq 10^{+14}\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 < -4.7999999999999997e42 or 1e14 < y Initial program 73.3%
Taylor expanded in y around inf 73.3%
associate-/l*99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
if -4.7999999999999997e42 < y < 1e14Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (/ x z)))))
(if (<= y -1e-63)
(+ (/ x z) t_0)
(if (<= y 3200000000000.0) (/ (+ x (* y (- z x))) z) t_0))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - (x / z));
double tmp;
if (y <= -1e-63) {
tmp = (x / z) + t_0;
} else if (y <= 3200000000000.0) {
tmp = (x + (y * (z - 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 = y * (1.0d0 - (x / z))
if (y <= (-1d-63)) then
tmp = (x / z) + t_0
else if (y <= 3200000000000.0d0) then
tmp = (x + (y * (z - 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 = y * (1.0 - (x / z));
double tmp;
if (y <= -1e-63) {
tmp = (x / z) + t_0;
} else if (y <= 3200000000000.0) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - (x / z)) tmp = 0 if y <= -1e-63: tmp = (x / z) + t_0 elif y <= 3200000000000.0: tmp = (x + (y * (z - x))) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - Float64(x / z))) tmp = 0.0 if (y <= -1e-63) tmp = Float64(Float64(x / z) + t_0); elseif (y <= 3200000000000.0) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - (x / z)); tmp = 0.0; if (y <= -1e-63) tmp = (x / z) + t_0; elseif (y <= 3200000000000.0) tmp = (x + (y * (z - x))) / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1e-63], N[(N[(x / z), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[y, 3200000000000.0], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{if}\;y \leq -1 \cdot 10^{-63}:\\
\;\;\;\;\frac{x}{z} + t\_0\\
\mathbf{elif}\;y \leq 3200000000000:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.00000000000000007e-63Initial program 79.1%
Taylor expanded in y around 0 99.9%
if -1.00000000000000007e-63 < y < 3.2e12Initial program 100.0%
if 3.2e12 < y Initial program 76.1%
Taylor expanded in y around inf 76.1%
associate-/l*100.0%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -32.0) (not (<= y 1.65e-5))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -32.0) || !(y <= 1.65e-5)) {
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 <= (-32.0d0)) .or. (.not. (y <= 1.65d-5))) 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 <= -32.0) || !(y <= 1.65e-5)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -32.0) or not (y <= 1.65e-5): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -32.0) || !(y <= 1.65e-5)) 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 <= -32.0) || ~((y <= 1.65e-5))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -32.0], N[Not[LessEqual[y, 1.65e-5]], $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 -32 \lor \neg \left(y \leq 1.65 \cdot 10^{-5}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -32 or 1.6500000000000001e-5 < y Initial program 75.0%
Taylor expanded in y around inf 74.4%
associate-/l*99.4%
div-sub99.4%
*-inverses99.4%
Simplified99.4%
if -32 < y < 1.6500000000000001e-5Initial program 99.9%
Taylor expanded in y around 0 94.7%
Taylor expanded in x around 0 99.0%
Taylor expanded in y around 0 99.0%
+-commutative99.0%
Simplified99.0%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -3600000000.0) (not (<= x 4.3e+124))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3600000000.0) || !(x <= 4.3e+124)) {
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 <= (-3600000000.0d0)) .or. (.not. (x <= 4.3d+124))) 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 <= -3600000000.0) || !(x <= 4.3e+124)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3600000000.0) or not (x <= 4.3e+124): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3600000000.0) || !(x <= 4.3e+124)) 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 <= -3600000000.0) || ~((x <= 4.3e+124))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3600000000.0], N[Not[LessEqual[x, 4.3e+124]], $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 -3600000000 \lor \neg \left(x \leq 4.3 \cdot 10^{+124}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -3.6e9 or 4.3e124 < x Initial program 85.7%
Taylor expanded in x around inf 78.3%
associate-/l*84.1%
mul-1-neg84.1%
unsub-neg84.1%
Simplified84.1%
if -3.6e9 < x < 4.3e124Initial program 86.3%
Taylor expanded in y around 0 99.3%
Taylor expanded in x around 0 84.5%
Taylor expanded in y around 0 84.5%
+-commutative84.5%
Simplified84.5%
Final simplification84.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.4e-33) (not (<= y 2.9e-32))) y (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e-33) || !(y <= 2.9e-32)) {
tmp = 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.4d-33)) .or. (.not. (y <= 2.9d-32))) then
tmp = 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.4e-33) || !(y <= 2.9e-32)) {
tmp = y;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e-33) or not (y <= 2.9e-32): tmp = y else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e-33) || !(y <= 2.9e-32)) tmp = y; else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.4e-33) || ~((y <= 2.9e-32))) tmp = y; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e-33], N[Not[LessEqual[y, 2.9e-32]], $MachinePrecision]], y, N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{-33} \lor \neg \left(y \leq 2.9 \cdot 10^{-32}\right):\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -3.4000000000000001e-33 or 2.89999999999999996e-32 < y Initial program 77.5%
Taylor expanded in x around 0 53.3%
if -3.4000000000000001e-33 < y < 2.89999999999999996e-32Initial program 100.0%
Taylor expanded in y around 0 74.1%
Final simplification61.3%
(FPCore (x y z) :precision binary64 (if (<= y 1.65e-5) (+ y (/ x z)) (- y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.65e-5) {
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.65d-5) 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.65e-5) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.65e-5: tmp = y + (x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.65e-5) tmp = Float64(y + 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.65e-5) tmp = y + (x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.65e-5], 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.65 \cdot 10^{-5}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < 1.6500000000000001e-5Initial program 89.6%
Taylor expanded in y around 0 96.6%
Taylor expanded in x around 0 83.7%
Taylor expanded in y around 0 83.7%
+-commutative83.7%
Simplified83.7%
if 1.6500000000000001e-5 < y Initial program 77.7%
Taylor expanded in y around 0 85.5%
Taylor expanded in x around 0 52.3%
*-rgt-identity52.3%
add-sqr-sqrt19.9%
sqrt-unprod67.9%
sqr-neg67.9%
sqrt-unprod44.7%
add-sqr-sqrt67.7%
distribute-frac-neg67.7%
sub-neg67.7%
add-sqr-sqrt40.2%
cancel-sign-sub-inv40.2%
Applied egg-rr40.2%
distribute-lft-neg-out40.2%
rem-square-sqrt67.7%
sub-neg67.7%
Simplified67.7%
Final simplification78.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 86.1%
Taylor expanded in y around 0 93.3%
Taylor expanded in x around 0 74.4%
Taylor expanded in y around 0 74.4%
+-commutative74.4%
Simplified74.4%
Final simplification74.4%
(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 86.1%
Taylor expanded in x around 0 43.5%
(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 2024096
(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))