
(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 13 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%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (or (<= (exp re) 1.0) (not (<= (exp re) 1.000001))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 1.0) || !(exp(re) <= 1.000001)) {
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.000001d0))) 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.000001)) {
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.000001): 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.000001)) 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.000001))) 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.000001]], $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.000001\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 1 or 1.00000099999999992 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 69.4%
if 1 < (exp.f64 re) < 1.00000099999999992Initial program 99.2%
Taylor expanded in re around 0 77.3%
Final simplification69.4%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.027)
t_0
(if (<= re 1.05e-6)
(* (sin im) (+ (+ re 1.0) (* re (* re 0.5))))
(if (<= re 6.2e+100)
t_0
(*
(sin im)
(+ (+ re 1.0) (* (* re re) (+ 0.5 (* re 0.16666666666666666))))))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -0.027) {
tmp = t_0;
} else if (re <= 1.05e-6) {
tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 6.2e+100) {
tmp = t_0;
} else {
tmp = sin(im) * ((re + 1.0) + ((re * 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) :: t_0
real(8) :: tmp
t_0 = exp(re) * im
if (re <= (-0.027d0)) then
tmp = t_0
else if (re <= 1.05d-6) then
tmp = sin(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
else if (re <= 6.2d+100) then
tmp = t_0
else
tmp = sin(im) * ((re + 1.0d0) + ((re * re) * (0.5d0 + (re * 0.16666666666666666d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * im;
double tmp;
if (re <= -0.027) {
tmp = t_0;
} else if (re <= 1.05e-6) {
tmp = Math.sin(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 6.2e+100) {
tmp = t_0;
} else {
tmp = Math.sin(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666))));
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -0.027: tmp = t_0 elif re <= 1.05e-6: tmp = math.sin(im) * ((re + 1.0) + (re * (re * 0.5))) elif re <= 6.2e+100: tmp = t_0 else: tmp = math.sin(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666)))) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -0.027) tmp = t_0; elseif (re <= 1.05e-6) tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); elseif (re <= 6.2e+100) tmp = t_0; else tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(Float64(re * re) * Float64(0.5 + Float64(re * 0.16666666666666666))))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -0.027) tmp = t_0; elseif (re <= 1.05e-6) tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5))); elseif (re <= 6.2e+100) tmp = t_0; else tmp = sin(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666)))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -0.027], t$95$0, If[LessEqual[re, 1.05e-6], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 6.2e+100], t$95$0, N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -0.027:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 1.05 \cdot 10^{-6}:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\mathbf{elif}\;re \leq 6.2 \cdot 10^{+100}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if re < -0.0269999999999999997 or 1.0499999999999999e-6 < re < 6.20000000000000014e100Initial program 100.0%
Taylor expanded in im around 0 93.7%
if -0.0269999999999999997 < re < 1.0499999999999999e-6Initial program 100.0%
Taylor expanded in re around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft1-in100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
if 6.20000000000000014e100 < re Initial program 100.0%
Taylor expanded in re around 0 98.0%
associate-+r+98.0%
*-commutative98.0%
distribute-rgt1-in98.0%
*-commutative98.0%
+-commutative98.0%
*-commutative98.0%
associate-*r*98.0%
*-commutative98.0%
associate-*r*98.0%
distribute-rgt-out98.0%
distribute-lft-out98.0%
+-commutative98.0%
Simplified98.0%
Final simplification97.7%
(FPCore (re im) :precision binary64 (if (or (<= re -0.0022) (and (not (<= re 1.05e-6)) (<= re 1.9e+154))) (* (exp re) im) (* (sin im) (+ (+ re 1.0) (* re (* re 0.5))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.0022) || (!(re <= 1.05e-6) && (re <= 1.9e+154))) {
tmp = exp(re) * im;
} else {
tmp = sin(im) * ((re + 1.0) + (re * (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 <= (-0.0022d0)) .or. (.not. (re <= 1.05d-6)) .and. (re <= 1.9d+154)) then
tmp = exp(re) * im
else
tmp = sin(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.0022) || (!(re <= 1.05e-6) && (re <= 1.9e+154))) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * ((re + 1.0) + (re * (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.0022) or (not (re <= 1.05e-6) and (re <= 1.9e+154)): tmp = math.exp(re) * im else: tmp = math.sin(im) * ((re + 1.0) + (re * (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.0022) || (!(re <= 1.05e-6) && (re <= 1.9e+154))) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.0022) || (~((re <= 1.05e-6)) && (re <= 1.9e+154))) tmp = exp(re) * im; else tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.0022], And[N[Not[LessEqual[re, 1.05e-6]], $MachinePrecision], LessEqual[re, 1.9e+154]]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0022 \lor \neg \left(re \leq 1.05 \cdot 10^{-6}\right) \land re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.00220000000000000013 or 1.0499999999999999e-6 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 90.1%
if -0.00220000000000000013 < re < 1.0499999999999999e-6 or 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft1-in100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification96.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -3.2e-8)
t_0
(if (<= re 1.05e-6)
(* (sin im) (+ re 1.0))
(if (<= re 5.2e+157) t_0 (* re (* 0.5 (* re (sin im)))))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -3.2e-8) {
tmp = t_0;
} else if (re <= 1.05e-6) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 5.2e+157) {
tmp = t_0;
} else {
tmp = re * (0.5 * (re * sin(im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = exp(re) * im
if (re <= (-3.2d-8)) then
tmp = t_0
else if (re <= 1.05d-6) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 5.2d+157) then
tmp = t_0
else
tmp = re * (0.5d0 * (re * sin(im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * im;
double tmp;
if (re <= -3.2e-8) {
tmp = t_0;
} else if (re <= 1.05e-6) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 5.2e+157) {
tmp = t_0;
} else {
tmp = re * (0.5 * (re * Math.sin(im)));
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -3.2e-8: tmp = t_0 elif re <= 1.05e-6: tmp = math.sin(im) * (re + 1.0) elif re <= 5.2e+157: tmp = t_0 else: tmp = re * (0.5 * (re * math.sin(im))) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -3.2e-8) tmp = t_0; elseif (re <= 1.05e-6) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 5.2e+157) tmp = t_0; else tmp = Float64(re * Float64(0.5 * Float64(re * sin(im)))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -3.2e-8) tmp = t_0; elseif (re <= 1.05e-6) tmp = sin(im) * (re + 1.0); elseif (re <= 5.2e+157) tmp = t_0; else tmp = re * (0.5 * (re * sin(im))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -3.2e-8], t$95$0, If[LessEqual[re, 1.05e-6], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 5.2e+157], t$95$0, N[(re * N[(0.5 * N[(re * N[Sin[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -3.2 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 1.05 \cdot 10^{-6}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 5.2 \cdot 10^{+157}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot \left(re \cdot \sin im\right)\right)\\
\end{array}
\end{array}
if re < -3.2000000000000002e-8 or 1.0499999999999999e-6 < re < 5.20000000000000022e157Initial program 100.0%
Taylor expanded in im around 0 90.3%
if -3.2000000000000002e-8 < re < 1.0499999999999999e-6Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
distribute-rgt1-in100.0%
Simplified100.0%
if 5.20000000000000022e157 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
*-commutative100.0%
distribute-lft1-in100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
unpow2100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
associate-*r*91.6%
*-commutative91.6%
associate-*l*91.6%
Simplified91.6%
Final simplification95.4%
(FPCore (re im) :precision binary64 (if (or (<= re -3.2e-8) (not (<= re 1.05e-6))) (* (exp re) im) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -3.2e-8) || !(re <= 1.05e-6)) {
tmp = exp(re) * im;
} 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 ((re <= (-3.2d-8)) .or. (.not. (re <= 1.05d-6))) then
tmp = exp(re) * im
else
tmp = sin(im) * (re + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -3.2e-8) || !(re <= 1.05e-6)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -3.2e-8) or not (re <= 1.05e-6): tmp = math.exp(re) * im else: tmp = math.sin(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -3.2e-8) || !(re <= 1.05e-6)) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(re + 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -3.2e-8) || ~((re <= 1.05e-6))) tmp = exp(re) * im; else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -3.2e-8], N[Not[LessEqual[re, 1.05e-6]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -3.2 \cdot 10^{-8} \lor \neg \left(re \leq 1.05 \cdot 10^{-6}\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -3.2000000000000002e-8 or 1.0499999999999999e-6 < re Initial program 100.0%
Taylor expanded in im around 0 84.9%
if -3.2000000000000002e-8 < re < 1.0499999999999999e-6Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Final simplification92.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* re re))))
(if (<= re 2.9e-9)
(sin im)
(if (<= re 5e+153)
(+
im
(* im (/ (- (* 0.25 (* (* re re) (* re re))) (* re re)) (- t_0 re))))
(* im t_0)))))
double code(double re, double im) {
double t_0 = 0.5 * (re * re);
double tmp;
if (re <= 2.9e-9) {
tmp = sin(im);
} else if (re <= 5e+153) {
tmp = im + (im * (((0.25 * ((re * re) * (re * re))) - (re * re)) / (t_0 - re)));
} else {
tmp = im * t_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) :: tmp
t_0 = 0.5d0 * (re * re)
if (re <= 2.9d-9) then
tmp = sin(im)
else if (re <= 5d+153) then
tmp = im + (im * (((0.25d0 * ((re * re) * (re * re))) - (re * re)) / (t_0 - re)))
else
tmp = im * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (re * re);
double tmp;
if (re <= 2.9e-9) {
tmp = Math.sin(im);
} else if (re <= 5e+153) {
tmp = im + (im * (((0.25 * ((re * re) * (re * re))) - (re * re)) / (t_0 - re)));
} else {
tmp = im * t_0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (re * re) tmp = 0 if re <= 2.9e-9: tmp = math.sin(im) elif re <= 5e+153: tmp = im + (im * (((0.25 * ((re * re) * (re * re))) - (re * re)) / (t_0 - re))) else: tmp = im * t_0 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(re * re)) tmp = 0.0 if (re <= 2.9e-9) tmp = sin(im); elseif (re <= 5e+153) tmp = Float64(im + Float64(im * Float64(Float64(Float64(0.25 * Float64(Float64(re * re) * Float64(re * re))) - Float64(re * re)) / Float64(t_0 - re)))); else tmp = Float64(im * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (re * re); tmp = 0.0; if (re <= 2.9e-9) tmp = sin(im); elseif (re <= 5e+153) tmp = im + (im * (((0.25 * ((re * re) * (re * re))) - (re * re)) / (t_0 - re))); else tmp = im * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 2.9e-9], N[Sin[im], $MachinePrecision], If[LessEqual[re, 5e+153], N[(im + N[(im * N[(N[(N[(0.25 * N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(re \cdot re\right)\\
\mathbf{if}\;re \leq 2.9 \cdot 10^{-9}:\\
\;\;\;\;\sin im\\
\mathbf{elif}\;re \leq 5 \cdot 10^{+153}:\\
\;\;\;\;im + im \cdot \frac{0.25 \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) - re \cdot re}{t_0 - re}\\
\mathbf{else}:\\
\;\;\;\;im \cdot t_0\\
\end{array}
\end{array}
if re < 2.89999999999999991e-9Initial program 100.0%
Taylor expanded in re around 0 72.4%
if 2.89999999999999991e-9 < re < 5.00000000000000018e153Initial program 100.0%
Taylor expanded in im around 0 76.9%
Taylor expanded in re around 0 18.7%
associate-+r+18.7%
+-commutative18.7%
unpow218.7%
associate-*r*18.7%
*-commutative18.7%
associate-*r*18.7%
distribute-rgt-out18.7%
+-commutative18.7%
associate-*r*18.7%
*-commutative18.7%
fma-def18.7%
Simplified18.7%
fma-udef18.7%
flip-+38.3%
Applied egg-rr38.3%
unpow238.3%
unpow238.3%
swap-sqr38.3%
metadata-eval38.3%
unpow238.3%
unpow238.3%
unpow238.3%
*-commutative38.3%
unpow238.3%
Simplified38.3%
if 5.00000000000000018e153 < re Initial program 100.0%
Taylor expanded in re around 0 97.5%
associate-+r+97.5%
+-commutative97.5%
*-commutative97.5%
distribute-lft1-in97.5%
*-commutative97.5%
associate-*r*97.5%
distribute-rgt-out97.5%
*-commutative97.5%
unpow297.5%
associate-*l*97.5%
Simplified97.5%
Taylor expanded in re around inf 97.5%
unpow297.5%
*-commutative97.5%
associate-*r*97.5%
*-commutative97.5%
associate-*r*97.5%
associate-*r*89.3%
*-commutative89.3%
associate-*l*89.3%
Simplified89.3%
Taylor expanded in im around 0 70.6%
*-commutative70.6%
*-commutative70.6%
associate-*r*70.6%
unpow270.6%
Simplified70.6%
Final simplification66.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* re re))))
(if (<= re 5e+153)
(+
im
(* im (/ (- (* 0.25 (* (* re re) (* re re))) (* re re)) (- t_0 re))))
(* im t_0))))
double code(double re, double im) {
double t_0 = 0.5 * (re * re);
double tmp;
if (re <= 5e+153) {
tmp = im + (im * (((0.25 * ((re * re) * (re * re))) - (re * re)) / (t_0 - re)));
} else {
tmp = im * t_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) :: tmp
t_0 = 0.5d0 * (re * re)
if (re <= 5d+153) then
tmp = im + (im * (((0.25d0 * ((re * re) * (re * re))) - (re * re)) / (t_0 - re)))
else
tmp = im * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (re * re);
double tmp;
if (re <= 5e+153) {
tmp = im + (im * (((0.25 * ((re * re) * (re * re))) - (re * re)) / (t_0 - re)));
} else {
tmp = im * t_0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (re * re) tmp = 0 if re <= 5e+153: tmp = im + (im * (((0.25 * ((re * re) * (re * re))) - (re * re)) / (t_0 - re))) else: tmp = im * t_0 return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(re * re)) tmp = 0.0 if (re <= 5e+153) tmp = Float64(im + Float64(im * Float64(Float64(Float64(0.25 * Float64(Float64(re * re) * Float64(re * re))) - Float64(re * re)) / Float64(t_0 - re)))); else tmp = Float64(im * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (re * re); tmp = 0.0; if (re <= 5e+153) tmp = im + (im * (((0.25 * ((re * re) * (re * re))) - (re * re)) / (t_0 - re))); else tmp = im * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, 5e+153], N[(im + N[(im * N[(N[(N[(0.25 * N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(re \cdot re\right)\\
\mathbf{if}\;re \leq 5 \cdot 10^{+153}:\\
\;\;\;\;im + im \cdot \frac{0.25 \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot re\right)\right) - re \cdot re}{t_0 - re}\\
\mathbf{else}:\\
\;\;\;\;im \cdot t_0\\
\end{array}
\end{array}
if re < 5.00000000000000018e153Initial program 100.0%
Taylor expanded in im around 0 69.0%
Taylor expanded in re around 0 36.2%
associate-+r+36.2%
+-commutative36.2%
unpow236.2%
associate-*r*36.2%
*-commutative36.2%
associate-*r*36.2%
distribute-rgt-out36.3%
+-commutative36.3%
associate-*r*36.3%
*-commutative36.3%
fma-def36.3%
Simplified36.3%
fma-udef36.3%
flip-+39.6%
Applied egg-rr39.6%
unpow239.6%
unpow239.6%
swap-sqr39.6%
metadata-eval39.6%
unpow239.6%
unpow239.6%
unpow239.6%
*-commutative39.6%
unpow239.6%
Simplified39.6%
if 5.00000000000000018e153 < re Initial program 100.0%
Taylor expanded in re around 0 97.5%
associate-+r+97.5%
+-commutative97.5%
*-commutative97.5%
distribute-lft1-in97.5%
*-commutative97.5%
associate-*r*97.5%
distribute-rgt-out97.5%
*-commutative97.5%
unpow297.5%
associate-*l*97.5%
Simplified97.5%
Taylor expanded in re around inf 97.5%
unpow297.5%
*-commutative97.5%
associate-*r*97.5%
*-commutative97.5%
associate-*r*97.5%
associate-*r*89.3%
*-commutative89.3%
associate-*l*89.3%
Simplified89.3%
Taylor expanded in im around 0 70.6%
*-commutative70.6%
*-commutative70.6%
associate-*r*70.6%
unpow270.6%
Simplified70.6%
Final simplification43.7%
(FPCore (re im) :precision binary64 (+ im (* im (+ re (* 0.5 (* re re))))))
double code(double re, double im) {
return im + (im * (re + (0.5 * (re * re))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im + (im * (re + (0.5d0 * (re * re))))
end function
public static double code(double re, double im) {
return im + (im * (re + (0.5 * (re * re))));
}
def code(re, im): return im + (im * (re + (0.5 * (re * re))))
function code(re, im) return Float64(im + Float64(im * Float64(re + Float64(0.5 * Float64(re * re))))) end
function tmp = code(re, im) tmp = im + (im * (re + (0.5 * (re * re)))); end
code[re_, im_] := N[(im + N[(im * N[(re + N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im + im \cdot \left(re + 0.5 \cdot \left(re \cdot re\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 69.2%
Taylor expanded in re around 0 40.8%
associate-+r+40.8%
+-commutative40.8%
unpow240.8%
associate-*r*40.8%
*-commutative40.8%
associate-*r*40.8%
distribute-rgt-out40.9%
+-commutative40.9%
associate-*r*40.9%
*-commutative40.9%
fma-def40.9%
Simplified40.9%
fma-udef40.9%
Applied egg-rr40.9%
Final simplification40.9%
(FPCore (re im) :precision binary64 (if (<= re 2.7) (+ im (* re im)) (* im (* 0.5 (* re re)))))
double code(double re, double im) {
double tmp;
if (re <= 2.7) {
tmp = im + (re * im);
} else {
tmp = im * (0.5 * (re * re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 2.7d0) then
tmp = im + (re * im)
else
tmp = im * (0.5d0 * (re * re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 2.7) {
tmp = im + (re * im);
} else {
tmp = im * (0.5 * (re * re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 2.7: tmp = im + (re * im) else: tmp = im * (0.5 * (re * re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 2.7) tmp = Float64(im + Float64(re * im)); else tmp = Float64(im * Float64(0.5 * Float64(re * re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 2.7) tmp = im + (re * im); else tmp = im * (0.5 * (re * re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 2.7], N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision], N[(im * N[(0.5 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.7:\\
\;\;\;\;im + re \cdot im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if re < 2.7000000000000002Initial program 100.0%
Taylor expanded in im around 0 67.9%
Taylor expanded in re around 0 40.4%
if 2.7000000000000002 < re Initial program 100.0%
Taylor expanded in re around 0 49.5%
associate-+r+49.5%
+-commutative49.5%
*-commutative49.5%
distribute-lft1-in49.5%
*-commutative49.5%
associate-*r*49.5%
distribute-rgt-out49.5%
*-commutative49.5%
unpow249.5%
associate-*l*49.5%
Simplified49.5%
Taylor expanded in re around inf 49.5%
unpow249.5%
*-commutative49.5%
associate-*r*49.5%
*-commutative49.5%
associate-*r*49.5%
associate-*r*45.6%
*-commutative45.6%
associate-*l*45.6%
Simplified45.6%
Taylor expanded in im around 0 41.5%
*-commutative41.5%
*-commutative41.5%
associate-*r*41.5%
unpow241.5%
Simplified41.5%
Final simplification40.7%
(FPCore (re im) :precision binary64 (if (<= re 1.0) im (* re im)))
double code(double re, double im) {
double tmp;
if (re <= 1.0) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.0d0) then
tmp = im
else
tmp = re * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.0) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.0: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= 1.0) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.0) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.0], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < 1Initial program 100.0%
Taylor expanded in im around 0 67.9%
Taylor expanded in re around 0 39.7%
if 1 < re Initial program 100.0%
Taylor expanded in im around 0 72.9%
Taylor expanded in re around 0 15.6%
Taylor expanded in re around inf 15.6%
Final simplification33.1%
(FPCore (re im) :precision binary64 (+ im (* re im)))
double code(double re, double im) {
return im + (re * im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im + (re * im)
end function
public static double code(double re, double im) {
return im + (re * im);
}
def code(re, im): return im + (re * im)
function code(re, im) return Float64(im + Float64(re * im)) end
function tmp = code(re, im) tmp = im + (re * im); end
code[re_, im_] := N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im + re \cdot im
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 69.2%
Taylor expanded in re around 0 33.6%
Final simplification33.6%
(FPCore (re im) :precision binary64 im)
double code(double re, double im) {
return im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im
end function
public static double code(double re, double im) {
return im;
}
def code(re, im): return im
function code(re, im) return im end
function tmp = code(re, im) tmp = im; end
code[re_, im_] := im
\begin{array}{l}
\\
im
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 69.2%
Taylor expanded in re around 0 29.6%
Final simplification29.6%
herbie shell --seed 2023189
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))