
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (tanh (/ t y)) (tanh (/ x y))))) (if (<= (+ x (* (* y z) t_1)) 1e+306) (fma z (* y t_1) x) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y)) - tanh((x / y));
double tmp;
if ((x + ((y * z) * t_1)) <= 1e+306) {
tmp = fma(z, (y * t_1), x);
} else {
tmp = z * (t - x);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) tmp = 0.0 if (Float64(x + Float64(Float64(y * z) * t_1)) <= 1e+306) tmp = fma(z, Float64(y * t_1), x); else tmp = Float64(z * Float64(t - x)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + N[(N[(y * z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 1e+306], N[(z * N[(y * t$95$1), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\
\mathbf{if}\;x + \left(y \cdot z\right) \cdot t_1 \leq 10^{+306}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot t_1, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 1.00000000000000002e306Initial program 96.7%
+-commutative96.7%
*-commutative96.7%
associate-*l*99.1%
fma-def99.2%
Simplified99.2%
if 1.00000000000000002e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 54.7%
Taylor expanded in y around inf 99.2%
Taylor expanded in z around inf 99.2%
Final simplification99.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))) (if (or (<= t_1 (- INFINITY)) (not (<= t_1 1e+306))) (* z (- t x)) t_1)))
double code(double x, double y, double z, double t) {
double t_1 = x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 1e+306)) {
tmp = z * (t - x);
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 1e+306)) {
tmp = z * (t - x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y)))) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 1e+306): tmp = z * (t - x) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 1e+306)) tmp = Float64(z * Float64(t - x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 1e+306))) tmp = z * (t - x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 1e+306]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 10^{+306}\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 1.00000000000000002e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 60.2%
Taylor expanded in y around inf 99.6%
Taylor expanded in z around inf 99.6%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 1.00000000000000002e306Initial program 99.0%
Final simplification99.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 3.9e-53) (+ x (* (* y z) t_1)) (+ x (* z (- (* y t_1) x))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 3.9e-53) {
tmp = x + ((y * z) * t_1);
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 3.9d-53) then
tmp = x + ((y * z) * t_1)
else
tmp = x + (z * ((y * t_1) - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 3.9e-53) {
tmp = x + ((y * z) * t_1);
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 3.9e-53: tmp = x + ((y * z) * t_1) else: tmp = x + (z * ((y * t_1) - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 3.9e-53) tmp = Float64(x + Float64(Float64(y * z) * t_1)); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 3.9e-53) tmp = x + ((y * z) * t_1); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 3.9e-53], N[(x + N[(N[(y * z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 3.9 \cdot 10^{-53}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 3.9000000000000002e-53Initial program 96.1%
Taylor expanded in x around 0 20.7%
associate-/r*20.7%
rec-exp20.7%
div-sub20.7%
rec-exp20.7%
tanh-def-a84.8%
Simplified84.8%
if 3.9000000000000002e-53 < y Initial program 87.7%
Taylor expanded in x around 0 40.9%
+-commutative40.9%
Simplified85.3%
Taylor expanded in y around 0 42.1%
mul-1-neg42.1%
+-commutative42.1%
fma-def42.1%
Simplified85.3%
Final simplification85.0%
(FPCore (x y z t) :precision binary64 (if (<= y 2.1e+186) (+ x (* (* y z) (tanh (/ t y)))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.1e+186) {
tmp = x + ((y * z) * tanh((t / y)));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 2.1d+186) then
tmp = x + ((y * z) * tanh((t / y)))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.1e+186) {
tmp = x + ((y * z) * Math.tanh((t / y)));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.1e+186: tmp = x + ((y * z) * math.tanh((t / y))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.1e+186) tmp = Float64(x + Float64(Float64(y * z) * tanh(Float64(t / y)))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.1e+186) tmp = x + ((y * z) * tanh((t / y))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.1e+186], N[(x + N[(N[(y * z), $MachinePrecision] * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+186}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.1e186Initial program 96.5%
Taylor expanded in x around 0 23.6%
associate-/r*23.6%
rec-exp23.6%
div-sub23.6%
rec-exp23.6%
tanh-def-a83.6%
Simplified83.6%
if 2.1e186 < y Initial program 72.6%
Taylor expanded in y around inf 83.7%
Final simplification83.7%
(FPCore (x y z t)
:precision binary64
(if (<= y 7.2e+61)
x
(if (or (<= y 8.2e+187) (not (<= y 4.1e+225)))
(* z (- t x))
(* x (- 1.0 z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.2e+61) {
tmp = x;
} else if ((y <= 8.2e+187) || !(y <= 4.1e+225)) {
tmp = z * (t - x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 7.2d+61) then
tmp = x
else if ((y <= 8.2d+187) .or. (.not. (y <= 4.1d+225))) then
tmp = z * (t - x)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.2e+61) {
tmp = x;
} else if ((y <= 8.2e+187) || !(y <= 4.1e+225)) {
tmp = z * (t - x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 7.2e+61: tmp = x elif (y <= 8.2e+187) or not (y <= 4.1e+225): tmp = z * (t - x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 7.2e+61) tmp = x; elseif ((y <= 8.2e+187) || !(y <= 4.1e+225)) tmp = Float64(z * Float64(t - x)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 7.2e+61) tmp = x; elseif ((y <= 8.2e+187) || ~((y <= 4.1e+225))) tmp = z * (t - x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 7.2e+61], x, If[Or[LessEqual[y, 8.2e+187], N[Not[LessEqual[y, 4.1e+225]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.2 \cdot 10^{+61}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+187} \lor \neg \left(y \leq 4.1 \cdot 10^{+225}\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 7.20000000000000021e61Initial program 96.6%
Taylor expanded in y around inf 58.6%
Taylor expanded in z around 0 62.8%
if 7.20000000000000021e61 < y < 8.2e187 or 4.0999999999999999e225 < y Initial program 86.4%
Taylor expanded in y around inf 84.9%
Taylor expanded in z around inf 68.9%
if 8.2e187 < y < 4.0999999999999999e225Initial program 72.3%
Taylor expanded in y around inf 66.5%
Taylor expanded in x around inf 60.2%
mul-1-neg60.2%
unsub-neg60.2%
Simplified60.2%
Final simplification63.7%
(FPCore (x y z t) :precision binary64 (if (or (<= y 3.2e+98) (and (not (<= y 5.4e+187)) (<= y 4.1e+225))) x (* z t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 3.2e+98) || (!(y <= 5.4e+187) && (y <= 4.1e+225))) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= 3.2d+98) .or. (.not. (y <= 5.4d+187)) .and. (y <= 4.1d+225)) then
tmp = x
else
tmp = z * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 3.2e+98) || (!(y <= 5.4e+187) && (y <= 4.1e+225))) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= 3.2e+98) or (not (y <= 5.4e+187) and (y <= 4.1e+225)): tmp = x else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= 3.2e+98) || (!(y <= 5.4e+187) && (y <= 4.1e+225))) tmp = x; else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= 3.2e+98) || (~((y <= 5.4e+187)) && (y <= 4.1e+225))) tmp = x; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, 3.2e+98], And[N[Not[LessEqual[y, 5.4e+187]], $MachinePrecision], LessEqual[y, 4.1e+225]]], x, N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.2 \cdot 10^{+98} \lor \neg \left(y \leq 5.4 \cdot 10^{+187}\right) \land y \leq 4.1 \cdot 10^{+225}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 3.2000000000000002e98 or 5.40000000000000016e187 < y < 4.0999999999999999e225Initial program 94.7%
Taylor expanded in y around inf 59.1%
Taylor expanded in z around 0 60.6%
if 3.2000000000000002e98 < y < 5.40000000000000016e187 or 4.0999999999999999e225 < y Initial program 85.0%
Taylor expanded in t around 0 73.2%
Taylor expanded in y around 0 71.3%
+-commutative71.3%
*-commutative71.3%
Simplified71.3%
Taylor expanded in z around inf 58.8%
Final simplification60.3%
(FPCore (x y z t) :precision binary64 (if (<= y 1.15e-48) x (if (<= y 6.2e+283) (* x (- 1.0 z)) (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.15e-48) {
tmp = x;
} else if (y <= 6.2e+283) {
tmp = x * (1.0 - z);
} else {
tmp = z * t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 1.15d-48) then
tmp = x
else if (y <= 6.2d+283) then
tmp = x * (1.0d0 - z)
else
tmp = z * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.15e-48) {
tmp = x;
} else if (y <= 6.2e+283) {
tmp = x * (1.0 - z);
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.15e-48: tmp = x elif y <= 6.2e+283: tmp = x * (1.0 - z) else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.15e-48) tmp = x; elseif (y <= 6.2e+283) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.15e-48) tmp = x; elseif (y <= 6.2e+283) tmp = x * (1.0 - z); else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.15e-48], x, If[LessEqual[y, 6.2e+283], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.15 \cdot 10^{-48}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+283}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 1.15e-48Initial program 96.1%
Taylor expanded in y around inf 58.0%
Taylor expanded in z around 0 62.7%
if 1.15e-48 < y < 6.19999999999999976e283Initial program 89.2%
Taylor expanded in y around inf 72.6%
Taylor expanded in x around inf 50.3%
mul-1-neg50.3%
unsub-neg50.3%
Simplified50.3%
if 6.19999999999999976e283 < y Initial program 67.6%
Taylor expanded in t around 0 67.6%
Taylor expanded in y around 0 84.4%
+-commutative84.4%
*-commutative84.4%
Simplified84.4%
Taylor expanded in z around inf 84.4%
Final simplification59.3%
(FPCore (x y z t) :precision binary64 (if (<= y 5.4e-30) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.4e-30) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 5.4d-30) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.4e-30) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5.4e-30: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5.4e-30) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 5.4e-30) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.4e-30], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.4 \cdot 10^{-30}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 5.39999999999999975e-30Initial program 96.2%
Taylor expanded in y around inf 58.3%
Taylor expanded in z around 0 63.4%
if 5.39999999999999975e-30 < y Initial program 86.8%
Taylor expanded in y around inf 74.9%
Final simplification67.0%
(FPCore (x y z t) :precision binary64 (if (<= y 5.4e-30) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.4e-30) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y <= 5.4d-30) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.4e-30) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5.4e-30: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5.4e-30) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 5.4e-30) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.4e-30], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.4 \cdot 10^{-30}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 5.39999999999999975e-30Initial program 96.2%
Taylor expanded in y around inf 58.3%
Taylor expanded in z around 0 63.4%
if 5.39999999999999975e-30 < y Initial program 86.8%
Taylor expanded in t around 0 68.1%
Taylor expanded in y around 0 62.5%
+-commutative62.5%
*-commutative62.5%
Simplified62.5%
Final simplification63.1%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.2%
Taylor expanded in y around inf 63.5%
Taylor expanded in z around 0 53.8%
Final simplification53.8%
(FPCore (x y z t) :precision binary64 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
herbie shell --seed 2023332
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:herbie-target
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))