
(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 12 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) 1e-15) (not (<= (exp re) 20.0))) (* (exp re) im) (sin im)))
double code(double re, double im) {
double tmp;
if ((exp(re) <= 1e-15) || !(exp(re) <= 20.0)) {
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) <= 1d-15) .or. (.not. (exp(re) <= 20.0d0))) 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) <= 1e-15) || !(Math.exp(re) <= 20.0)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im);
}
return tmp;
}
def code(re, im): tmp = 0 if (math.exp(re) <= 1e-15) or not (math.exp(re) <= 20.0): tmp = math.exp(re) * im else: tmp = math.sin(im) return tmp
function code(re, im) tmp = 0.0 if ((exp(re) <= 1e-15) || !(exp(re) <= 20.0)) 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) <= 1e-15) || ~((exp(re) <= 20.0))) tmp = exp(re) * im; else tmp = sin(im); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[N[Exp[re], $MachinePrecision], 1e-15], N[Not[LessEqual[N[Exp[re], $MachinePrecision], 20.0]], $MachinePrecision]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[Sin[im], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 10^{-15} \lor \neg \left(e^{re} \leq 20\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im\\
\end{array}
\end{array}
if (exp.f64 re) < 1.0000000000000001e-15 or 20 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 85.6%
if 1.0000000000000001e-15 < (exp.f64 re) < 20Initial program 100.0%
Taylor expanded in re around 0 97.2%
Final simplification91.2%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.33) (and (not (<= re 3.0)) (<= re 1.46e+99)))
(* (exp re) im)
(*
(sin im)
(+ (+ re 1.0) (* (* re re) (+ (* re 0.16666666666666666) 0.5))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.33) || (!(re <= 3.0) && (re <= 1.46e+99))) {
tmp = exp(re) * im;
} else {
tmp = sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 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.33d0)) .or. (.not. (re <= 3.0d0)) .and. (re <= 1.46d+99)) then
tmp = exp(re) * im
else
tmp = sin(im) * ((re + 1.0d0) + ((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.33) || (!(re <= 3.0) && (re <= 1.46e+99))) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.33) or (not (re <= 3.0) and (re <= 1.46e+99)): tmp = math.exp(re) * im else: tmp = math.sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.33) || (!(re <= 3.0) && (re <= 1.46e+99))) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.33) || (~((re <= 3.0)) && (re <= 1.46e+99))) tmp = exp(re) * im; else tmp = sin(im) * ((re + 1.0) + ((re * re) * ((re * 0.16666666666666666) + 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.33], And[N[Not[LessEqual[re, 3.0]], $MachinePrecision], LessEqual[re, 1.46e+99]]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.33 \lor \neg \left(re \leq 3\right) \land re \leq 1.46 \cdot 10^{+99}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.330000000000000016 or 3 < re < 1.4600000000000001e99Initial program 100.0%
Taylor expanded in im around 0 93.7%
if -0.330000000000000016 < re < 3 or 1.4600000000000001e99 < re Initial program 100.0%
Taylor expanded in re around 0 98.3%
associate-+r+98.3%
*-commutative98.3%
distribute-rgt1-in98.3%
*-commutative98.3%
+-commutative98.3%
*-commutative98.3%
associate-*r*98.3%
*-commutative98.3%
associate-*r*98.3%
distribute-rgt-out98.3%
distribute-lft-out98.3%
+-commutative98.3%
Simplified98.3%
Final simplification96.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.058)
t_0
(if (<= re 3.0)
(* (sin im) (+ (+ re 1.0) (* re (* re 0.5))))
(if (<= re 1.32e+154) t_0 (* (* re re) (* (sin im) 0.5)))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -0.058) {
tmp = t_0;
} else if (re <= 3.0) {
tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 1.32e+154) {
tmp = t_0;
} else {
tmp = (re * re) * (sin(im) * 0.5);
}
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.058d0)) then
tmp = t_0
else if (re <= 3.0d0) then
tmp = sin(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
else if (re <= 1.32d+154) then
tmp = t_0
else
tmp = (re * re) * (sin(im) * 0.5d0)
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.058) {
tmp = t_0;
} else if (re <= 3.0) {
tmp = Math.sin(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 1.32e+154) {
tmp = t_0;
} else {
tmp = (re * re) * (Math.sin(im) * 0.5);
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -0.058: tmp = t_0 elif re <= 3.0: tmp = math.sin(im) * ((re + 1.0) + (re * (re * 0.5))) elif re <= 1.32e+154: tmp = t_0 else: tmp = (re * re) * (math.sin(im) * 0.5) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -0.058) tmp = t_0; elseif (re <= 3.0) tmp = Float64(sin(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); elseif (re <= 1.32e+154) tmp = t_0; else tmp = Float64(Float64(re * re) * Float64(sin(im) * 0.5)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -0.058) tmp = t_0; elseif (re <= 3.0) tmp = sin(im) * ((re + 1.0) + (re * (re * 0.5))); elseif (re <= 1.32e+154) tmp = t_0; else tmp = (re * re) * (sin(im) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -0.058], t$95$0, If[LessEqual[re, 3.0], N[(N[Sin[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.32e+154], t$95$0, N[(N[(re * re), $MachinePrecision] * N[(N[Sin[im], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -0.058:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 3:\\
\;\;\;\;\sin im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\mathbf{elif}\;re \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(\sin im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -0.0580000000000000029 or 3 < re < 1.31999999999999998e154Initial program 100.0%
Taylor expanded in im around 0 90.5%
if -0.0580000000000000029 < re < 3Initial program 100.0%
Taylor expanded in re around 0 98.2%
associate-+r+98.2%
+-commutative98.2%
*-commutative98.2%
distribute-lft1-in98.2%
*-commutative98.2%
associate-*r*98.2%
distribute-rgt-out98.2%
*-commutative98.2%
unpow298.2%
associate-*l*98.2%
Simplified98.2%
if 1.31999999999999998e154 < 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%
*-commutative100.0%
unpow2100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification95.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.058)
t_0
(if (<= re 3.0)
(* (sin im) (+ re 1.0))
(if (<= re 1.32e+154) t_0 (* (* re re) (* (sin im) 0.5)))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -0.058) {
tmp = t_0;
} else if (re <= 3.0) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 1.32e+154) {
tmp = t_0;
} else {
tmp = (re * re) * (sin(im) * 0.5);
}
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.058d0)) then
tmp = t_0
else if (re <= 3.0d0) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 1.32d+154) then
tmp = t_0
else
tmp = (re * re) * (sin(im) * 0.5d0)
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.058) {
tmp = t_0;
} else if (re <= 3.0) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 1.32e+154) {
tmp = t_0;
} else {
tmp = (re * re) * (Math.sin(im) * 0.5);
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -0.058: tmp = t_0 elif re <= 3.0: tmp = math.sin(im) * (re + 1.0) elif re <= 1.32e+154: tmp = t_0 else: tmp = (re * re) * (math.sin(im) * 0.5) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -0.058) tmp = t_0; elseif (re <= 3.0) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 1.32e+154) tmp = t_0; else tmp = Float64(Float64(re * re) * Float64(sin(im) * 0.5)); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -0.058) tmp = t_0; elseif (re <= 3.0) tmp = sin(im) * (re + 1.0); elseif (re <= 1.32e+154) tmp = t_0; else tmp = (re * re) * (sin(im) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -0.058], t$95$0, If[LessEqual[re, 3.0], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.32e+154], t$95$0, N[(N[(re * re), $MachinePrecision] * N[(N[Sin[im], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -0.058:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 3:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(\sin im \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -0.0580000000000000029 or 3 < re < 1.31999999999999998e154Initial program 100.0%
Taylor expanded in im around 0 90.5%
if -0.0580000000000000029 < re < 3Initial program 100.0%
Taylor expanded in re around 0 97.8%
*-commutative97.8%
distribute-rgt1-in97.8%
Simplified97.8%
if 1.31999999999999998e154 < 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%
*-commutative100.0%
unpow2100.0%
*-commutative100.0%
associate-*l*100.0%
Simplified100.0%
Final simplification95.0%
(FPCore (re im) :precision binary64 (if (or (<= re -0.065) (not (<= re 3.0))) (* (exp re) im) (* (sin im) (+ re 1.0))))
double code(double re, double im) {
double tmp;
if ((re <= -0.065) || !(re <= 3.0)) {
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 <= (-0.065d0)) .or. (.not. (re <= 3.0d0))) 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 <= -0.065) || !(re <= 3.0)) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (re + 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.065) or not (re <= 3.0): tmp = math.exp(re) * im else: tmp = math.sin(im) * (re + 1.0) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.065) || !(re <= 3.0)) 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 <= -0.065) || ~((re <= 3.0))) tmp = exp(re) * im; else tmp = sin(im) * (re + 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.065], N[Not[LessEqual[re, 3.0]], $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 -0.065 \lor \neg \left(re \leq 3\right):\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\end{array}
\end{array}
if re < -0.065000000000000002 or 3 < re Initial program 100.0%
Taylor expanded in im around 0 85.6%
if -0.065000000000000002 < re < 3Initial program 100.0%
Taylor expanded in re around 0 97.8%
*-commutative97.8%
distribute-rgt1-in97.8%
Simplified97.8%
Final simplification91.5%
(FPCore (re im) :precision binary64 (if (<= re -105.0) 0.0 (if (<= re 1.45e+78) (sin im) (* im (* (* re re) 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -105.0) {
tmp = 0.0;
} else if (re <= 1.45e+78) {
tmp = sin(im);
} else {
tmp = im * ((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 <= (-105.0d0)) then
tmp = 0.0d0
else if (re <= 1.45d+78) then
tmp = sin(im)
else
tmp = im * ((re * re) * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -105.0) {
tmp = 0.0;
} else if (re <= 1.45e+78) {
tmp = Math.sin(im);
} else {
tmp = im * ((re * re) * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -105.0: tmp = 0.0 elif re <= 1.45e+78: tmp = math.sin(im) else: tmp = im * ((re * re) * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= -105.0) tmp = 0.0; elseif (re <= 1.45e+78) tmp = sin(im); else tmp = Float64(im * Float64(Float64(re * re) * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -105.0) tmp = 0.0; elseif (re <= 1.45e+78) tmp = sin(im); else tmp = im * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -105.0], 0.0, If[LessEqual[re, 1.45e+78], N[Sin[im], $MachinePrecision], N[(im * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -105:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 1.45 \cdot 10^{+78}:\\
\;\;\;\;\sin im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -105Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef99.3%
log1p-udef99.3%
add-exp-log99.3%
Applied egg-rr99.3%
Taylor expanded in im around 0 99.3%
if -105 < re < 1.45000000000000008e78Initial program 100.0%
Taylor expanded in re around 0 84.7%
if 1.45000000000000008e78 < re Initial program 100.0%
Taylor expanded in re around 0 66.3%
associate-+r+66.3%
+-commutative66.3%
*-commutative66.3%
distribute-lft1-in66.3%
*-commutative66.3%
associate-*r*66.3%
distribute-rgt-out66.3%
*-commutative66.3%
unpow266.3%
associate-*l*66.3%
Simplified66.3%
Taylor expanded in re around inf 66.3%
*-commutative66.3%
unpow266.3%
*-commutative66.3%
associate-*l*66.3%
Simplified66.3%
Taylor expanded in im around 0 55.5%
*-commutative55.5%
unpow255.5%
*-commutative55.5%
associate-*l*55.5%
*-commutative55.5%
Simplified55.5%
Final simplification83.9%
(FPCore (re im) :precision binary64 (if (<= re -4.8e-8) 0.0 (if (<= re 0.0265) (+ im (* re im)) (* im (* (* re re) 0.5)))))
double code(double re, double im) {
double tmp;
if (re <= -4.8e-8) {
tmp = 0.0;
} else if (re <= 0.0265) {
tmp = im + (re * im);
} else {
tmp = im * ((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 <= (-4.8d-8)) then
tmp = 0.0d0
else if (re <= 0.0265d0) then
tmp = im + (re * im)
else
tmp = im * ((re * re) * 0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -4.8e-8) {
tmp = 0.0;
} else if (re <= 0.0265) {
tmp = im + (re * im);
} else {
tmp = im * ((re * re) * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -4.8e-8: tmp = 0.0 elif re <= 0.0265: tmp = im + (re * im) else: tmp = im * ((re * re) * 0.5) return tmp
function code(re, im) tmp = 0.0 if (re <= -4.8e-8) tmp = 0.0; elseif (re <= 0.0265) tmp = Float64(im + Float64(re * im)); else tmp = Float64(im * Float64(Float64(re * re) * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -4.8e-8) tmp = 0.0; elseif (re <= 0.0265) tmp = im + (re * im); else tmp = im * ((re * re) * 0.5); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -4.8e-8], 0.0, If[LessEqual[re, 0.0265], N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision], N[(im * N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.8 \cdot 10^{-8}:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 0.0265:\\
\;\;\;\;im + re \cdot im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(\left(re \cdot re\right) \cdot 0.5\right)\\
\end{array}
\end{array}
if re < -4.79999999999999997e-8Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef98.0%
log1p-udef98.0%
add-exp-log98.0%
Applied egg-rr98.0%
Taylor expanded in im around 0 94.2%
if -4.79999999999999997e-8 < re < 0.0264999999999999993Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Taylor expanded in im around 0 43.0%
*-commutative43.0%
distribute-lft-in43.0%
*-rgt-identity43.0%
Simplified43.0%
if 0.0264999999999999993 < re Initial program 100.0%
Taylor expanded in re around 0 47.0%
associate-+r+47.0%
+-commutative47.0%
*-commutative47.0%
distribute-lft1-in47.0%
*-commutative47.0%
associate-*r*47.0%
distribute-rgt-out47.0%
*-commutative47.0%
unpow247.0%
associate-*l*47.0%
Simplified47.0%
Taylor expanded in re around inf 46.4%
*-commutative46.4%
unpow246.4%
*-commutative46.4%
associate-*l*46.4%
Simplified46.4%
Taylor expanded in im around 0 38.4%
*-commutative38.4%
unpow238.4%
*-commutative38.4%
associate-*l*38.4%
*-commutative38.4%
Simplified38.4%
Final simplification56.9%
(FPCore (re im) :precision binary64 (if (<= re -110.0) 0.0 (if (<= re 105.0) im (* re im))))
double code(double re, double im) {
double tmp;
if (re <= -110.0) {
tmp = 0.0;
} else if (re <= 105.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 <= (-110.0d0)) then
tmp = 0.0d0
else if (re <= 105.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 <= -110.0) {
tmp = 0.0;
} else if (re <= 105.0) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -110.0: tmp = 0.0 elif re <= 105.0: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= -110.0) tmp = 0.0; elseif (re <= 105.0) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -110.0) tmp = 0.0; elseif (re <= 105.0) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -110.0], 0.0, If[LessEqual[re, 105.0], im, N[(re * im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -110:\\
\;\;\;\;0\\
\mathbf{elif}\;re \leq 105:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < -110Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef99.3%
log1p-udef99.3%
add-exp-log99.3%
Applied egg-rr99.3%
Taylor expanded in im around 0 99.3%
if -110 < re < 105Initial program 100.0%
Taylor expanded in re around 0 97.1%
*-commutative97.1%
distribute-rgt1-in97.1%
Simplified97.1%
Taylor expanded in im around 0 41.1%
*-commutative41.1%
distribute-lft-in41.1%
*-rgt-identity41.1%
Simplified41.1%
Taylor expanded in re around 0 41.1%
if 105 < re Initial program 100.0%
Taylor expanded in re around 0 4.5%
*-commutative4.5%
distribute-rgt1-in4.5%
Simplified4.5%
Taylor expanded in re around inf 4.5%
Taylor expanded in im around 0 15.7%
Final simplification51.3%
(FPCore (re im) :precision binary64 (if (<= re -4.8e-8) 0.0 (+ im (* re im))))
double code(double re, double im) {
double tmp;
if (re <= -4.8e-8) {
tmp = 0.0;
} else {
tmp = im + (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 <= (-4.8d-8)) then
tmp = 0.0d0
else
tmp = im + (re * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -4.8e-8) {
tmp = 0.0;
} else {
tmp = im + (re * im);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -4.8e-8: tmp = 0.0 else: tmp = im + (re * im) return tmp
function code(re, im) tmp = 0.0 if (re <= -4.8e-8) tmp = 0.0; else tmp = Float64(im + Float64(re * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -4.8e-8) tmp = 0.0; else tmp = im + (re * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -4.8e-8], 0.0, N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.8 \cdot 10^{-8}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;im + re \cdot im\\
\end{array}
\end{array}
if re < -4.79999999999999997e-8Initial program 100.0%
expm1-log1p-u100.0%
expm1-udef98.0%
log1p-udef98.0%
add-exp-log98.0%
Applied egg-rr98.0%
Taylor expanded in im around 0 94.2%
if -4.79999999999999997e-8 < re Initial program 100.0%
Taylor expanded in re around 0 67.5%
*-commutative67.5%
distribute-rgt1-in67.5%
Simplified67.5%
Taylor expanded in im around 0 33.5%
*-commutative33.5%
distribute-lft-in33.5%
*-rgt-identity33.5%
Simplified33.5%
Final simplification51.3%
(FPCore (re im) :precision binary64 (if (<= re 3.0) im (* re im)))
double code(double re, double im) {
double tmp;
if (re <= 3.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 <= 3.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 <= 3.0) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.0: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= 3.0) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 3.0) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.0], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < 3Initial program 100.0%
Taylor expanded in re around 0 63.0%
*-commutative63.0%
distribute-rgt1-in63.0%
Simplified63.0%
Taylor expanded in im around 0 27.2%
*-commutative27.2%
distribute-lft-in27.2%
*-rgt-identity27.2%
Simplified27.2%
Taylor expanded in re around 0 27.8%
if 3 < re Initial program 100.0%
Taylor expanded in re around 0 4.5%
*-commutative4.5%
distribute-rgt1-in4.5%
Simplified4.5%
Taylor expanded in re around inf 4.5%
Taylor expanded in im around 0 15.7%
Final simplification25.0%
(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 re around 0 49.3%
*-commutative49.3%
distribute-rgt1-in49.3%
Simplified49.3%
Taylor expanded in im around 0 24.5%
*-commutative24.5%
distribute-lft-in24.5%
*-rgt-identity24.5%
Simplified24.5%
Taylor expanded in re around 0 21.9%
Final simplification21.9%
herbie shell --seed 2023195
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))