
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = (sin(ky) / sqrt(((sin(kx) ** 2.0d0) + (sin(ky) ** 2.0d0)))) * sin(th)
end function
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.sqrt((Math.pow(Math.sin(kx), 2.0) + Math.pow(Math.sin(ky), 2.0)))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.sqrt((math.pow(math.sin(kx), 2.0) + math.pow(math.sin(ky), 2.0)))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[kx], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Sin[ky], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\end{array}
(FPCore (kx ky th) :precision binary64 (* (/ (sin ky) (hypot (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
return (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th);
}
public static double code(double kx, double ky, double th) {
return (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * Math.sin(th);
}
def code(kx, ky, th): return (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * math.sin(th)
function code(kx, ky, th) return Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * sin(th)) end
function tmp = code(kx, ky, th) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * sin(th); end
code[kx_, ky_, th_] := N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th
\end{array}
Initial program 92.8%
+-commutative92.8%
unpow292.8%
unpow292.8%
hypot-undefine99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.0002)
(- (sin th))
(if (<= (sin ky) 0.002)
(* (sin ky) (/ (sin th) (fabs (sin kx))))
(sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = -sin(th);
} else if (sin(ky) <= 0.002) {
tmp = sin(ky) * (sin(th) / fabs(sin(kx)));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.0002d0)) then
tmp = -sin(th)
else if (sin(ky) <= 0.002d0) then
tmp = sin(ky) * (sin(th) / abs(sin(kx)))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.0002) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 0.002) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.abs(Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0002: tmp = -math.sin(th) elif math.sin(ky) <= 0.002: tmp = math.sin(ky) * (math.sin(th) / math.fabs(math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0002) tmp = Float64(-sin(th)); elseif (sin(ky) <= 0.002) tmp = Float64(sin(ky) * Float64(sin(th) / abs(sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.0002) tmp = -sin(th); elseif (sin(ky) <= 0.002) tmp = sin(ky) * (sin(th) / abs(sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0002], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 0.002], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Abs[N[Sin[kx], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0002:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 0.002:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\left|\sin kx\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.5%
associate-*l/99.4%
associate-/l*99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
unpow299.4%
sin-neg99.4%
sin-neg99.4%
sqr-neg99.4%
unpow299.4%
Simplified99.5%
Taylor expanded in kx around 0 2.7%
add-sqr-sqrt1.4%
sqrt-unprod28.0%
pow228.0%
Applied egg-rr28.0%
unpow228.0%
rem-sqrt-square31.7%
Simplified31.7%
clear-num31.6%
associate-/r/31.5%
Applied egg-rr31.5%
add-sqr-sqrt1.4%
fabs-sqr1.4%
add-sqr-sqrt2.7%
associate-*l/2.7%
*-un-lft-identity2.7%
associate-*r/2.7%
frac-2neg2.7%
*-commutative2.7%
add-sqr-sqrt2.7%
sqrt-unprod2.7%
sqr-neg2.7%
sqrt-unprod0.0%
add-sqr-sqrt60.4%
Applied egg-rr60.4%
distribute-frac-neg60.4%
associate-/l*60.5%
*-inverses60.5%
*-rgt-identity60.5%
Simplified60.5%
if -2.0000000000000001e-4 < (sin.f64 ky) < 2e-3Initial program 86.2%
associate-*l/84.7%
associate-/l*86.2%
unpow286.2%
sqr-neg86.2%
sin-neg86.2%
sin-neg86.2%
unpow286.2%
unpow286.2%
sin-neg86.2%
sin-neg86.2%
sqr-neg86.2%
unpow286.2%
Simplified99.7%
expm1-log1p-u99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 30.7%
log1p-define45.7%
Simplified45.7%
expm1-log1p-u45.8%
add-sqr-sqrt38.5%
sqrt-unprod67.8%
pow267.8%
Applied egg-rr67.8%
unpow267.8%
rem-sqrt-square74.0%
Simplified74.0%
if 2e-3 < (sin.f64 ky) Initial program 99.5%
associate-*l/99.4%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.6%
Taylor expanded in kx around 0 53.1%
Final simplification65.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.0002) (- (sin th)) (if (<= (sin ky) 5e-46) (* (sin ky) (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = -sin(th);
} else if (sin(ky) <= 5e-46) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.0002d0)) then
tmp = -sin(th)
else if (sin(ky) <= 5d-46) then
tmp = sin(ky) * (sin(th) / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.0002) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 5e-46) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0002: tmp = -math.sin(th) elif math.sin(ky) <= 5e-46: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0002) tmp = Float64(-sin(th)); elseif (sin(ky) <= 5e-46) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.0002) tmp = -sin(th); elseif (sin(ky) <= 5e-46) tmp = sin(ky) * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0002], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-46], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0002:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-46}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.5%
associate-*l/99.4%
associate-/l*99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
unpow299.4%
sin-neg99.4%
sin-neg99.4%
sqr-neg99.4%
unpow299.4%
Simplified99.5%
Taylor expanded in kx around 0 2.7%
add-sqr-sqrt1.4%
sqrt-unprod28.0%
pow228.0%
Applied egg-rr28.0%
unpow228.0%
rem-sqrt-square31.7%
Simplified31.7%
clear-num31.6%
associate-/r/31.5%
Applied egg-rr31.5%
add-sqr-sqrt1.4%
fabs-sqr1.4%
add-sqr-sqrt2.7%
associate-*l/2.7%
*-un-lft-identity2.7%
associate-*r/2.7%
frac-2neg2.7%
*-commutative2.7%
add-sqr-sqrt2.7%
sqrt-unprod2.7%
sqr-neg2.7%
sqrt-unprod0.0%
add-sqr-sqrt60.4%
Applied egg-rr60.4%
distribute-frac-neg60.4%
associate-/l*60.5%
*-inverses60.5%
*-rgt-identity60.5%
Simplified60.5%
if -2.0000000000000001e-4 < (sin.f64 ky) < 4.99999999999999992e-46Initial program 85.0%
associate-*l/83.2%
associate-/l*85.0%
unpow285.0%
sqr-neg85.0%
sin-neg85.0%
sin-neg85.0%
unpow285.0%
unpow285.0%
sin-neg85.0%
sin-neg85.0%
sqr-neg85.0%
unpow285.0%
Simplified99.7%
Taylor expanded in ky around 0 46.9%
if 4.99999999999999992e-46 < (sin.f64 ky) Initial program 99.6%
associate-*l/99.5%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.6%
Taylor expanded in kx around 0 54.1%
Final simplification52.5%
(FPCore (kx ky th) :precision binary64 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
double code(double kx, double ky, double th) {
return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th): return math.sin(ky) * (math.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
function code(kx, ky, th) return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx)))) end
function tmp = code(kx, ky, th) tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx))); end
code[kx_, ky_, th_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}
\end{array}
Initial program 92.8%
associate-*l/91.9%
associate-/l*92.7%
unpow292.7%
sqr-neg92.7%
sin-neg92.7%
sin-neg92.7%
unpow292.7%
unpow292.7%
sin-neg92.7%
sin-neg92.7%
sqr-neg92.7%
unpow292.7%
Simplified99.6%
Final simplification99.6%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.0002) (- (sin th)) (if (<= (sin ky) 5e-46) (* ky (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.0002) {
tmp = -sin(th);
} else if (sin(ky) <= 5e-46) {
tmp = ky * (sin(th) / sin(kx));
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (sin(ky) <= (-0.0002d0)) then
tmp = -sin(th)
else if (sin(ky) <= 5d-46) then
tmp = ky * (sin(th) / sin(kx))
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(ky) <= -0.0002) {
tmp = -Math.sin(th);
} else if (Math.sin(ky) <= 5e-46) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.0002: tmp = -math.sin(th) elif math.sin(ky) <= 5e-46: tmp = ky * (math.sin(th) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.0002) tmp = Float64(-sin(th)); elseif (sin(ky) <= 5e-46) tmp = Float64(ky * Float64(sin(th) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.0002) tmp = -sin(th); elseif (sin(ky) <= 5e-46) tmp = ky * (sin(th) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.0002], (-N[Sin[th], $MachinePrecision]), If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-46], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.0002:\\
\;\;\;\;-\sin th\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-46}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -2.0000000000000001e-4Initial program 99.5%
associate-*l/99.4%
associate-/l*99.4%
unpow299.4%
sqr-neg99.4%
sin-neg99.4%
sin-neg99.4%
unpow299.4%
unpow299.4%
sin-neg99.4%
sin-neg99.4%
sqr-neg99.4%
unpow299.4%
Simplified99.5%
Taylor expanded in kx around 0 2.7%
add-sqr-sqrt1.4%
sqrt-unprod28.0%
pow228.0%
Applied egg-rr28.0%
unpow228.0%
rem-sqrt-square31.7%
Simplified31.7%
clear-num31.6%
associate-/r/31.5%
Applied egg-rr31.5%
add-sqr-sqrt1.4%
fabs-sqr1.4%
add-sqr-sqrt2.7%
associate-*l/2.7%
*-un-lft-identity2.7%
associate-*r/2.7%
frac-2neg2.7%
*-commutative2.7%
add-sqr-sqrt2.7%
sqrt-unprod2.7%
sqr-neg2.7%
sqrt-unprod0.0%
add-sqr-sqrt60.4%
Applied egg-rr60.4%
distribute-frac-neg60.4%
associate-/l*60.5%
*-inverses60.5%
*-rgt-identity60.5%
Simplified60.5%
if -2.0000000000000001e-4 < (sin.f64 ky) < 4.99999999999999992e-46Initial program 85.0%
associate-*l/83.2%
associate-/l*85.0%
unpow285.0%
sqr-neg85.0%
sin-neg85.0%
sin-neg85.0%
unpow285.0%
unpow285.0%
sin-neg85.0%
sin-neg85.0%
sqr-neg85.0%
unpow285.0%
Simplified99.7%
Taylor expanded in ky around 0 42.6%
associate-/l*46.9%
Simplified46.9%
if 4.99999999999999992e-46 < (sin.f64 ky) Initial program 99.6%
associate-*l/99.5%
associate-/l*99.5%
unpow299.5%
sqr-neg99.5%
sin-neg99.5%
sin-neg99.5%
unpow299.5%
unpow299.5%
sin-neg99.5%
sin-neg99.5%
sqr-neg99.5%
unpow299.5%
Simplified99.6%
Taylor expanded in kx around 0 54.1%
Final simplification52.5%
(FPCore (kx ky th) :precision binary64 (if (<= th 1.8e-188) (* -0.16666666666666666 (pow th 3.0)) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.8e-188) {
tmp = -0.16666666666666666 * pow(th, 3.0);
} else {
tmp = sin(th);
}
return tmp;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
real(8) :: tmp
if (th <= 1.8d-188) then
tmp = (-0.16666666666666666d0) * (th ** 3.0d0)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (th <= 1.8e-188) {
tmp = -0.16666666666666666 * Math.pow(th, 3.0);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if th <= 1.8e-188: tmp = -0.16666666666666666 * math.pow(th, 3.0) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (th <= 1.8e-188) tmp = Float64(-0.16666666666666666 * (th ^ 3.0)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (th <= 1.8e-188) tmp = -0.16666666666666666 * (th ^ 3.0); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[th, 1.8e-188], N[(-0.16666666666666666 * N[Power[th, 3.0], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq 1.8 \cdot 10^{-188}:\\
\;\;\;\;-0.16666666666666666 \cdot {th}^{3}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if th < 1.7999999999999998e-188Initial program 94.3%
associate-*l/92.9%
associate-/l*94.2%
unpow294.2%
sqr-neg94.2%
sin-neg94.2%
sin-neg94.2%
unpow294.2%
unpow294.2%
sin-neg94.2%
sin-neg94.2%
sqr-neg94.2%
unpow294.2%
Simplified99.6%
Taylor expanded in kx around 0 20.3%
Taylor expanded in th around 0 12.4%
Taylor expanded in th around inf 12.8%
if 1.7999999999999998e-188 < th Initial program 90.7%
associate-*l/90.6%
associate-/l*90.7%
unpow290.7%
sqr-neg90.7%
sin-neg90.7%
sin-neg90.7%
unpow290.7%
unpow290.7%
sin-neg90.7%
sin-neg90.7%
sqr-neg90.7%
unpow290.7%
Simplified99.6%
Taylor expanded in kx around 0 18.5%
Final simplification15.3%
(FPCore (kx ky th) :precision binary64 (sin th))
double code(double kx, double ky, double th) {
return sin(th);
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = sin(th)
end function
public static double code(double kx, double ky, double th) {
return Math.sin(th);
}
def code(kx, ky, th): return math.sin(th)
function code(kx, ky, th) return sin(th) end
function tmp = code(kx, ky, th) tmp = sin(th); end
code[kx_, ky_, th_] := N[Sin[th], $MachinePrecision]
\begin{array}{l}
\\
\sin th
\end{array}
Initial program 92.8%
associate-*l/91.9%
associate-/l*92.7%
unpow292.7%
sqr-neg92.7%
sin-neg92.7%
sin-neg92.7%
unpow292.7%
unpow292.7%
sin-neg92.7%
sin-neg92.7%
sqr-neg92.7%
unpow292.7%
Simplified99.6%
Taylor expanded in kx around 0 19.6%
Final simplification19.6%
(FPCore (kx ky th) :precision binary64 th)
double code(double kx, double ky, double th) {
return th;
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = th
end function
public static double code(double kx, double ky, double th) {
return th;
}
def code(kx, ky, th): return th
function code(kx, ky, th) return th end
function tmp = code(kx, ky, th) tmp = th; end
code[kx_, ky_, th_] := th
\begin{array}{l}
\\
th
\end{array}
Initial program 92.8%
associate-*l/91.9%
associate-/l*92.7%
unpow292.7%
sqr-neg92.7%
sin-neg92.7%
sin-neg92.7%
unpow292.7%
unpow292.7%
sin-neg92.7%
sin-neg92.7%
sqr-neg92.7%
unpow292.7%
Simplified99.6%
Taylor expanded in kx around 0 19.5%
Taylor expanded in th around 0 11.7%
Final simplification11.7%
herbie shell --seed 2024039
(FPCore (kx ky th)
:name "Toniolo and Linder, Equation (3b), real"
:precision binary64
(* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))