
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (fma 4.0 (+ 0.75 (/ (- x z) y)) 1.0))
double code(double x, double y, double z) {
return fma(4.0, (0.75 + ((x - z) / y)), 1.0);
}
function code(x, y, z) return fma(4.0, Float64(0.75 + Float64(Float64(x - z) / y)), 1.0) end
code[x_, y_, z_] := N[(4.0 * N[(0.75 + N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, 0.75 + \frac{x - z}{y}, 1\right)
\end{array}
Initial program 99.6%
+-commutative99.6%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* z -4.0) y)))
(if (<= z -5.8e+42)
t_0
(if (<= z -1.12e-245) (* 4.0 (/ x y)) (if (<= z 6.5e+91) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = (z * -4.0) / y;
double tmp;
if (z <= -5.8e+42) {
tmp = t_0;
} else if (z <= -1.12e-245) {
tmp = 4.0 * (x / y);
} else if (z <= 6.5e+91) {
tmp = 4.0;
} 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 = (z * (-4.0d0)) / y
if (z <= (-5.8d+42)) then
tmp = t_0
else if (z <= (-1.12d-245)) then
tmp = 4.0d0 * (x / y)
else if (z <= 6.5d+91) then
tmp = 4.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z * -4.0) / y;
double tmp;
if (z <= -5.8e+42) {
tmp = t_0;
} else if (z <= -1.12e-245) {
tmp = 4.0 * (x / y);
} else if (z <= 6.5e+91) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z * -4.0) / y tmp = 0 if z <= -5.8e+42: tmp = t_0 elif z <= -1.12e-245: tmp = 4.0 * (x / y) elif z <= 6.5e+91: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z * -4.0) / y) tmp = 0.0 if (z <= -5.8e+42) tmp = t_0; elseif (z <= -1.12e-245) tmp = Float64(4.0 * Float64(x / y)); elseif (z <= 6.5e+91) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z * -4.0) / y; tmp = 0.0; if (z <= -5.8e+42) tmp = t_0; elseif (z <= -1.12e-245) tmp = 4.0 * (x / y); elseif (z <= 6.5e+91) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[z, -5.8e+42], t$95$0, If[LessEqual[z, -1.12e-245], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.5e+91], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z \cdot -4}{y}\\
\mathbf{if}\;z \leq -5.8 \cdot 10^{+42}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.12 \cdot 10^{-245}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+91}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -5.79999999999999961e42 or 6.4999999999999997e91 < z Initial program 99.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around inf 75.2%
*-commutative75.2%
associate-*l/75.2%
Simplified75.2%
if -5.79999999999999961e42 < z < -1.12e-245Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 66.1%
*-commutative66.1%
Simplified66.1%
if -1.12e-245 < z < 6.4999999999999997e91Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 52.4%
Final simplification64.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ -4.0 y))))
(if (<= z -1.2e+43)
t_0
(if (<= z -1.8e-243) (* 4.0 (/ x y)) (if (<= z 6.5e+91) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double tmp;
if (z <= -1.2e+43) {
tmp = t_0;
} else if (z <= -1.8e-243) {
tmp = 4.0 * (x / y);
} else if (z <= 6.5e+91) {
tmp = 4.0;
} 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 = z * ((-4.0d0) / y)
if (z <= (-1.2d+43)) then
tmp = t_0
else if (z <= (-1.8d-243)) then
tmp = 4.0d0 * (x / y)
else if (z <= 6.5d+91) then
tmp = 4.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double tmp;
if (z <= -1.2e+43) {
tmp = t_0;
} else if (z <= -1.8e-243) {
tmp = 4.0 * (x / y);
} else if (z <= 6.5e+91) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (-4.0 / y) tmp = 0 if z <= -1.2e+43: tmp = t_0 elif z <= -1.8e-243: tmp = 4.0 * (x / y) elif z <= 6.5e+91: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-4.0 / y)) tmp = 0.0 if (z <= -1.2e+43) tmp = t_0; elseif (z <= -1.8e-243) tmp = Float64(4.0 * Float64(x / y)); elseif (z <= 6.5e+91) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (-4.0 / y); tmp = 0.0; if (z <= -1.2e+43) tmp = t_0; elseif (z <= -1.8e-243) tmp = 4.0 * (x / y); elseif (z <= 6.5e+91) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.2e+43], t$95$0, If[LessEqual[z, -1.8e-243], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.5e+91], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{-4}{y}\\
\mathbf{if}\;z \leq -1.2 \cdot 10^{+43}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{-243}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+91}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.20000000000000012e43 or 6.4999999999999997e91 < z Initial program 99.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 99.0%
distribute-lft-out99.0%
Simplified99.0%
Taylor expanded in z around inf 75.2%
associate-*r/75.2%
associate-*l/74.9%
*-commutative74.9%
Simplified74.9%
if -1.20000000000000012e43 < z < -1.8000000000000001e-243Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 66.1%
*-commutative66.1%
Simplified66.1%
if -1.8000000000000001e-243 < z < 6.4999999999999997e91Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 52.4%
Final simplification64.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ -4.0 y))))
(if (<= z -4.1e+41)
t_0
(if (<= z -2.3e-243) (* x (/ 4.0 y)) (if (<= z 6.5e+91) 4.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double tmp;
if (z <= -4.1e+41) {
tmp = t_0;
} else if (z <= -2.3e-243) {
tmp = x * (4.0 / y);
} else if (z <= 6.5e+91) {
tmp = 4.0;
} 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 = z * ((-4.0d0) / y)
if (z <= (-4.1d+41)) then
tmp = t_0
else if (z <= (-2.3d-243)) then
tmp = x * (4.0d0 / y)
else if (z <= 6.5d+91) then
tmp = 4.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double tmp;
if (z <= -4.1e+41) {
tmp = t_0;
} else if (z <= -2.3e-243) {
tmp = x * (4.0 / y);
} else if (z <= 6.5e+91) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (-4.0 / y) tmp = 0 if z <= -4.1e+41: tmp = t_0 elif z <= -2.3e-243: tmp = x * (4.0 / y) elif z <= 6.5e+91: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-4.0 / y)) tmp = 0.0 if (z <= -4.1e+41) tmp = t_0; elseif (z <= -2.3e-243) tmp = Float64(x * Float64(4.0 / y)); elseif (z <= 6.5e+91) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (-4.0 / y); tmp = 0.0; if (z <= -4.1e+41) tmp = t_0; elseif (z <= -2.3e-243) tmp = x * (4.0 / y); elseif (z <= 6.5e+91) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.1e+41], t$95$0, If[LessEqual[z, -2.3e-243], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.5e+91], 4.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{-4}{y}\\
\mathbf{if}\;z \leq -4.1 \cdot 10^{+41}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2.3 \cdot 10^{-243}:\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+91}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.1000000000000004e41 or 6.4999999999999997e91 < z Initial program 99.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 99.0%
distribute-lft-out99.0%
Simplified99.0%
Taylor expanded in z around inf 75.2%
associate-*r/75.2%
associate-*l/74.9%
*-commutative74.9%
Simplified74.9%
if -4.1000000000000004e41 < z < -2.3e-243Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 66.1%
*-commutative66.1%
associate-*l/66.1%
associate-*r/65.9%
Simplified65.9%
if -2.3e-243 < z < 6.4999999999999997e91Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 52.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.7e+118) (not (<= y 1.3e+69))) (+ 4.0 (/ (* z -4.0) y)) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.7e+118) || !(y <= 1.3e+69)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 4.0 * ((x - 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 ((y <= (-1.7d+118)) .or. (.not. (y <= 1.3d+69))) then
tmp = 4.0d0 + ((z * (-4.0d0)) / y)
else
tmp = 4.0d0 * ((x - z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.7e+118) || !(y <= 1.3e+69)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.7e+118) or not (y <= 1.3e+69): tmp = 4.0 + ((z * -4.0) / y) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.7e+118) || !(y <= 1.3e+69)) tmp = Float64(4.0 + Float64(Float64(z * -4.0) / y)); else tmp = Float64(4.0 * Float64(Float64(x - z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.7e+118) || ~((y <= 1.3e+69))) tmp = 4.0 + ((z * -4.0) / y); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.7e+118], N[Not[LessEqual[y, 1.3e+69]], $MachinePrecision]], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+118} \lor \neg \left(y \leq 1.3 \cdot 10^{+69}\right):\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -1.69999999999999993e118 or 1.3000000000000001e69 < y Initial program 98.6%
+-commutative98.6%
associate-/l*99.8%
fma-define99.8%
associate--l+99.8%
+-commutative99.8%
remove-double-neg99.8%
sub-neg99.8%
associate--r+99.8%
div-sub99.8%
sub-neg99.8%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 93.8%
sub-neg93.8%
distribute-lft-in93.8%
metadata-eval93.8%
associate-+r+93.8%
metadata-eval93.8%
neg-mul-193.8%
associate-*r*93.8%
metadata-eval93.8%
*-commutative93.8%
associate-*l/93.8%
Simplified93.8%
if -1.69999999999999993e118 < y < 1.3000000000000001e69Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 89.4%
*-commutative89.4%
Simplified89.4%
Final simplification90.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.05e+26) (not (<= z 2.9e+92))) (* 4.0 (/ (- x z) y)) (+ 4.0 (* x (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e+26) || !(z <= 2.9e+92)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (x * (4.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 <= (-1.05d+26)) .or. (.not. (z <= 2.9d+92))) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 4.0d0 + (x * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e+26) || !(z <= 2.9e+92)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (x * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.05e+26) or not (z <= 2.9e+92): tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 + (x * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.05e+26) || !(z <= 2.9e+92)) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(4.0 + Float64(x * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.05e+26) || ~((z <= 2.9e+92))) tmp = 4.0 * ((x - z) / y); else tmp = 4.0 + (x * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.05e+26], N[Not[LessEqual[z, 2.9e+92]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{+26} \lor \neg \left(z \leq 2.9 \cdot 10^{+92}\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\end{array}
\end{array}
if z < -1.05e26 or 2.9000000000000001e92 < z Initial program 99.1%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 88.3%
*-commutative88.3%
Simplified88.3%
if -1.05e26 < z < 2.9000000000000001e92Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 88.7%
distribute-lft-in88.7%
metadata-eval88.7%
associate-+r+88.7%
metadata-eval88.7%
*-commutative88.7%
associate-*l/88.7%
associate-*r/88.6%
Simplified88.6%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (if (<= y -7.8e+132) 4.0 (if (<= y 6e+125) (* 4.0 (/ (- x z) y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.8e+132) {
tmp = 4.0;
} else if (y <= 6e+125) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.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 (y <= (-7.8d+132)) then
tmp = 4.0d0
else if (y <= 6d+125) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.8e+132) {
tmp = 4.0;
} else if (y <= 6e+125) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.8e+132: tmp = 4.0 elif y <= 6e+125: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.8e+132) tmp = 4.0; elseif (y <= 6e+125) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.8e+132) tmp = 4.0; elseif (y <= 6e+125) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.8e+132], 4.0, If[LessEqual[y, 6e+125], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+132}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+125}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -7.80000000000000002e132 or 6.0000000000000003e125 < y Initial program 98.4%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 79.5%
if -7.80000000000000002e132 < y < 6.0000000000000003e125Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 87.4%
*-commutative87.4%
Simplified87.4%
Final simplification85.3%
(FPCore (x y z) :precision binary64 (if (<= y -1.5e+112) 4.0 (if (<= y 6.2e+82) (* x (/ 4.0 y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.5e+112) {
tmp = 4.0;
} else if (y <= 6.2e+82) {
tmp = x * (4.0 / y);
} else {
tmp = 4.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 (y <= (-1.5d+112)) then
tmp = 4.0d0
else if (y <= 6.2d+82) then
tmp = x * (4.0d0 / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.5e+112) {
tmp = 4.0;
} else if (y <= 6.2e+82) {
tmp = x * (4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.5e+112: tmp = 4.0 elif y <= 6.2e+82: tmp = x * (4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.5e+112) tmp = 4.0; elseif (y <= 6.2e+82) tmp = Float64(x * Float64(4.0 / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.5e+112) tmp = 4.0; elseif (y <= 6.2e+82) tmp = x * (4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.5e+112], 4.0, If[LessEqual[y, 6.2e+82], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+112}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+82}:\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -1.4999999999999999e112 or 6.20000000000000065e82 < y Initial program 98.6%
associate-/l*99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in y around inf 72.6%
if -1.4999999999999999e112 < y < 6.20000000000000065e82Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around inf 49.1%
*-commutative49.1%
associate-*l/49.1%
associate-*r/49.0%
Simplified49.0%
(FPCore (x y z) :precision binary64 (+ 1.0 (* 4.0 (/ (+ x (- (* 0.75 y) z)) y))))
double code(double x, double y, double z) {
return 1.0 + (4.0 * ((x + ((0.75 * y) - 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 + ((0.75d0 * y) - z)) / y))
end function
public static double code(double x, double y, double z) {
return 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y));
}
def code(x, y, z): return 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y))
function code(x, y, z) return Float64(1.0 + Float64(4.0 * Float64(Float64(x + Float64(Float64(0.75 * y) - z)) / y))) end
function tmp = code(x, y, z) tmp = 1.0 + (4.0 * ((x + ((0.75 * y) - z)) / y)); end
code[x_, y_, z_] := N[(1.0 + N[(4.0 * N[(N[(x + N[(N[(0.75 * y), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 4 \cdot \frac{x + \left(0.75 \cdot y - z\right)}{y}
\end{array}
Initial program 99.6%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (/ (* 4.0 (+ (- x z) y)) y))
double code(double x, double y, double z) {
return (4.0 * ((x - z) + y)) / y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - z) + y)) / y
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - z) + y)) / y;
}
def code(x, y, z): return (4.0 * ((x - z) + y)) / y
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - z) + y)) / y) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - z) + y)) / y; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - z), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - z\right) + y\right)}{y}
\end{array}
Initial program 99.6%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 99.6%
distribute-lft-out99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z) :precision binary64 4.0)
double code(double x, double y, double z) {
return 4.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 4.0d0
end function
public static double code(double x, double y, double z) {
return 4.0;
}
def code(x, y, z): return 4.0
function code(x, y, z) return 4.0 end
function tmp = code(x, y, z) tmp = 4.0; end
code[x_, y_, z_] := 4.0
\begin{array}{l}
\\
4
\end{array}
Initial program 99.6%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 29.9%
herbie shell --seed 2024145
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, A"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))