Average Error: 3.8 → 0.3
Time: 36.6s
Precision: binary64
Cost: 32384
\[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
\[\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \]
(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
 (* (sin ky) (/ (sin th) (hypot (sin ky) (sin kx)))))
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) {
	return sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
}
public static double code(double kx, double ky, double th) {
	return (Math.sin(ky) / Math.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) {
	return Math.sin(ky) * (Math.sin(th) / Math.hypot(Math.sin(ky), Math.sin(kx)));
}
def code(kx, ky, th):
	return (math.sin(ky) / math.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.sin(th) / math.hypot(math.sin(ky), math.sin(kx)))
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)
	return Float64(sin(ky) * Float64(sin(th) / hypot(sin(ky), sin(kx))))
end
function tmp = code(kx, ky, th)
	tmp = (sin(ky) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th);
end
function tmp = code(kx, ky, th)
	tmp = sin(ky) * (sin(th) / hypot(sin(ky), sin(kx)));
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_] := N[(N[Sin[ky], $MachinePrecision] * N[(N[Sin[th], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 3.8

    \[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
  2. Simplified0.3

    \[\leadsto \color{blue}{\frac{\sin ky}{\frac{\mathsf{hypot}\left(\sin ky, \sin kx\right)}{\sin th}}} \]
    Proof
    (/.f64 (sin.f64 ky) (/.f64 (hypot.f64 (sin.f64 ky) (sin.f64 kx)) (sin.f64 th))): 0 points increase in error, 0 points decrease in error
    (/.f64 (sin.f64 ky) (/.f64 (Rewrite<= hypot-def_binary64 (sqrt.f64 (+.f64 (*.f64 (sin.f64 ky) (sin.f64 ky)) (*.f64 (sin.f64 kx) (sin.f64 kx))))) (sin.f64 th))): 0 points increase in error, 0 points decrease in error
    (/.f64 (sin.f64 ky) (/.f64 (sqrt.f64 (+.f64 (Rewrite<= unpow2_binary64 (pow.f64 (sin.f64 ky) 2)) (*.f64 (sin.f64 kx) (sin.f64 kx)))) (sin.f64 th))): 6 points increase in error, 0 points decrease in error
    (/.f64 (sin.f64 ky) (/.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 ky) 2) (Rewrite<= unpow2_binary64 (pow.f64 (sin.f64 kx) 2)))) (sin.f64 th))): 5 points increase in error, 1 points decrease in error
    (/.f64 (sin.f64 ky) (/.f64 (sqrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 (pow.f64 (sin.f64 kx) 2) (pow.f64 (sin.f64 ky) 2)))) (sin.f64 th))): 0 points increase in error, 5 points decrease in error
    (Rewrite=> associate-/r/_binary64 (*.f64 (/.f64 (sin.f64 ky) (sqrt.f64 (+.f64 (pow.f64 (sin.f64 kx) 2) (pow.f64 (sin.f64 ky) 2)))) (sin.f64 th))): 0 points increase in error, 1 points decrease in error
  3. Applied egg-rr0.3

    \[\leadsto \color{blue}{\frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin ky} \]
  4. Final simplification0.3

    \[\leadsto \sin ky \cdot \frac{\sin th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \]

Alternatives

Alternative 1
Error36.9
Cost52308
\[\begin{array}{l} t_1 := \sin th \cdot \sin ky\\ t_2 := \frac{t_1}{\sin ky}\\ \mathbf{if}\;\sin kx \leq -0.01:\\ \;\;\;\;\frac{th \cdot ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-66}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin kx \leq -5 \cdot 10^{-86}:\\ \;\;\;\;\frac{\left|t_1\right|}{kx}\\ \mathbf{elif}\;\sin kx \leq 10^{-251}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;\sin kx \leq 0.005:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\sin th \cdot \left(\sin ky \cdot \frac{1}{\sin kx}\right)\\ \end{array} \]
Alternative 2
Error36.9
Cost52180
\[\begin{array}{l} t_1 := \sin th \cdot \sin ky\\ t_2 := \frac{t_1}{\sin ky}\\ \mathbf{if}\;\sin kx \leq -0.01:\\ \;\;\;\;\frac{th \cdot ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{elif}\;\sin kx \leq -1 \cdot 10^{-66}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\sin kx \leq -5 \cdot 10^{-86}:\\ \;\;\;\;\frac{\left|t_1\right|}{kx}\\ \mathbf{elif}\;\sin kx \leq 10^{-251}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;\sin kx \leq 0.005:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\sin ky \cdot \frac{\sin th}{\sin kx}\\ \end{array} \]
Alternative 3
Error17.2
Cost39048
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\ \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;th \cdot \frac{\sin ky}{t_1}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-11}:\\ \;\;\;\;\frac{\sin th \cdot ky}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 4
Error17.2
Cost39048
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\ \mathbf{if}\;\sin ky \leq -0.02:\\ \;\;\;\;\frac{\sin ky}{t_1 \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-11}:\\ \;\;\;\;\frac{\sin th \cdot ky}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 5
Error38.4
Cost32716
\[\begin{array}{l} t_1 := \frac{\sin th}{\sin kx}\\ \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-128}:\\ \;\;\;\;\frac{t_1}{ky \cdot 0.16666666666666666 + \frac{1}{ky}}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-68}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-11}:\\ \;\;\;\;ky \cdot t_1\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 6
Error37.9
Cost32716
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-128}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-68}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;\sin ky \leq 2 \cdot 10^{-11}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 7
Error0.2
Cost32384
\[\sin th \cdot \frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \]
Alternative 8
Error34.5
Cost26845
\[\begin{array}{l} t_1 := \frac{\sin ky}{\sin kx}\\ \mathbf{if}\;ky \leq -45000:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -1 \cdot 10^{-82}:\\ \;\;\;\;\frac{th \cdot ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{elif}\;ky \leq -2.2 \cdot 10^{-137}:\\ \;\;\;\;\left|\sin th \cdot t_1\right|\\ \mathbf{elif}\;ky \leq -1.3 \cdot 10^{-283}:\\ \;\;\;\;\frac{\sin th \cdot ky}{\sin kx}\\ \mathbf{elif}\;ky \leq 5.4 \cdot 10^{-90} \lor \neg \left(ky \leq 2.4 \cdot 10^{-68}\right) \land ky \leq 1.65 \cdot 10^{-7}:\\ \;\;\;\;\sin th \cdot \left|t_1\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 9
Error24.8
Cost26248
\[\begin{array}{l} \mathbf{if}\;th \leq -2400000:\\ \;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\ \mathbf{elif}\;th \leq 0.000375:\\ \;\;\;\;\sin ky \cdot \frac{th}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{elif}\;th \leq 3.7 \cdot 10^{+131}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin ky}{\sin th}}\\ \mathbf{elif}\;th \leq 7 \cdot 10^{+281}:\\ \;\;\;\;\sin th \cdot \left(\sin ky \cdot \frac{1}{\sin kx}\right)\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 10
Error39.4
Cost21024
\[\begin{array}{l} t_1 := \frac{\sin th \cdot ky}{\sin kx}\\ t_2 := \frac{th \cdot ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{if}\;ky \leq -45000:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -1.48 \cdot 10^{-83}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;ky \leq -2 \cdot 10^{-171}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq -3.6 \cdot 10^{-274}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;ky \leq 1.1 \cdot 10^{-216}:\\ \;\;\;\;\sin th \cdot \left|\frac{\sin ky}{kx}\right|\\ \mathbf{elif}\;ky \leq 7.6 \cdot 10^{-157}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;ky \leq 4.6 \cdot 10^{-145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;ky \leq 1.05 \cdot 10^{-61}:\\ \;\;\;\;\frac{\sin th}{1 + \frac{0.5 \cdot \left(kx \cdot kx\right)}{{\sin ky}^{2}}}\\ \mathbf{elif}\;ky \leq 1.5 \cdot 10^{-11}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 11
Error44.2
Cost19912
\[\begin{array}{l} \mathbf{if}\;\sin kx \leq -0.002:\\ \;\;\;\;th \cdot \left|\frac{ky}{\sin kx}\right|\\ \mathbf{elif}\;\sin kx \leq 0.08:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\sin kx}{th \cdot ky}}\\ \end{array} \]
Alternative 12
Error38.7
Cost13649
\[\begin{array}{l} \mathbf{if}\;ky \leq -9 \cdot 10^{-5}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 2.8 \cdot 10^{-125} \lor \neg \left(ky \leq 2 \cdot 10^{-67}\right) \land ky \leq 1.2 \cdot 10^{-10}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 13
Error44.7
Cost13648
\[\begin{array}{l} \mathbf{if}\;ky \leq -1 \cdot 10^{-6}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.12 \cdot 10^{-213}:\\ \;\;\;\;\frac{1}{\frac{\sin kx}{th \cdot ky}}\\ \mathbf{elif}\;ky \leq 1.2 \cdot 10^{-60}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.5 \cdot 10^{-11}:\\ \;\;\;\;\left|\frac{th \cdot ky}{\sin kx}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 14
Error38.6
Cost13648
\[\begin{array}{l} \mathbf{if}\;ky \leq -9 \cdot 10^{-5}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.85 \cdot 10^{-125}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{elif}\;ky \leq 5.3 \cdot 10^{-61}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 3.4 \cdot 10^{-9}:\\ \;\;\;\;ky \cdot \frac{\sin th}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 15
Error44.8
Cost7377
\[\begin{array}{l} \mathbf{if}\;ky \leq -1 \cdot 10^{-6}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 10^{-213} \lor \neg \left(ky \leq 1.3 \cdot 10^{-60}\right) \land ky \leq 1.5 \cdot 10^{-11}:\\ \;\;\;\;\frac{1}{\frac{\sin kx}{th \cdot ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 16
Error44.3
Cost7249
\[\begin{array}{l} \mathbf{if}\;ky \leq -1 \cdot 10^{-6}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 5.1 \cdot 10^{-214} \lor \neg \left(ky \leq 1.25 \cdot 10^{-60}\right) \land ky \leq 1.5 \cdot 10^{-11}:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 17
Error44.7
Cost7249
\[\begin{array}{l} \mathbf{if}\;ky \leq -1 \cdot 10^{-6}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.12 \cdot 10^{-213} \lor \neg \left(ky \leq 4.4 \cdot 10^{-61}\right) \land ky \leq 1.7 \cdot 10^{-10}:\\ \;\;\;\;\frac{th \cdot ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 18
Error44.3
Cost7248
\[\begin{array}{l} \mathbf{if}\;ky \leq -1 \cdot 10^{-6}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.12 \cdot 10^{-213}:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \mathbf{elif}\;ky \leq 1.15 \cdot 10^{-64}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.5 \cdot 10^{-11}:\\ \;\;\;\;\frac{th}{\frac{\sin kx}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 19
Error42.8
Cost6984
\[\begin{array}{l} \mathbf{if}\;ky \leq -9 \cdot 10^{-5}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 1.12 \cdot 10^{-213}:\\ \;\;\;\;\sin th \cdot \frac{ky}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 20
Error44.7
Cost6728
\[\begin{array}{l} \mathbf{if}\;ky \leq -1 \cdot 10^{-6}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 4.6 \cdot 10^{-224}:\\ \;\;\;\;\frac{1}{\frac{kx}{th \cdot ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 21
Error50.2
Cost584
\[\begin{array}{l} \mathbf{if}\;ky \leq -1 \cdot 10^{-6}:\\ \;\;\;\;th\\ \mathbf{elif}\;ky \leq 1.75 \cdot 10^{-124}:\\ \;\;\;\;th \cdot \frac{ky}{kx}\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \]
Alternative 22
Error55.2
Cost64
\[th \]

Error

Reproduce

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