
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Initial program 100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (pow im 2.0))) (t_1 (* 0.5 (+ (exp (- im)) (exp im)))))
(if (<= (cos re) 0.5)
(cos re)
(if (<= (cos re) 0.68)
t_1
(if (<= (cos re) 0.72)
(cos re)
(if (<= (cos re) 0.73)
t_0
(if (<= (cos re) 0.765)
(cos re)
(if (<= (cos re) 0.82)
t_1
(if (<= (cos re) 0.826)
(cos re)
(if (<= (cos re) 0.88)
t_1
(if (<= (cos re) 0.9)
(cos re)
(if (<= (cos re) 0.91)
t_1
(if (<= (cos re) 0.912)
(cos re)
(if (<= (cos re) 0.92)
t_1
(if (<= (cos re) 0.94)
(cos re)
(if (<= (cos re) 0.942)
t_0
(if (<= (cos re) 0.96)
(cos re)
(if (<= (cos re) 0.965)
t_1
(if (<= (cos re) 0.97)
(cos re)
(if (<= (cos re) 0.99)
t_1
(if (<= (cos re) 0.999)
(cos re)
(if (<= (cos re) 0.9995)
t_0
(if (<= (cos re) 1.0)
(cos re)
t_1)))))))))))))))))))))))
double code(double re, double im) {
double t_0 = 0.5 * pow(im, 2.0);
double t_1 = 0.5 * (exp(-im) + exp(im));
double tmp;
if (cos(re) <= 0.5) {
tmp = cos(re);
} else if (cos(re) <= 0.68) {
tmp = t_1;
} else if (cos(re) <= 0.72) {
tmp = cos(re);
} else if (cos(re) <= 0.73) {
tmp = t_0;
} else if (cos(re) <= 0.765) {
tmp = cos(re);
} else if (cos(re) <= 0.82) {
tmp = t_1;
} else if (cos(re) <= 0.826) {
tmp = cos(re);
} else if (cos(re) <= 0.88) {
tmp = t_1;
} else if (cos(re) <= 0.9) {
tmp = cos(re);
} else if (cos(re) <= 0.91) {
tmp = t_1;
} else if (cos(re) <= 0.912) {
tmp = cos(re);
} else if (cos(re) <= 0.92) {
tmp = t_1;
} else if (cos(re) <= 0.94) {
tmp = cos(re);
} else if (cos(re) <= 0.942) {
tmp = t_0;
} else if (cos(re) <= 0.96) {
tmp = cos(re);
} else if (cos(re) <= 0.965) {
tmp = t_1;
} else if (cos(re) <= 0.97) {
tmp = cos(re);
} else if (cos(re) <= 0.99) {
tmp = t_1;
} else if (cos(re) <= 0.999) {
tmp = cos(re);
} else if (cos(re) <= 0.9995) {
tmp = t_0;
} else if (cos(re) <= 1.0) {
tmp = cos(re);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (im ** 2.0d0)
t_1 = 0.5d0 * (exp(-im) + exp(im))
if (cos(re) <= 0.5d0) then
tmp = cos(re)
else if (cos(re) <= 0.68d0) then
tmp = t_1
else if (cos(re) <= 0.72d0) then
tmp = cos(re)
else if (cos(re) <= 0.73d0) then
tmp = t_0
else if (cos(re) <= 0.765d0) then
tmp = cos(re)
else if (cos(re) <= 0.82d0) then
tmp = t_1
else if (cos(re) <= 0.826d0) then
tmp = cos(re)
else if (cos(re) <= 0.88d0) then
tmp = t_1
else if (cos(re) <= 0.9d0) then
tmp = cos(re)
else if (cos(re) <= 0.91d0) then
tmp = t_1
else if (cos(re) <= 0.912d0) then
tmp = cos(re)
else if (cos(re) <= 0.92d0) then
tmp = t_1
else if (cos(re) <= 0.94d0) then
tmp = cos(re)
else if (cos(re) <= 0.942d0) then
tmp = t_0
else if (cos(re) <= 0.96d0) then
tmp = cos(re)
else if (cos(re) <= 0.965d0) then
tmp = t_1
else if (cos(re) <= 0.97d0) then
tmp = cos(re)
else if (cos(re) <= 0.99d0) then
tmp = t_1
else if (cos(re) <= 0.999d0) then
tmp = cos(re)
else if (cos(re) <= 0.9995d0) then
tmp = t_0
else if (cos(re) <= 1.0d0) then
tmp = cos(re)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.pow(im, 2.0);
double t_1 = 0.5 * (Math.exp(-im) + Math.exp(im));
double tmp;
if (Math.cos(re) <= 0.5) {
tmp = Math.cos(re);
} else if (Math.cos(re) <= 0.68) {
tmp = t_1;
} else if (Math.cos(re) <= 0.72) {
tmp = Math.cos(re);
} else if (Math.cos(re) <= 0.73) {
tmp = t_0;
} else if (Math.cos(re) <= 0.765) {
tmp = Math.cos(re);
} else if (Math.cos(re) <= 0.82) {
tmp = t_1;
} else if (Math.cos(re) <= 0.826) {
tmp = Math.cos(re);
} else if (Math.cos(re) <= 0.88) {
tmp = t_1;
} else if (Math.cos(re) <= 0.9) {
tmp = Math.cos(re);
} else if (Math.cos(re) <= 0.91) {
tmp = t_1;
} else if (Math.cos(re) <= 0.912) {
tmp = Math.cos(re);
} else if (Math.cos(re) <= 0.92) {
tmp = t_1;
} else if (Math.cos(re) <= 0.94) {
tmp = Math.cos(re);
} else if (Math.cos(re) <= 0.942) {
tmp = t_0;
} else if (Math.cos(re) <= 0.96) {
tmp = Math.cos(re);
} else if (Math.cos(re) <= 0.965) {
tmp = t_1;
} else if (Math.cos(re) <= 0.97) {
tmp = Math.cos(re);
} else if (Math.cos(re) <= 0.99) {
tmp = t_1;
} else if (Math.cos(re) <= 0.999) {
tmp = Math.cos(re);
} else if (Math.cos(re) <= 0.9995) {
tmp = t_0;
} else if (Math.cos(re) <= 1.0) {
tmp = Math.cos(re);
} else {
tmp = t_1;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.pow(im, 2.0) t_1 = 0.5 * (math.exp(-im) + math.exp(im)) tmp = 0 if math.cos(re) <= 0.5: tmp = math.cos(re) elif math.cos(re) <= 0.68: tmp = t_1 elif math.cos(re) <= 0.72: tmp = math.cos(re) elif math.cos(re) <= 0.73: tmp = t_0 elif math.cos(re) <= 0.765: tmp = math.cos(re) elif math.cos(re) <= 0.82: tmp = t_1 elif math.cos(re) <= 0.826: tmp = math.cos(re) elif math.cos(re) <= 0.88: tmp = t_1 elif math.cos(re) <= 0.9: tmp = math.cos(re) elif math.cos(re) <= 0.91: tmp = t_1 elif math.cos(re) <= 0.912: tmp = math.cos(re) elif math.cos(re) <= 0.92: tmp = t_1 elif math.cos(re) <= 0.94: tmp = math.cos(re) elif math.cos(re) <= 0.942: tmp = t_0 elif math.cos(re) <= 0.96: tmp = math.cos(re) elif math.cos(re) <= 0.965: tmp = t_1 elif math.cos(re) <= 0.97: tmp = math.cos(re) elif math.cos(re) <= 0.99: tmp = t_1 elif math.cos(re) <= 0.999: tmp = math.cos(re) elif math.cos(re) <= 0.9995: tmp = t_0 elif math.cos(re) <= 1.0: tmp = math.cos(re) else: tmp = t_1 return tmp
function code(re, im) t_0 = Float64(0.5 * (im ^ 2.0)) t_1 = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (cos(re) <= 0.5) tmp = cos(re); elseif (cos(re) <= 0.68) tmp = t_1; elseif (cos(re) <= 0.72) tmp = cos(re); elseif (cos(re) <= 0.73) tmp = t_0; elseif (cos(re) <= 0.765) tmp = cos(re); elseif (cos(re) <= 0.82) tmp = t_1; elseif (cos(re) <= 0.826) tmp = cos(re); elseif (cos(re) <= 0.88) tmp = t_1; elseif (cos(re) <= 0.9) tmp = cos(re); elseif (cos(re) <= 0.91) tmp = t_1; elseif (cos(re) <= 0.912) tmp = cos(re); elseif (cos(re) <= 0.92) tmp = t_1; elseif (cos(re) <= 0.94) tmp = cos(re); elseif (cos(re) <= 0.942) tmp = t_0; elseif (cos(re) <= 0.96) tmp = cos(re); elseif (cos(re) <= 0.965) tmp = t_1; elseif (cos(re) <= 0.97) tmp = cos(re); elseif (cos(re) <= 0.99) tmp = t_1; elseif (cos(re) <= 0.999) tmp = cos(re); elseif (cos(re) <= 0.9995) tmp = t_0; elseif (cos(re) <= 1.0) tmp = cos(re); else tmp = t_1; end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (im ^ 2.0); t_1 = 0.5 * (exp(-im) + exp(im)); tmp = 0.0; if (cos(re) <= 0.5) tmp = cos(re); elseif (cos(re) <= 0.68) tmp = t_1; elseif (cos(re) <= 0.72) tmp = cos(re); elseif (cos(re) <= 0.73) tmp = t_0; elseif (cos(re) <= 0.765) tmp = cos(re); elseif (cos(re) <= 0.82) tmp = t_1; elseif (cos(re) <= 0.826) tmp = cos(re); elseif (cos(re) <= 0.88) tmp = t_1; elseif (cos(re) <= 0.9) tmp = cos(re); elseif (cos(re) <= 0.91) tmp = t_1; elseif (cos(re) <= 0.912) tmp = cos(re); elseif (cos(re) <= 0.92) tmp = t_1; elseif (cos(re) <= 0.94) tmp = cos(re); elseif (cos(re) <= 0.942) tmp = t_0; elseif (cos(re) <= 0.96) tmp = cos(re); elseif (cos(re) <= 0.965) tmp = t_1; elseif (cos(re) <= 0.97) tmp = cos(re); elseif (cos(re) <= 0.99) tmp = t_1; elseif (cos(re) <= 0.999) tmp = cos(re); elseif (cos(re) <= 0.9995) tmp = t_0; elseif (cos(re) <= 1.0) tmp = cos(re); else tmp = t_1; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[re], $MachinePrecision], 0.5], N[Cos[re], $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.68], t$95$1, If[LessEqual[N[Cos[re], $MachinePrecision], 0.72], N[Cos[re], $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.73], t$95$0, If[LessEqual[N[Cos[re], $MachinePrecision], 0.765], N[Cos[re], $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.82], t$95$1, If[LessEqual[N[Cos[re], $MachinePrecision], 0.826], N[Cos[re], $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.88], t$95$1, If[LessEqual[N[Cos[re], $MachinePrecision], 0.9], N[Cos[re], $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.91], t$95$1, If[LessEqual[N[Cos[re], $MachinePrecision], 0.912], N[Cos[re], $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.92], t$95$1, If[LessEqual[N[Cos[re], $MachinePrecision], 0.94], N[Cos[re], $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.942], t$95$0, If[LessEqual[N[Cos[re], $MachinePrecision], 0.96], N[Cos[re], $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.965], t$95$1, If[LessEqual[N[Cos[re], $MachinePrecision], 0.97], N[Cos[re], $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.99], t$95$1, If[LessEqual[N[Cos[re], $MachinePrecision], 0.999], N[Cos[re], $MachinePrecision], If[LessEqual[N[Cos[re], $MachinePrecision], 0.9995], t$95$0, If[LessEqual[N[Cos[re], $MachinePrecision], 1.0], N[Cos[re], $MachinePrecision], t$95$1]]]]]]]]]]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot {im}^{2}\\
t_1 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;\cos re \leq 0.5:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;\cos re \leq 0.68:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\cos re \leq 0.72:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;\cos re \leq 0.73:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\cos re \leq 0.765:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;\cos re \leq 0.82:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\cos re \leq 0.826:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;\cos re \leq 0.88:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\cos re \leq 0.9:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;\cos re \leq 0.91:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\cos re \leq 0.912:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;\cos re \leq 0.92:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\cos re \leq 0.94:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;\cos re \leq 0.942:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\cos re \leq 0.96:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;\cos re \leq 0.965:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\cos re \leq 0.97:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;\cos re \leq 0.99:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\cos re \leq 0.999:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;\cos re \leq 0.9995:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\cos re \leq 1:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (cos.f64 re) < 0.5 or 0.680000000000000049 < (cos.f64 re) < 0.71999999999999997 or 0.72999999999999998 < (cos.f64 re) < 0.765000000000000013 or 0.819999999999999951 < (cos.f64 re) < 0.825999999999999956 or 0.880000000000000004 < (cos.f64 re) < 0.900000000000000022 or 0.910000000000000031 < (cos.f64 re) < 0.912000000000000033 or 0.92000000000000004 < (cos.f64 re) < 0.93999999999999995 or 0.94199999999999995 < (cos.f64 re) < 0.95999999999999996 or 0.964999999999999969 < (cos.f64 re) < 0.96999999999999997 or 0.98999999999999999 < (cos.f64 re) < 0.998999999999999999 or 0.99950000000000006 < (cos.f64 re) < 1Initial program 100.0%
Taylor expanded in im around 0 55.9%
if 0.5 < (cos.f64 re) < 0.680000000000000049 or 0.765000000000000013 < (cos.f64 re) < 0.819999999999999951 or 0.825999999999999956 < (cos.f64 re) < 0.880000000000000004 or 0.900000000000000022 < (cos.f64 re) < 0.910000000000000031 or 0.912000000000000033 < (cos.f64 re) < 0.92000000000000004 or 0.95999999999999996 < (cos.f64 re) < 0.964999999999999969 or 0.96999999999999997 < (cos.f64 re) < 0.98999999999999999 or 1 < (cos.f64 re) Initial program 100.0%
Taylor expanded in re around 0 89.4%
if 0.71999999999999997 < (cos.f64 re) < 0.72999999999999998 or 0.93999999999999995 < (cos.f64 re) < 0.94199999999999995 or 0.998999999999999999 < (cos.f64 re) < 0.99950000000000006Initial program 100.0%
Taylor expanded in im around 0 100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around 0 100.0%
Final simplification59.4%
(FPCore (re im) :precision binary64 (if (<= (cos re) 1.0) (* (cos re) (+ 1.0 (* 0.5 (pow im 2.0)))) (* 0.5 (+ (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if (cos(re) <= 1.0) {
tmp = cos(re) * (1.0 + (0.5 * pow(im, 2.0)));
} else {
tmp = 0.5 * (exp(-im) + exp(im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (cos(re) <= 1.0d0) then
tmp = cos(re) * (1.0d0 + (0.5d0 * (im ** 2.0d0)))
else
tmp = 0.5d0 * (exp(-im) + exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.cos(re) <= 1.0) {
tmp = Math.cos(re) * (1.0 + (0.5 * Math.pow(im, 2.0)));
} else {
tmp = 0.5 * (Math.exp(-im) + Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if math.cos(re) <= 1.0: tmp = math.cos(re) * (1.0 + (0.5 * math.pow(im, 2.0))) else: tmp = 0.5 * (math.exp(-im) + math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (cos(re) <= 1.0) tmp = Float64(cos(re) * Float64(1.0 + Float64(0.5 * (im ^ 2.0)))); else tmp = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (cos(re) <= 1.0) tmp = cos(re) * (1.0 + (0.5 * (im ^ 2.0))); else tmp = 0.5 * (exp(-im) + exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], 1.0], N[(N[Cos[re], $MachinePrecision] * N[(1.0 + N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq 1:\\
\;\;\;\;\cos re \cdot \left(1 + 0.5 \cdot {im}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\end{array}
\end{array}
if (cos.f64 re) < 1Initial program 100.0%
Taylor expanded in im around 0 77.8%
associate-*r*77.8%
distribute-rgt1-in77.8%
Simplified77.8%
if 1 < (cos.f64 re) Initial program 100.0%
Taylor expanded in re around 0 62.5%
Final simplification77.8%
(FPCore (re im)
:precision binary64
(if (<= im 250.0)
(cos re)
(if (or (<= im 2.3e+18)
(and (not (<= im 7.8e+18))
(or (<= im 9.5e+34)
(and (not (<= im 1e+35))
(or (<= im 8.5e+79)
(and (not (<= im 8.6e+79))
(or (<= im 7.2e+130)
(and (not (<= im 7.5e+130))
(or (<= im 1.05e+144)
(and (not (<= im 1.06e+144))
(or (<= im 3.8e+146)
(and (not
(<= im 6.4e+151))
(<=
im
1.4e+154)))))))))))))
(* 0.5 (+ (exp (- im)) (exp im)))
(* (cos re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = cos(re);
} else if ((im <= 2.3e+18) || (!(im <= 7.8e+18) && ((im <= 9.5e+34) || (!(im <= 1e+35) && ((im <= 8.5e+79) || (!(im <= 8.6e+79) && ((im <= 7.2e+130) || (!(im <= 7.5e+130) && ((im <= 1.05e+144) || (!(im <= 1.06e+144) && ((im <= 3.8e+146) || (!(im <= 6.4e+151) && (im <= 1.4e+154))))))))))))) {
tmp = 0.5 * (exp(-im) + exp(im));
} else {
tmp = cos(re) * (0.5 * pow(im, 2.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 250.0d0) then
tmp = cos(re)
else if ((im <= 2.3d+18) .or. (.not. (im <= 7.8d+18)) .and. (im <= 9.5d+34) .or. (.not. (im <= 1d+35)) .and. (im <= 8.5d+79) .or. (.not. (im <= 8.6d+79)) .and. (im <= 7.2d+130) .or. (.not. (im <= 7.5d+130)) .and. (im <= 1.05d+144) .or. (.not. (im <= 1.06d+144)) .and. (im <= 3.8d+146) .or. (.not. (im <= 6.4d+151)) .and. (im <= 1.4d+154)) then
tmp = 0.5d0 * (exp(-im) + exp(im))
else
tmp = cos(re) * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 250.0) {
tmp = Math.cos(re);
} else if ((im <= 2.3e+18) || (!(im <= 7.8e+18) && ((im <= 9.5e+34) || (!(im <= 1e+35) && ((im <= 8.5e+79) || (!(im <= 8.6e+79) && ((im <= 7.2e+130) || (!(im <= 7.5e+130) && ((im <= 1.05e+144) || (!(im <= 1.06e+144) && ((im <= 3.8e+146) || (!(im <= 6.4e+151) && (im <= 1.4e+154))))))))))))) {
tmp = 0.5 * (Math.exp(-im) + Math.exp(im));
} else {
tmp = Math.cos(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 250.0: tmp = math.cos(re) elif (im <= 2.3e+18) or (not (im <= 7.8e+18) and ((im <= 9.5e+34) or (not (im <= 1e+35) and ((im <= 8.5e+79) or (not (im <= 8.6e+79) and ((im <= 7.2e+130) or (not (im <= 7.5e+130) and ((im <= 1.05e+144) or (not (im <= 1.06e+144) and ((im <= 3.8e+146) or (not (im <= 6.4e+151) and (im <= 1.4e+154)))))))))))): tmp = 0.5 * (math.exp(-im) + math.exp(im)) else: tmp = math.cos(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 250.0) tmp = cos(re); elseif ((im <= 2.3e+18) || (!(im <= 7.8e+18) && ((im <= 9.5e+34) || (!(im <= 1e+35) && ((im <= 8.5e+79) || (!(im <= 8.6e+79) && ((im <= 7.2e+130) || (!(im <= 7.5e+130) && ((im <= 1.05e+144) || (!(im <= 1.06e+144) && ((im <= 3.8e+146) || (!(im <= 6.4e+151) && (im <= 1.4e+154))))))))))))) tmp = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(cos(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 250.0) tmp = cos(re); elseif ((im <= 2.3e+18) || (~((im <= 7.8e+18)) && ((im <= 9.5e+34) || (~((im <= 1e+35)) && ((im <= 8.5e+79) || (~((im <= 8.6e+79)) && ((im <= 7.2e+130) || (~((im <= 7.5e+130)) && ((im <= 1.05e+144) || (~((im <= 1.06e+144)) && ((im <= 3.8e+146) || (~((im <= 6.4e+151)) && (im <= 1.4e+154))))))))))))) tmp = 0.5 * (exp(-im) + exp(im)); else tmp = cos(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 250.0], N[Cos[re], $MachinePrecision], If[Or[LessEqual[im, 2.3e+18], And[N[Not[LessEqual[im, 7.8e+18]], $MachinePrecision], Or[LessEqual[im, 9.5e+34], And[N[Not[LessEqual[im, 1e+35]], $MachinePrecision], Or[LessEqual[im, 8.5e+79], And[N[Not[LessEqual[im, 8.6e+79]], $MachinePrecision], Or[LessEqual[im, 7.2e+130], And[N[Not[LessEqual[im, 7.5e+130]], $MachinePrecision], Or[LessEqual[im, 1.05e+144], And[N[Not[LessEqual[im, 1.06e+144]], $MachinePrecision], Or[LessEqual[im, 3.8e+146], And[N[Not[LessEqual[im, 6.4e+151]], $MachinePrecision], LessEqual[im, 1.4e+154]]]]]]]]]]]]], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 250:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.3 \cdot 10^{+18} \lor \neg \left(im \leq 7.8 \cdot 10^{+18}\right) \land \left(im \leq 9.5 \cdot 10^{+34} \lor \neg \left(im \leq 10^{+35}\right) \land \left(im \leq 8.5 \cdot 10^{+79} \lor \neg \left(im \leq 8.6 \cdot 10^{+79}\right) \land \left(im \leq 7.2 \cdot 10^{+130} \lor \neg \left(im \leq 7.5 \cdot 10^{+130}\right) \land \left(im \leq 1.05 \cdot 10^{+144} \lor \neg \left(im \leq 1.06 \cdot 10^{+144}\right) \land \left(im \leq 3.8 \cdot 10^{+146} \lor \neg \left(im \leq 6.4 \cdot 10^{+151}\right) \land im \leq 1.4 \cdot 10^{+154}\right)\right)\right)\right)\right):\\
\;\;\;\;0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 250Initial program 100.0%
Taylor expanded in im around 0 67.1%
if 250 < im < 2.3e18 or 7.8e18 < im < 9.4999999999999999e34 or 9.9999999999999997e34 < im < 8.4999999999999998e79 or 8.6000000000000006e79 < im < 7.2000000000000002e130 or 7.5000000000000003e130 < im < 1.04999999999999998e144 or 1.06e144 < im < 3.79999999999999979e146 or 6.39999999999999988e151 < im < 1.4e154Initial program 100.0%
Taylor expanded in re around 0 100.0%
if 2.3e18 < im < 7.8e18 or 9.4999999999999999e34 < im < 9.9999999999999997e34 or 8.4999999999999998e79 < im < 8.6000000000000006e79 or 7.2000000000000002e130 < im < 7.5000000000000003e130 or 1.04999999999999998e144 < im < 1.06e144 or 3.79999999999999979e146 < im < 6.39999999999999988e151 or 1.4e154 < im Initial program 100.0%
Taylor expanded in im around 0 84.2%
associate-*r*84.2%
distribute-rgt1-in84.2%
Simplified84.2%
Taylor expanded in im around inf 84.2%
associate-*r*84.2%
*-commutative84.2%
Simplified84.2%
Final simplification72.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (pow im 2.0) (* -0.25 (pow re 2.0))))
(t_1 (* 0.5 (+ (exp (- im)) (exp im)))))
(if (<= im 250.0)
(cos re)
(if (<= im 2.3e+18)
t_1
(if (<= im 7.8e+18)
t_0
(if (<= im 9.5e+34)
t_1
(if (<= im 1e+35)
t_0
(if (<= im 8.5e+79)
t_1
(if (<= im 8.6e+79)
t_0
(if (<= im 7.2e+130)
t_1
(if (<= im 7.5e+130)
t_0
(if (<= im 9e+143)
t_1
(if (<= im 1.06e+144)
t_0
(if (<= im 3.8e+146)
t_1
(if (<= im 6.4e+151)
t_0
(if (<= im 1.4e+154)
t_1
(*
(cos re)
(* 0.5 (pow im 2.0)))))))))))))))))))
double code(double re, double im) {
double t_0 = pow(im, 2.0) * (-0.25 * pow(re, 2.0));
double t_1 = 0.5 * (exp(-im) + exp(im));
double tmp;
if (im <= 250.0) {
tmp = cos(re);
} else if (im <= 2.3e+18) {
tmp = t_1;
} else if (im <= 7.8e+18) {
tmp = t_0;
} else if (im <= 9.5e+34) {
tmp = t_1;
} else if (im <= 1e+35) {
tmp = t_0;
} else if (im <= 8.5e+79) {
tmp = t_1;
} else if (im <= 8.6e+79) {
tmp = t_0;
} else if (im <= 7.2e+130) {
tmp = t_1;
} else if (im <= 7.5e+130) {
tmp = t_0;
} else if (im <= 9e+143) {
tmp = t_1;
} else if (im <= 1.06e+144) {
tmp = t_0;
} else if (im <= 3.8e+146) {
tmp = t_1;
} else if (im <= 6.4e+151) {
tmp = t_0;
} else if (im <= 1.4e+154) {
tmp = t_1;
} else {
tmp = cos(re) * (0.5 * pow(im, 2.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (im ** 2.0d0) * ((-0.25d0) * (re ** 2.0d0))
t_1 = 0.5d0 * (exp(-im) + exp(im))
if (im <= 250.0d0) then
tmp = cos(re)
else if (im <= 2.3d+18) then
tmp = t_1
else if (im <= 7.8d+18) then
tmp = t_0
else if (im <= 9.5d+34) then
tmp = t_1
else if (im <= 1d+35) then
tmp = t_0
else if (im <= 8.5d+79) then
tmp = t_1
else if (im <= 8.6d+79) then
tmp = t_0
else if (im <= 7.2d+130) then
tmp = t_1
else if (im <= 7.5d+130) then
tmp = t_0
else if (im <= 9d+143) then
tmp = t_1
else if (im <= 1.06d+144) then
tmp = t_0
else if (im <= 3.8d+146) then
tmp = t_1
else if (im <= 6.4d+151) then
tmp = t_0
else if (im <= 1.4d+154) then
tmp = t_1
else
tmp = cos(re) * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.pow(im, 2.0) * (-0.25 * Math.pow(re, 2.0));
double t_1 = 0.5 * (Math.exp(-im) + Math.exp(im));
double tmp;
if (im <= 250.0) {
tmp = Math.cos(re);
} else if (im <= 2.3e+18) {
tmp = t_1;
} else if (im <= 7.8e+18) {
tmp = t_0;
} else if (im <= 9.5e+34) {
tmp = t_1;
} else if (im <= 1e+35) {
tmp = t_0;
} else if (im <= 8.5e+79) {
tmp = t_1;
} else if (im <= 8.6e+79) {
tmp = t_0;
} else if (im <= 7.2e+130) {
tmp = t_1;
} else if (im <= 7.5e+130) {
tmp = t_0;
} else if (im <= 9e+143) {
tmp = t_1;
} else if (im <= 1.06e+144) {
tmp = t_0;
} else if (im <= 3.8e+146) {
tmp = t_1;
} else if (im <= 6.4e+151) {
tmp = t_0;
} else if (im <= 1.4e+154) {
tmp = t_1;
} else {
tmp = Math.cos(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): t_0 = math.pow(im, 2.0) * (-0.25 * math.pow(re, 2.0)) t_1 = 0.5 * (math.exp(-im) + math.exp(im)) tmp = 0 if im <= 250.0: tmp = math.cos(re) elif im <= 2.3e+18: tmp = t_1 elif im <= 7.8e+18: tmp = t_0 elif im <= 9.5e+34: tmp = t_1 elif im <= 1e+35: tmp = t_0 elif im <= 8.5e+79: tmp = t_1 elif im <= 8.6e+79: tmp = t_0 elif im <= 7.2e+130: tmp = t_1 elif im <= 7.5e+130: tmp = t_0 elif im <= 9e+143: tmp = t_1 elif im <= 1.06e+144: tmp = t_0 elif im <= 3.8e+146: tmp = t_1 elif im <= 6.4e+151: tmp = t_0 elif im <= 1.4e+154: tmp = t_1 else: tmp = math.cos(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) t_0 = Float64((im ^ 2.0) * Float64(-0.25 * (re ^ 2.0))) t_1 = Float64(0.5 * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (im <= 250.0) tmp = cos(re); elseif (im <= 2.3e+18) tmp = t_1; elseif (im <= 7.8e+18) tmp = t_0; elseif (im <= 9.5e+34) tmp = t_1; elseif (im <= 1e+35) tmp = t_0; elseif (im <= 8.5e+79) tmp = t_1; elseif (im <= 8.6e+79) tmp = t_0; elseif (im <= 7.2e+130) tmp = t_1; elseif (im <= 7.5e+130) tmp = t_0; elseif (im <= 9e+143) tmp = t_1; elseif (im <= 1.06e+144) tmp = t_0; elseif (im <= 3.8e+146) tmp = t_1; elseif (im <= 6.4e+151) tmp = t_0; elseif (im <= 1.4e+154) tmp = t_1; else tmp = Float64(cos(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) t_0 = (im ^ 2.0) * (-0.25 * (re ^ 2.0)); t_1 = 0.5 * (exp(-im) + exp(im)); tmp = 0.0; if (im <= 250.0) tmp = cos(re); elseif (im <= 2.3e+18) tmp = t_1; elseif (im <= 7.8e+18) tmp = t_0; elseif (im <= 9.5e+34) tmp = t_1; elseif (im <= 1e+35) tmp = t_0; elseif (im <= 8.5e+79) tmp = t_1; elseif (im <= 8.6e+79) tmp = t_0; elseif (im <= 7.2e+130) tmp = t_1; elseif (im <= 7.5e+130) tmp = t_0; elseif (im <= 9e+143) tmp = t_1; elseif (im <= 1.06e+144) tmp = t_0; elseif (im <= 3.8e+146) tmp = t_1; elseif (im <= 6.4e+151) tmp = t_0; elseif (im <= 1.4e+154) tmp = t_1; else tmp = cos(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Power[im, 2.0], $MachinePrecision] * N[(-0.25 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 250.0], N[Cos[re], $MachinePrecision], If[LessEqual[im, 2.3e+18], t$95$1, If[LessEqual[im, 7.8e+18], t$95$0, If[LessEqual[im, 9.5e+34], t$95$1, If[LessEqual[im, 1e+35], t$95$0, If[LessEqual[im, 8.5e+79], t$95$1, If[LessEqual[im, 8.6e+79], t$95$0, If[LessEqual[im, 7.2e+130], t$95$1, If[LessEqual[im, 7.5e+130], t$95$0, If[LessEqual[im, 9e+143], t$95$1, If[LessEqual[im, 1.06e+144], t$95$0, If[LessEqual[im, 3.8e+146], t$95$1, If[LessEqual[im, 6.4e+151], t$95$0, If[LessEqual[im, 1.4e+154], t$95$1, N[(N[Cos[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {im}^{2} \cdot \left(-0.25 \cdot {re}^{2}\right)\\
t_1 := 0.5 \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;im \leq 250:\\
\;\;\;\;\cos re\\
\mathbf{elif}\;im \leq 2.3 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;im \leq 7.8 \cdot 10^{+18}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 9.5 \cdot 10^{+34}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;im \leq 10^{+35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 8.5 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;im \leq 8.6 \cdot 10^{+79}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 7.2 \cdot 10^{+130}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;im \leq 7.5 \cdot 10^{+130}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 9 \cdot 10^{+143}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;im \leq 1.06 \cdot 10^{+144}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 3.8 \cdot 10^{+146}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;im \leq 6.4 \cdot 10^{+151}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\cos re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 250Initial program 100.0%
Taylor expanded in im around 0 67.1%
if 250 < im < 2.3e18 or 7.8e18 < im < 9.4999999999999999e34 or 9.9999999999999997e34 < im < 8.4999999999999998e79 or 8.6000000000000006e79 < im < 7.2000000000000002e130 or 7.5000000000000003e130 < im < 8.9999999999999993e143 or 1.06e144 < im < 3.79999999999999979e146 or 6.39999999999999988e151 < im < 1.4e154Initial program 100.0%
Taylor expanded in re around 0 100.0%
if 2.3e18 < im < 7.8e18 or 9.4999999999999999e34 < im < 9.9999999999999997e34 or 8.4999999999999998e79 < im < 8.6000000000000006e79 or 7.2000000000000002e130 < im < 7.5000000000000003e130 or 8.9999999999999993e143 < im < 1.06e144 or 3.79999999999999979e146 < im < 6.39999999999999988e151Initial program 100.0%
Taylor expanded in im around 0 5.4%
associate-*r*5.4%
distribute-rgt1-in5.4%
Simplified5.4%
Taylor expanded in im around inf 5.4%
associate-*r*5.4%
*-commutative5.4%
Simplified5.4%
Taylor expanded in re around 0 84.1%
*-commutative84.1%
associate-*r*84.1%
distribute-rgt-out84.1%
+-commutative84.1%
Simplified84.1%
Taylor expanded in re around inf 84.1%
associate-*r*84.1%
*-commutative84.1%
associate-*r*84.1%
Simplified84.1%
if 1.4e154 < im Initial program 100.0%
Taylor expanded in im around 0 100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification74.7%
(FPCore (re im) :precision binary64 (if (<= (cos re) 0.999) (cos re) (+ 1.0 (* 0.5 (pow im 2.0)))))
double code(double re, double im) {
double tmp;
if (cos(re) <= 0.999) {
tmp = cos(re);
} else {
tmp = 1.0 + (0.5 * pow(im, 2.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (cos(re) <= 0.999d0) then
tmp = cos(re)
else
tmp = 1.0d0 + (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.cos(re) <= 0.999) {
tmp = Math.cos(re);
} else {
tmp = 1.0 + (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if math.cos(re) <= 0.999: tmp = math.cos(re) else: tmp = 1.0 + (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (cos(re) <= 0.999) tmp = cos(re); else tmp = Float64(1.0 + Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (cos(re) <= 0.999) tmp = cos(re); else tmp = 1.0 + (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Cos[re], $MachinePrecision], 0.999], N[Cos[re], $MachinePrecision], N[(1.0 + N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos re \leq 0.999:\\
\;\;\;\;\cos re\\
\mathbf{else}:\\
\;\;\;\;1 + 0.5 \cdot {im}^{2}\\
\end{array}
\end{array}
if (cos.f64 re) < 0.998999999999999999Initial program 100.0%
Taylor expanded in im around 0 55.9%
if 0.998999999999999999 < (cos.f64 re) Initial program 100.0%
Taylor expanded in im around 0 71.7%
associate-*r*71.7%
distribute-rgt1-in71.7%
Simplified71.7%
Taylor expanded in re around 0 71.2%
(FPCore (re im) :precision binary64 (cos re))
double code(double re, double im) {
return cos(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = cos(re)
end function
public static double code(double re, double im) {
return Math.cos(re);
}
def code(re, im): return math.cos(re)
function code(re, im) return cos(re) end
function tmp = code(re, im) tmp = cos(re); end
code[re_, im_] := N[Cos[re], $MachinePrecision]
\begin{array}{l}
\\
\cos re
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 51.6%
(FPCore (re im) :precision binary64 1.0)
double code(double re, double im) {
return 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 1.0d0
end function
public static double code(double re, double im) {
return 1.0;
}
def code(re, im): return 1.0
function code(re, im) return 1.0 end
function tmp = code(re, im) tmp = 1.0; end
code[re_, im_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Applied egg-rr26.6%
+-inverses26.6%
+-rgt-identity26.6%
*-inverses26.6%
Simplified26.6%
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
return 0.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0d0
end function
public static double code(double re, double im) {
return 0.0;
}
def code(re, im): return 0.0
function code(re, im) return 0.0 end
function tmp = code(re, im) tmp = 0.0; end
code[re_, im_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 100.0%
Applied egg-rr2.4%
pow-base-12.4%
metadata-eval2.4%
Simplified2.4%
herbie shell --seed 2024096
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))