
(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 (- (tan a) (/ (+ (tan y) (tan z)) (- 1.0 (* (tan y) (tan z)))))))
double code(double x, double y, double z, double a) {
return x - (tan(a) - ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(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(a) - ((tan(y) + tan(z)) / (1.0d0 - (tan(y) * tan(z)))))
end function
public static double code(double x, double y, double z, double a) {
return x - (Math.tan(a) - ((Math.tan(y) + Math.tan(z)) / (1.0 - (Math.tan(y) * Math.tan(z)))));
}
def code(x, y, z, a): return x - (math.tan(a) - ((math.tan(y) + math.tan(z)) / (1.0 - (math.tan(y) * math.tan(z)))))
function code(x, y, z, a) return Float64(x - Float64(tan(a) - Float64(Float64(tan(y) + tan(z)) / Float64(1.0 - Float64(tan(y) * tan(z)))))) end
function tmp = code(x, y, z, a) tmp = x - (tan(a) - ((tan(y) + tan(z)) / (1.0 - (tan(y) * tan(z))))); end
code[x_, y_, z_, a_] := N[(x - N[(N[Tan[a], $MachinePrecision] - 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]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(\tan a - \frac{\tan y + \tan z}{1 - \tan y \cdot \tan z}\right)
\end{array}
Initial program 76.6%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z a)
:precision binary64
(let* ((t_0 (+ (tan y) (tan z))))
(if (or (<= (tan a) -0.02) (not (<= (tan a) 1e-20)))
(- (+ x t_0) (tan a))
(+ x (/ t_0 (- 1.0 (* (tan y) (tan z))))))))
double code(double x, double y, double z, double a) {
double t_0 = tan(y) + tan(z);
double tmp;
if ((tan(a) <= -0.02) || !(tan(a) <= 1e-20)) {
tmp = (x + t_0) - tan(a);
} else {
tmp = x + (t_0 / (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) :: t_0
real(8) :: tmp
t_0 = tan(y) + tan(z)
if ((tan(a) <= (-0.02d0)) .or. (.not. (tan(a) <= 1d-20))) then
tmp = (x + t_0) - tan(a)
else
tmp = x + (t_0 / (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 t_0 = Math.tan(y) + Math.tan(z);
double tmp;
if ((Math.tan(a) <= -0.02) || !(Math.tan(a) <= 1e-20)) {
tmp = (x + t_0) - Math.tan(a);
} else {
tmp = x + (t_0 / (1.0 - (Math.tan(y) * Math.tan(z))));
}
return tmp;
}
def code(x, y, z, a): t_0 = math.tan(y) + math.tan(z) tmp = 0 if (math.tan(a) <= -0.02) or not (math.tan(a) <= 1e-20): tmp = (x + t_0) - math.tan(a) else: tmp = x + (t_0 / (1.0 - (math.tan(y) * math.tan(z)))) return tmp
function code(x, y, z, a) t_0 = Float64(tan(y) + tan(z)) tmp = 0.0 if ((tan(a) <= -0.02) || !(tan(a) <= 1e-20)) tmp = Float64(Float64(x + t_0) - tan(a)); else tmp = Float64(x + Float64(t_0 / Float64(1.0 - Float64(tan(y) * tan(z))))); end return tmp end
function tmp_2 = code(x, y, z, a) t_0 = tan(y) + tan(z); tmp = 0.0; if ((tan(a) <= -0.02) || ~((tan(a) <= 1e-20))) tmp = (x + t_0) - tan(a); else tmp = x + (t_0 / (1.0 - (tan(y) * tan(z)))); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := Block[{t$95$0 = N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[Tan[a], $MachinePrecision], -0.02], N[Not[LessEqual[N[Tan[a], $MachinePrecision], 1e-20]], $MachinePrecision]], N[(N[(x + t$95$0), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$0 / N[(1.0 - N[(N[Tan[y], $MachinePrecision] * N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan y + \tan z\\
\mathbf{if}\;\tan a \leq -0.02 \lor \neg \left(\tan a \leq 10^{-20}\right):\\
\;\;\;\;\left(x + t_0\right) - \tan a\\
\mathbf{else}:\\
\;\;\;\;x + \frac{t_0}{1 - \tan y \cdot \tan z}\\
\end{array}
\end{array}
if (tan.f64 a) < -0.0200000000000000004 or 9.99999999999999945e-21 < (tan.f64 a) Initial program 76.1%
associate-+r-75.9%
Simplified75.9%
tan-sum99.6%
div-inv99.7%
Applied egg-rr99.4%
Taylor expanded in y around 0 76.5%
if -0.0200000000000000004 < (tan.f64 a) < 9.99999999999999945e-21Initial program 77.1%
+-commutative77.1%
associate-+l-77.1%
Applied egg-rr77.1%
Taylor expanded in a around 0 77.1%
neg-mul-177.1%
Simplified77.1%
sub-neg77.1%
add-sqr-sqrt0.0%
sqrt-unprod3.2%
sqr-neg3.2%
sqrt-unprod3.2%
add-sqr-sqrt3.2%
add-sqr-sqrt0.0%
sqrt-unprod77.1%
sqr-neg77.1%
sqrt-unprod76.7%
add-sqr-sqrt77.1%
Applied egg-rr77.1%
tan-sum99.8%
div-inv99.8%
Applied egg-rr99.6%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.6%
Final simplification88.4%
(FPCore (x y z a) :precision binary64 (- (+ x (+ (tan y) (tan z))) (tan a)))
double code(double x, double y, double z, double a) {
return (x + (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))) - tan(a)
end function
public static double code(double x, double y, double z, double a) {
return (x + (Math.tan(y) + Math.tan(z))) - Math.tan(a);
}
def code(x, y, z, a): return (x + (math.tan(y) + math.tan(z))) - math.tan(a)
function code(x, y, z, a) return Float64(Float64(x + Float64(tan(y) + tan(z))) - tan(a)) end
function tmp = code(x, y, z, a) tmp = (x + (tan(y) + tan(z))) - tan(a); end
code[x_, y_, z_, a_] := N[(N[(x + N[(N[Tan[y], $MachinePrecision] + N[Tan[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \left(\tan y + \tan z\right)\right) - \tan a
\end{array}
Initial program 76.6%
associate-+r-76.5%
Simplified76.5%
tan-sum99.7%
div-inv99.7%
Applied egg-rr99.6%
Taylor expanded in y around 0 77.0%
Final simplification77.0%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -0.0002) (+ x (tan (+ y z))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -0.0002) {
tmp = x + tan((y + z));
} else {
tmp = x + (tan(z) - 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) :: tmp
if ((y + z) <= (-0.0002d0)) then
tmp = x + tan((y + z))
else
tmp = x + (tan(z) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -0.0002) {
tmp = x + Math.tan((y + z));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -0.0002: tmp = x + math.tan((y + z)) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -0.0002) tmp = Float64(x + tan(Float64(y + z))); else tmp = Float64(x + Float64(tan(z) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -0.0002) tmp = x + tan((y + z)); else tmp = x + (tan(z) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -0.0002], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -0.0002:\\
\;\;\;\;x + \tan \left(y + z\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -2.0000000000000001e-4Initial program 71.9%
+-commutative71.9%
associate-+l-71.8%
Applied egg-rr71.8%
Taylor expanded in a around 0 46.5%
neg-mul-146.5%
Simplified46.5%
sub-neg46.5%
add-sqr-sqrt0.0%
sqrt-unprod3.8%
sqr-neg3.8%
sqrt-unprod3.8%
add-sqr-sqrt3.8%
add-sqr-sqrt0.0%
sqrt-unprod46.5%
sqr-neg46.5%
sqrt-unprod46.4%
add-sqr-sqrt46.5%
Applied egg-rr46.5%
if -2.0000000000000001e-4 < (+.f64 y z) Initial program 79.3%
+-commutative79.3%
associate-+l-79.3%
Applied egg-rr79.3%
Taylor expanded in y around 0 64.2%
tan-quot64.2%
associate--r-64.2%
Applied egg-rr64.2%
Final simplification57.9%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -0.0002) (+ x (/ (sin y) (cos y))) (+ x (- (tan z) (tan a)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -0.0002) {
tmp = x + (sin(y) / cos(y));
} else {
tmp = x + (tan(z) - 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) :: tmp
if ((y + z) <= (-0.0002d0)) then
tmp = x + (sin(y) / cos(y))
else
tmp = x + (tan(z) - tan(a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -0.0002) {
tmp = x + (Math.sin(y) / Math.cos(y));
} else {
tmp = x + (Math.tan(z) - Math.tan(a));
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -0.0002: tmp = x + (math.sin(y) / math.cos(y)) else: tmp = x + (math.tan(z) - math.tan(a)) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -0.0002) tmp = Float64(x + Float64(sin(y) / cos(y))); else tmp = Float64(x + Float64(tan(z) - tan(a))); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -0.0002) tmp = x + (sin(y) / cos(y)); else tmp = x + (tan(z) - tan(a)); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -0.0002], N[(x + N[(N[Sin[y], $MachinePrecision] / N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Tan[z], $MachinePrecision] - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -0.0002:\\
\;\;\;\;x + \frac{\sin y}{\cos y}\\
\mathbf{else}:\\
\;\;\;\;x + \left(\tan z - \tan a\right)\\
\end{array}
\end{array}
if (+.f64 y z) < -2.0000000000000001e-4Initial program 71.9%
+-commutative71.9%
associate-+l-71.8%
Applied egg-rr71.8%
Taylor expanded in a around 0 46.5%
neg-mul-146.5%
Simplified46.5%
Taylor expanded in z around 0 34.6%
if -2.0000000000000001e-4 < (+.f64 y z) Initial program 79.3%
+-commutative79.3%
associate-+l-79.3%
Applied egg-rr79.3%
Taylor expanded in y around 0 64.2%
tan-quot64.2%
associate--r-64.2%
Applied egg-rr64.2%
Final simplification53.6%
(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 76.6%
Final simplification76.6%
(FPCore (x y z a) :precision binary64 (if (<= (+ y z) -0.0002) (+ x (tan (+ y z))) (if (<= (+ y z) 2e-5) (+ z (- x (tan a))) (+ x (tan z)))))
double code(double x, double y, double z, double a) {
double tmp;
if ((y + z) <= -0.0002) {
tmp = x + tan((y + z));
} else if ((y + z) <= 2e-5) {
tmp = z + (x - tan(a));
} else {
tmp = x + 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 ((y + z) <= (-0.0002d0)) then
tmp = x + tan((y + z))
else if ((y + z) <= 2d-5) then
tmp = z + (x - tan(a))
else
tmp = x + tan(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.0002) {
tmp = x + Math.tan((y + z));
} else if ((y + z) <= 2e-5) {
tmp = z + (x - Math.tan(a));
} else {
tmp = x + Math.tan(z);
}
return tmp;
}
def code(x, y, z, a): tmp = 0 if (y + z) <= -0.0002: tmp = x + math.tan((y + z)) elif (y + z) <= 2e-5: tmp = z + (x - math.tan(a)) else: tmp = x + math.tan(z) return tmp
function code(x, y, z, a) tmp = 0.0 if (Float64(y + z) <= -0.0002) tmp = Float64(x + tan(Float64(y + z))); elseif (Float64(y + z) <= 2e-5) tmp = Float64(z + Float64(x - tan(a))); else tmp = Float64(x + tan(z)); end return tmp end
function tmp_2 = code(x, y, z, a) tmp = 0.0; if ((y + z) <= -0.0002) tmp = x + tan((y + z)); elseif ((y + z) <= 2e-5) tmp = z + (x - tan(a)); else tmp = x + tan(z); end tmp_2 = tmp; end
code[x_, y_, z_, a_] := If[LessEqual[N[(y + z), $MachinePrecision], -0.0002], N[(x + N[Tan[N[(y + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y + z), $MachinePrecision], 2e-5], N[(z + N[(x - N[Tan[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y + z \leq -0.0002:\\
\;\;\;\;x + \tan \left(y + z\right)\\
\mathbf{elif}\;y + z \leq 2 \cdot 10^{-5}:\\
\;\;\;\;z + \left(x - \tan a\right)\\
\mathbf{else}:\\
\;\;\;\;x + \tan z\\
\end{array}
\end{array}
if (+.f64 y z) < -2.0000000000000001e-4Initial program 71.9%
+-commutative71.9%
associate-+l-71.8%
Applied egg-rr71.8%
Taylor expanded in a around 0 46.5%
neg-mul-146.5%
Simplified46.5%
sub-neg46.5%
add-sqr-sqrt0.0%
sqrt-unprod3.8%
sqr-neg3.8%
sqrt-unprod3.8%
add-sqr-sqrt3.8%
add-sqr-sqrt0.0%
sqrt-unprod46.5%
sqr-neg46.5%
sqrt-unprod46.4%
add-sqr-sqrt46.5%
Applied egg-rr46.5%
if -2.0000000000000001e-4 < (+.f64 y z) < 2.00000000000000016e-5Initial program 99.9%
+-commutative99.9%
associate-+l-99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 98.2%
Taylor expanded in z around 0 98.2%
if 2.00000000000000016e-5 < (+.f64 y z) Initial program 65.4%
+-commutative65.4%
associate-+l-65.4%
Applied egg-rr65.4%
Taylor expanded in y around 0 41.3%
tan-quot41.3%
add-sqr-sqrt23.8%
sqrt-unprod33.1%
pow233.1%
Applied egg-rr33.1%
unpow233.1%
rem-sqrt-square33.1%
Simplified33.1%
Taylor expanded in a around 0 27.7%
rem-square-sqrt18.9%
fabs-sqr18.9%
rem-square-sqrt34.5%
Simplified34.5%
Final simplification55.3%
(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 76.6%
+-commutative76.6%
associate-+l-76.6%
Applied egg-rr76.6%
Taylor expanded in a around 0 50.8%
neg-mul-150.8%
Simplified50.8%
sub-neg50.8%
add-sqr-sqrt0.0%
sqrt-unprod3.5%
sqr-neg3.5%
sqrt-unprod3.5%
add-sqr-sqrt3.5%
add-sqr-sqrt0.0%
sqrt-unprod50.8%
sqr-neg50.8%
sqrt-unprod50.6%
add-sqr-sqrt50.8%
Applied egg-rr50.8%
Final simplification50.8%
(FPCore (x y z a) :precision binary64 (+ x (tan z)))
double code(double x, double y, double z, double a) {
return x + tan(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(z)
end function
public static double code(double x, double y, double z, double a) {
return x + Math.tan(z);
}
def code(x, y, z, a): return x + math.tan(z)
function code(x, y, z, a) return Float64(x + tan(z)) end
function tmp = code(x, y, z, a) tmp = x + tan(z); end
code[x_, y_, z_, a_] := N[(x + N[Tan[z], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \tan z
\end{array}
Initial program 76.6%
+-commutative76.6%
associate-+l-76.6%
Applied egg-rr76.6%
Taylor expanded in y around 0 57.9%
tan-quot57.9%
add-sqr-sqrt31.1%
sqrt-unprod51.1%
pow251.1%
Applied egg-rr51.1%
unpow251.1%
rem-sqrt-square51.1%
Simplified51.1%
Taylor expanded in a around 0 36.8%
rem-square-sqrt20.8%
fabs-sqr20.8%
rem-square-sqrt41.5%
Simplified41.5%
Final simplification41.5%
(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 76.6%
Taylor expanded in x around inf 32.7%
Final simplification32.7%
herbie shell --seed 2023200
(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))))