
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
(FPCore (x y z a) :precision binary64 (+ x (fma (+ (tan y) (tan z)) (/ 1.0 (- 1.0 (* (tan y) (tan z)))) (- (tan a)))))
double code(double x, double y, double z, double a) {
return x + fma((tan(y) + tan(z)), (1.0 / (1.0 - (tan(y) * tan(z)))), -tan(a));
}
function code(x, y, z, a) return Float64(x + fma(Float64(tan(y) + tan(z)), Float64(1.0 / Float64(1.0 - Float64(tan(y) * tan(z)))), Float64(-tan(a)))) end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[Tan[a], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \mathsf{fma}\left(\tan y + \tan z, \frac{1}{1 - \tan y \cdot \tan z}, -\tan a\right)
\end{array}
Initial program 81.8%
tan-sum99.8%
div-inv99.8%
fma-neg99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y z a) :precision binary64 (if (or (<= (tan a) -0.005) (not (<= (tan a) 2e-11))) (+ x (log (exp (- (tan (+ y z)) (tan a))))) (+ x (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))))))
double code(double x, double y, double z, double a) {
double tmp;
if ((tan(a) <= -0.005) || !(tan(a) <= 2e-11)) {
tmp = x + log(exp((tan((y + z)) - tan(a))));
} else {
tmp = x + ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z))));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((tan(a) <= (-0.005d0)) .or. (.not. (tan(a) <= 2d-11))) then
tmp = x + log(exp((tan((y + z)) - tan(a))))
else
tmp = x + ((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((Math.tan(a) <= -0.005) || !(Math.tan(a) <= 2e-11)) {
tmp = x + Math.log(Math.exp((Math.tan((y + z)) - Math.tan(a))));
} else {
tmp = x + ((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z))));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (math.tan(a) <= -0.005) or not (math.tan(a) <= 2e-11): tmp = x + math.log(math.exp((math.tan((y + z)) - math.tan(a)))) else: tmp = x + ((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) return tmp
function code(x, y, z, a) tmp = 0.0 if ((tan(a) <= -0.005) || !(tan(a) <= 2e-11)) tmp = Float64(x + log(exp(Float64(tan(Float64(y + z)) - tan(a))))); else tmp = Float64(x + Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z))))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((tan(a) <= -0.005) || ~((tan(a) <= 2e-11))) tmp = x + log(exp((tan((y + z)) - tan(a)))); else tmp = x + ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.005], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 2e-11]], $MachinePrecision]], N[(x + N[Log[N[Exp[N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan a \leq -0.005 \lor \neg \left(\tan a \leq 2 \cdot 10^{-11}\right):\\
\;\;\;\;x + \log \left(e^{\tan \left(y + z\right) - \tan a}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0050000000000000001 or 1.99999999999999988e-11 < (tan.f64 a) Initial program 82.0%
add-log-exp82.0%
Applied egg-rr82.0%
if -0.0050000000000000001 < (tan.f64 a) < 1.99999999999999988e-11Initial program 81.7%
+-commutative81.7%
associate-+l-81.7%
Applied egg-rr81.7%
Taylor expanded in a around 0 81.6%
neg-mul-181.6%
Simplified81.6%
sub-neg81.6%
add-sqr-sqrt0.0%
sqrt-unprod2.6%
sqr-neg2.6%
sqrt-unprod2.6%
add-sqr-sqrt2.6%
add-sqr-sqrt0.0%
sqrt-unprod81.6%
sqr-neg81.6%
sqrt-unprod81.0%
add-sqr-sqrt81.6%
Applied egg-rr81.6%
tan-sum99.6%
div-inv99.6%
Applied egg-rr99.6%
associate-*r/99.6%
*-rgt-identity99.6%
Simplified99.6%
Final simplification90.6%
(FPCore (x y z a) :precision binary64 (+ x (- (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))) (tan a))))
double code(double x, double y, double z, double a) {
return x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))) - Math.tan(a));
}
def code(x, y, z, a): return x + (((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z)))) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[(N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{\tan y + \tan z}{1 - \tan y \cdot \tan z} - \tan a\right)
\end{array}
Initial program 81.8%
tan-sum61.2%
div-inv61.2%
Applied egg-rr99.8%
associate-*r/61.2%
*-rgt-identity61.2%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z a) :precision binary64 (let* ((t_0 (tan (+ y z))) (t_1 (+ x t_0))) (if (<= t_0 -0.02) t_1 (if (<= t_0 0.015) (+ y (- x (tan a))) (fabs t_1)))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double t_1 = x + t_0;
double tmp;
if (t_0 <= -0.02) {
tmp = t_1;
} else if (t_0 <= 0.015) {
tmp = y + (x - tan(a));
} else {
tmp = fabs(t_1);
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = tan((y + z))
t_1 = x + t_0
if (t_0 <= (-0.02d0)) then
tmp = t_1
else if (t_0 <= 0.015d0) then
tmp = y + (x - tan(a))
else
tmp = abs(t_1)
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan((y + z));
double t_1 = x + t_0;
double tmp;
if (t_0 <= -0.02) {
tmp = t_1;
} else if (t_0 <= 0.015) {
tmp = y + (x - Math.tan(a));
} else {
tmp = Math.abs(t_1);
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) t_1 = x + t_0 tmp = 0 if t_0 <= -0.02: tmp = t_1 elif t_0 <= 0.015: tmp = y + (x - math.tan(a)) else: tmp = math.fabs(t_1) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) t_1 = Float64(x + t_0) tmp = 0.0 if (t_0 <= -0.02) tmp = t_1; elseif (t_0 <= 0.015) tmp = Float64(y + Float64(x - tan(a))); else tmp = abs(t_1); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); t_1 = x + t_0; tmp = 0.0; if (t_0 <= -0.02) tmp = t_1; elseif (t_0 <= 0.015) tmp = y + (x - tan(a)); else tmp = abs(t_1); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x + t$95$0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.02], t$95$1, If[LessEqual[t$95$0, 0.015], N[(y + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Abs[t$95$1], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
t_1 := x + t_0\\
\mathbf{if}\;t_0 \leq -0.02:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 0.015:\\
\;\;\;\;y + \left(x - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;\left|t_1\right|\\
\end{array}
\end{array}
if (tan.f64 (+.f64 y z)) < -0.0200000000000000004Initial program 73.0%
+-commutative73.0%
associate-+l-72.9%
Applied egg-rr72.9%
Taylor expanded in a around 0 45.2%
neg-mul-145.2%
Simplified45.2%
sub-neg45.2%
add-sqr-sqrt0.0%
sqrt-unprod3.1%
sqr-neg3.1%
sqrt-unprod3.1%
add-sqr-sqrt3.1%
add-sqr-sqrt0.0%
sqrt-unprod45.2%
sqr-neg45.2%
sqrt-unprod45.0%
add-sqr-sqrt45.2%
Applied egg-rr45.2%
if -0.0200000000000000004 < (tan.f64 (+.f64 y z)) < 0.014999999999999999Initial program 99.8%
+-commutative99.8%
associate-+l-99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 98.0%
Taylor expanded in y around 0 96.7%
if 0.014999999999999999 < (tan.f64 (+.f64 y z)) Initial program 77.1%
+-commutative77.1%
associate-+l-77.0%
Applied egg-rr77.0%
Taylor expanded in a around 0 51.7%
neg-mul-151.7%
Simplified51.7%
add-sqr-sqrt51.5%
sqrt-unprod51.7%
pow251.7%
sub-neg51.7%
add-sqr-sqrt0.0%
sqrt-unprod21.6%
sqr-neg21.6%
sqrt-unprod21.6%
add-sqr-sqrt21.6%
add-sqr-sqrt0.0%
sqrt-unprod51.7%
sqr-neg51.7%
sqrt-unprod51.4%
add-sqr-sqrt51.7%
Applied egg-rr51.7%
unpow251.7%
rem-sqrt-square51.7%
+-commutative51.7%
Simplified51.7%
Final simplification61.8%
(FPCore (x y z a) :precision binary64 (+ x (log (exp (- (tan (+ y z)) (tan a))))))
double code(double x, double y, double z, double a) {
return x + log(exp((tan((y + z)) - tan(a))));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + log(exp((tan((y + z)) - tan(a))))
end function
public static double code(double x, double y, double z, double a) {
return x + Math.log(Math.exp((Math.tan((y + z)) - Math.tan(a))));
}
def code(x, y, z, a): return x + math.log(math.exp((math.tan((y + z)) - math.tan(a))))
function code(x, y, z, a) return Float64(x + log(exp(Float64(tan(Float64(y + z)) - tan(a))))) end
function tmp = code(x, y, z, a) tmp = x + log(exp((tan((y + z)) - tan(a)))); end
code[x_, y_, z_, a_] := N[(x + N[Log[N[Exp[N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \log \left(e^{\tan \left(y + z\right) - \tan a}\right)
\end{array}
Initial program 81.8%
add-log-exp81.8%
Applied egg-rr81.8%
Final simplification81.8%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (tan (+ y z))))
(if (or (<= t_0 -0.02) (not (<= t_0 0.015)))
(+ x t_0)
(+ y (- x (tan a))))))
double code(double x, double y, double z, double a) {
double t_0 = tan((y + z));
double tmp;
if ((t_0 <= -0.02) || !(t_0 <= 0.015)) {
tmp = x + t_0;
} else {
tmp = y + (x - tan(a));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: t_0
real(8) :: tmp
t_0 = tan((y + z))
if ((t_0 <= (-0.02d0)) .or. (.not. (t_0 <= 0.015d0))) then
tmp = x + t_0
else
tmp = y + (x - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double t_0 = Math.tan((y + z));
double tmp;
if ((t_0 <= -0.02) || !(t_0 <= 0.015)) {
tmp = x + t_0;
} else {
tmp = y + (x - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan((y + z)) tmp = 0 if (t_0 <= -0.02) or not (t_0 <= 0.015): tmp = x + t_0 else: tmp = y + (x - math.tan(a)) return tmp
function code(x, y, z, a) t_0 = tan(Float64(y + z)) tmp = 0.0 if ((t_0 <= -0.02) || !(t_0 <= 0.015)) tmp = Float64(x + t_0); else tmp = Float64(y + Float64(x - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan((y + z)); tmp = 0.0; if ((t_0 <= -0.02) || ~((t_0 <= 0.015))) tmp = x + t_0; else tmp = y + (x - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.02], N[Not[LessEqual[t$95$0, 0.015]], $MachinePrecision]], N[(x + t$95$0), $MachinePrecision], N[(y + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan \left(y + z\right)\\
\mathbf{if}\;t_0 \leq -0.02 \lor \neg \left(t_0 \leq 0.015\right):\\
\;\;\;\;x + t_0\\
\mathbf{else}:\\
\;\;\;\;y + \left(x - \tan a\right)\\
\end{array}
\end{array}
if (tan.f64 (+.f64 y z)) < -0.0200000000000000004 or 0.014999999999999999 < (tan.f64 (+.f64 y z)) Initial program 74.8%
+-commutative74.8%
associate-+l-74.7%
Applied egg-rr74.7%
Taylor expanded in a around 0 48.1%
neg-mul-148.1%
Simplified48.1%
sub-neg48.1%
add-sqr-sqrt0.0%
sqrt-unprod3.4%
sqr-neg3.4%
sqrt-unprod3.4%
add-sqr-sqrt3.4%
add-sqr-sqrt0.0%
sqrt-unprod48.1%
sqr-neg48.1%
sqrt-unprod47.9%
add-sqr-sqrt48.1%
Applied egg-rr48.1%
if -0.0200000000000000004 < (tan.f64 (+.f64 y z)) < 0.014999999999999999Initial program 99.8%
+-commutative99.8%
associate-+l-99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 98.0%
Taylor expanded in y around 0 96.7%
Final simplification61.8%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) 0.002) (+ x (- (tan y) (tan a))) (+ x (tan (+ y z)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 0.002) {
tmp = x + (tan(y) - tan(a));
} else {
tmp = x + tan((y + z));
}
return tmp;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
real(8) :: tmp
if ((y + z) <= 0.002d0) then
tmp = x + (tan(y) - tan(a))
else
tmp = x + tan((y + z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= 0.002) {
tmp = x + (Math.tan(y) - Math.tan(a));
} else {
tmp = x + Math.tan((y + z));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= 0.002: tmp = x + (math.tan(y) - math.tan(a)) else: tmp = x + math.tan((y + z)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= 0.002) tmp = Float64(x + Float64(tan(y) - tan(a))); else tmp = Float64(x + tan(Float64(y + z))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= 0.002) tmp = x + (tan(y) - tan(a)); else tmp = x + tan((y + z)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], 0.002], N[(x + N[(N[Tan[y], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq 0.002:\\
\;\;\;\;x + \left(\tan y - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \tan \left(y + z\right)\\
\end{array}
\end{array}
if (+.f64 y z) < 2e-3Initial program 87.3%
+-commutative87.3%
associate-+l-87.2%
Applied egg-rr87.2%
Taylor expanded in z around 0 70.4%
tan-quot70.4%
associate--r-70.5%
Applied egg-rr70.5%
if 2e-3 < (+.f64 y z) Initial program 71.7%
+-commutative71.7%
associate-+l-71.5%
Applied egg-rr71.5%
Taylor expanded in a around 0 45.5%
neg-mul-145.5%
Simplified45.5%
sub-neg45.5%
add-sqr-sqrt0.0%
sqrt-unprod3.6%
sqr-neg3.6%
sqrt-unprod3.6%
add-sqr-sqrt3.6%
add-sqr-sqrt0.0%
sqrt-unprod45.5%
sqr-neg45.5%
sqrt-unprod45.3%
add-sqr-sqrt45.5%
Applied egg-rr45.5%
Final simplification61.8%
(FPCore (x y z a) :precision binary64 (+ x (- (tan (+ y z)) (tan a))))
double code(double x, double y, double z, double a) {
return x + (tan((y + z)) - tan(a));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + (tan((y + z)) - tan(a))
end function
public static double code(double x, double y, double z, double a) {
return x + (Math.tan((y + z)) - Math.tan(a));
}
def code(x, y, z, a): return x + (math.tan((y + z)) - math.tan(a))
function code(x, y, z, a) return Float64(x + Float64(tan(Float64(y + z)) - tan(a))) end
function tmp = code(x, y, z, a) tmp = x + (tan((y + z)) - tan(a)); end
code[x_, y_, z_, a_] := N[(x + N[(N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\tan \left(y + z\right) - \tan a\right)
\end{array}
Initial program 81.8%
Final simplification81.8%
(FPCore (x y z a) :precision binary64 (+ x (tan (+ y z))))
double code(double x, double y, double z, double a) {
return x + tan((y + z));
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x + tan((y + z))
end function
public static double code(double x, double y, double z, double a) {
return x + Math.tan((y + z));
}
def code(x, y, z, a): return x + math.tan((y + z))
function code(x, y, z, a) return Float64(x + tan(Float64(y + z))) end
function tmp = code(x, y, z, a) tmp = x + tan((y + z)); end
code[x_, y_, z_, a_] := N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \tan \left(y + z\right)
\end{array}
Initial program 81.8%
+-commutative81.8%
associate-+l-81.8%
Applied egg-rr81.8%
Taylor expanded in a around 0 52.0%
neg-mul-152.0%
Simplified52.0%
sub-neg52.0%
add-sqr-sqrt0.0%
sqrt-unprod3.1%
sqr-neg3.1%
sqrt-unprod3.1%
add-sqr-sqrt3.1%
add-sqr-sqrt0.0%
sqrt-unprod52.0%
sqr-neg52.0%
sqrt-unprod51.7%
add-sqr-sqrt52.0%
Applied egg-rr52.0%
Final simplification52.0%
(FPCore (x y z a) :precision binary64 x)
double code(double x, double y, double z, double a) {
return x;
}
real(8) function code(x, y, z, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: a
code = x
end function
public static double code(double x, double y, double z, double a) {
return x;
}
def code(x, y, z, a): return x
function code(x, y, z, a) return x end
function tmp = code(x, y, z, a) tmp = x; end
code[x_, y_, z_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 81.8%
Taylor expanded in x around inf 33.7%
Final simplification33.7%
herbie shell --seed 2024021
(FPCore (x y z a)
:name "tan-example (used to crash)"
:precision binary64
:pre (and (and (and (or (== x 0.0) (and (<= 0.5884142 x) (<= x 505.5909))) (or (and (<= -1.796658e+308 y) (<= y -9.425585e-310)) (and (<= 1.284938e-309 y) (<= y 1.751224e+308)))) (or (and (<= -1.776707e+308 z) (<= z -8.599796e-310)) (and (<= 3.293145e-311 z) (<= z 1.725154e+308)))) (or (and (<= -1.796658e+308 a) (<= a -9.425585e-310)) (and (<= 1.284938e-309 a) (<= a 1.751224e+308))))
(+ x (- (tan (+ y z)) (tan a))))