
(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 (- y (* (/ x z) (+ y -1.0))))
double code(double x, double y, double z) {
return y - ((x / z) * (y + -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 = y - ((x / z) * (y + (-1.0d0)))
end function
public static double code(double x, double y, double z) {
return y - ((x / z) * (y + -1.0));
}
def code(x, y, z): return y - ((x / z) * (y + -1.0))
function code(x, y, z) return Float64(y - Float64(Float64(x / z) * Float64(y + -1.0))) end
function tmp = code(x, y, z) tmp = y - ((x / z) * (y + -1.0)); end
code[x_, y_, z_] := N[(y - N[(N[(x / z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y - \frac{x}{z} \cdot \left(y + -1\right)
\end{array}
Initial program 90.4%
Taylor expanded in x around -inf 98.8%
mul-1-neg98.8%
unsub-neg98.8%
associate-/l*95.2%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ (- y) z))))
(if (<= y -1.04e+270)
t_0
(if (<= y 6.4e+22)
(+ y (/ x z))
(if (or (<= y 3.8e+119) (not (<= y 3.8e+248))) t_0 (/ z (/ z y)))))))
double code(double x, double y, double z) {
double t_0 = x * (-y / z);
double tmp;
if (y <= -1.04e+270) {
tmp = t_0;
} else if (y <= 6.4e+22) {
tmp = y + (x / z);
} else if ((y <= 3.8e+119) || !(y <= 3.8e+248)) {
tmp = t_0;
} else {
tmp = z / (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) :: t_0
real(8) :: tmp
t_0 = x * (-y / z)
if (y <= (-1.04d+270)) then
tmp = t_0
else if (y <= 6.4d+22) then
tmp = y + (x / z)
else if ((y <= 3.8d+119) .or. (.not. (y <= 3.8d+248))) then
tmp = t_0
else
tmp = z / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (-y / z);
double tmp;
if (y <= -1.04e+270) {
tmp = t_0;
} else if (y <= 6.4e+22) {
tmp = y + (x / z);
} else if ((y <= 3.8e+119) || !(y <= 3.8e+248)) {
tmp = t_0;
} else {
tmp = z / (z / y);
}
return tmp;
}
def code(x, y, z): t_0 = x * (-y / z) tmp = 0 if y <= -1.04e+270: tmp = t_0 elif y <= 6.4e+22: tmp = y + (x / z) elif (y <= 3.8e+119) or not (y <= 3.8e+248): tmp = t_0 else: tmp = z / (z / y) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(Float64(-y) / z)) tmp = 0.0 if (y <= -1.04e+270) tmp = t_0; elseif (y <= 6.4e+22) tmp = Float64(y + Float64(x / z)); elseif ((y <= 3.8e+119) || !(y <= 3.8e+248)) tmp = t_0; else tmp = Float64(z / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (-y / z); tmp = 0.0; if (y <= -1.04e+270) tmp = t_0; elseif (y <= 6.4e+22) tmp = y + (x / z); elseif ((y <= 3.8e+119) || ~((y <= 3.8e+248))) tmp = t_0; else tmp = z / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.04e+270], t$95$0, If[LessEqual[y, 6.4e+22], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 3.8e+119], N[Not[LessEqual[y, 3.8e+248]], $MachinePrecision]], t$95$0, N[(z / N[(z / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{-y}{z}\\
\mathbf{if}\;y \leq -1.04 \cdot 10^{+270}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 6.4 \cdot 10^{+22}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+119} \lor \neg \left(y \leq 3.8 \cdot 10^{+248}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -1.04e270 or 6.4e22 < y < 3.7999999999999999e119 or 3.8000000000000001e248 < y Initial program 82.0%
Taylor expanded in y around inf 82.0%
associate-/l*99.9%
associate-/r/93.1%
Simplified93.1%
Taylor expanded in z around 0 71.7%
mul-1-neg71.7%
associate-*r/71.7%
distribute-rgt-neg-in71.7%
distribute-neg-frac71.7%
Simplified71.7%
if -1.04e270 < y < 6.4e22Initial program 95.0%
Taylor expanded in x around -inf 99.4%
mul-1-neg99.4%
unsub-neg99.4%
associate-/l*96.6%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 89.3%
mul-1-neg89.3%
distribute-neg-frac89.3%
Simplified89.3%
Taylor expanded in y around 0 89.3%
+-commutative89.3%
Simplified89.3%
if 3.7999999999999999e119 < y < 3.8000000000000001e248Initial program 65.3%
Taylor expanded in y around inf 65.3%
Taylor expanded in z around inf 39.0%
associate-/l*73.6%
associate-/r/77.7%
Applied egg-rr77.7%
*-commutative77.7%
clear-num77.5%
un-div-inv77.8%
Applied egg-rr77.8%
Final simplification85.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (/ (- z) x))))
(if (<= y -4e+268)
t_0
(if (<= y 2.4e+22)
(+ y (/ x z))
(if (or (<= y 1.6e+113) (not (<= y 1.35e+258))) t_0 (/ z (/ z y)))))))
double code(double x, double y, double z) {
double t_0 = y / (-z / x);
double tmp;
if (y <= -4e+268) {
tmp = t_0;
} else if (y <= 2.4e+22) {
tmp = y + (x / z);
} else if ((y <= 1.6e+113) || !(y <= 1.35e+258)) {
tmp = t_0;
} else {
tmp = z / (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) :: t_0
real(8) :: tmp
t_0 = y / (-z / x)
if (y <= (-4d+268)) then
tmp = t_0
else if (y <= 2.4d+22) then
tmp = y + (x / z)
else if ((y <= 1.6d+113) .or. (.not. (y <= 1.35d+258))) then
tmp = t_0
else
tmp = z / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (-z / x);
double tmp;
if (y <= -4e+268) {
tmp = t_0;
} else if (y <= 2.4e+22) {
tmp = y + (x / z);
} else if ((y <= 1.6e+113) || !(y <= 1.35e+258)) {
tmp = t_0;
} else {
tmp = z / (z / y);
}
return tmp;
}
def code(x, y, z): t_0 = y / (-z / x) tmp = 0 if y <= -4e+268: tmp = t_0 elif y <= 2.4e+22: tmp = y + (x / z) elif (y <= 1.6e+113) or not (y <= 1.35e+258): tmp = t_0 else: tmp = z / (z / y) return tmp
function code(x, y, z) t_0 = Float64(y / Float64(Float64(-z) / x)) tmp = 0.0 if (y <= -4e+268) tmp = t_0; elseif (y <= 2.4e+22) tmp = Float64(y + Float64(x / z)); elseif ((y <= 1.6e+113) || !(y <= 1.35e+258)) tmp = t_0; else tmp = Float64(z / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (-z / x); tmp = 0.0; if (y <= -4e+268) tmp = t_0; elseif (y <= 2.4e+22) tmp = y + (x / z); elseif ((y <= 1.6e+113) || ~((y <= 1.35e+258))) tmp = t_0; else tmp = z / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[((-z) / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4e+268], t$95$0, If[LessEqual[y, 2.4e+22], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.6e+113], N[Not[LessEqual[y, 1.35e+258]], $MachinePrecision]], t$95$0, N[(z / N[(z / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{\frac{-z}{x}}\\
\mathbf{if}\;y \leq -4 \cdot 10^{+268}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+22}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+113} \lor \neg \left(y \leq 1.35 \cdot 10^{+258}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -3.9999999999999999e268 or 2.4e22 < y < 1.5999999999999999e113 or 1.34999999999999998e258 < y Initial program 82.0%
Taylor expanded in y around inf 82.0%
associate-/l*99.9%
associate-/r/93.1%
Simplified93.1%
Taylor expanded in y around 0 82.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around 0 76.3%
neg-mul-176.3%
distribute-neg-frac76.3%
Simplified76.3%
if -3.9999999999999999e268 < y < 2.4e22Initial program 95.0%
Taylor expanded in x around -inf 99.4%
mul-1-neg99.4%
unsub-neg99.4%
associate-/l*96.6%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 89.3%
mul-1-neg89.3%
distribute-neg-frac89.3%
Simplified89.3%
Taylor expanded in y around 0 89.3%
+-commutative89.3%
Simplified89.3%
if 1.5999999999999999e113 < y < 1.34999999999999998e258Initial program 65.3%
Taylor expanded in y around inf 65.3%
Taylor expanded in z around inf 39.0%
associate-/l*73.6%
associate-/r/77.7%
Applied egg-rr77.7%
*-commutative77.7%
clear-num77.5%
un-div-inv77.8%
Applied egg-rr77.8%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.7e+49) (not (<= x 4.1e+65))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.7e+49) || !(x <= 4.1e+65)) {
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 <= (-5.7d+49)) .or. (.not. (x <= 4.1d+65))) 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 <= -5.7e+49) || !(x <= 4.1e+65)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.7e+49) or not (x <= 4.1e+65): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.7e+49) || !(x <= 4.1e+65)) 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 <= -5.7e+49) || ~((x <= 4.1e+65))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.7e+49], N[Not[LessEqual[x, 4.1e+65]], $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 -5.7 \cdot 10^{+49} \lor \neg \left(x \leq 4.1 \cdot 10^{+65}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -5.6999999999999998e49 or 4.1000000000000001e65 < x Initial program 95.9%
Taylor expanded in x around inf 92.0%
mul-1-neg92.0%
unsub-neg92.0%
Simplified92.0%
Taylor expanded in y around 0 83.4%
mul-1-neg83.4%
associate-*l/77.9%
*-commutative77.9%
distribute-lft-neg-out77.9%
distribute-lft1-in94.0%
+-commutative94.0%
sub-neg94.0%
associate-*r/92.0%
associate-*l/93.8%
*-commutative93.8%
Simplified93.8%
if -5.6999999999999998e49 < x < 4.1000000000000001e65Initial program 87.2%
Taylor expanded in x around -inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
associate-/l*92.5%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 84.8%
mul-1-neg84.8%
distribute-neg-frac84.8%
Simplified84.8%
Taylor expanded in y around 0 84.8%
+-commutative84.8%
Simplified84.8%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.5e-100) (not (<= z 5.8e-146))) (+ y (/ x z)) (* (/ x z) (- 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.5e-100) || !(z <= 5.8e-146)) {
tmp = y + (x / z);
} else {
tmp = (x / z) * (1.0 - 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 ((z <= (-8.5d-100)) .or. (.not. (z <= 5.8d-146))) then
tmp = y + (x / z)
else
tmp = (x / z) * (1.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -8.5e-100) || !(z <= 5.8e-146)) {
tmp = y + (x / z);
} else {
tmp = (x / z) * (1.0 - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.5e-100) or not (z <= 5.8e-146): tmp = y + (x / z) else: tmp = (x / z) * (1.0 - y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.5e-100) || !(z <= 5.8e-146)) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(x / z) * Float64(1.0 - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8.5e-100) || ~((z <= 5.8e-146))) tmp = y + (x / z); else tmp = (x / z) * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.5e-100], N[Not[LessEqual[z, 5.8e-146]], $MachinePrecision]], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-100} \lor \neg \left(z \leq 5.8 \cdot 10^{-146}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -8.50000000000000017e-100 or 5.80000000000000022e-146 < z Initial program 85.7%
Taylor expanded in x around -inf 98.3%
mul-1-neg98.3%
unsub-neg98.3%
associate-/l*100.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 86.2%
mul-1-neg86.2%
distribute-neg-frac86.2%
Simplified86.2%
Taylor expanded in y around 0 86.2%
+-commutative86.2%
Simplified86.2%
if -8.50000000000000017e-100 < z < 5.80000000000000022e-146Initial program 99.9%
Taylor expanded in x around inf 94.4%
associate-/l*84.2%
associate-/r/94.5%
mul-1-neg94.5%
unsub-neg94.5%
Simplified94.5%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.55))) (* (- z x) (/ y z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 0.55)) {
tmp = (z - x) * (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 ((y <= (-1.0d0)) .or. (.not. (y <= 0.55d0))) then
tmp = (z - x) * (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 ((y <= -1.0) || !(y <= 0.55)) {
tmp = (z - x) * (y / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 0.55): tmp = (z - x) * (y / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.55)) tmp = Float64(Float64(z - x) * Float64(y / 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 <= 0.55))) tmp = (z - x) * (y / 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, 0.55]], $MachinePrecision]], N[(N[(z - x), $MachinePrecision] * N[(y / z), $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 0.55\right):\\
\;\;\;\;\left(z - x\right) \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 0.55000000000000004 < y Initial program 80.0%
Taylor expanded in y around inf 79.1%
associate-/l*99.1%
associate-/r/89.2%
Simplified89.2%
if -1 < y < 0.55000000000000004Initial program 99.9%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-/l*100.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
mul-1-neg98.7%
distribute-neg-frac98.7%
Simplified98.7%
Taylor expanded in y around 0 98.7%
+-commutative98.7%
Simplified98.7%
Final simplification94.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.55))) (/ y (/ z (- z x))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 0.55)) {
tmp = y / (z / (z - x));
} 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 <= 0.55d0))) then
tmp = y / (z / (z - x))
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 <= 0.55)) {
tmp = y / (z / (z - x));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 0.55): tmp = y / (z / (z - x)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.55)) tmp = Float64(y / Float64(z / Float64(z - x))); 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 <= 0.55))) tmp = y / (z / (z - x)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.55]], $MachinePrecision]], N[(y / N[(z / N[(z - x), $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 0.55\right):\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 0.55000000000000004 < y Initial program 80.0%
Taylor expanded in y around inf 79.1%
associate-/l*99.1%
associate-/r/89.2%
Simplified89.2%
Taylor expanded in y around 0 79.1%
associate-/l*99.1%
Simplified99.1%
if -1 < y < 0.55000000000000004Initial program 99.9%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-/l*100.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
mul-1-neg98.7%
distribute-neg-frac98.7%
Simplified98.7%
Taylor expanded in y around 0 98.7%
+-commutative98.7%
Simplified98.7%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.9e-6) (not (<= x 1.7e+34))) (/ x z) y))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.9e-6) || !(x <= 1.7e+34)) {
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.9d-6)) .or. (.not. (x <= 1.7d+34))) 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.9e-6) || !(x <= 1.7e+34)) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.9e-6) or not (x <= 1.7e+34): tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.9e-6) || !(x <= 1.7e+34)) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.9e-6) || ~((x <= 1.7e+34))) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.9e-6], N[Not[LessEqual[x, 1.7e+34]], $MachinePrecision]], N[(x / z), $MachinePrecision], y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{-6} \lor \neg \left(x \leq 1.7 \cdot 10^{+34}\right):\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -2.9000000000000002e-6 or 1.7e34 < x Initial program 95.5%
Taylor expanded in y around 0 60.8%
if -2.9000000000000002e-6 < x < 1.7e34Initial program 86.5%
Taylor expanded in x around 0 63.6%
Final simplification62.4%
(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 90.4%
Taylor expanded in x around -inf 98.8%
mul-1-neg98.8%
unsub-neg98.8%
associate-/l*95.2%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 78.3%
mul-1-neg78.3%
distribute-neg-frac78.3%
Simplified78.3%
Taylor expanded in y around 0 78.3%
+-commutative78.3%
Simplified78.3%
Final simplification78.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 90.4%
Taylor expanded in x around 0 41.3%
Final simplification41.3%
(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 2024014
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:herbie-target
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))