
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ (- d2 d3) (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * ((d2 - d3) + (d4 - d1))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d2 - d3) + (d4 - d1));
}
def code(d1, d2, d3, d4): return d1 * ((d2 - d3) + (d4 - d1))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d2 - d3) + Float64(d4 - d1))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d2 - d3) + (d4 - d1)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d2 - d3), $MachinePrecision] + N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d2 - d3\right) + \left(d4 - d1\right)\right)
\end{array}
Initial program 87.5%
associate--l+87.5%
distribute-lft-out--88.2%
distribute-rgt-out--91.0%
distribute-lft-out100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d3 -3.6e+68)
t_0
(if (<= d3 3.8e-177)
(* d1 (- d4 d1))
(if (<= d3 2.7e+57) (* d1 (+ d2 d4)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -3.6e+68) {
tmp = t_0;
} else if (d3 <= 3.8e-177) {
tmp = d1 * (d4 - d1);
} else if (d3 <= 2.7e+57) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d3 <= (-3.6d+68)) then
tmp = t_0
else if (d3 <= 3.8d-177) then
tmp = d1 * (d4 - d1)
else if (d3 <= 2.7d+57) then
tmp = d1 * (d2 + d4)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -3.6e+68) {
tmp = t_0;
} else if (d3 <= 3.8e-177) {
tmp = d1 * (d4 - d1);
} else if (d3 <= 2.7e+57) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d3 <= -3.6e+68: tmp = t_0 elif d3 <= 3.8e-177: tmp = d1 * (d4 - d1) elif d3 <= 2.7e+57: tmp = d1 * (d2 + d4) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d3 <= -3.6e+68) tmp = t_0; elseif (d3 <= 3.8e-177) tmp = Float64(d1 * Float64(d4 - d1)); elseif (d3 <= 2.7e+57) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d3 <= -3.6e+68) tmp = t_0; elseif (d3 <= 3.8e-177) tmp = d1 * (d4 - d1); elseif (d3 <= 2.7e+57) tmp = d1 * (d2 + d4); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -3.6e+68], t$95$0, If[LessEqual[d3, 3.8e-177], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 2.7e+57], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d3 \leq -3.6 \cdot 10^{+68}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 3.8 \cdot 10^{-177}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{elif}\;d3 \leq 2.7 \cdot 10^{+57}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -3.5999999999999999e68 or 2.6999999999999998e57 < d3 Initial program 84.8%
associate--l+84.8%
distribute-lft-out--86.5%
distribute-rgt-out--86.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.7%
Taylor expanded in d1 around 0 72.3%
if -3.5999999999999999e68 < d3 < 3.80000000000000004e-177Initial program 87.4%
associate--l+87.4%
distribute-lft-out--87.4%
distribute-rgt-out--92.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 93.2%
Taylor expanded in d2 around 0 73.3%
Taylor expanded in d3 around 0 70.6%
if 3.80000000000000004e-177 < d3 < 2.6999999999999998e57Initial program 95.1%
associate--l+95.1%
distribute-lft-out--95.1%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 87.8%
Taylor expanded in d3 around 0 82.9%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d3 -4.4e+68)
t_0
(if (<= d3 2.08e-227)
(* d1 (- d2 d1))
(if (<= d3 1.6e+58) (* d1 (+ d2 d4)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -4.4e+68) {
tmp = t_0;
} else if (d3 <= 2.08e-227) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 1.6e+58) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d3 <= (-4.4d+68)) then
tmp = t_0
else if (d3 <= 2.08d-227) then
tmp = d1 * (d2 - d1)
else if (d3 <= 1.6d+58) then
tmp = d1 * (d2 + d4)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d3 <= -4.4e+68) {
tmp = t_0;
} else if (d3 <= 2.08e-227) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 1.6e+58) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d3 <= -4.4e+68: tmp = t_0 elif d3 <= 2.08e-227: tmp = d1 * (d2 - d1) elif d3 <= 1.6e+58: tmp = d1 * (d2 + d4) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d3 <= -4.4e+68) tmp = t_0; elseif (d3 <= 2.08e-227) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d3 <= 1.6e+58) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d3 <= -4.4e+68) tmp = t_0; elseif (d3 <= 2.08e-227) tmp = d1 * (d2 - d1); elseif (d3 <= 1.6e+58) tmp = d1 * (d2 + d4); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -4.4e+68], t$95$0, If[LessEqual[d3, 2.08e-227], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 1.6e+58], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d3 \leq -4.4 \cdot 10^{+68}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 2.08 \cdot 10^{-227}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d3 \leq 1.6 \cdot 10^{+58}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -4.39999999999999974e68 or 1.60000000000000008e58 < d3 Initial program 84.8%
associate--l+84.8%
distribute-lft-out--86.5%
distribute-rgt-out--86.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 82.7%
Taylor expanded in d1 around 0 72.3%
if -4.39999999999999974e68 < d3 < 2.08e-227Initial program 86.9%
associate--l+86.9%
distribute-lft-out--86.9%
distribute-rgt-out--92.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 74.5%
Taylor expanded in d3 around 0 72.3%
if 2.08e-227 < d3 < 1.60000000000000008e58Initial program 94.2%
associate--l+94.2%
distribute-lft-out--94.2%
distribute-rgt-out--98.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 80.9%
Taylor expanded in d3 around 0 77.1%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d3))))
(if (<= d3 -1.85e+180)
t_0
(if (<= d3 1.8e-231)
(* d1 (- d2 d1))
(if (<= d3 6.3e+155) (* d1 (+ d2 d4)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d3 <= -1.85e+180) {
tmp = t_0;
} else if (d3 <= 1.8e-231) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 6.3e+155) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * -d3
if (d3 <= (-1.85d+180)) then
tmp = t_0
else if (d3 <= 1.8d-231) then
tmp = d1 * (d2 - d1)
else if (d3 <= 6.3d+155) then
tmp = d1 * (d2 + d4)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d3;
double tmp;
if (d3 <= -1.85e+180) {
tmp = t_0;
} else if (d3 <= 1.8e-231) {
tmp = d1 * (d2 - d1);
} else if (d3 <= 6.3e+155) {
tmp = d1 * (d2 + d4);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d3 tmp = 0 if d3 <= -1.85e+180: tmp = t_0 elif d3 <= 1.8e-231: tmp = d1 * (d2 - d1) elif d3 <= 6.3e+155: tmp = d1 * (d2 + d4) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d3)) tmp = 0.0 if (d3 <= -1.85e+180) tmp = t_0; elseif (d3 <= 1.8e-231) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d3 <= 6.3e+155) tmp = Float64(d1 * Float64(d2 + d4)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d3; tmp = 0.0; if (d3 <= -1.85e+180) tmp = t_0; elseif (d3 <= 1.8e-231) tmp = d1 * (d2 - d1); elseif (d3 <= 6.3e+155) tmp = d1 * (d2 + d4); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d3)), $MachinePrecision]}, If[LessEqual[d3, -1.85e+180], t$95$0, If[LessEqual[d3, 1.8e-231], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d3, 6.3e+155], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d3\right)\\
\mathbf{if}\;d3 \leq -1.85 \cdot 10^{+180}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 1.8 \cdot 10^{-231}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d3 \leq 6.3 \cdot 10^{+155}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d3 < -1.8500000000000001e180 or 6.30000000000000001e155 < d3 Initial program 80.6%
associate--l+80.6%
distribute-lft-out--83.5%
distribute-rgt-out--83.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 81.6%
associate-*r*81.6%
neg-mul-181.6%
Simplified81.6%
if -1.8500000000000001e180 < d3 < 1.79999999999999987e-231Initial program 87.0%
associate--l+87.0%
distribute-lft-out--87.0%
distribute-rgt-out--91.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 74.2%
Taylor expanded in d3 around 0 65.1%
if 1.79999999999999987e-231 < d3 < 6.30000000000000001e155Initial program 95.4%
associate--l+95.4%
distribute-lft-out--95.4%
distribute-rgt-out--98.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 83.5%
Taylor expanded in d3 around 0 76.6%
Final simplification72.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.85e+52) (* d1 (- d2 d3)) (if (<= d2 -2.02e-63) (* d1 (- (- d1) d3)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.85e+52) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -2.02e-63) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-1.85d+52)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-2.02d-63)) then
tmp = d1 * (-d1 - d3)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.85e+52) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -2.02e-63) {
tmp = d1 * (-d1 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.85e+52: tmp = d1 * (d2 - d3) elif d2 <= -2.02e-63: tmp = d1 * (-d1 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.85e+52) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -2.02e-63) tmp = Float64(d1 * Float64(Float64(-d1) - d3)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.85e+52) tmp = d1 * (d2 - d3); elseif (d2 <= -2.02e-63) tmp = d1 * (-d1 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.85e+52], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -2.02e-63], N[(d1 * N[((-d1) - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.85 \cdot 10^{+52}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -2.02 \cdot 10^{-63}:\\
\;\;\;\;d1 \cdot \left(\left(-d1\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -1.85e52Initial program 87.3%
associate--l+87.3%
distribute-lft-out--89.1%
distribute-rgt-out--89.1%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 82.3%
Taylor expanded in d1 around 0 75.0%
if -1.85e52 < d2 < -2.02000000000000003e-63Initial program 75.7%
associate--l+75.7%
distribute-lft-out--75.6%
distribute-rgt-out--78.6%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 100.0%
Taylor expanded in d2 around 0 88.5%
Taylor expanded in d4 around 0 76.6%
associate-*r*76.6%
mul-1-neg76.6%
Simplified76.6%
if -2.02000000000000003e-63 < d2 Initial program 89.9%
associate--l+89.9%
distribute-lft-out--90.4%
distribute-rgt-out--94.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 77.6%
Taylor expanded in d4 around 0 77.5%
Taylor expanded in d2 around 0 62.3%
+-commutative62.3%
mul-1-neg62.3%
unsub-neg62.3%
distribute-lft-out--62.4%
Simplified62.4%
Final simplification66.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -8e+182) (not (<= d3 1.35e+156))) (* d1 (- d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -8e+182) || !(d3 <= 1.35e+156)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d3 <= (-8d+182)) .or. (.not. (d3 <= 1.35d+156))) then
tmp = d1 * -d3
else
tmp = d1 * (d2 + d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -8e+182) || !(d3 <= 1.35e+156)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -8e+182) or not (d3 <= 1.35e+156): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -8e+182) || !(d3 <= 1.35e+156)) tmp = Float64(d1 * Float64(-d3)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -8e+182) || ~((d3 <= 1.35e+156))) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -8e+182], N[Not[LessEqual[d3, 1.35e+156]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -8 \cdot 10^{+182} \lor \neg \left(d3 \leq 1.35 \cdot 10^{+156}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -8.0000000000000005e182 or 1.35e156 < d3 Initial program 79.7%
associate--l+79.7%
distribute-lft-out--82.8%
distribute-rgt-out--82.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 84.4%
associate-*r*84.4%
neg-mul-184.4%
Simplified84.4%
if -8.0000000000000005e182 < d3 < 1.35e156Initial program 90.1%
associate--l+90.1%
distribute-lft-out--90.1%
distribute-rgt-out--93.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 74.5%
Taylor expanded in d3 around 0 64.6%
Final simplification69.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.9e+61) (* d1 (- d2 (+ d1 d3))) (if (<= d4 1.8e+212) (* d1 (- d4 d3)) (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.9e+61) {
tmp = d1 * (d2 - (d1 + d3));
} else if (d4 <= 1.8e+212) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 3.9d+61) then
tmp = d1 * (d2 - (d1 + d3))
else if (d4 <= 1.8d+212) then
tmp = d1 * (d4 - d3)
else
tmp = d1 * (d4 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.9e+61) {
tmp = d1 * (d2 - (d1 + d3));
} else if (d4 <= 1.8e+212) {
tmp = d1 * (d4 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.9e+61: tmp = d1 * (d2 - (d1 + d3)) elif d4 <= 1.8e+212: tmp = d1 * (d4 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.9e+61) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); elseif (d4 <= 1.8e+212) tmp = Float64(d1 * Float64(d4 - d3)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 3.9e+61) tmp = d1 * (d2 - (d1 + d3)); elseif (d4 <= 1.8e+212) tmp = d1 * (d4 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.9e+61], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d4, 1.8e+212], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.9 \cdot 10^{+61}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{elif}\;d4 \leq 1.8 \cdot 10^{+212}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d4 < 3.89999999999999987e61Initial program 87.2%
associate--l+87.2%
distribute-lft-out--88.1%
distribute-rgt-out--90.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around 0 84.0%
if 3.89999999999999987e61 < d4 < 1.8e212Initial program 99.9%
associate--l+99.9%
distribute-lft-out--99.9%
distribute-rgt-out--99.9%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d1 around 0 99.6%
Taylor expanded in d4 around 0 99.5%
Taylor expanded in d2 around 0 87.0%
+-commutative87.0%
mul-1-neg87.0%
unsub-neg87.0%
distribute-lft-out--87.1%
Simplified87.1%
if 1.8e212 < d4 Initial program 72.2%
associate--l+72.2%
distribute-lft-out--72.2%
distribute-rgt-out--88.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 94.4%
Taylor expanded in d2 around 0 99.1%
Taylor expanded in d3 around 0 99.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.55e+52) (* d1 d2) (if (<= d2 3e-237) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.55e+52) {
tmp = d1 * d2;
} else if (d2 <= 3e-237) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-1.55d+52)) then
tmp = d1 * d2
else if (d2 <= 3d-237) then
tmp = d1 * -d1
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.55e+52) {
tmp = d1 * d2;
} else if (d2 <= 3e-237) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.55e+52: tmp = d1 * d2 elif d2 <= 3e-237: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.55e+52) tmp = Float64(d1 * d2); elseif (d2 <= 3e-237) tmp = Float64(d1 * Float64(-d1)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.55e+52) tmp = d1 * d2; elseif (d2 <= 3e-237) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.55e+52], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, 3e-237], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.55 \cdot 10^{+52}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq 3 \cdot 10^{-237}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.55e52Initial program 87.3%
associate--l+87.3%
distribute-lft-out--89.1%
distribute-rgt-out--89.1%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around inf 59.0%
if -1.55e52 < d2 < 3.00000000000000024e-237Initial program 86.6%
associate--l+86.6%
distribute-lft-out--86.6%
distribute-rgt-out--91.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 40.3%
neg-mul-140.3%
Simplified40.3%
if 3.00000000000000024e-237 < d2 Initial program 88.5%
associate--l+88.5%
distribute-lft-out--89.6%
distribute-rgt-out--91.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 27.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5.5e-11) (* d1 (- d2 (+ d1 d3))) (* d1 (- d4 (+ d1 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.5e-11) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-5.5d-11)) then
tmp = d1 * (d2 - (d1 + d3))
else
tmp = d1 * (d4 - (d1 + d3))
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.5e-11) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = d1 * (d4 - (d1 + d3));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5.5e-11: tmp = d1 * (d2 - (d1 + d3)) else: tmp = d1 * (d4 - (d1 + d3)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5.5e-11) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); else tmp = Float64(d1 * Float64(d4 - Float64(d1 + d3))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -5.5e-11) tmp = d1 * (d2 - (d1 + d3)); else tmp = d1 * (d4 - (d1 + d3)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.5e-11], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5.5 \cdot 10^{-11}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - \left(d1 + d3\right)\right)\\
\end{array}
\end{array}
if d2 < -5.49999999999999975e-11Initial program 81.6%
associate--l+81.6%
distribute-lft-out--82.8%
distribute-rgt-out--84.1%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d4 around 0 84.6%
if -5.49999999999999975e-11 < d2 Initial program 90.0%
associate--l+90.0%
distribute-lft-out--90.5%
distribute-rgt-out--93.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 96.7%
Taylor expanded in d2 around 0 85.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -6e-12) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -6e-12) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-6d-12)) then
tmp = d1 * d2
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -6e-12) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -6e-12: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -6e-12) tmp = Float64(d1 * d2); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -6e-12) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -6e-12], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -6 \cdot 10^{-12}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -6.0000000000000003e-12Initial program 81.6%
associate--l+81.6%
distribute-lft-out--82.8%
distribute-rgt-out--84.1%
distribute-lft-out99.9%
Simplified99.9%
Taylor expanded in d2 around inf 48.7%
if -6.0000000000000003e-12 < d2 Initial program 90.0%
associate--l+90.0%
distribute-lft-out--90.5%
distribute-rgt-out--93.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 32.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d2
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 87.5%
associate--l+87.5%
distribute-lft-out--88.2%
distribute-rgt-out--91.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 28.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
real(8) function code(d1, d2, d3, d4)
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (((d2 - d3) + d4) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
def code(d1, d2, d3, d4): return d1 * (((d2 - d3) + d4) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d2 - d3) + d4) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
\end{array}
herbie shell --seed 2024136
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(! :herbie-platform default (* d1 (- (+ (- d2 d3) d4) d1)))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))