
(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 14 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 85.5%
associate--l+85.5%
distribute-lft-out--86.7%
distribute-rgt-out--89.4%
distribute-lft-out100.0%
Simplified100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d1))))
(if (<= d4 -6.5e-295)
(* d1 d2)
(if (<= d4 2.95e-46)
t_0
(if (<= d4 5e+39) (* d1 (- d3)) (if (<= d4 4.5e+61) t_0 (* d1 d4)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double tmp;
if (d4 <= -6.5e-295) {
tmp = d1 * d2;
} else if (d4 <= 2.95e-46) {
tmp = t_0;
} else if (d4 <= 5e+39) {
tmp = d1 * -d3;
} else if (d4 <= 4.5e+61) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = d1 * -d1
if (d4 <= (-6.5d-295)) then
tmp = d1 * d2
else if (d4 <= 2.95d-46) then
tmp = t_0
else if (d4 <= 5d+39) then
tmp = d1 * -d3
else if (d4 <= 4.5d+61) then
tmp = t_0
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * -d1;
double tmp;
if (d4 <= -6.5e-295) {
tmp = d1 * d2;
} else if (d4 <= 2.95e-46) {
tmp = t_0;
} else if (d4 <= 5e+39) {
tmp = d1 * -d3;
} else if (d4 <= 4.5e+61) {
tmp = t_0;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * -d1 tmp = 0 if d4 <= -6.5e-295: tmp = d1 * d2 elif d4 <= 2.95e-46: tmp = t_0 elif d4 <= 5e+39: tmp = d1 * -d3 elif d4 <= 4.5e+61: tmp = t_0 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(-d1)) tmp = 0.0 if (d4 <= -6.5e-295) tmp = Float64(d1 * d2); elseif (d4 <= 2.95e-46) tmp = t_0; elseif (d4 <= 5e+39) tmp = Float64(d1 * Float64(-d3)); elseif (d4 <= 4.5e+61) tmp = t_0; else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * -d1; tmp = 0.0; if (d4 <= -6.5e-295) tmp = d1 * d2; elseif (d4 <= 2.95e-46) tmp = t_0; elseif (d4 <= 5e+39) tmp = d1 * -d3; elseif (d4 <= 4.5e+61) tmp = t_0; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * (-d1)), $MachinePrecision]}, If[LessEqual[d4, -6.5e-295], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 2.95e-46], t$95$0, If[LessEqual[d4, 5e+39], N[(d1 * (-d3)), $MachinePrecision], If[LessEqual[d4, 4.5e+61], t$95$0, N[(d1 * d4), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(-d1\right)\\
\mathbf{if}\;d4 \leq -6.5 \cdot 10^{-295}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 2.95 \cdot 10^{-46}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d4 \leq 5 \cdot 10^{+39}:\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{elif}\;d4 \leq 4.5 \cdot 10^{+61}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -6.4999999999999998e-295Initial program 88.4%
associate--l+88.4%
distribute-lft-out--88.4%
distribute-rgt-out--90.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 33.2%
if -6.4999999999999998e-295 < d4 < 2.95e-46 or 5.00000000000000015e39 < d4 < 4.5e61Initial program 81.8%
associate--l+81.8%
distribute-lft-out--84.8%
distribute-rgt-out--86.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 49.5%
neg-mul-149.5%
Simplified49.5%
if 2.95e-46 < d4 < 5.00000000000000015e39Initial program 87.5%
associate--l+87.5%
distribute-lft-out--93.8%
distribute-rgt-out--93.8%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 45.1%
mul-1-neg45.1%
distribute-rgt-neg-out45.1%
Simplified45.1%
if 4.5e61 < d4 Initial program 83.0%
associate--l+83.0%
distribute-lft-out--83.0%
distribute-rgt-out--88.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 65.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -4.1e+124) (* d1 (- d2 d1)) (if (<= d1 3.1e+143) (* d1 (- (+ d2 d4) d3)) (* d1 (- (- d3) d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -4.1e+124) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 3.1e+143) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * (-d3 - 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 (d1 <= (-4.1d+124)) then
tmp = d1 * (d2 - d1)
else if (d1 <= 3.1d+143) then
tmp = d1 * ((d2 + d4) - d3)
else
tmp = d1 * (-d3 - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -4.1e+124) {
tmp = d1 * (d2 - d1);
} else if (d1 <= 3.1e+143) {
tmp = d1 * ((d2 + d4) - d3);
} else {
tmp = d1 * (-d3 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -4.1e+124: tmp = d1 * (d2 - d1) elif d1 <= 3.1e+143: tmp = d1 * ((d2 + d4) - d3) else: tmp = d1 * (-d3 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -4.1e+124) tmp = Float64(d1 * Float64(d2 - d1)); elseif (d1 <= 3.1e+143) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); else tmp = Float64(d1 * Float64(Float64(-d3) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -4.1e+124) tmp = d1 * (d2 - d1); elseif (d1 <= 3.1e+143) tmp = d1 * ((d2 + d4) - d3); else tmp = d1 * (-d3 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -4.1e+124], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 3.1e+143], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[((-d3) - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -4.1 \cdot 10^{+124}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{elif}\;d1 \leq 3.1 \cdot 10^{+143}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(-d3\right) - d1\right)\\
\end{array}
\end{array}
if d1 < -4.10000000000000001e124Initial program 57.1%
Taylor expanded in d4 around 0 64.3%
associate--r+64.3%
distribute-lft-out--69.0%
unpow269.0%
distribute-lft-out--95.2%
Simplified95.2%
Taylor expanded in d3 around 0 92.9%
if -4.10000000000000001e124 < d1 < 3.0999999999999999e143Initial program 100.0%
associate--l+100.0%
distribute-lft-out--100.0%
distribute-rgt-out--100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 88.7%
if 3.0999999999999999e143 < d1 Initial program 40.6%
associate--l+40.6%
distribute-lft-out--43.8%
distribute-rgt-out--56.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 93.8%
associate--r+93.8%
Simplified93.8%
Taylor expanded in d4 around 0 93.8%
associate-*r*93.8%
mul-1-neg93.8%
Simplified93.8%
Final simplification90.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -4.15e+55) (not (<= d3 1.7e+78))) (* d1 (- d2 d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -4.15e+55) || !(d3 <= 1.7e+78)) {
tmp = d1 * (d2 - 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 <= (-4.15d+55)) .or. (.not. (d3 <= 1.7d+78))) then
tmp = d1 * (d2 - 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 <= -4.15e+55) || !(d3 <= 1.7e+78)) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -4.15e+55) or not (d3 <= 1.7e+78): tmp = d1 * (d2 - d3) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -4.15e+55) || !(d3 <= 1.7e+78)) tmp = Float64(d1 * Float64(d2 - 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 <= -4.15e+55) || ~((d3 <= 1.7e+78))) tmp = d1 * (d2 - d3); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -4.15e+55], N[Not[LessEqual[d3, 1.7e+78]], $MachinePrecision]], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -4.15 \cdot 10^{+55} \lor \neg \left(d3 \leq 1.7 \cdot 10^{+78}\right):\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -4.15000000000000024e55 or 1.70000000000000004e78 < d3 Initial program 81.0%
associate--l+81.0%
distribute-lft-out--83.0%
distribute-rgt-out--85.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 88.7%
Taylor expanded in d4 around 0 78.5%
if -4.15000000000000024e55 < d3 < 1.70000000000000004e78Initial program 88.4%
associate--l+88.4%
distribute-lft-out--89.1%
distribute-rgt-out--92.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 72.4%
Taylor expanded in d3 around 0 70.6%
Final simplification73.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1e+214) (not (<= d3 4.2e+91))) (* d1 (- d3)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1e+214) || !(d3 <= 4.2e+91)) {
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 <= (-1d+214)) .or. (.not. (d3 <= 4.2d+91))) 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 <= -1e+214) || !(d3 <= 4.2e+91)) {
tmp = d1 * -d3;
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1e+214) or not (d3 <= 4.2e+91): tmp = d1 * -d3 else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1e+214) || !(d3 <= 4.2e+91)) 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 <= -1e+214) || ~((d3 <= 4.2e+91))) tmp = d1 * -d3; else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1e+214], N[Not[LessEqual[d3, 4.2e+91]], $MachinePrecision]], N[(d1 * (-d3)), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1 \cdot 10^{+214} \lor \neg \left(d3 \leq 4.2 \cdot 10^{+91}\right):\\
\;\;\;\;d1 \cdot \left(-d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d3 < -9.9999999999999995e213 or 4.20000000000000015e91 < d3 Initial program 78.9%
associate--l+78.9%
distribute-lft-out--81.7%
distribute-rgt-out--84.5%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d3 around inf 79.5%
mul-1-neg79.5%
distribute-rgt-neg-out79.5%
Simplified79.5%
if -9.9999999999999995e213 < d3 < 4.20000000000000015e91Initial program 88.1%
associate--l+88.1%
distribute-lft-out--88.6%
distribute-rgt-out--91.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 75.0%
Taylor expanded in d3 around 0 69.3%
Final simplification72.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -650000000.0) (* d1 (- d2 d3)) (if (<= d2 7e-130) (* d1 (- d4 d1)) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -650000000.0) {
tmp = d1 * (d2 - d3);
} else if (d2 <= 7e-130) {
tmp = d1 * (d4 - d1);
} 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 <= (-650000000.0d0)) then
tmp = d1 * (d2 - d3)
else if (d2 <= 7d-130) then
tmp = d1 * (d4 - d1)
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 <= -650000000.0) {
tmp = d1 * (d2 - d3);
} else if (d2 <= 7e-130) {
tmp = d1 * (d4 - d1);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -650000000.0: tmp = d1 * (d2 - d3) elif d2 <= 7e-130: tmp = d1 * (d4 - d1) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -650000000.0) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= 7e-130) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -650000000.0) tmp = d1 * (d2 - d3); elseif (d2 <= 7e-130) tmp = d1 * (d4 - d1); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -650000000.0], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, 7e-130], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -650000000:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq 7 \cdot 10^{-130}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -6.5e8Initial program 80.4%
associate--l+80.4%
distribute-lft-out--82.3%
distribute-rgt-out--82.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 86.2%
Taylor expanded in d4 around 0 71.0%
if -6.5e8 < d2 < 6.9999999999999998e-130Initial program 88.0%
associate--l+88.0%
distribute-lft-out--88.0%
distribute-rgt-out--92.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 98.0%
associate--r+98.0%
Simplified98.0%
Taylor expanded in d3 around 0 75.7%
if 6.9999999999999998e-130 < d2 Initial program 85.8%
associate--l+85.8%
distribute-lft-out--87.6%
distribute-rgt-out--90.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 83.8%
Taylor expanded in d2 around 0 53.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -4.8e-296) (* d1 d2) (if (<= d4 4e+61) (* d1 (- d1)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -4.8e-296) {
tmp = d1 * d2;
} else if (d4 <= 4e+61) {
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 (d4 <= (-4.8d-296)) then
tmp = d1 * d2
else if (d4 <= 4d+61) 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 (d4 <= -4.8e-296) {
tmp = d1 * d2;
} else if (d4 <= 4e+61) {
tmp = d1 * -d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -4.8e-296: tmp = d1 * d2 elif d4 <= 4e+61: tmp = d1 * -d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -4.8e-296) tmp = Float64(d1 * d2); elseif (d4 <= 4e+61) 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 (d4 <= -4.8e-296) tmp = d1 * d2; elseif (d4 <= 4e+61) tmp = d1 * -d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -4.8e-296], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 4e+61], N[(d1 * (-d1)), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -4.8 \cdot 10^{-296}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 4 \cdot 10^{+61}:\\
\;\;\;\;d1 \cdot \left(-d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -4.79999999999999992e-296Initial program 88.4%
associate--l+88.4%
distribute-lft-out--88.4%
distribute-rgt-out--90.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 33.2%
if -4.79999999999999992e-296 < d4 < 3.9999999999999998e61Initial program 82.9%
associate--l+82.9%
distribute-lft-out--86.5%
distribute-rgt-out--87.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 42.8%
neg-mul-142.8%
Simplified42.8%
if 3.9999999999999998e61 < d4 Initial program 83.0%
associate--l+83.0%
distribute-lft-out--83.0%
distribute-rgt-out--88.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 65.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -6500000.0) (* d1 (- (- d2 d3) d1)) (* d1 (- (- d4 d1) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -6500000.0) {
tmp = d1 * ((d2 - d3) - d1);
} 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 <= (-6500000.0d0)) then
tmp = d1 * ((d2 - d3) - d1)
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 <= -6500000.0) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d4 - d1) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -6500000.0: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d4 - d1) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -6500000.0) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d4 - d1) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -6500000.0) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d4 - d1) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -6500000.0], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -6500000:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\
\end{array}
\end{array}
if d2 < -6.5e6Initial program 81.1%
Taylor expanded in d4 around 0 68.3%
associate--r+68.3%
distribute-lft-out--70.2%
unpow270.2%
distribute-lft-out--85.3%
Simplified85.3%
if -6.5e6 < d2 Initial program 86.7%
associate--l+86.7%
distribute-lft-out--87.7%
distribute-rgt-out--91.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.7%
associate--r+83.7%
Simplified83.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.9e+60) (* d1 (- (- d2 d3) d1)) (* d1 (- (+ d2 d4) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.9e+60) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + 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 (d4 <= 3.9d+60) then
tmp = d1 * ((d2 - d3) - d1)
else
tmp = d1 * ((d2 + d4) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.9e+60) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = d1 * ((d2 + d4) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.9e+60: tmp = d1 * ((d2 - d3) - d1) else: tmp = d1 * ((d2 + d4) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.9e+60) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = Float64(d1 * Float64(Float64(d2 + d4) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 3.9e+60) tmp = d1 * ((d2 - d3) - d1); else tmp = d1 * ((d2 + d4) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.9e+60], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.9 \cdot 10^{+60}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\end{array}
\end{array}
if d4 < 3.9000000000000003e60Initial program 86.1%
Taylor expanded in d4 around 0 73.2%
associate--r+73.2%
distribute-lft-out--74.7%
unpow274.7%
distribute-lft-out--84.1%
Simplified84.1%
if 3.9000000000000003e60 < d4 Initial program 83.3%
associate--l+83.3%
distribute-lft-out--83.3%
distribute-rgt-out--88.9%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 88.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1920000000.0) (* d1 (- d2 d3)) (* d1 (- d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1920000000.0) {
tmp = d1 * (d2 - 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 (d2 <= (-1920000000.0d0)) then
tmp = d1 * (d2 - 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 (d2 <= -1920000000.0) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1920000000.0: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1920000000.0) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1920000000.0) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1920000000.0], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1920000000:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\end{array}
\end{array}
if d2 < -1.92e9Initial program 80.4%
associate--l+80.4%
distribute-lft-out--82.3%
distribute-rgt-out--82.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 86.2%
Taylor expanded in d4 around 0 71.0%
if -1.92e9 < d2 Initial program 86.8%
associate--l+86.8%
distribute-lft-out--87.8%
distribute-rgt-out--91.2%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around 0 83.4%
associate--r+83.4%
Simplified83.4%
Taylor expanded in d3 around 0 61.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.65e+62) (* d1 (- d2 d1)) (* d1 (+ d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.65e+62) {
tmp = d1 * (d2 - d1);
} 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 (d4 <= 1.65d+62) then
tmp = d1 * (d2 - d1)
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 (d4 <= 1.65e+62) {
tmp = d1 * (d2 - d1);
} else {
tmp = d1 * (d2 + d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.65e+62: tmp = d1 * (d2 - d1) else: tmp = d1 * (d2 + d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.65e+62) tmp = Float64(d1 * Float64(d2 - d1)); else tmp = Float64(d1 * Float64(d2 + d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.65e+62) tmp = d1 * (d2 - d1); else tmp = d1 * (d2 + d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.65e+62], N[(d1 * N[(d2 - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.65 \cdot 10^{+62}:\\
\;\;\;\;d1 \cdot \left(d2 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d2 + d4\right)\\
\end{array}
\end{array}
if d4 < 1.65e62Initial program 86.2%
Taylor expanded in d4 around 0 73.3%
associate--r+73.3%
distribute-lft-out--74.8%
unpow274.8%
distribute-lft-out--84.2%
Simplified84.2%
Taylor expanded in d3 around 0 60.9%
if 1.65e62 < d4 Initial program 83.0%
associate--l+83.0%
distribute-lft-out--83.0%
distribute-rgt-out--88.7%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around 0 88.7%
Taylor expanded in d3 around 0 76.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -0.00136) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -0.00136) {
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 <= (-0.00136d0)) 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 <= -0.00136) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -0.00136: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -0.00136) 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 <= -0.00136) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -0.00136], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -0.00136:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -0.00136Initial program 81.5%
associate--l+81.5%
distribute-lft-out--83.3%
distribute-rgt-out--83.3%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 53.1%
if -0.00136 < d2 Initial program 86.6%
associate--l+86.6%
distribute-lft-out--87.6%
distribute-rgt-out--91.1%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d4 around inf 34.8%
(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 85.5%
associate--l+85.5%
distribute-lft-out--86.7%
distribute-rgt-out--89.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d2 around inf 31.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d1))
double code(double d1, double d2, double d3, double d4) {
return 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 * d1
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d1;
}
def code(d1, d2, d3, d4): return d1 * d1
function code(d1, d2, d3, d4) return Float64(d1 * d1) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d1; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d1), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d1
\end{array}
Initial program 85.5%
associate--l+85.5%
distribute-lft-out--86.7%
distribute-rgt-out--89.4%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in d1 around inf 35.7%
neg-mul-135.7%
Simplified35.7%
neg-sub035.7%
sub-neg35.7%
add-sqr-sqrt19.0%
sqrt-unprod24.9%
sqr-neg24.9%
sqrt-unprod5.8%
add-sqr-sqrt8.6%
Applied egg-rr8.6%
+-lft-identity8.6%
Simplified8.6%
(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 2024144
(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)))