
(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 14 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 93.8%
+-commutative93.8%
unpow293.8%
unpow293.8%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -2e-5)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin th) 2e-31)
(* th (/ (sin ky) (hypot (sin kx) (sin ky))))
(if (<= (sin th) 0.95)
(/ (sin ky) (fabs (/ (sin ky) (sin th))))
(* (sin th) (/ (sin ky) (sin kx)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -2e-5) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(th) <= 2e-31) {
tmp = th * (sin(ky) / hypot(sin(kx), sin(ky)));
} else if (sin(th) <= 0.95) {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -2e-5) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(th) <= 2e-31) {
tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky)));
} else if (Math.sin(th) <= 0.95) {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -2e-5: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(th) <= 2e-31: tmp = th * (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) elif math.sin(th) <= 0.95: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -2e-5) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(th) <= 2e-31) tmp = Float64(th * Float64(sin(ky) / hypot(sin(kx), sin(ky)))); elseif (sin(th) <= 0.95) tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -2e-5) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(th) <= 2e-31) tmp = th * (sin(ky) / hypot(sin(kx), sin(ky))); elseif (sin(th) <= 0.95) tmp = sin(ky) / abs((sin(ky) / sin(th))); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -2e-5], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 2e-31], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 0.95], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -2 \cdot 10^{-5}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin th \leq 2 \cdot 10^{-31}:\\
\;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{elif}\;\sin th \leq 0.95:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 th) < -2.00000000000000016e-5Initial program 95.9%
associate-/r/95.9%
+-commutative95.9%
unpow295.9%
sqr-neg95.9%
sin-neg95.9%
sin-neg95.9%
unpow295.9%
+-commutative95.9%
Simplified99.5%
clear-num99.3%
associate-/r/99.5%
clear-num99.6%
hypot-udef96.0%
unpow296.0%
unpow296.0%
+-commutative96.0%
unpow296.0%
unpow296.0%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 31.3%
if -2.00000000000000016e-5 < (sin.f64 th) < 2e-31Initial program 93.7%
associate-/r/93.6%
+-commutative93.6%
unpow293.6%
sqr-neg93.6%
sin-neg93.6%
sin-neg93.6%
unpow293.6%
+-commutative93.6%
Simplified99.6%
Taylor expanded in th around 0 93.5%
*-un-lft-identity93.5%
unpow293.5%
unpow293.5%
hypot-udef99.4%
times-frac99.6%
clear-num99.8%
/-rgt-identity99.8%
Applied egg-rr99.8%
if 2e-31 < (sin.f64 th) < 0.94999999999999996Initial program 90.6%
associate-/r/90.5%
+-commutative90.5%
unpow290.5%
sqr-neg90.5%
sin-neg90.5%
sin-neg90.5%
unpow290.5%
+-commutative90.5%
Simplified99.3%
Taylor expanded in kx around 0 29.8%
add-sqr-sqrt28.8%
sqrt-unprod42.1%
pow242.1%
Applied egg-rr42.1%
unpow242.1%
rem-sqrt-square49.3%
Simplified49.3%
if 0.94999999999999996 < (sin.f64 th) Initial program 93.5%
Taylor expanded in ky around 0 11.2%
Final simplification67.0%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (or (<= (sin ky) -0.01) (not (<= (sin ky) 0.0001)))
(/ (sin ky) (* t_1 (+ (/ 1.0 th) (* th 0.16666666666666666))))
(* ky (/ 1.0 (/ t_1 (sin th)))))))
double code(double kx, double ky, double th) {
double t_1 = hypot(sin(ky), sin(kx));
double tmp;
if ((sin(ky) <= -0.01) || !(sin(ky) <= 0.0001)) {
tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = ky * (1.0 / (t_1 / sin(th)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double t_1 = Math.hypot(Math.sin(ky), Math.sin(kx));
double tmp;
if ((Math.sin(ky) <= -0.01) || !(Math.sin(ky) <= 0.0001)) {
tmp = Math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666)));
} else {
tmp = ky * (1.0 / (t_1 / Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.hypot(math.sin(ky), math.sin(kx)) tmp = 0 if (math.sin(ky) <= -0.01) or not (math.sin(ky) <= 0.0001): tmp = math.sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))) else: tmp = ky * (1.0 / (t_1 / math.sin(th))) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if ((sin(ky) <= -0.01) || !(sin(ky) <= 0.0001)) tmp = Float64(sin(ky) / Float64(t_1 * Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666)))); else tmp = Float64(ky * Float64(1.0 / Float64(t_1 / sin(th)))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)); tmp = 0.0; if ((sin(ky) <= -0.01) || ~((sin(ky) <= 0.0001))) tmp = sin(ky) / (t_1 * ((1.0 / th) + (th * 0.16666666666666666))); else tmp = ky * (1.0 / (t_1 / sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, If[Or[LessEqual[N[Sin[ky], $MachinePrecision], -0.01], N[Not[LessEqual[N[Sin[ky], $MachinePrecision], 0.0001]], $MachinePrecision]], N[(N[Sin[ky], $MachinePrecision] / N[(t$95$1 * N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(ky * N[(1.0 / N[(t$95$1 / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin ky \leq -0.01 \lor \neg \left(\sin ky \leq 0.0001\right):\\
\;\;\;\;\frac{\sin ky}{t_1 \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{1}{\frac{t_1}{\sin th}}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0100000000000000002 or 1.00000000000000005e-4 < (sin.f64 ky) Initial program 99.6%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.5%
Taylor expanded in th around 0 57.1%
+-commutative57.1%
unpow257.1%
unpow257.1%
hypot-def57.1%
associate-*r*57.1%
unpow257.1%
unpow257.1%
hypot-def57.1%
distribute-rgt-out57.1%
Simplified57.1%
if -0.0100000000000000002 < (sin.f64 ky) < 1.00000000000000005e-4Initial program 88.0%
associate-*l/83.5%
+-commutative83.5%
unpow283.5%
unpow283.5%
hypot-def93.1%
Simplified93.1%
Taylor expanded in ky around 0 92.6%
associate-/l*99.0%
div-inv98.9%
Applied egg-rr98.9%
Final simplification78.0%
(FPCore (kx ky th) :precision binary64 (if (or (<= (sin ky) -0.01) (not (<= (sin ky) 0.0001))) (* th (/ (sin ky) (hypot (sin kx) (sin ky)))) (* ky (/ 1.0 (/ (hypot (sin ky) (sin kx)) (sin th))))))
double code(double kx, double ky, double th) {
double tmp;
if ((sin(ky) <= -0.01) || !(sin(ky) <= 0.0001)) {
tmp = th * (sin(ky) / hypot(sin(kx), sin(ky)));
} else {
tmp = ky * (1.0 / (hypot(sin(ky), sin(kx)) / sin(th)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if ((Math.sin(ky) <= -0.01) || !(Math.sin(ky) <= 0.0001)) {
tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky)));
} else {
tmp = ky * (1.0 / (Math.hypot(Math.sin(ky), Math.sin(kx)) / Math.sin(th)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (math.sin(ky) <= -0.01) or not (math.sin(ky) <= 0.0001): tmp = th * (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) else: tmp = ky * (1.0 / (math.hypot(math.sin(ky), math.sin(kx)) / math.sin(th))) return tmp
function code(kx, ky, th) tmp = 0.0 if ((sin(ky) <= -0.01) || !(sin(ky) <= 0.0001)) tmp = Float64(th * Float64(sin(ky) / hypot(sin(kx), sin(ky)))); else tmp = Float64(ky * Float64(1.0 / Float64(hypot(sin(ky), sin(kx)) / sin(th)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((sin(ky) <= -0.01) || ~((sin(ky) <= 0.0001))) tmp = th * (sin(ky) / hypot(sin(kx), sin(ky))); else tmp = ky * (1.0 / (hypot(sin(ky), sin(kx)) / sin(th))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[N[Sin[ky], $MachinePrecision], -0.01], N[Not[LessEqual[N[Sin[ky], $MachinePrecision], 0.0001]], $MachinePrecision]], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(ky * N[(1.0 / N[(N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.01 \lor \neg \left(\sin ky \leq 0.0001\right):\\
\;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{1}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0100000000000000002 or 1.00000000000000005e-4 < (sin.f64 ky) Initial program 99.6%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.5%
Taylor expanded in th around 0 56.5%
*-un-lft-identity56.5%
unpow256.5%
unpow256.5%
hypot-udef56.5%
times-frac56.6%
clear-num56.7%
/-rgt-identity56.7%
Applied egg-rr56.7%
if -0.0100000000000000002 < (sin.f64 ky) < 1.00000000000000005e-4Initial program 88.0%
associate-*l/83.5%
+-commutative83.5%
unpow283.5%
unpow283.5%
hypot-def93.1%
Simplified93.1%
Taylor expanded in ky around 0 92.6%
associate-/l*99.0%
div-inv98.9%
Applied egg-rr98.9%
Final simplification77.8%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.01)
(fabs (sin th))
(if (<= (sin ky) -1e-303)
(* ky (/ (sin th) (sin kx)))
(if (<= (sin ky) 2e-44) (* (sin th) (fabs (/ ky (sin kx)))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.01) {
tmp = fabs(sin(th));
} else if (sin(ky) <= -1e-303) {
tmp = ky * (sin(th) / sin(kx));
} else if (sin(ky) <= 2e-44) {
tmp = sin(th) * fabs((ky / 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.01d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= (-1d-303)) then
tmp = ky * (sin(th) / sin(kx))
else if (sin(ky) <= 2d-44) then
tmp = sin(th) * abs((ky / 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.01) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= -1e-303) {
tmp = ky * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(ky) <= 2e-44) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.01: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= -1e-303: tmp = ky * (math.sin(th) / math.sin(kx)) elif math.sin(ky) <= 2e-44: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.01) tmp = abs(sin(th)); elseif (sin(ky) <= -1e-303) tmp = Float64(ky * Float64(sin(th) / sin(kx))); elseif (sin(ky) <= 2e-44) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.01) tmp = abs(sin(th)); elseif (sin(ky) <= -1e-303) tmp = ky * (sin(th) / sin(kx)); elseif (sin(ky) <= 2e-44) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.01], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-303], N[(ky * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-44], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.01:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq -1 \cdot 10^{-303}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-44}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0100000000000000002Initial program 99.7%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
associate-/r/3.0%
*-inverses3.0%
*-un-lft-identity3.0%
add-sqr-sqrt2.0%
sqrt-unprod23.2%
pow223.2%
Applied egg-rr23.2%
unpow223.2%
rem-sqrt-square23.7%
Simplified23.7%
if -0.0100000000000000002 < (sin.f64 ky) < -9.99999999999999931e-304Initial program 83.0%
+-commutative83.0%
unpow283.0%
unpow283.0%
hypot-def99.6%
Simplified99.6%
log1p-expm1-u99.6%
hypot-udef83.0%
unpow283.0%
unpow283.0%
+-commutative83.0%
unpow283.0%
unpow283.0%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 45.8%
associate-*r/48.5%
Simplified48.5%
if -9.99999999999999931e-304 < (sin.f64 ky) < 1.99999999999999991e-44Initial program 92.8%
+-commutative92.8%
unpow292.8%
unpow292.8%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 50.8%
add-sqr-sqrt35.7%
sqrt-unprod60.9%
pow260.9%
Applied egg-rr60.9%
unpow260.9%
rem-sqrt-square88.0%
Simplified88.0%
if 1.99999999999999991e-44 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 59.4%
Final simplification54.0%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.04)
(/ (sin ky) (fabs (/ (sin ky) th)))
(if (<= (sin ky) -1e-303)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin ky) 2e-44) (* (sin th) (fabs (/ ky (sin kx)))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.04) {
tmp = sin(ky) / fabs((sin(ky) / th));
} else if (sin(ky) <= -1e-303) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(ky) <= 2e-44) {
tmp = sin(th) * fabs((ky / 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.04d0)) then
tmp = sin(ky) / abs((sin(ky) / th))
else if (sin(ky) <= (-1d-303)) then
tmp = sin(ky) * (sin(th) / sin(kx))
else if (sin(ky) <= 2d-44) then
tmp = sin(th) * abs((ky / 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.04) {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / th));
} else if (Math.sin(ky) <= -1e-303) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(ky) <= 2e-44) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.04: tmp = math.sin(ky) / math.fabs((math.sin(ky) / th)) elif math.sin(ky) <= -1e-303: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(ky) <= 2e-44: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.04) tmp = Float64(sin(ky) / abs(Float64(sin(ky) / th))); elseif (sin(ky) <= -1e-303) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(ky) <= 2e-44) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.04) tmp = sin(ky) / abs((sin(ky) / th)); elseif (sin(ky) <= -1e-303) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(ky) <= 2e-44) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.04], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / th), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-303], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-44], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.04:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{th}\right|}\\
\mathbf{elif}\;\sin ky \leq -1 \cdot 10^{-303}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-44}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0400000000000000008Initial program 99.7%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.5%
Taylor expanded in kx around 0 2.9%
add-sqr-sqrt0.8%
sqrt-unprod24.7%
pow224.7%
Applied egg-rr24.7%
unpow224.7%
rem-sqrt-square36.1%
Simplified36.1%
Taylor expanded in th around 0 24.7%
if -0.0400000000000000008 < (sin.f64 ky) < -9.99999999999999931e-304Initial program 83.3%
associate-/r/83.3%
+-commutative83.3%
unpow283.3%
sqr-neg83.3%
sin-neg83.3%
sin-neg83.3%
unpow283.3%
+-commutative83.3%
Simplified99.6%
clear-num99.4%
associate-/r/99.4%
clear-num99.7%
hypot-udef83.4%
unpow283.4%
unpow283.4%
+-commutative83.4%
unpow283.4%
unpow283.4%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 47.9%
if -9.99999999999999931e-304 < (sin.f64 ky) < 1.99999999999999991e-44Initial program 92.8%
+-commutative92.8%
unpow292.8%
unpow292.8%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 50.8%
add-sqr-sqrt35.7%
sqrt-unprod60.9%
pow260.9%
Applied egg-rr60.9%
unpow260.9%
rem-sqrt-square88.0%
Simplified88.0%
if 1.99999999999999991e-44 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 59.4%
Final simplification54.2%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin ky) -0.04)
(/ (sin ky) (fabs (/ (sin ky) (sin th))))
(if (<= (sin ky) -1e-303)
(* (sin ky) (/ (sin th) (sin kx)))
(if (<= (sin ky) 2e-44) (* (sin th) (fabs (/ ky (sin kx)))) (sin th)))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.04) {
tmp = sin(ky) / fabs((sin(ky) / sin(th)));
} else if (sin(ky) <= -1e-303) {
tmp = sin(ky) * (sin(th) / sin(kx));
} else if (sin(ky) <= 2e-44) {
tmp = sin(th) * fabs((ky / 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.04d0)) then
tmp = sin(ky) / abs((sin(ky) / sin(th)))
else if (sin(ky) <= (-1d-303)) then
tmp = sin(ky) * (sin(th) / sin(kx))
else if (sin(ky) <= 2d-44) then
tmp = sin(th) * abs((ky / 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.04) {
tmp = Math.sin(ky) / Math.abs((Math.sin(ky) / Math.sin(th)));
} else if (Math.sin(ky) <= -1e-303) {
tmp = Math.sin(ky) * (Math.sin(th) / Math.sin(kx));
} else if (Math.sin(ky) <= 2e-44) {
tmp = Math.sin(th) * Math.abs((ky / Math.sin(kx)));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= -0.04: tmp = math.sin(ky) / math.fabs((math.sin(ky) / math.sin(th))) elif math.sin(ky) <= -1e-303: tmp = math.sin(ky) * (math.sin(th) / math.sin(kx)) elif math.sin(ky) <= 2e-44: tmp = math.sin(th) * math.fabs((ky / math.sin(kx))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= -0.04) tmp = Float64(sin(ky) / abs(Float64(sin(ky) / sin(th)))); elseif (sin(ky) <= -1e-303) tmp = Float64(sin(ky) * Float64(sin(th) / sin(kx))); elseif (sin(ky) <= 2e-44) tmp = Float64(sin(th) * abs(Float64(ky / sin(kx)))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= -0.04) tmp = sin(ky) / abs((sin(ky) / sin(th))); elseif (sin(ky) <= -1e-303) tmp = sin(ky) * (sin(th) / sin(kx)); elseif (sin(ky) <= 2e-44) tmp = sin(th) * abs((ky / sin(kx))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], -0.04], N[(N[Sin[ky], $MachinePrecision] / N[Abs[N[(N[Sin[ky], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], -1e-303], N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-44], N[(N[Sin[th], $MachinePrecision] * N[Abs[N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq -0.04:\\
\;\;\;\;\frac{\sin ky}{\left|\frac{\sin ky}{\sin th}\right|}\\
\mathbf{elif}\;\sin ky \leq -1 \cdot 10^{-303}:\\
\;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-44}:\\
\;\;\;\;\sin th \cdot \left|\frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0400000000000000008Initial program 99.7%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.5%
Taylor expanded in kx around 0 2.9%
add-sqr-sqrt0.8%
sqrt-unprod24.7%
pow224.7%
Applied egg-rr24.7%
unpow224.7%
rem-sqrt-square36.1%
Simplified36.1%
if -0.0400000000000000008 < (sin.f64 ky) < -9.99999999999999931e-304Initial program 83.3%
associate-/r/83.3%
+-commutative83.3%
unpow283.3%
sqr-neg83.3%
sin-neg83.3%
sin-neg83.3%
unpow283.3%
+-commutative83.3%
Simplified99.6%
clear-num99.4%
associate-/r/99.4%
clear-num99.7%
hypot-udef83.4%
unpow283.4%
unpow283.4%
+-commutative83.4%
unpow283.4%
unpow283.4%
hypot-def99.7%
Applied egg-rr99.7%
Taylor expanded in ky around 0 47.9%
if -9.99999999999999931e-304 < (sin.f64 ky) < 1.99999999999999991e-44Initial program 92.8%
+-commutative92.8%
unpow292.8%
unpow292.8%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 50.8%
add-sqr-sqrt35.7%
sqrt-unprod60.9%
pow260.9%
Applied egg-rr60.9%
unpow260.9%
rem-sqrt-square88.0%
Simplified88.0%
if 1.99999999999999991e-44 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 59.4%
Final simplification57.0%
(FPCore (kx ky th) :precision binary64 (if (or (<= th -2.4e-5) (not (<= th 330000.0))) (/ (* ky (sin th)) (hypot (sin ky) (sin kx))) (* th (/ (sin ky) (hypot (sin kx) (sin ky))))))
double code(double kx, double ky, double th) {
double tmp;
if ((th <= -2.4e-5) || !(th <= 330000.0)) {
tmp = (ky * sin(th)) / hypot(sin(ky), sin(kx));
} else {
tmp = th * (sin(ky) / hypot(sin(kx), sin(ky)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if ((th <= -2.4e-5) || !(th <= 330000.0)) {
tmp = (ky * Math.sin(th)) / Math.hypot(Math.sin(ky), Math.sin(kx));
} else {
tmp = th * (Math.sin(ky) / Math.hypot(Math.sin(kx), Math.sin(ky)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (th <= -2.4e-5) or not (th <= 330000.0): tmp = (ky * math.sin(th)) / math.hypot(math.sin(ky), math.sin(kx)) else: tmp = th * (math.sin(ky) / math.hypot(math.sin(kx), math.sin(ky))) return tmp
function code(kx, ky, th) tmp = 0.0 if ((th <= -2.4e-5) || !(th <= 330000.0)) tmp = Float64(Float64(ky * sin(th)) / hypot(sin(ky), sin(kx))); else tmp = Float64(th * Float64(sin(ky) / hypot(sin(kx), sin(ky)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((th <= -2.4e-5) || ~((th <= 330000.0))) tmp = (ky * sin(th)) / hypot(sin(ky), sin(kx)); else tmp = th * (sin(ky) / hypot(sin(kx), sin(ky))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[th, -2.4e-5], N[Not[LessEqual[th, 330000.0]], $MachinePrecision]], N[(N[(ky * N[Sin[th], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], N[(th * N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[kx], $MachinePrecision] ^ 2 + N[Sin[ky], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;th \leq -2.4 \cdot 10^{-5} \lor \neg \left(th \leq 330000\right):\\
\;\;\;\;\frac{ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\
\mathbf{else}:\\
\;\;\;\;th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\
\end{array}
\end{array}
if th < -2.4000000000000001e-5 or 3.3e5 < th Initial program 93.6%
associate-*l/93.7%
+-commutative93.7%
unpow293.7%
unpow293.7%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 55.3%
if -2.4000000000000001e-5 < th < 3.3e5Initial program 94.0%
associate-/r/93.9%
+-commutative93.9%
unpow293.9%
sqr-neg93.9%
sin-neg93.9%
sin-neg93.9%
unpow293.9%
+-commutative93.9%
Simplified99.6%
Taylor expanded in th around 0 92.8%
*-un-lft-identity92.8%
unpow292.8%
unpow292.8%
hypot-udef98.6%
times-frac98.7%
clear-num98.9%
/-rgt-identity98.9%
Applied egg-rr98.9%
Final simplification77.8%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) -0.01) (fabs (sin th)) (if (<= (sin ky) 5e-75) (* ky (/ (sin th) (sin kx))) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= -0.01) {
tmp = fabs(sin(th));
} else if (sin(ky) <= 5e-75) {
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.01d0)) then
tmp = abs(sin(th))
else if (sin(ky) <= 5d-75) 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.01) {
tmp = Math.abs(Math.sin(th));
} else if (Math.sin(ky) <= 5e-75) {
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.01: tmp = math.fabs(math.sin(th)) elif math.sin(ky) <= 5e-75: 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.01) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-75) 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.01) tmp = abs(sin(th)); elseif (sin(ky) <= 5e-75) 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.01], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 5e-75], 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.01:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-75}:\\
\;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -0.0100000000000000002Initial program 99.7%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.5%
Taylor expanded in kx around 0 3.0%
associate-/r/3.0%
*-inverses3.0%
*-un-lft-identity3.0%
add-sqr-sqrt2.0%
sqrt-unprod23.2%
pow223.2%
Applied egg-rr23.2%
unpow223.2%
rem-sqrt-square23.7%
Simplified23.7%
if -0.0100000000000000002 < (sin.f64 ky) < 4.99999999999999979e-75Initial program 86.6%
+-commutative86.6%
unpow286.6%
unpow286.6%
hypot-def99.6%
Simplified99.6%
log1p-expm1-u99.6%
hypot-udef86.6%
unpow286.6%
unpow286.6%
+-commutative86.6%
unpow286.6%
unpow286.6%
hypot-def99.6%
Applied egg-rr99.6%
Taylor expanded in ky around 0 47.6%
associate-*r/50.2%
Simplified50.2%
if 4.99999999999999979e-75 < (sin.f64 ky) Initial program 99.6%
Taylor expanded in kx around 0 57.6%
Final simplification45.9%
(FPCore (kx ky th) :precision binary64 (if (<= ky -1e-105) (fabs (sin th)) (if (<= ky 4.8e-75) (* (sin th) (/ ky kx)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -1e-105) {
tmp = fabs(sin(th));
} else if (ky <= 4.8e-75) {
tmp = sin(th) * (ky / 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 (ky <= (-1d-105)) then
tmp = abs(sin(th))
else if (ky <= 4.8d-75) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -1e-105) {
tmp = Math.abs(Math.sin(th));
} else if (ky <= 4.8e-75) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -1e-105: tmp = math.fabs(math.sin(th)) elif ky <= 4.8e-75: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -1e-105) tmp = abs(sin(th)); elseif (ky <= 4.8e-75) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -1e-105) tmp = abs(sin(th)); elseif (ky <= 4.8e-75) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -1e-105], N[Abs[N[Sin[th], $MachinePrecision]], $MachinePrecision], If[LessEqual[ky, 4.8e-75], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -1 \cdot 10^{-105}:\\
\;\;\;\;\left|\sin th\right|\\
\mathbf{elif}\;ky \leq 4.8 \cdot 10^{-75}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -9.99999999999999965e-106Initial program 99.7%
associate-/r/99.6%
+-commutative99.6%
unpow299.6%
sqr-neg99.6%
sin-neg99.6%
sin-neg99.6%
unpow299.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in kx around 0 25.1%
associate-/r/25.2%
*-inverses25.2%
*-un-lft-identity25.2%
add-sqr-sqrt15.1%
sqrt-unprod29.1%
pow229.1%
Applied egg-rr29.1%
unpow229.1%
rem-sqrt-square32.8%
Simplified32.8%
if -9.99999999999999965e-106 < ky < 4.80000000000000039e-75Initial program 82.2%
+-commutative82.2%
unpow282.2%
unpow282.2%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 54.5%
Taylor expanded in kx around 0 39.3%
associate-/l*42.6%
associate-/r/42.6%
Simplified42.6%
if 4.80000000000000039e-75 < ky Initial program 99.5%
Taylor expanded in kx around 0 31.7%
Final simplification35.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky -2e+57) (sin th) (if (<= ky 4.5e-75) (* (sin th) (/ ky kx)) (sin th))))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -2e+57) {
tmp = sin(th);
} else if (ky <= 4.5e-75) {
tmp = sin(th) * (ky / 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 (ky <= (-2d+57)) then
tmp = sin(th)
else if (ky <= 4.5d-75) then
tmp = sin(th) * (ky / kx)
else
tmp = sin(th)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -2e+57) {
tmp = Math.sin(th);
} else if (ky <= 4.5e-75) {
tmp = Math.sin(th) * (ky / kx);
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -2e+57: tmp = math.sin(th) elif ky <= 4.5e-75: tmp = math.sin(th) * (ky / kx) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -2e+57) tmp = sin(th); elseif (ky <= 4.5e-75) tmp = Float64(sin(th) * Float64(ky / kx)); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -2e+57) tmp = sin(th); elseif (ky <= 4.5e-75) tmp = sin(th) * (ky / kx); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -2e+57], N[Sin[th], $MachinePrecision], If[LessEqual[ky, 4.5e-75], N[(N[Sin[th], $MachinePrecision] * N[(ky / kx), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -2 \cdot 10^{+57}:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;ky \leq 4.5 \cdot 10^{-75}:\\
\;\;\;\;\sin th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if ky < -2.0000000000000001e57 or 4.5000000000000003e-75 < ky Initial program 99.6%
Taylor expanded in kx around 0 35.3%
if -2.0000000000000001e57 < ky < 4.5000000000000003e-75Initial program 87.6%
+-commutative87.6%
unpow287.6%
unpow287.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 46.8%
Taylor expanded in kx around 0 29.6%
associate-/l*31.9%
associate-/r/31.9%
Simplified31.9%
Final simplification33.6%
(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 93.8%
Taylor expanded in kx around 0 21.6%
Final simplification21.6%
(FPCore (kx ky th) :precision binary64 (/ 1.0 (+ (/ 1.0 th) (* th 0.16666666666666666))))
double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
real(8) function code(kx, ky, th)
real(8), intent (in) :: kx
real(8), intent (in) :: ky
real(8), intent (in) :: th
code = 1.0d0 / ((1.0d0 / th) + (th * 0.16666666666666666d0))
end function
public static double code(double kx, double ky, double th) {
return 1.0 / ((1.0 / th) + (th * 0.16666666666666666));
}
def code(kx, ky, th): return 1.0 / ((1.0 / th) + (th * 0.16666666666666666))
function code(kx, ky, th) return Float64(1.0 / Float64(Float64(1.0 / th) + Float64(th * 0.16666666666666666))) end
function tmp = code(kx, ky, th) tmp = 1.0 / ((1.0 / th) + (th * 0.16666666666666666)); end
code[kx_, ky_, th_] := N[(1.0 / N[(N[(1.0 / th), $MachinePrecision] + N[(th * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{1}{th} + th \cdot 0.16666666666666666}
\end{array}
Initial program 93.8%
associate-/r/93.7%
+-commutative93.7%
unpow293.7%
sqr-neg93.7%
sin-neg93.7%
sin-neg93.7%
unpow293.7%
+-commutative93.7%
Simplified99.5%
Taylor expanded in th around 0 50.3%
+-commutative50.3%
unpow250.3%
unpow250.3%
hypot-def53.6%
associate-*r*53.6%
unpow253.6%
unpow253.6%
hypot-def53.7%
distribute-rgt-out53.7%
Simplified53.7%
Taylor expanded in kx around 0 16.0%
Final simplification16.0%
(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 93.8%
associate-/r/93.7%
+-commutative93.7%
unpow293.7%
sqr-neg93.7%
sin-neg93.7%
sin-neg93.7%
unpow293.7%
+-commutative93.7%
Simplified99.5%
Taylor expanded in kx around 0 21.5%
Taylor expanded in th around 0 15.4%
Final simplification15.4%
herbie shell --seed 2023271
(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)))