Average Error: 3.7 → 0.2
Time: 31.2s
Precision: binary64
Cost: 38916
\[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\ \mathbf{if}\;\sin ky \ne 0:\\ \;\;\;\;\frac{\sin th}{\frac{t_1}{\sin ky}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky \cdot \sin th}{t_1}\\ \end{array} \]
(FPCore (kx ky th)
 :precision binary64
 (* (/ (sin ky) (sqrt (+ (pow (sin kx) 2.0) (pow (sin ky) 2.0)))) (sin th)))
(FPCore (kx ky th)
 :precision binary64
 (let* ((t_1 (hypot (sin ky) (sin kx))))
   (if (!= (sin ky) 0.0)
     (/ (sin th) (/ t_1 (sin ky)))
     (/ (* (sin ky) (sin th)) t_1))))
double code(double kx, double ky, double th) {
	return (sin(ky) / sqrt((pow(sin(kx), 2.0) + pow(sin(ky), 2.0)))) * sin(th);
}
double code(double kx, double ky, double th) {
	double t_1 = hypot(sin(ky), sin(kx));
	double tmp;
	if (sin(ky) != 0.0) {
		tmp = sin(th) / (t_1 / sin(ky));
	} else {
		tmp = (sin(ky) * sin(th)) / t_1;
	}
	return tmp;
}
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);
}
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.0) {
		tmp = Math.sin(th) / (t_1 / Math.sin(ky));
	} else {
		tmp = (Math.sin(ky) * Math.sin(th)) / t_1;
	}
	return tmp;
}
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)
def code(kx, ky, th):
	t_1 = math.hypot(math.sin(ky), math.sin(kx))
	tmp = 0
	if math.sin(ky) != 0.0:
		tmp = math.sin(th) / (t_1 / math.sin(ky))
	else:
		tmp = (math.sin(ky) * math.sin(th)) / t_1
	return tmp
function code(kx, ky, th)
	return Float64(Float64(sin(ky) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th))
end
function code(kx, ky, th)
	t_1 = hypot(sin(ky), sin(kx))
	tmp = 0.0
	if (sin(ky) != 0.0)
		tmp = Float64(sin(th) / Float64(t_1 / sin(ky)));
	else
		tmp = Float64(Float64(sin(ky) * sin(th)) / t_1);
	end
	return tmp
end
function tmp = code(kx, ky, th)
	tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th);
end
function tmp_2 = code(kx, ky, th)
	t_1 = hypot(sin(ky), sin(kx));
	tmp = 0.0;
	if (sin(ky) ~= 0.0)
		tmp = sin(th) / (t_1 / sin(ky));
	else
		tmp = (sin(ky) * sin(th)) / t_1;
	end
	tmp_2 = tmp;
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]
code[kx_, ky_, th_] := Block[{t$95$1 = N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]}, If[Unequal[N[Sin[ky], $MachinePrecision], 0.0], N[(N[Sin[th], $MachinePrecision] / N[(t$95$1 / N[Sin[ky], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[ky], $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]]]
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\begin{array}{l}
t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\
\mathbf{if}\;\sin ky \ne 0:\\
\;\;\;\;\frac{\sin th}{\frac{t_1}{\sin ky}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sin ky \cdot \sin th}{t_1}\\


\end{array}

Error

Derivation

  1. Initial program 3.7

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Applied egg-rr0.2

    \[\leadsto \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;\sin ky \ne 0:\\ \;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin kx, \sin ky\right)}{\sin ky}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)}\\ } \end{array}} \]
  3. Simplified0.2

    \[\leadsto \color{blue}{\begin{array}{l} \color{blue}{\mathbf{if}\;\sin ky \ne 0:\\ \;\;\;\;\frac{\sin th}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin ky}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky \cdot \sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ } \end{array}} \]
    Proof

Alternatives

Alternative 1
Error14.0
Cost52244
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\ t_2 := \frac{\sin ky}{\left|\sin ky\right|} \cdot \sin th\\ \mathbf{if}\;\sin ky \leq -0.88:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin ky \leq -0.3:\\ \;\;\;\;\frac{th}{t_1} \cdot \sin ky\\ \mathbf{elif}\;\sin ky \leq -0.02:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin ky \leq 0.0005:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;ky \ne 0:\\ \;\;\;\;\frac{\sin th}{\frac{t_1}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin th \cdot ky}{t_1}\\ \end{array}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error16.1
Cost39048
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin kx, \sin ky\right)\\ t_2 := \frac{\sin th \cdot ky}{t_1}\\ \mathbf{if}\;\sin th \leq -0.005:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin th \leq 0.05:\\ \;\;\;\;\frac{\sin ky}{t_1} \cdot th\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error21.2
Cost38984
\[\begin{array}{l} t_1 := \frac{\sin ky}{\left|\sin kx\right|} \cdot \sin th\\ \mathbf{if}\;\sin kx \leq -1.9 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\sin kx \leq 2.45 \cdot 10^{-60}:\\ \;\;\;\;\frac{\sin ky}{\left|\sin ky\right|} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error0.2
Cost32384
\[\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th \]
Alternative 5
Error18.4
Cost26580
\[\begin{array}{l} t_1 := \frac{\sin th}{\left|\sin kx\right|} \cdot \sin ky\\ t_2 := \frac{\sin ky}{\left|\sin ky\right|} \cdot \sin th\\ \mathbf{if}\;th \leq -2.25 \cdot 10^{+112}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;th \leq -1.4 \cdot 10^{+61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -0.082:\\ \;\;\;\;t_2\\ \mathbf{elif}\;th \leq 30000000:\\ \;\;\;\;\frac{th}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot \sin ky\\ \mathbf{elif}\;th \leq 7.2 \cdot 10^{+102}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error18.4
Cost26580
\[\begin{array}{l} t_1 := \frac{\sin th}{\left|\sin kx\right|} \cdot \sin ky\\ t_2 := \frac{\sin ky}{\left|\sin ky\right|} \cdot \sin th\\ \mathbf{if}\;th \leq -1.95 \cdot 10^{+112}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;th \leq -4.6 \cdot 10^{+61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;th \leq -0.072:\\ \;\;\;\;t_2\\ \mathbf{elif}\;th \leq 30000000:\\ \;\;\;\;\frac{\sin ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot th\\ \mathbf{elif}\;th \leq 8.5 \cdot 10^{+101}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error33.7
Cost26184
\[\begin{array}{l} t_1 := \frac{\sin ky}{\left|\sin kx\right|} \cdot \sin th\\ \mathbf{if}\;kx \leq -5 \cdot 10^{-122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;kx \leq 1.8 \cdot 10^{-165}:\\ \;\;\;\;\frac{ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot th\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error21.0
Cost26184
\[\begin{array}{l} t_1 := \left|\sin kx\right|\\ \mathbf{if}\;kx \leq -4.2 \cdot 10^{-49}:\\ \;\;\;\;\frac{\sin th}{t_1} \cdot \sin ky\\ \mathbf{elif}\;kx \leq 4.5 \cdot 10^{-63}:\\ \;\;\;\;\frac{\sin ky}{\left|\sin ky\right|} \cdot \sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{t_1} \cdot \sin th\\ \end{array} \]
Alternative 9
Error52.0
Cost19584
\[\frac{ky}{\sqrt{{\sin kx}^{2}}} \cdot th \]
Alternative 10
Error47.0
Cost19584
\[\frac{ky}{\mathsf{hypot}\left(\sin kx, \sin ky\right)} \cdot th \]

Error

Reproduce

herbie shell --seed 2023010 
(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)))