Average Error: 3.8 → 0.2
Time: 35.4s
Precision: binary64
Cost: 32384
\[\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th \]
\[\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th \]
(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) (hypot (sin ky) (sin kx))) (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);
}
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.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.hypot(Math.sin(ky), Math.sin(kx))) * 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)
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) / sqrt(Float64((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * sin(th))
end
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) / sqrt(((sin(kx) ^ 2.0) + (sin(ky) ^ 2.0)))) * 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[(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[(N[Sin[ky], $MachinePrecision] / N[Sqrt[N[Sin[ky], $MachinePrecision] ^ 2 + N[Sin[kx], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[Sin[th], $MachinePrecision]), $MachinePrecision]
\frac{\sin ky}{\sqrt{{\sin kx}^{2} + {\sin ky}^{2}}} \cdot \sin th
\frac{\sin ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)} \cdot \sin th

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.2

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

    [Start]3.8

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

    +-commutative [=>]3.8

    \[ \frac{\sin ky}{\sqrt{\color{blue}{{\sin ky}^{2} + {\sin kx}^{2}}}} \cdot \sin th \]

    unpow2 [=>]3.8

    \[ \frac{\sin ky}{\sqrt{\color{blue}{\sin ky \cdot \sin ky} + {\sin kx}^{2}}} \cdot \sin th \]

    unpow2 [=>]3.8

    \[ \frac{\sin ky}{\sqrt{\sin ky \cdot \sin ky + \color{blue}{\sin kx \cdot \sin kx}}} \cdot \sin th \]

    hypot-def [=>]0.2

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

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

Alternatives

Alternative 1
Error36.9
Cost38984
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-265}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-94}:\\ \;\;\;\;\left|\sin th \cdot \frac{\sin ky}{\sin kx}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 2
Error33.6
Cost38984
\[\begin{array}{l} t_1 := \frac{\sin ky}{\sin kx}\\ \mathbf{if}\;\sin ky \leq -1 \cdot 10^{-290}:\\ \;\;\;\;\frac{\sin th}{\frac{1}{t_1}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-66}:\\ \;\;\;\;\sin th \cdot \left|t_1\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 3
Error33.3
Cost38984
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq -5 \cdot 10^{-294}:\\ \;\;\;\;\frac{\sin ky}{\left|\frac{\sin kx}{\sin th}\right|}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-66}:\\ \;\;\;\;\sin th \cdot \left|\frac{\sin ky}{\sin kx}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 4
Error37.4
Cost32584
\[\begin{array}{l} t_1 := \frac{\sin th}{\sin kx}\\ \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-265}:\\ \;\;\;\;\frac{t_1}{ky \cdot 0.16666666666666666 + \frac{1}{ky}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-94}:\\ \;\;\;\;\left|ky \cdot t_1\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 5
Error37.4
Cost32584
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-265}:\\ \;\;\;\;\frac{\frac{\sin th}{\sin kx}}{ky \cdot 0.16666666666666666 + \frac{1}{ky}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-94}:\\ \;\;\;\;\left|\frac{\sin th}{\frac{\sin kx}{ky}}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 6
Error36.9
Cost32584
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-265}:\\ \;\;\;\;\sin th \cdot \frac{\sin ky}{\sin kx}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-94}:\\ \;\;\;\;\left|\frac{\sin th}{\frac{\sin kx}{ky}}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 7
Error36.9
Cost32584
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 5 \cdot 10^{-265}:\\ \;\;\;\;\frac{\sin ky}{\frac{\sin kx}{\sin th}}\\ \mathbf{elif}\;\sin ky \leq 5 \cdot 10^{-94}:\\ \;\;\;\;\left|\frac{\sin th}{\frac{\sin kx}{ky}}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 8
Error22.0
Cost32516
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 0.03:\\ \;\;\;\;\sin th \cdot \frac{ky}{\mathsf{hypot}\left(\sin ky, \sin kx\right)}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 9
Error16.5
Cost26764
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\ t_2 := \frac{\sin ky}{t_1 \cdot \left(\frac{1}{th} + th \cdot 0.16666666666666666\right)}\\ \mathbf{if}\;ky \leq -0.0005:\\ \;\;\;\;t_2\\ \mathbf{elif}\;ky \leq 0.028:\\ \;\;\;\;\frac{\sin th}{\frac{t_1}{ky}}\\ \mathbf{elif}\;ky \leq 1.1 \cdot 10^{+93}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Error16.6
Cost26380
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\ t_2 := \sin ky \cdot \frac{th}{t_1}\\ \mathbf{if}\;ky \leq -0.012:\\ \;\;\;\;t_2\\ \mathbf{elif}\;ky \leq 0.045:\\ \;\;\;\;\sin th \cdot \frac{ky}{t_1}\\ \mathbf{elif}\;ky \leq 6.5 \cdot 10^{+90}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error16.7
Cost26380
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\ \mathbf{if}\;ky \leq -0.0012:\\ \;\;\;\;\sin ky \cdot \frac{th}{t_1}\\ \mathbf{elif}\;ky \leq 0.028:\\ \;\;\;\;\sin th \cdot \frac{ky}{t_1}\\ \mathbf{elif}\;ky \leq 1.5 \cdot 10^{+93}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{t_1} \cdot th\\ \end{array} \]
Alternative 12
Error16.7
Cost26380
\[\begin{array}{l} t_1 := \mathsf{hypot}\left(\sin ky, \sin kx\right)\\ \mathbf{if}\;ky \leq -0.0022:\\ \;\;\;\;\sin ky \cdot \frac{th}{t_1}\\ \mathbf{elif}\;ky \leq 0.07:\\ \;\;\;\;\frac{\sin th}{\frac{t_1}{ky}}\\ \mathbf{elif}\;ky \leq 1.1 \cdot 10^{+93}:\\ \;\;\;\;\sin th\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin ky}{t_1} \cdot th\\ \end{array} \]
Alternative 13
Error37.4
Cost20036
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 2 \cdot 10^{-120}:\\ \;\;\;\;\frac{\frac{\sin th}{\sin kx}}{ky \cdot 0.16666666666666666 + \frac{1}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 14
Error37.7
Cost19780
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 2 \cdot 10^{-120}:\\ \;\;\;\;\frac{\frac{\sin th}{\sin kx}}{\frac{1}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 15
Error37.8
Cost19652
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 2 \cdot 10^{-120}:\\ \;\;\;\;\sin th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 16
Error37.8
Cost19652
\[\begin{array}{l} \mathbf{if}\;\sin ky \leq 2 \cdot 10^{-120}:\\ \;\;\;\;\frac{\sin th}{\frac{\sin kx}{ky}}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 17
Error42.4
Cost13516
\[\begin{array}{l} \mathbf{if}\;ky \leq -7 \cdot 10^{-24}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq -3.95 \cdot 10^{-203}:\\ \;\;\;\;\frac{ky}{\frac{\sin kx}{th}}\\ \mathbf{elif}\;ky \leq 3 \cdot 10^{-119}:\\ \;\;\;\;th \cdot \left|\frac{ky}{\sin kx}\right|\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 18
Error42.8
Cost6984
\[\begin{array}{l} \mathbf{if}\;ky \leq -7 \cdot 10^{-24}:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 7.5 \cdot 10^{-120}:\\ \;\;\;\;th \cdot \frac{ky}{\sin kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 19
Error43.8
Cost6728
\[\begin{array}{l} \mathbf{if}\;ky \leq -15.6:\\ \;\;\;\;\sin th\\ \mathbf{elif}\;ky \leq 2.3 \cdot 10^{-120}:\\ \;\;\;\;th \cdot \frac{ky}{kx}\\ \mathbf{else}:\\ \;\;\;\;\sin th\\ \end{array} \]
Alternative 20
Error49.6
Cost584
\[\begin{array}{l} \mathbf{if}\;ky \leq -15:\\ \;\;\;\;th\\ \mathbf{elif}\;ky \leq 1.75 \cdot 10^{-119}:\\ \;\;\;\;th \cdot \frac{ky}{kx}\\ \mathbf{else}:\\ \;\;\;\;th\\ \end{array} \]
Alternative 21
Error55.2
Cost64
\[th \]

Error

Reproduce

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