
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Initial program 100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.0) (not (<= (exp re) 2.0))) (exp re) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.0) || !(exp(re) <= 2.0)) {
tmp = exp(re);
} else {
tmp = sin(im) * (re + 1.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) <= 0.0d0) .or. (.not. (exp(re) <= 2.0d0))) then
tmp = exp(re)
else
tmp = sin(im) * (re + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 0.0) || !(Math.exp(re) <= 2.0)) {
tmp = Math.exp(re);
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.0) or not (math.exp(re) <= 2.0): tmp = math.exp(re) else: tmp = math.sin(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.0) || !(exp(re) <= 2.0)) tmp = exp(re); else tmp = Float64(sin(im) * Float64(re + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.0) || ~((exp(re) <= 2.0))) tmp = exp(re); else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 2.0]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0 \lor \neg \left(e^{re} \leq 2\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0 or 2 < (exp.f64 re) Initial program 100.0%
add-exp-log76.7%
*-un-lft-identity76.7%
exp-prod76.7%
exp-1-e76.7%
log-prod50.0%
add-log-exp50.0%
Applied egg-rr50.0%
Taylor expanded in re around inf 76.7%
*-un-lft-identity76.7%
e-exp-176.7%
pow-exp76.7%
*-un-lft-identity76.7%
Applied egg-rr76.7%
*-lft-identity76.7%
Simplified76.7%
if 0.0 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 98.4%
distribute-rgt1-in98.4%
Simplified98.4%
Final simplification88.6%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 1.0) (not (<= (exp re) 1.00000005))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 1.0) || !(exp(re) <= 1.00000005)) {
tmp = exp(re) * im;
} else {
tmp = sin(im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) <= 1.0d0) .or. (.not. (exp(re) <= 1.00000005d0))) then
tmp = exp(re) * im
else
tmp = sin(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 1.0) || !(Math.exp(re) <= 1.00000005)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 1.0) or not (math.exp(re) <= 1.00000005): tmp = math.exp(re) * im else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 1.0) || !(exp(re) <= 1.00000005)) tmp = Float64(exp(re) * im); else tmp = sin(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 1.0) || ~((exp(re) <= 1.00000005))) tmp = exp(re) * im; else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.00000005]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1 \lor \neg \left(e^{re} \leq 1.00000005\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 1 or 1.00000004999999992 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 70.3%
if 1 < (exp.f64 re) < 1.00000004999999992Initial program 100.0%
Taylor expanded in re around 0 72.2%
Final simplification70.3%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.0) (not (<= (exp re) 2.0))) (exp re) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.0) || !(exp(re) <= 2.0)) {
tmp = exp(re);
} else {
tmp = sin(im);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) <= 0.0d0) .or. (.not. (exp(re) <= 2.0d0))) then
tmp = exp(re)
else
tmp = sin(im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 0.0) || !(Math.exp(re) <= 2.0)) {
tmp = Math.exp(re);
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.0) or not (math.exp(re) <= 2.0): tmp = math.exp(re) else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.0) || !(exp(re) <= 2.0)) tmp = exp(re); else tmp = sin(im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.0) || ~((exp(re) <= 2.0))) tmp = exp(re); else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 2.0]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0 \lor \neg \left(e^{re} \leq 2\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0 or 2 < (exp.f64 re) Initial program 100.0%
add-exp-log76.7%
*-un-lft-identity76.7%
exp-prod76.7%
exp-1-e76.7%
log-prod50.0%
add-log-exp50.0%
Applied egg-rr50.0%
Taylor expanded in re around inf 76.7%
*-un-lft-identity76.7%
e-exp-176.7%
pow-exp76.7%
*-un-lft-identity76.7%
Applied egg-rr76.7%
*-lft-identity76.7%
Simplified76.7%
if 0.0 < (exp.f64 re) < 2Initial program 100.0%
Taylor expanded in re around 0 97.0%
Final simplification87.8%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 0.999998) (not (<= (exp re) 1.005))) (exp re) (* im (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 0.999998) || !(exp(re) <= 1.005)) {
tmp = exp(re);
} else {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((exp(re) <= 0.999998d0) .or. (.not. (exp(re) <= 1.005d0))) then
tmp = exp(re)
else
tmp = im * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((Math.exp(re) <= 0.999998) || !(Math.exp(re) <= 1.005)) {
tmp = Math.exp(re);
} else {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 0.999998) or not (math.exp(re) <= 1.005): tmp = math.exp(re) else: tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 0.999998) || !(exp(re) <= 1.005)) tmp = exp(re); else tmp = Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((exp(re) <= 0.999998) || ~((exp(re) <= 1.005))) tmp = exp(re); else tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 0.999998], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 1.005]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0.999998 \lor \neg \left(e^{re} \leq 1.005\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if (exp.f64 re) < 0.999998000000000054 or 1.0049999999999999 < (exp.f64 re) Initial program 100.0%
add-exp-log77.3%
*-un-lft-identity77.3%
exp-prod77.3%
exp-1-e77.3%
log-prod51.2%
add-log-exp51.2%
Applied egg-rr51.2%
Taylor expanded in re around inf 75.3%
*-un-lft-identity75.3%
e-exp-175.3%
pow-exp75.3%
*-un-lft-identity75.3%
Applied egg-rr75.3%
*-lft-identity75.3%
Simplified75.3%
if 0.999998000000000054 < (exp.f64 re) < 1.0049999999999999Initial program 100.0%
Taylor expanded in re around 0 99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in im around 0 52.0%
Final simplification62.8%
(FPCore (re im)
:precision binary64
(if (or (<= re -1.6) (and (not (<= re 140.0)) (<= re 1.02e+103)))
(exp re)
(*
(sin im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if ((re <= -1.6) || (!(re <= 140.0) && (re <= 1.02e+103))) {
tmp = exp(re);
} else {
tmp = sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-1.6d0)) .or. (.not. (re <= 140.0d0)) .and. (re <= 1.02d+103)) then
tmp = exp(re)
else
tmp = sin(im) * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -1.6) || (!(re <= 140.0) && (re <= 1.02e+103))) {
tmp = Math.exp(re);
} else {
tmp = Math.sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -1.6) or (not (re <= 140.0) and (re <= 1.02e+103)): tmp = math.exp(re) else: tmp = math.sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -1.6) || (!(re <= 140.0) && (re <= 1.02e+103))) tmp = exp(re); else tmp = Float64(sin(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -1.6) || (~((re <= 140.0)) && (re <= 1.02e+103))) tmp = exp(re); else tmp = sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -1.6], And[N[Not[LessEqual[re, 140.0]], $MachinePrecision], LessEqual[re, 1.02e+103]]], N[Exp[re], $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.6 \lor \neg \left(re \leq 140\right) \land re \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if re < -1.6000000000000001 or 140 < re < 1.01999999999999991e103Initial program 100.0%
add-exp-log93.3%
*-un-lft-identity93.3%
exp-prod93.3%
exp-1-e93.3%
log-prod52.0%
add-log-exp52.0%
Applied egg-rr52.0%
Taylor expanded in re around inf 93.3%
*-un-lft-identity93.3%
e-exp-193.3%
pow-exp93.3%
*-un-lft-identity93.3%
Applied egg-rr93.3%
*-lft-identity93.3%
Simplified93.3%
if -1.6000000000000001 < re < 140 or 1.01999999999999991e103 < re Initial program 100.0%
Taylor expanded in re around 0 98.9%
*-commutative98.9%
Simplified98.9%
Final simplification97.3%
(FPCore (re im) :precision binary64 (if (or (<= re -80.0) (not (<= re 205.0))) (exp re) (* (sin im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if ((re <= -80.0) || !(re <= 205.0)) {
tmp = exp(re);
} else {
tmp = sin(im) * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-80.0d0)) .or. (.not. (re <= 205.0d0))) then
tmp = exp(re)
else
tmp = sin(im) * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -80.0) || !(re <= 205.0)) {
tmp = Math.exp(re);
} else {
tmp = Math.sin(im) * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -80.0) or not (re <= 205.0): tmp = math.exp(re) else: tmp = math.sin(im) * (1.0 + (re * (1.0 + (re * 0.5)))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -80.0) || !(re <= 205.0)) tmp = exp(re); else tmp = Float64(sin(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -80.0) || ~((re <= 205.0))) tmp = exp(re); else tmp = sin(im) * (1.0 + (re * (1.0 + (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -80.0], N[Not[LessEqual[re, 205.0]], $MachinePrecision]], N[Exp[re], $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -80 \lor \neg \left(re \leq 205\right):\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -80 or 205 < re Initial program 100.0%
add-exp-log77.4%
*-un-lft-identity77.4%
exp-prod77.4%
exp-1-e77.4%
log-prod50.4%
add-log-exp50.4%
Applied egg-rr50.4%
Taylor expanded in re around inf 77.4%
*-un-lft-identity77.4%
e-exp-177.4%
pow-exp77.4%
*-un-lft-identity77.4%
Applied egg-rr77.4%
*-lft-identity77.4%
Simplified77.4%
if -80 < re < 205Initial program 100.0%
Taylor expanded in re around 0 98.4%
*-commutative98.4%
Simplified98.4%
Final simplification88.9%
(FPCore (re im) :precision binary64 (* im (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666))))))))
double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
end function
public static double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
def code(re, im): return im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))))
function code(re, im) return Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))) end
function tmp = code(re, im) tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end
code[re_, im_] := N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 70.6%
*-commutative70.6%
Simplified70.6%
Taylor expanded in im around 0 42.9%
Final simplification42.9%
(FPCore (re im) :precision binary64 (if (<= re 1.3e+86) (* im (+ re 1.0)) (+ 1.0 (* re (+ 1.0 (/ re 2.0))))))
double code(double re, double im) {
double tmp;
if (re <= 1.3e+86) {
tmp = im * (re + 1.0);
} else {
tmp = 1.0 + (re * (1.0 + (re / 2.0)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.3d+86) then
tmp = im * (re + 1.0d0)
else
tmp = 1.0d0 + (re * (1.0d0 + (re / 2.0d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.3e+86) {
tmp = im * (re + 1.0);
} else {
tmp = 1.0 + (re * (1.0 + (re / 2.0)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.3e+86: tmp = im * (re + 1.0) else: tmp = 1.0 + (re * (1.0 + (re / 2.0))) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.3e+86) tmp = Float64(im * Float64(re + 1.0)); else tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(re / 2.0)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.3e+86) tmp = im * (re + 1.0); else tmp = 1.0 + (re * (1.0 + (re / 2.0))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.3e+86], N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(re / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.3 \cdot 10^{+86}:\\
\;\;\;\;im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + \frac{re}{2}\right)\\
\end{array}
\end{array}
if re < 1.2999999999999999e86Initial program 100.0%
Taylor expanded in re around 0 65.1%
distribute-rgt1-in65.1%
Simplified65.1%
Taylor expanded in im around 0 34.4%
if 1.2999999999999999e86 < re Initial program 100.0%
add-exp-log48.8%
*-un-lft-identity48.8%
exp-prod48.8%
exp-1-e48.8%
log-prod48.8%
add-log-exp48.8%
Applied egg-rr48.8%
Taylor expanded in re around inf 48.8%
Taylor expanded in re around 0 39.8%
log-E39.8%
associate-*r*39.8%
log-E39.8%
metadata-eval39.8%
associate-*r*39.8%
Simplified39.8%
metadata-eval39.8%
*-rgt-identity39.8%
associate-/r/39.8%
clear-num39.8%
Applied egg-rr39.8%
Final simplification35.2%
(FPCore (re im) :precision binary64 (* im (+ 1.0 (* re (+ 1.0 (* re 0.5))))))
double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * 0.5))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
end function
public static double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * 0.5))));
}
def code(re, im): return im * (1.0 + (re * (1.0 + (re * 0.5))))
function code(re, im) return Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))) end
function tmp = code(re, im) tmp = im * (1.0 + (re * (1.0 + (re * 0.5)))); end
code[re_, im_] := N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 63.6%
*-commutative63.6%
*-commutative63.6%
Simplified63.6%
Taylor expanded in im around 0 41.4%
*-commutative41.4%
Simplified41.4%
(FPCore (re im) :precision binary64 (if (<= im 420.0) im (+ re 1.0)))
double code(double re, double im) {
double tmp;
if (im <= 420.0) {
tmp = im;
} else {
tmp = re + 1.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 420.0d0) then
tmp = im
else
tmp = re + 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 420.0) {
tmp = im;
} else {
tmp = re + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 420.0: tmp = im else: tmp = re + 1.0 return tmp
function code(re, im) tmp = 0.0 if (im <= 420.0) tmp = im; else tmp = Float64(re + 1.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 420.0) tmp = im; else tmp = re + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 420.0], im, N[(re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 420:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re + 1\\
\end{array}
\end{array}
if im < 420Initial program 100.0%
Taylor expanded in re around 0 52.3%
Taylor expanded in im around 0 35.3%
if 420 < im Initial program 100.0%
add-exp-log62.1%
*-un-lft-identity62.1%
exp-prod62.1%
exp-1-e62.1%
log-prod52.7%
add-log-exp52.7%
Applied egg-rr52.7%
Taylor expanded in re around inf 38.3%
Taylor expanded in re around 0 7.4%
log-E7.4%
*-rgt-identity7.4%
+-commutative7.4%
Simplified7.4%
(FPCore (re im) :precision binary64 (if (<= im 1.0) im 1.0))
double code(double re, double im) {
double tmp;
if (im <= 1.0) {
tmp = im;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.0d0) then
tmp = im
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.0) {
tmp = im;
} else {
tmp = 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.0: tmp = im else: tmp = 1.0 return tmp
function code(re, im) tmp = 0.0 if (im <= 1.0) tmp = im; else tmp = 1.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.0) tmp = im; else tmp = 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.0], im, 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if im < 1Initial program 100.0%
Taylor expanded in re around 0 52.3%
Taylor expanded in im around 0 35.3%
if 1 < im Initial program 100.0%
add-exp-log62.1%
*-un-lft-identity62.1%
exp-prod62.1%
exp-1-e62.1%
log-prod52.7%
add-log-exp52.7%
Applied egg-rr52.7%
Taylor expanded in re around inf 38.3%
*-un-lft-identity38.3%
e-exp-138.3%
pow-exp38.3%
*-un-lft-identity38.3%
Applied egg-rr38.3%
*-lft-identity38.3%
Simplified38.3%
Taylor expanded in re around 0 7.2%
(FPCore (re im) :precision binary64 (* im (+ re 1.0)))
double code(double re, double im) {
return im * (re + 1.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (re + 1.0d0)
end function
public static double code(double re, double im) {
return im * (re + 1.0);
}
def code(re, im): return im * (re + 1.0)
function code(re, im) return Float64(im * Float64(re + 1.0)) end
function tmp = code(re, im) tmp = im * (re + 1.0); end
code[re_, im_] := N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(re + 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 55.5%
distribute-rgt1-in55.5%
Simplified55.5%
Taylor expanded in im around 0 31.0%
Final simplification31.0%
(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%
add-exp-log60.2%
*-un-lft-identity60.2%
exp-prod60.2%
exp-1-e60.2%
log-prod48.1%
add-log-exp48.1%
Applied egg-rr48.1%
Taylor expanded in re around inf 38.8%
*-un-lft-identity38.8%
e-exp-138.8%
pow-exp38.8%
*-un-lft-identity38.8%
Applied egg-rr38.8%
*-lft-identity38.8%
Simplified38.8%
Taylor expanded in re around 0 5.2%
herbie shell --seed 2024180
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))