
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ (/ (- x z) (* y 0.25)) 2.0))
double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((x - z) / (y * 0.25d0)) + 2.0d0
end function
public static double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 2.0;
}
def code(x, y, z): return ((x - z) / (y * 0.25)) + 2.0
function code(x, y, z) return Float64(Float64(Float64(x - z) / Float64(y * 0.25)) + 2.0) end
function tmp = code(x, y, z) tmp = ((x - z) / (y * 0.25)) + 2.0; end
code[x_, y_, z_] := N[(N[(N[(x - z), $MachinePrecision] / N[(y * 0.25), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - z}{y \cdot 0.25} + 2
\end{array}
Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* -4.0 (/ z y)) 1.0)) (t_1 (+ 1.0 (/ (* x 4.0) y))))
(if (<= x -1.32e+118)
t_1
(if (<= x -2e+75)
t_0
(if (<= x -2.2e+45)
t_1
(if (<= x -2.35e-63) 2.0 (if (<= x 4.1e+60) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = (-4.0 * (z / y)) + 1.0;
double t_1 = 1.0 + ((x * 4.0) / y);
double tmp;
if (x <= -1.32e+118) {
tmp = t_1;
} else if (x <= -2e+75) {
tmp = t_0;
} else if (x <= -2.2e+45) {
tmp = t_1;
} else if (x <= -2.35e-63) {
tmp = 2.0;
} else if (x <= 4.1e+60) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = ((-4.0d0) * (z / y)) + 1.0d0
t_1 = 1.0d0 + ((x * 4.0d0) / y)
if (x <= (-1.32d+118)) then
tmp = t_1
else if (x <= (-2d+75)) then
tmp = t_0
else if (x <= (-2.2d+45)) then
tmp = t_1
else if (x <= (-2.35d-63)) then
tmp = 2.0d0
else if (x <= 4.1d+60) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (-4.0 * (z / y)) + 1.0;
double t_1 = 1.0 + ((x * 4.0) / y);
double tmp;
if (x <= -1.32e+118) {
tmp = t_1;
} else if (x <= -2e+75) {
tmp = t_0;
} else if (x <= -2.2e+45) {
tmp = t_1;
} else if (x <= -2.35e-63) {
tmp = 2.0;
} else if (x <= 4.1e+60) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (-4.0 * (z / y)) + 1.0 t_1 = 1.0 + ((x * 4.0) / y) tmp = 0 if x <= -1.32e+118: tmp = t_1 elif x <= -2e+75: tmp = t_0 elif x <= -2.2e+45: tmp = t_1 elif x <= -2.35e-63: tmp = 2.0 elif x <= 4.1e+60: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(-4.0 * Float64(z / y)) + 1.0) t_1 = Float64(1.0 + Float64(Float64(x * 4.0) / y)) tmp = 0.0 if (x <= -1.32e+118) tmp = t_1; elseif (x <= -2e+75) tmp = t_0; elseif (x <= -2.2e+45) tmp = t_1; elseif (x <= -2.35e-63) tmp = 2.0; elseif (x <= 4.1e+60) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (-4.0 * (z / y)) + 1.0; t_1 = 1.0 + ((x * 4.0) / y); tmp = 0.0; if (x <= -1.32e+118) tmp = t_1; elseif (x <= -2e+75) tmp = t_0; elseif (x <= -2.2e+45) tmp = t_1; elseif (x <= -2.35e-63) tmp = 2.0; elseif (x <= 4.1e+60) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.32e+118], t$95$1, If[LessEqual[x, -2e+75], t$95$0, If[LessEqual[x, -2.2e+45], t$95$1, If[LessEqual[x, -2.35e-63], 2.0, If[LessEqual[x, 4.1e+60], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y} + 1\\
t_1 := 1 + \frac{x \cdot 4}{y}\\
\mathbf{if}\;x \leq -1.32 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2 \cdot 10^{+75}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.2 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.35 \cdot 10^{-63}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{+60}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.3199999999999999e118 or -1.99999999999999985e75 < x < -2.2e45 or 4.1e60 < x Initial program 100.0%
Taylor expanded in x around inf 73.6%
associate-*r/73.6%
Simplified73.6%
if -1.3199999999999999e118 < x < -1.99999999999999985e75 or -2.35e-63 < x < 4.1e60Initial program 100.0%
Taylor expanded in z around inf 57.4%
*-commutative57.4%
Simplified57.4%
if -2.2e45 < x < -2.35e-63Initial program 99.9%
Taylor expanded in y around inf 66.1%
Final simplification64.8%
(FPCore (x y z)
:precision binary64
(if (or (<= x -1.7e+118)
(not
(or (<= x -6.2e+78) (and (not (<= x -2.25e-55)) (<= x 9.2e+52)))))
(+ 2.0 (* 4.0 (/ x y)))
(+ 2.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.7e+118) || !((x <= -6.2e+78) || (!(x <= -2.25e-55) && (x <= 9.2e+52)))) {
tmp = 2.0 + (4.0 * (x / y));
} else {
tmp = 2.0 + (-4.0 * (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) :: tmp
if ((x <= (-1.7d+118)) .or. (.not. (x <= (-6.2d+78)) .or. (.not. (x <= (-2.25d-55))) .and. (x <= 9.2d+52))) then
tmp = 2.0d0 + (4.0d0 * (x / y))
else
tmp = 2.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.7e+118) || !((x <= -6.2e+78) || (!(x <= -2.25e-55) && (x <= 9.2e+52)))) {
tmp = 2.0 + (4.0 * (x / y));
} else {
tmp = 2.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.7e+118) or not ((x <= -6.2e+78) or (not (x <= -2.25e-55) and (x <= 9.2e+52))): tmp = 2.0 + (4.0 * (x / y)) else: tmp = 2.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.7e+118) || !((x <= -6.2e+78) || (!(x <= -2.25e-55) && (x <= 9.2e+52)))) tmp = Float64(2.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(2.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.7e+118) || ~(((x <= -6.2e+78) || (~((x <= -2.25e-55)) && (x <= 9.2e+52))))) tmp = 2.0 + (4.0 * (x / y)); else tmp = 2.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.7e+118], N[Not[Or[LessEqual[x, -6.2e+78], And[N[Not[LessEqual[x, -2.25e-55]], $MachinePrecision], LessEqual[x, 9.2e+52]]]], $MachinePrecision]], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+118} \lor \neg \left(x \leq -6.2 \cdot 10^{+78} \lor \neg \left(x \leq -2.25 \cdot 10^{-55}\right) \land x \leq 9.2 \cdot 10^{+52}\right):\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -1.69999999999999993e118 or -6.2e78 < x < -2.24999999999999985e-55 or 9.1999999999999999e52 < x Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 89.2%
if -1.69999999999999993e118 < x < -6.2e78 or -2.24999999999999985e-55 < x < 9.1999999999999999e52Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 94.1%
Final simplification91.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.9e+34) (not (<= z 1.8e+63))) (+ 1.0 (* z (/ -4.0 y))) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.9e+34) || !(z <= 1.8e+63)) {
tmp = 1.0 + (z * (-4.0 / y));
} else {
tmp = 2.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) :: tmp
if ((z <= (-2.9d+34)) .or. (.not. (z <= 1.8d+63))) then
tmp = 1.0d0 + (z * ((-4.0d0) / y))
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.9e+34) || !(z <= 1.8e+63)) {
tmp = 1.0 + (z * (-4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.9e+34) or not (z <= 1.8e+63): tmp = 1.0 + (z * (-4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.9e+34) || !(z <= 1.8e+63)) tmp = Float64(1.0 + Float64(z * Float64(-4.0 / y))); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.9e+34) || ~((z <= 1.8e+63))) tmp = 1.0 + (z * (-4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.9e+34], N[Not[LessEqual[z, 1.8e+63]], $MachinePrecision]], N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.9 \cdot 10^{+34} \lor \neg \left(z \leq 1.8 \cdot 10^{+63}\right):\\
\;\;\;\;1 + z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if z < -2.9000000000000001e34 or 1.79999999999999999e63 < z Initial program 100.0%
Taylor expanded in z around inf 67.3%
associate-*r/67.3%
metadata-eval67.3%
associate-*r*67.3%
neg-mul-167.3%
associate-*l/67.2%
*-commutative67.2%
distribute-lft-neg-out67.2%
distribute-rgt-neg-in67.2%
distribute-neg-frac67.2%
metadata-eval67.2%
Simplified67.2%
if -2.9000000000000001e34 < z < 1.79999999999999999e63Initial program 100.0%
Taylor expanded in y around inf 49.3%
Final simplification56.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.15e+34) (not (<= z 3.1e+60))) (+ (* -4.0 (/ z y)) 1.0) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.15e+34) || !(z <= 3.1e+60)) {
tmp = (-4.0 * (z / y)) + 1.0;
} else {
tmp = 2.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) :: tmp
if ((z <= (-3.15d+34)) .or. (.not. (z <= 3.1d+60))) then
tmp = ((-4.0d0) * (z / y)) + 1.0d0
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.15e+34) || !(z <= 3.1e+60)) {
tmp = (-4.0 * (z / y)) + 1.0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.15e+34) or not (z <= 3.1e+60): tmp = (-4.0 * (z / y)) + 1.0 else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.15e+34) || !(z <= 3.1e+60)) tmp = Float64(Float64(-4.0 * Float64(z / y)) + 1.0); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.15e+34) || ~((z <= 3.1e+60))) tmp = (-4.0 * (z / y)) + 1.0; else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.15e+34], N[Not[LessEqual[z, 3.1e+60]], $MachinePrecision]], N[(N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.15 \cdot 10^{+34} \lor \neg \left(z \leq 3.1 \cdot 10^{+60}\right):\\
\;\;\;\;-4 \cdot \frac{z}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if z < -3.15e34 or 3.1000000000000001e60 < z Initial program 100.0%
Taylor expanded in z around inf 67.3%
*-commutative67.3%
Simplified67.3%
if -3.15e34 < z < 3.1000000000000001e60Initial program 100.0%
Taylor expanded in y around inf 49.3%
Final simplification56.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.35e+119) (not (<= x 2.5e+100))) (+ 1.0 (/ (* x 4.0) y)) (+ 2.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.35e+119) || !(x <= 2.5e+100)) {
tmp = 1.0 + ((x * 4.0) / y);
} else {
tmp = 2.0 + (-4.0 * (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) :: tmp
if ((x <= (-1.35d+119)) .or. (.not. (x <= 2.5d+100))) then
tmp = 1.0d0 + ((x * 4.0d0) / y)
else
tmp = 2.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.35e+119) || !(x <= 2.5e+100)) {
tmp = 1.0 + ((x * 4.0) / y);
} else {
tmp = 2.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.35e+119) or not (x <= 2.5e+100): tmp = 1.0 + ((x * 4.0) / y) else: tmp = 2.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.35e+119) || !(x <= 2.5e+100)) tmp = Float64(1.0 + Float64(Float64(x * 4.0) / y)); else tmp = Float64(2.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.35e+119) || ~((x <= 2.5e+100))) tmp = 1.0 + ((x * 4.0) / y); else tmp = 2.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.35e+119], N[Not[LessEqual[x, 2.5e+100]], $MachinePrecision]], N[(1.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+119} \lor \neg \left(x \leq 2.5 \cdot 10^{+100}\right):\\
\;\;\;\;1 + \frac{x \cdot 4}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -1.3499999999999999e119 or 2.4999999999999999e100 < x Initial program 100.0%
Taylor expanded in x around inf 76.9%
associate-*r/76.9%
Simplified76.9%
if -1.3499999999999999e119 < x < 2.4999999999999999e100Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 85.3%
Final simplification82.6%
(FPCore (x y z) :precision binary64 (+ 2.0 (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 + ((x - z) * (4.0d0 / y))
end function
public static double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
def code(x, y, z): return 2.0 + ((x - z) * (4.0 / y))
function code(x, y, z) return Float64(2.0 + Float64(Float64(x - z) * Float64(4.0 / y))) end
function tmp = code(x, y, z) tmp = 2.0 + ((x - z) * (4.0 / y)); end
code[x_, y_, z_] := N[(2.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 + \left(x - z\right) \cdot \frac{4}{y}
\end{array}
Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 2.0)
double code(double x, double y, double z) {
return 2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0
end function
public static double code(double x, double y, double z) {
return 2.0;
}
def code(x, y, z): return 2.0
function code(x, y, z) return 2.0 end
function tmp = code(x, y, z) tmp = 2.0; end
code[x_, y_, z_] := 2.0
\begin{array}{l}
\\
2
\end{array}
Initial program 100.0%
Taylor expanded in y around inf 37.1%
Final simplification37.1%
herbie shell --seed 2024066
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))