
(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 16 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.7%
+-commutative93.7%
unpow293.7%
unpow293.7%
hypot-def99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin th) (sin kx))) (t_2 (* (sin ky) (fabs t_1))))
(if (<= (sin kx) -0.82)
t_2
(if (<= (sin kx) -0.505)
(fabs (* (sin ky) t_1))
(if (<= (sin kx) -0.02)
t_2
(if (<= (sin kx) 2e-19)
(sin th)
(* (sin th) (/ (sin ky) (sin kx)))))))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) / sin(kx);
double t_2 = sin(ky) * fabs(t_1);
double tmp;
if (sin(kx) <= -0.82) {
tmp = t_2;
} else if (sin(kx) <= -0.505) {
tmp = fabs((sin(ky) * t_1));
} else if (sin(kx) <= -0.02) {
tmp = t_2;
} else if (sin(kx) <= 2e-19) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = sin(th) / sin(kx)
t_2 = sin(ky) * abs(t_1)
if (sin(kx) <= (-0.82d0)) then
tmp = t_2
else if (sin(kx) <= (-0.505d0)) then
tmp = abs((sin(ky) * t_1))
else if (sin(kx) <= (-0.02d0)) then
tmp = t_2
else if (sin(kx) <= 2d-19) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) / Math.sin(kx);
double t_2 = Math.sin(ky) * Math.abs(t_1);
double tmp;
if (Math.sin(kx) <= -0.82) {
tmp = t_2;
} else if (Math.sin(kx) <= -0.505) {
tmp = Math.abs((Math.sin(ky) * t_1));
} else if (Math.sin(kx) <= -0.02) {
tmp = t_2;
} else if (Math.sin(kx) <= 2e-19) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) / math.sin(kx) t_2 = math.sin(ky) * math.fabs(t_1) tmp = 0 if math.sin(kx) <= -0.82: tmp = t_2 elif math.sin(kx) <= -0.505: tmp = math.fabs((math.sin(ky) * t_1)) elif math.sin(kx) <= -0.02: tmp = t_2 elif math.sin(kx) <= 2e-19: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) / sin(kx)) t_2 = Float64(sin(ky) * abs(t_1)) tmp = 0.0 if (sin(kx) <= -0.82) tmp = t_2; elseif (sin(kx) <= -0.505) tmp = abs(Float64(sin(ky) * t_1)); elseif (sin(kx) <= -0.02) tmp = t_2; elseif (sin(kx) <= 2e-19) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) / sin(kx); t_2 = sin(ky) * abs(t_1); tmp = 0.0; if (sin(kx) <= -0.82) tmp = t_2; elseif (sin(kx) <= -0.505) tmp = abs((sin(ky) * t_1)); elseif (sin(kx) <= -0.02) tmp = t_2; elseif (sin(kx) <= 2e-19) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[ky], $MachinePrecision] * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.82], t$95$2, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.505], N[Abs[N[(N[Sin[ky], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], -0.02], t$95$2, If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-19], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin th}{\sin kx}\\
t_2 := \sin ky \cdot \left|t_1\right|\\
\mathbf{if}\;\sin kx \leq -0.82:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\sin kx \leq -0.505:\\
\;\;\;\;\left|\sin ky \cdot t_1\right|\\
\mathbf{elif}\;\sin kx \leq -0.02:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.819999999999999951 or -0.505000000000000004 < (sin.f64 kx) < -0.0200000000000000004Initial program 99.5%
associate-*l/99.3%
*-commutative99.3%
associate-*l/99.4%
+-commutative99.4%
unpow299.4%
unpow299.4%
hypot-def99.5%
Simplified99.5%
Taylor expanded in ky around 0 9.0%
add-sqr-sqrt5.8%
sqrt-unprod40.2%
pow240.2%
Applied egg-rr40.2%
unpow240.2%
rem-sqrt-square40.2%
Simplified40.2%
if -0.819999999999999951 < (sin.f64 kx) < -0.505000000000000004Initial program 99.4%
Taylor expanded in ky around 0 13.5%
associate-*l/13.5%
*-commutative13.5%
add-sqr-sqrt7.3%
sqrt-unprod41.4%
pow241.4%
associate-/l*41.5%
associate-/r/41.4%
Applied egg-rr41.4%
unpow241.4%
rem-sqrt-square65.4%
*-commutative65.4%
Simplified65.4%
if -0.0200000000000000004 < (sin.f64 kx) < 2e-19Initial program 87.1%
+-commutative87.1%
unpow287.1%
unpow287.1%
hypot-def99.9%
Simplified99.9%
Taylor expanded in kx around 0 43.9%
if 2e-19 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 52.7%
Final simplification46.4%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin th) (sin kx))))
(if (<= (sin kx) -0.82)
(* (sin ky) (fabs t_1))
(if (<= (sin kx) -0.5)
(fabs (* (sin ky) t_1))
(if (<= (sin kx) -0.005)
(* (sin th) (/ (fabs (sin ky)) (sin kx)))
(if (<= (sin kx) 2e-19)
(sin th)
(* (sin th) (/ (sin ky) (sin kx)))))))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) / sin(kx);
double tmp;
if (sin(kx) <= -0.82) {
tmp = sin(ky) * fabs(t_1);
} else if (sin(kx) <= -0.5) {
tmp = fabs((sin(ky) * t_1));
} else if (sin(kx) <= -0.005) {
tmp = sin(th) * (fabs(sin(ky)) / sin(kx));
} else if (sin(kx) <= 2e-19) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
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) :: t_1
real(8) :: tmp
t_1 = sin(th) / sin(kx)
if (sin(kx) <= (-0.82d0)) then
tmp = sin(ky) * abs(t_1)
else if (sin(kx) <= (-0.5d0)) then
tmp = abs((sin(ky) * t_1))
else if (sin(kx) <= (-0.005d0)) then
tmp = sin(th) * (abs(sin(ky)) / sin(kx))
else if (sin(kx) <= 2d-19) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) / Math.sin(kx);
double tmp;
if (Math.sin(kx) <= -0.82) {
tmp = Math.sin(ky) * Math.abs(t_1);
} else if (Math.sin(kx) <= -0.5) {
tmp = Math.abs((Math.sin(ky) * t_1));
} else if (Math.sin(kx) <= -0.005) {
tmp = Math.sin(th) * (Math.abs(Math.sin(ky)) / Math.sin(kx));
} else if (Math.sin(kx) <= 2e-19) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) / math.sin(kx) tmp = 0 if math.sin(kx) <= -0.82: tmp = math.sin(ky) * math.fabs(t_1) elif math.sin(kx) <= -0.5: tmp = math.fabs((math.sin(ky) * t_1)) elif math.sin(kx) <= -0.005: tmp = math.sin(th) * (math.fabs(math.sin(ky)) / math.sin(kx)) elif math.sin(kx) <= 2e-19: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) / sin(kx)) tmp = 0.0 if (sin(kx) <= -0.82) tmp = Float64(sin(ky) * abs(t_1)); elseif (sin(kx) <= -0.5) tmp = abs(Float64(sin(ky) * t_1)); elseif (sin(kx) <= -0.005) tmp = Float64(sin(th) * Float64(abs(sin(ky)) / sin(kx))); elseif (sin(kx) <= 2e-19) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) / sin(kx); tmp = 0.0; if (sin(kx) <= -0.82) tmp = sin(ky) * abs(t_1); elseif (sin(kx) <= -0.5) tmp = abs((sin(ky) * t_1)); elseif (sin(kx) <= -0.005) tmp = sin(th) * (abs(sin(ky)) / sin(kx)); elseif (sin(kx) <= 2e-19) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.82], N[(N[Sin[ky], $MachinePrecision] * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], -0.5], N[Abs[N[(N[Sin[ky], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(N[Sin[th], $MachinePrecision] * N[(N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-19], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin th}{\sin kx}\\
\mathbf{if}\;\sin kx \leq -0.82:\\
\;\;\;\;\sin ky \cdot \left|t_1\right|\\
\mathbf{elif}\;\sin kx \leq -0.5:\\
\;\;\;\;\left|\sin ky \cdot t_1\right|\\
\mathbf{elif}\;\sin kx \leq -0.005:\\
\;\;\;\;\sin th \cdot \frac{\left|\sin ky\right|}{\sin kx}\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.819999999999999951Initial program 99.5%
associate-*l/99.4%
*-commutative99.4%
associate-*l/99.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Simplified99.3%
Taylor expanded in ky around 0 2.3%
add-sqr-sqrt0.7%
sqrt-unprod40.3%
pow240.3%
Applied egg-rr40.3%
unpow240.3%
rem-sqrt-square40.2%
Simplified40.2%
if -0.819999999999999951 < (sin.f64 kx) < -0.5Initial program 99.3%
Taylor expanded in ky around 0 12.8%
associate-*l/12.8%
*-commutative12.8%
add-sqr-sqrt6.8%
sqrt-unprod44.9%
pow244.9%
associate-/l*45.1%
associate-/r/44.9%
Applied egg-rr44.9%
unpow244.9%
rem-sqrt-square67.5%
*-commutative67.5%
Simplified67.5%
if -0.5 < (sin.f64 kx) < -0.0050000000000000001Initial program 99.5%
Taylor expanded in ky around 0 15.9%
add-sqr-sqrt7.2%
sqrt-prod24.0%
rem-sqrt-square38.7%
Applied egg-rr38.7%
if -0.0050000000000000001 < (sin.f64 kx) < 2e-19Initial program 86.8%
+-commutative86.8%
unpow286.8%
unpow286.8%
hypot-def99.9%
Simplified99.9%
Taylor expanded in kx around 0 44.6%
if 2e-19 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 52.7%
Final simplification46.7%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (/ (sin th) (sin kx))))
(if (<= (sin kx) -0.82)
(* (sin ky) (fabs t_1))
(if (<= (sin kx) -0.5)
(fabs (* (sin ky) t_1))
(if (<= (sin kx) -0.005)
(* t_1 (fabs (sin ky)))
(if (<= (sin kx) 2e-19)
(sin th)
(* (sin th) (/ (sin ky) (sin kx)))))))))
double code(double kx, double ky, double th) {
double t_1 = sin(th) / sin(kx);
double tmp;
if (sin(kx) <= -0.82) {
tmp = sin(ky) * fabs(t_1);
} else if (sin(kx) <= -0.5) {
tmp = fabs((sin(ky) * t_1));
} else if (sin(kx) <= -0.005) {
tmp = t_1 * fabs(sin(ky));
} else if (sin(kx) <= 2e-19) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
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) :: t_1
real(8) :: tmp
t_1 = sin(th) / sin(kx)
if (sin(kx) <= (-0.82d0)) then
tmp = sin(ky) * abs(t_1)
else if (sin(kx) <= (-0.5d0)) then
tmp = abs((sin(ky) * t_1))
else if (sin(kx) <= (-0.005d0)) then
tmp = t_1 * abs(sin(ky))
else if (sin(kx) <= 2d-19) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double t_1 = Math.sin(th) / Math.sin(kx);
double tmp;
if (Math.sin(kx) <= -0.82) {
tmp = Math.sin(ky) * Math.abs(t_1);
} else if (Math.sin(kx) <= -0.5) {
tmp = Math.abs((Math.sin(ky) * t_1));
} else if (Math.sin(kx) <= -0.005) {
tmp = t_1 * Math.abs(Math.sin(ky));
} else if (Math.sin(kx) <= 2e-19) {
tmp = Math.sin(th);
} else {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): t_1 = math.sin(th) / math.sin(kx) tmp = 0 if math.sin(kx) <= -0.82: tmp = math.sin(ky) * math.fabs(t_1) elif math.sin(kx) <= -0.5: tmp = math.fabs((math.sin(ky) * t_1)) elif math.sin(kx) <= -0.005: tmp = t_1 * math.fabs(math.sin(ky)) elif math.sin(kx) <= 2e-19: tmp = math.sin(th) else: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) return tmp
function code(kx, ky, th) t_1 = Float64(sin(th) / sin(kx)) tmp = 0.0 if (sin(kx) <= -0.82) tmp = Float64(sin(ky) * abs(t_1)); elseif (sin(kx) <= -0.5) tmp = abs(Float64(sin(ky) * t_1)); elseif (sin(kx) <= -0.005) tmp = Float64(t_1 * abs(sin(ky))); elseif (sin(kx) <= 2e-19) tmp = sin(th); else tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) t_1 = sin(th) / sin(kx); tmp = 0.0; if (sin(kx) <= -0.82) tmp = sin(ky) * abs(t_1); elseif (sin(kx) <= -0.5) tmp = abs((sin(ky) * t_1)); elseif (sin(kx) <= -0.005) tmp = t_1 * abs(sin(ky)); elseif (sin(kx) <= 2e-19) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := Block[{t$95$1 = N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[kx], $MachinePrecision], -0.82], N[(N[Sin[ky], $MachinePrecision] * N[Abs[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], -0.5], N[Abs[N[(N[Sin[ky], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[(t$95$1 * N[Abs[N[Sin[ky], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-19], N[Sin[th], $MachinePrecision], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\sin th}{\sin kx}\\
\mathbf{if}\;\sin kx \leq -0.82:\\
\;\;\;\;\sin ky \cdot \left|t_1\right|\\
\mathbf{elif}\;\sin kx \leq -0.5:\\
\;\;\;\;\left|\sin ky \cdot t_1\right|\\
\mathbf{elif}\;\sin kx \leq -0.005:\\
\;\;\;\;t_1 \cdot \left|\sin ky\right|\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.819999999999999951Initial program 99.5%
associate-*l/99.4%
*-commutative99.4%
associate-*l/99.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.3%
Simplified99.3%
Taylor expanded in ky around 0 2.3%
add-sqr-sqrt0.7%
sqrt-unprod40.3%
pow240.3%
Applied egg-rr40.3%
unpow240.3%
rem-sqrt-square40.2%
Simplified40.2%
if -0.819999999999999951 < (sin.f64 kx) < -0.5Initial program 99.3%
Taylor expanded in ky around 0 12.8%
associate-*l/12.8%
*-commutative12.8%
add-sqr-sqrt6.8%
sqrt-unprod44.9%
pow244.9%
associate-/l*45.1%
associate-/r/44.9%
Applied egg-rr44.9%
unpow244.9%
rem-sqrt-square67.5%
*-commutative67.5%
Simplified67.5%
if -0.5 < (sin.f64 kx) < -0.0050000000000000001Initial program 99.5%
associate-*l/99.1%
*-commutative99.1%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 15.9%
add-sqr-sqrt7.2%
sqrt-prod24.0%
rem-sqrt-square38.7%
Applied egg-rr38.8%
if -0.0050000000000000001 < (sin.f64 kx) < 2e-19Initial program 86.8%
+-commutative86.8%
unpow286.8%
unpow286.8%
hypot-def99.9%
Simplified99.9%
Taylor expanded in kx around 0 44.6%
if 2e-19 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 52.7%
Final simplification46.7%
(FPCore (kx ky th)
:precision binary64
(if (<= (sin th) -0.025)
(sin th)
(if (<= (sin th) 1e-5)
(* (/ (sin ky) (hypot (sin ky) (sin kx))) th)
(* (sin ky) (fabs (/ (sin th) (sin kx)))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(th) <= -0.025) {
tmp = sin(th);
} else if (sin(th) <= 1e-5) {
tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th;
} else {
tmp = sin(ky) * fabs((sin(th) / sin(kx)));
}
return tmp;
}
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(th) <= -0.025) {
tmp = Math.sin(th);
} else if (Math.sin(th) <= 1e-5) {
tmp = (Math.sin(ky) / Math.hypot(Math.sin(ky), Math.sin(kx))) * th;
} else {
tmp = Math.sin(ky) * Math.abs((Math.sin(th) / Math.sin(kx)));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(th) <= -0.025: tmp = math.sin(th) elif math.sin(th) <= 1e-5: tmp = (math.sin(ky) / math.hypot(math.sin(ky), math.sin(kx))) * th else: tmp = math.sin(ky) * math.fabs((math.sin(th) / math.sin(kx))) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(th) <= -0.025) tmp = sin(th); elseif (sin(th) <= 1e-5) tmp = Float64(Float64(sin(ky) / hypot(sin(ky), sin(kx))) * th); else tmp = Float64(sin(ky) * abs(Float64(sin(th) / sin(kx)))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(th) <= -0.025) tmp = sin(th); elseif (sin(th) <= 1e-5) tmp = (sin(ky) / hypot(sin(ky), sin(kx))) * th; else tmp = sin(ky) * abs((sin(th) / sin(kx))); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[th], $MachinePrecision], -0.025], N[Sin[th], $MachinePrecision], If[LessEqual[N[Sin[th], $MachinePrecision], 1e-5], N[(N[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * th), $MachinePrecision], N[(N[Sin[ky], $MachinePrecision] * N[Abs[N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin th \leq -0.025:\\
\;\;\;\;\sin th\\
\mathbf{elif}\;\sin th \leq 10^{-5}:\\
\;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot th\\
\mathbf{else}:\\
\;\;\;\;\sin ky \cdot \left|\frac{\sin th}{\sin kx}\right|\\
\end{array}
\end{array}
if (sin.f64 th) < -0.025000000000000001Initial program 91.2%
+-commutative91.2%
unpow291.2%
unpow291.2%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 34.1%
if -0.025000000000000001 < (sin.f64 th) < 1.00000000000000008e-5Initial program 96.7%
associate-*l/95.7%
*-commutative95.7%
associate-*l/96.6%
+-commutative96.6%
unpow296.6%
unpow296.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 94.6%
*-commutative94.6%
+-commutative94.6%
Simplified94.6%
add-log-exp18.5%
*-commutative18.5%
exp-prod19.3%
*-commutative19.3%
sqrt-div19.3%
metadata-eval19.3%
+-commutative19.3%
unpow219.3%
unpow219.3%
hypot-udef19.3%
un-div-inv19.3%
Applied egg-rr19.3%
log-pow73.2%
hypot-def72.4%
unpow272.4%
unpow272.4%
+-commutative72.4%
unpow272.4%
unpow272.4%
hypot-def73.2%
rem-log-exp98.5%
Simplified98.5%
expm1-log1p-u98.5%
expm1-udef19.3%
div-inv19.3%
associate-*l*19.3%
associate-/r/19.3%
clear-num19.3%
Applied egg-rr19.3%
expm1-def98.6%
expm1-log1p98.6%
Simplified98.6%
if 1.00000000000000008e-5 < (sin.f64 th) Initial program 90.0%
associate-*l/90.0%
*-commutative90.0%
associate-*l/90.1%
+-commutative90.1%
unpow290.1%
unpow290.1%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 16.8%
add-sqr-sqrt15.4%
sqrt-unprod41.2%
pow241.2%
Applied egg-rr41.2%
unpow241.2%
rem-sqrt-square45.9%
Simplified45.9%
Final simplification70.6%
(FPCore (kx ky th)
:precision binary64
(let* ((t_1 (hypot (sin ky) (sin kx))))
(if (<= (sin ky) -1e-7)
(* (/ (sin ky) t_1) th)
(if (<= (sin ky) 4e-15) (* (sin th) (/ ky 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) <= -1e-7) {
tmp = (sin(ky) / t_1) * th;
} else if (sin(ky) <= 4e-15) {
tmp = sin(th) * (ky / t_1);
} else {
tmp = 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) <= -1e-7) {
tmp = (Math.sin(ky) / t_1) * th;
} else if (Math.sin(ky) <= 4e-15) {
tmp = Math.sin(th) * (ky / t_1);
} else {
tmp = 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) <= -1e-7: tmp = (math.sin(ky) / t_1) * th elif math.sin(ky) <= 4e-15: tmp = math.sin(th) * (ky / t_1) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) t_1 = hypot(sin(ky), sin(kx)) tmp = 0.0 if (sin(ky) <= -1e-7) tmp = Float64(Float64(sin(ky) / t_1) * th); elseif (sin(ky) <= 4e-15) tmp = Float64(sin(th) * Float64(ky / t_1)); else tmp = 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) <= -1e-7) tmp = (sin(ky) / t_1) * th; elseif (sin(ky) <= 4e-15) tmp = sin(th) * (ky / t_1); else tmp = 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[LessEqual[N[Sin[ky], $MachinePrecision], -1e-7], N[(N[(N[Sin[ky], $MachinePrecision] / t$95$1), $MachinePrecision] * th), $MachinePrecision], If[LessEqual[N[Sin[ky], $MachinePrecision], 4e-15], N[(N[Sin[th], $MachinePrecision] * N[(ky / t$95$1), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin ky \leq -1 \cdot 10^{-7}:\\
\;\;\;\;\frac{\sin ky}{t_1} \cdot th\\
\mathbf{elif}\;\sin ky \leq 4 \cdot 10^{-15}:\\
\;\;\;\;\sin th \cdot \frac{ky}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < -9.9999999999999995e-8Initial program 99.5%
associate-*l/99.4%
*-commutative99.4%
associate-*l/99.5%
+-commutative99.5%
unpow299.5%
unpow299.5%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 58.1%
*-commutative58.1%
+-commutative58.1%
Simplified58.1%
add-log-exp4.7%
*-commutative4.7%
exp-prod4.7%
*-commutative4.7%
sqrt-div4.7%
metadata-eval4.7%
+-commutative4.7%
unpow24.7%
unpow24.7%
hypot-udef4.7%
un-div-inv4.7%
Applied egg-rr4.7%
log-pow57.6%
hypot-def57.6%
unpow257.6%
unpow257.6%
+-commutative57.6%
unpow257.6%
unpow257.6%
hypot-def57.6%
rem-log-exp58.3%
Simplified58.3%
expm1-log1p-u57.8%
expm1-udef4.5%
div-inv4.5%
associate-*l*4.5%
associate-/r/4.5%
clear-num4.5%
Applied egg-rr4.5%
expm1-def57.9%
expm1-log1p58.4%
Simplified58.4%
if -9.9999999999999995e-8 < (sin.f64 ky) < 4.0000000000000003e-15Initial program 85.7%
+-commutative85.7%
unpow285.7%
unpow285.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 99.7%
if 4.0000000000000003e-15 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 59.3%
Final simplification76.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin kx) -0.005) (fabs (* (sin ky) (/ (sin th) (sin kx)))) (if (<= (sin kx) 2e-19) (sin th) (* (sin th) (/ (sin ky) (sin kx))))))
double code(double kx, double ky, double th) {
double tmp;
if (sin(kx) <= -0.005) {
tmp = fabs((sin(ky) * (sin(th) / sin(kx))));
} else if (sin(kx) <= 2e-19) {
tmp = sin(th);
} else {
tmp = sin(th) * (sin(ky) / sin(kx));
}
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(kx) <= (-0.005d0)) then
tmp = abs((sin(ky) * (sin(th) / sin(kx))))
else if (sin(kx) <= 2d-19) then
tmp = sin(th)
else
tmp = sin(th) * (sin(ky) / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (Math.sin(kx) <= -0.005) {
tmp = Math.abs((Math.sin(ky) * (Math.sin(th) / Math.sin(kx))));
} else if (Math.sin(kx) <= 2e-19) {
tmp = 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(kx) <= -0.005: tmp = math.fabs((math.sin(ky) * (math.sin(th) / math.sin(kx)))) elif math.sin(kx) <= 2e-19: tmp = 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(kx) <= -0.005) tmp = abs(Float64(sin(ky) * Float64(sin(th) / sin(kx)))); elseif (sin(kx) <= 2e-19) tmp = 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(kx) <= -0.005) tmp = abs((sin(ky) * (sin(th) / sin(kx)))); elseif (sin(kx) <= 2e-19) tmp = sin(th); else tmp = sin(th) * (sin(ky) / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[kx], $MachinePrecision], -0.005], N[Abs[N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[Sin[kx], $MachinePrecision], 2e-19], N[Sin[th], $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 kx \leq -0.005:\\
\;\;\;\;\left|\sin ky \cdot \frac{\sin th}{\sin kx}\right|\\
\mathbf{elif}\;\sin kx \leq 2 \cdot 10^{-19}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\end{array}
\end{array}
if (sin.f64 kx) < -0.0050000000000000001Initial program 99.5%
Taylor expanded in ky around 0 9.8%
associate-*l/9.8%
*-commutative9.8%
add-sqr-sqrt7.6%
sqrt-unprod23.9%
pow223.9%
associate-/l*23.9%
associate-/r/23.9%
Applied egg-rr23.9%
unpow223.9%
rem-sqrt-square34.3%
*-commutative34.3%
Simplified34.3%
if -0.0050000000000000001 < (sin.f64 kx) < 2e-19Initial program 86.8%
+-commutative86.8%
unpow286.8%
unpow286.8%
hypot-def99.9%
Simplified99.9%
Taylor expanded in kx around 0 44.6%
if 2e-19 < (sin.f64 kx) Initial program 99.5%
Taylor expanded in ky around 0 52.7%
Final simplification43.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 4e-94) (* (sin th) (/ (sin ky) (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 4e-94) {
tmp = sin(th) * (sin(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) <= 4d-94) then
tmp = sin(th) * (sin(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) <= 4e-94) {
tmp = Math.sin(th) * (Math.sin(ky) / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 4e-94: tmp = math.sin(th) * (math.sin(ky) / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 4e-94) tmp = Float64(sin(th) * Float64(sin(ky) / sin(kx))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 4e-94) tmp = sin(th) * (sin(ky) / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 4e-94], N[(N[Sin[th], $MachinePrecision] * N[(N[Sin[ky], $MachinePrecision] / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 4 \cdot 10^{-94}:\\
\;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 3.9999999999999998e-94Initial program 90.6%
Taylor expanded in ky around 0 27.2%
if 3.9999999999999998e-94 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 57.4%
Final simplification37.7%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-211) (fabs (* th (/ ky (sin kx)))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-211) {
tmp = fabs((th * (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) <= 2d-211) then
tmp = abs((th * (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) <= 2e-211) {
tmp = Math.abs((th * (ky / Math.sin(kx))));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 2e-211: tmp = math.fabs((th * (ky / math.sin(kx)))) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 2e-211) tmp = abs(Float64(th * 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) <= 2e-211) tmp = abs((th * (ky / sin(kx)))); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-211], N[Abs[N[(th * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-211}:\\
\;\;\;\;\left|th \cdot \frac{ky}{\sin kx}\right|\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 2.00000000000000017e-211Initial program 93.1%
associate-*l/92.2%
*-commutative92.2%
associate-*l/93.0%
+-commutative93.0%
unpow293.0%
unpow293.0%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 52.4%
*-commutative52.4%
+-commutative52.4%
Simplified52.4%
Taylor expanded in ky around 0 14.8%
associate-/l*15.3%
Simplified15.3%
add-sqr-sqrt13.1%
sqrt-unprod14.1%
pow214.1%
associate-/r/14.1%
associate-*l/14.1%
Applied egg-rr14.1%
unpow214.1%
rem-sqrt-square16.2%
associate-*l/16.6%
*-commutative16.6%
Simplified16.6%
if 2.00000000000000017e-211 < (sin.f64 ky) Initial program 94.6%
+-commutative94.6%
unpow294.6%
unpow294.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 52.4%
Final simplification32.4%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 4e-94) (* (sin th) (/ ky (sin kx))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 4e-94) {
tmp = sin(th) * (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) <= 4d-94) then
tmp = sin(th) * (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) <= 4e-94) {
tmp = Math.sin(th) * (ky / Math.sin(kx));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 4e-94: tmp = math.sin(th) * (ky / math.sin(kx)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 4e-94) tmp = Float64(sin(th) * 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) <= 4e-94) tmp = sin(th) * (ky / sin(kx)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 4e-94], N[(N[Sin[th], $MachinePrecision] * N[(ky / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 4 \cdot 10^{-94}:\\
\;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 3.9999999999999998e-94Initial program 90.6%
Taylor expanded in ky around 0 24.8%
if 3.9999999999999998e-94 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 57.4%
Final simplification36.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 4e-94) (/ ky (/ (sin kx) (sin th))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 4e-94) {
tmp = ky / (sin(kx) / sin(th));
} 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) <= 4d-94) then
tmp = ky / (sin(kx) / sin(th))
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) <= 4e-94) {
tmp = ky / (Math.sin(kx) / Math.sin(th));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 4e-94: tmp = ky / (math.sin(kx) / math.sin(th)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 4e-94) tmp = Float64(ky / Float64(sin(kx) / sin(th))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 4e-94) tmp = ky / (sin(kx) / sin(th)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 4e-94], N[(ky / N[(N[Sin[kx], $MachinePrecision] / N[Sin[th], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 4 \cdot 10^{-94}:\\
\;\;\;\;\frac{ky}{\frac{\sin kx}{\sin th}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 3.9999999999999998e-94Initial program 90.6%
+-commutative90.6%
unpow290.6%
unpow290.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in ky around 0 24.3%
associate-/l*24.8%
Simplified24.8%
if 3.9999999999999998e-94 < (sin.f64 ky) Initial program 99.7%
+-commutative99.7%
unpow299.7%
unpow299.7%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 57.4%
Final simplification36.1%
(FPCore (kx ky th) :precision binary64 (if (<= (sin ky) 2e-211) (/ th (/ kx (sin ky))) (sin th)))
double code(double kx, double ky, double th) {
double tmp;
if (sin(ky) <= 2e-211) {
tmp = th / (kx / sin(ky));
} 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) <= 2d-211) then
tmp = th / (kx / sin(ky))
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) <= 2e-211) {
tmp = th / (kx / Math.sin(ky));
} else {
tmp = Math.sin(th);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if math.sin(ky) <= 2e-211: tmp = th / (kx / math.sin(ky)) else: tmp = math.sin(th) return tmp
function code(kx, ky, th) tmp = 0.0 if (sin(ky) <= 2e-211) tmp = Float64(th / Float64(kx / sin(ky))); else tmp = sin(th); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (sin(ky) <= 2e-211) tmp = th / (kx / sin(ky)); else tmp = sin(th); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[N[Sin[ky], $MachinePrecision], 2e-211], N[(th / N[(kx / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Sin[th], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\sin ky \leq 2 \cdot 10^{-211}:\\
\;\;\;\;\frac{th}{\frac{kx}{\sin ky}}\\
\mathbf{else}:\\
\;\;\;\;\sin th\\
\end{array}
\end{array}
if (sin.f64 ky) < 2.00000000000000017e-211Initial program 93.1%
associate-*l/92.2%
*-commutative92.2%
associate-*l/93.0%
+-commutative93.0%
unpow293.0%
unpow293.0%
hypot-def99.6%
Simplified99.6%
Taylor expanded in ky around 0 24.1%
Taylor expanded in th around 0 16.2%
associate-/l*16.8%
Simplified16.8%
Taylor expanded in kx around 0 14.1%
associate-/l*14.7%
Simplified14.7%
if 2.00000000000000017e-211 < (sin.f64 ky) Initial program 94.6%
+-commutative94.6%
unpow294.6%
unpow294.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 52.4%
Final simplification31.4%
(FPCore (kx ky th) :precision binary64 (if (<= kx 8.2e-10) (sin th) (* ky (/ th (sin kx)))))
double code(double kx, double ky, double th) {
double tmp;
if (kx <= 8.2e-10) {
tmp = sin(th);
} else {
tmp = ky * (th / sin(kx));
}
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 (kx <= 8.2d-10) then
tmp = sin(th)
else
tmp = ky * (th / sin(kx))
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (kx <= 8.2e-10) {
tmp = Math.sin(th);
} else {
tmp = ky * (th / Math.sin(kx));
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if kx <= 8.2e-10: tmp = math.sin(th) else: tmp = ky * (th / math.sin(kx)) return tmp
function code(kx, ky, th) tmp = 0.0 if (kx <= 8.2e-10) tmp = sin(th); else tmp = Float64(ky * Float64(th / sin(kx))); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (kx <= 8.2e-10) tmp = sin(th); else tmp = ky * (th / sin(kx)); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[kx, 8.2e-10], N[Sin[th], $MachinePrecision], N[(ky * N[(th / N[Sin[kx], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;kx \leq 8.2 \cdot 10^{-10}:\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;ky \cdot \frac{th}{\sin kx}\\
\end{array}
\end{array}
if kx < 8.1999999999999996e-10Initial program 91.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-def99.8%
Simplified99.8%
Taylor expanded in kx around 0 32.1%
if 8.1999999999999996e-10 < kx Initial program 99.4%
associate-*l/99.4%
*-commutative99.4%
associate-*l/99.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-def99.4%
Simplified99.4%
Taylor expanded in th around 0 57.2%
*-commutative57.2%
+-commutative57.2%
Simplified57.2%
Taylor expanded in ky around 0 23.2%
associate-/l*23.2%
Simplified23.2%
clear-num23.2%
associate-/r/23.2%
clear-num23.2%
Applied egg-rr23.2%
Final simplification29.7%
(FPCore (kx ky th) :precision binary64 (if (or (<= ky -70000.0) (not (<= ky 2.1e-210))) (sin th) (* th (/ ky kx))))
double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -70000.0) || !(ky <= 2.1e-210)) {
tmp = sin(th);
} else {
tmp = th * (ky / kx);
}
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 <= (-70000.0d0)) .or. (.not. (ky <= 2.1d-210))) then
tmp = sin(th)
else
tmp = th * (ky / kx)
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if ((ky <= -70000.0) || !(ky <= 2.1e-210)) {
tmp = Math.sin(th);
} else {
tmp = th * (ky / kx);
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if (ky <= -70000.0) or not (ky <= 2.1e-210): tmp = math.sin(th) else: tmp = th * (ky / kx) return tmp
function code(kx, ky, th) tmp = 0.0 if ((ky <= -70000.0) || !(ky <= 2.1e-210)) tmp = sin(th); else tmp = Float64(th * Float64(ky / kx)); end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if ((ky <= -70000.0) || ~((ky <= 2.1e-210))) tmp = sin(th); else tmp = th * (ky / kx); end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[Or[LessEqual[ky, -70000.0], N[Not[LessEqual[ky, 2.1e-210]], $MachinePrecision]], N[Sin[th], $MachinePrecision], N[(th * N[(ky / kx), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -70000 \lor \neg \left(ky \leq 2.1 \cdot 10^{-210}\right):\\
\;\;\;\;\sin th\\
\mathbf{else}:\\
\;\;\;\;th \cdot \frac{ky}{kx}\\
\end{array}
\end{array}
if ky < -7e4 or 2.10000000000000016e-210 < ky Initial program 96.6%
+-commutative96.6%
unpow296.6%
unpow296.6%
hypot-def99.7%
Simplified99.7%
Taylor expanded in kx around 0 32.7%
if -7e4 < ky < 2.10000000000000016e-210Initial program 86.0%
associate-*l/84.2%
*-commutative84.2%
associate-*l/85.9%
+-commutative85.9%
unpow285.9%
unpow285.9%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 47.8%
*-commutative47.8%
+-commutative47.8%
Simplified47.8%
Taylor expanded in ky around 0 28.0%
associate-/l*29.2%
Simplified29.2%
Taylor expanded in kx around 0 24.2%
associate-/l*25.4%
Simplified25.4%
associate-/r/25.5%
Applied egg-rr25.5%
Final simplification30.8%
(FPCore (kx ky th) :precision binary64 (if (<= ky -70000.0) th (if (<= ky 2.4e-118) (* th (/ ky kx)) th)))
double code(double kx, double ky, double th) {
double tmp;
if (ky <= -70000.0) {
tmp = th;
} else if (ky <= 2.4e-118) {
tmp = th * (ky / kx);
} else {
tmp = 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 <= (-70000.0d0)) then
tmp = th
else if (ky <= 2.4d-118) then
tmp = th * (ky / kx)
else
tmp = th
end if
code = tmp
end function
public static double code(double kx, double ky, double th) {
double tmp;
if (ky <= -70000.0) {
tmp = th;
} else if (ky <= 2.4e-118) {
tmp = th * (ky / kx);
} else {
tmp = th;
}
return tmp;
}
def code(kx, ky, th): tmp = 0 if ky <= -70000.0: tmp = th elif ky <= 2.4e-118: tmp = th * (ky / kx) else: tmp = th return tmp
function code(kx, ky, th) tmp = 0.0 if (ky <= -70000.0) tmp = th; elseif (ky <= 2.4e-118) tmp = Float64(th * Float64(ky / kx)); else tmp = th; end return tmp end
function tmp_2 = code(kx, ky, th) tmp = 0.0; if (ky <= -70000.0) tmp = th; elseif (ky <= 2.4e-118) tmp = th * (ky / kx); else tmp = th; end tmp_2 = tmp; end
code[kx_, ky_, th_] := If[LessEqual[ky, -70000.0], th, If[LessEqual[ky, 2.4e-118], N[(th * N[(ky / kx), $MachinePrecision]), $MachinePrecision], th]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ky \leq -70000:\\
\;\;\;\;th\\
\mathbf{elif}\;ky \leq 2.4 \cdot 10^{-118}:\\
\;\;\;\;th \cdot \frac{ky}{kx}\\
\mathbf{else}:\\
\;\;\;\;th\\
\end{array}
\end{array}
if ky < -7e4 or 2.4000000000000001e-118 < ky Initial program 99.6%
associate-*l/99.5%
*-commutative99.5%
associate-*l/99.6%
+-commutative99.6%
unpow299.6%
unpow299.6%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 54.5%
*-commutative54.5%
+-commutative54.5%
Simplified54.5%
Taylor expanded in kx around 0 18.4%
if -7e4 < ky < 2.4000000000000001e-118Initial program 82.1%
associate-*l/80.7%
*-commutative80.7%
associate-*l/82.0%
+-commutative82.0%
unpow282.0%
unpow282.0%
hypot-def99.7%
Simplified99.7%
Taylor expanded in th around 0 42.9%
*-commutative42.9%
+-commutative42.9%
Simplified42.9%
Taylor expanded in ky around 0 26.6%
associate-/l*27.5%
Simplified27.5%
Taylor expanded in kx around 0 22.7%
associate-/l*23.6%
Simplified23.6%
associate-/r/23.7%
Applied egg-rr23.7%
Final simplification20.2%
(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.7%
associate-*l/93.2%
*-commutative93.2%
associate-*l/93.7%
+-commutative93.7%
unpow293.7%
unpow293.7%
hypot-def99.6%
Simplified99.6%
Taylor expanded in th around 0 50.6%
*-commutative50.6%
+-commutative50.6%
Simplified50.6%
Taylor expanded in kx around 0 13.5%
Final simplification13.5%
herbie shell --seed 2023333
(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)))