
(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 4e-188)
(+ (/ x z) t_0)
(if (<= y 200000.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 <= 4e-188) {
tmp = (x / z) + t_0;
} else if (y <= 200000.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 <= 4d-188) then
tmp = (x / z) + t_0
else if (y <= 200000.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 <= 4e-188) {
tmp = (x / z) + t_0;
} else if (y <= 200000.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 <= 4e-188: tmp = (x / z) + t_0 elif y <= 200000.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 <= 4e-188) tmp = Float64(Float64(x / z) + t_0); elseif (y <= 200000.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 <= 4e-188) tmp = (x / z) + t_0; elseif (y <= 200000.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, 4e-188], N[(N[(x / z), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[y, 200000.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 4 \cdot 10^{-188}:\\
\;\;\;\;\frac{x}{z} + t_0\\
\mathbf{elif}\;y \leq 200000:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < 3.9999999999999998e-188Initial program 89.1%
Taylor expanded in y around 0 100.0%
if 3.9999999999999998e-188 < y < 2e5Initial program 100.0%
if 2e5 < y Initial program 75.7%
Taylor expanded in x around 0 96.9%
Taylor expanded in y around inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.5e+38) (not (<= y 200000.0))) (* y (- 1.0 (/ x z))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.5e+38) || !(y <= 200000.0)) {
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 <= (-3.5d+38)) .or. (.not. (y <= 200000.0d0))) 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 <= -3.5e+38) || !(y <= 200000.0)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.5e+38) or not (y <= 200000.0): 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 <= -3.5e+38) || !(y <= 200000.0)) 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 <= -3.5e+38) || ~((y <= 200000.0))) 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, -3.5e+38], N[Not[LessEqual[y, 200000.0]], $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 -3.5 \cdot 10^{+38} \lor \neg \left(y \leq 200000\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 < -3.50000000000000002e38 or 2e5 < y Initial program 73.3%
Taylor expanded in x around 0 95.9%
Taylor expanded in y around inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if -3.50000000000000002e38 < y < 2e5Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= y 1.0)
(+ y (/ x z))
(if (or (<= y 5.1e+244) (not (<= y 2.3e+283)))
(- y (/ x z))
(* y (/ (- x) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (x / z);
} else if ((y <= 5.1e+244) || !(y <= 2.3e+283)) {
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.0d0) then
tmp = y + (x / z)
else if ((y <= 5.1d+244) .or. (.not. (y <= 2.3d+283))) 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.0) {
tmp = y + (x / z);
} else if ((y <= 5.1e+244) || !(y <= 2.3e+283)) {
tmp = y - (x / z);
} else {
tmp = y * (-x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) elif (y <= 5.1e+244) or not (y <= 2.3e+283): tmp = y - (x / z) else: tmp = y * (-x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.0) tmp = Float64(y + Float64(x / z)); elseif ((y <= 5.1e+244) || !(y <= 2.3e+283)) tmp = Float64(y - Float64(x / z)); else tmp = Float64(y * Float64(Float64(-x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.0) tmp = y + (x / z); elseif ((y <= 5.1e+244) || ~((y <= 2.3e+283))) tmp = y - (x / z); else tmp = y * (-x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 5.1e+244], N[Not[LessEqual[y, 2.3e+283]], $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:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{+244} \lor \neg \left(y \leq 2.3 \cdot 10^{+283}\right):\\
\;\;\;\;y - \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\end{array}
\end{array}
if y < 1Initial program 91.2%
Taylor expanded in x around 0 98.3%
Taylor expanded in y around 0 91.0%
if 1 < y < 5.09999999999999985e244 or 2.3000000000000002e283 < y Initial program 73.7%
Taylor expanded in x around 0 96.7%
Taylor expanded in y around 0 45.2%
frac-2neg45.2%
add-sqr-sqrt26.8%
sqrt-unprod59.1%
sqr-neg59.1%
sqrt-unprod32.2%
add-sqr-sqrt74.4%
distribute-neg-frac74.4%
sub-neg74.4%
Applied egg-rr74.4%
if 5.09999999999999985e244 < y < 2.3000000000000002e283Initial program 100.0%
Taylor expanded in y around inf 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around 0 100.0%
associate-*r/100.0%
neg-mul-1100.0%
Simplified100.0%
frac-2neg100.0%
distribute-frac-neg100.0%
remove-double-neg100.0%
distribute-frac-neg100.0%
un-div-inv100.0%
clear-num100.0%
Applied egg-rr100.0%
Final simplification87.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.5e+27) (not (<= y 1.0))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.5e+27) || !(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 <= (-3.5d+27)) .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 <= -3.5e+27) || !(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 <= -3.5e+27) 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 <= -3.5e+27) || !(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 <= -3.5e+27) || ~((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, -3.5e+27], 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 -3.5 \cdot 10^{+27} \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 < -3.5000000000000002e27 or 1 < y Initial program 73.7%
Taylor expanded in x around 0 96.0%
Taylor expanded in y around inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
Simplified99.9%
if -3.5000000000000002e27 < y < 1Initial program 100.0%
Taylor expanded in x around 0 99.8%
Taylor expanded in y around 0 98.6%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (+ y (* x (- (/ 1.0 z) (/ y z)))))
double code(double x, double y, double z) {
return y + (x * ((1.0 / z) - (y / 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 * ((1.0d0 / z) - (y / z)))
end function
public static double code(double x, double y, double z) {
return y + (x * ((1.0 / z) - (y / z)));
}
def code(x, y, z): return y + (x * ((1.0 / z) - (y / z)))
function code(x, y, z) return Float64(y + Float64(x * Float64(Float64(1.0 / z) - Float64(y / z)))) end
function tmp = code(x, y, z) tmp = y + (x * ((1.0 / z) - (y / z))); end
code[x_, y_, z_] := N[(y + N[(x * N[(N[(1.0 / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + x \cdot \left(\frac{1}{z} - \frac{y}{z}\right)
\end{array}
Initial program 87.2%
Taylor expanded in x around 0 98.0%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.8e+69) (not (<= y 1.5e-15))) (* z (/ y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.8e+69) || !(y <= 1.5e-15)) {
tmp = z * (y / z);
} 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 <= (-4.8d+69)) .or. (.not. (y <= 1.5d-15))) then
tmp = z * (y / z)
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4.8e+69) || !(y <= 1.5e-15)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.8e+69) or not (y <= 1.5e-15): tmp = z * (y / z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.8e+69) || !(y <= 1.5e-15)) tmp = Float64(z * Float64(y / z)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.8e+69) || ~((y <= 1.5e-15))) tmp = z * (y / z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.8e+69], N[Not[LessEqual[y, 1.5e-15]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{+69} \lor \neg \left(y \leq 1.5 \cdot 10^{-15}\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -4.8000000000000003e69 or 1.5e-15 < y Initial program 73.4%
Taylor expanded in x around 0 28.9%
associate-/l*50.5%
associate-/r/55.2%
Applied egg-rr55.2%
if -4.8000000000000003e69 < y < 1.5e-15Initial program 99.2%
Taylor expanded in y around 0 73.7%
Final simplification65.1%
(FPCore (x y z) :precision binary64 (if (<= y 7.2e+20) (+ y (/ x z)) (if (<= y 2.45e+79) (/ (- x) z) (* z (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 7.2e+20) {
tmp = y + (x / z);
} else if (y <= 2.45e+79) {
tmp = -x / z;
} else {
tmp = z * (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) :: tmp
if (y <= 7.2d+20) then
tmp = y + (x / z)
else if (y <= 2.45d+79) then
tmp = -x / z
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 7.2e+20) {
tmp = y + (x / z);
} else if (y <= 2.45e+79) {
tmp = -x / z;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7.2e+20: tmp = y + (x / z) elif y <= 2.45e+79: tmp = -x / z else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7.2e+20) tmp = Float64(y + Float64(x / z)); elseif (y <= 2.45e+79) tmp = Float64(Float64(-x) / z); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 7.2e+20) tmp = y + (x / z); elseif (y <= 2.45e+79) tmp = -x / z; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7.2e+20], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45e+79], N[((-x) / z), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.2 \cdot 10^{+20}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{+79}:\\
\;\;\;\;\frac{-x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 7.2e20Initial program 91.4%
Taylor expanded in x around 0 98.4%
Taylor expanded in y around 0 90.1%
if 7.2e20 < y < 2.4499999999999999e79Initial program 86.2%
Taylor expanded in x around 0 99.8%
Taylor expanded in y around 0 7.5%
frac-2neg7.5%
add-sqr-sqrt0.3%
sqrt-unprod36.7%
sqr-neg36.7%
sqrt-unprod29.7%
add-sqr-sqrt53.3%
distribute-neg-frac53.3%
sub-neg53.3%
Applied egg-rr53.3%
Taylor expanded in y around 0 47.0%
mul-1-neg47.0%
distribute-frac-neg47.0%
Simplified47.0%
if 2.4499999999999999e79 < y Initial program 69.2%
Taylor expanded in x around 0 24.2%
associate-/l*50.5%
associate-/r/59.0%
Applied egg-rr59.0%
Final simplification82.3%
(FPCore (x y z) :precision binary64 (if (<= y -2.05e+68) y (if (<= y 3.3e-15) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.05e+68) {
tmp = y;
} else if (y <= 3.3e-15) {
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 <= (-2.05d+68)) then
tmp = y
else if (y <= 3.3d-15) 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 <= -2.05e+68) {
tmp = y;
} else if (y <= 3.3e-15) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.05e+68: tmp = y elif y <= 3.3e-15: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.05e+68) tmp = y; elseif (y <= 3.3e-15) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.05e+68) tmp = y; elseif (y <= 3.3e-15) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.05e+68], y, If[LessEqual[y, 3.3e-15], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{+68}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -2.05e68 or 3.3e-15 < y Initial program 73.4%
Taylor expanded in x around 0 50.5%
if -2.05e68 < y < 3.3e-15Initial program 99.2%
Taylor expanded in y around 0 73.7%
Final simplification62.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.0) (+ y (/ x z)) (- y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
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.0d0) 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.0) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.0) 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.0) tmp = y + (x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], 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:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < 1Initial program 91.2%
Taylor expanded in x around 0 98.3%
Taylor expanded in y around 0 91.0%
if 1 < y Initial program 75.7%
Taylor expanded in x around 0 96.9%
Taylor expanded in y around 0 41.9%
frac-2neg41.9%
add-sqr-sqrt24.8%
sqrt-unprod56.2%
sqr-neg56.2%
sqrt-unprod29.8%
add-sqr-sqrt68.9%
distribute-neg-frac68.9%
sub-neg68.9%
Applied egg-rr68.9%
Final simplification85.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 87.2%
Taylor expanded in x around 0 37.1%
Final simplification37.1%
(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 2023318
(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))