
(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 12 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 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))) (if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+304))) (* 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 <= 5e+304)) {
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 <= 5e+304)) {
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 <= 5e+304): 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 <= 5e+304)) 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 <= 5e+304))) 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, 5e+304]], $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 5 \cdot 10^{+304}\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 4.9999999999999997e304 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 44.8%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.9999999999999997e304Initial program 99.9%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (tanh (/ t y)) (tanh (/ x y))))) (if (<= (+ x (* (* y z) t_1)) 5e+304) (fma y (* z 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)) <= 5e+304) {
tmp = fma(y, (z * 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)) <= 5e+304) tmp = fma(y, Float64(z * 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], 5e+304], N[(y * N[(z * 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 5 \cdot 10^{+304}:\\
\;\;\;\;\mathsf{fma}\left(y, z \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))))) < 4.9999999999999997e304Initial program 96.8%
+-commutative96.8%
associate-*l*99.9%
fma-define99.9%
Simplified99.9%
if 4.9999999999999997e304 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 46.2%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 100.0%
Final simplification99.9%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (tanh (/ t y))))) (if (<= y 6.2e+40) (+ x (* y t_1)) (fma y t_1 (* x (- 1.0 z))))))
double code(double x, double y, double z, double t) {
double t_1 = z * tanh((t / y));
double tmp;
if (y <= 6.2e+40) {
tmp = x + (y * t_1);
} else {
tmp = fma(y, t_1, (x * (1.0 - z)));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * tanh(Float64(t / y))) tmp = 0.0 if (y <= 6.2e+40) tmp = Float64(x + Float64(y * t_1)); else tmp = fma(y, t_1, Float64(x * Float64(1.0 - z))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 6.2e+40], N[(x + N[(y * t$95$1), $MachinePrecision]), $MachinePrecision], N[(y * t$95$1 + N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 6.2 \cdot 10^{+40}:\\
\;\;\;\;x + y \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, t\_1, x \cdot \left(1 - z\right)\right)\\
\end{array}
\end{array}
if y < 6.1999999999999995e40Initial program 95.3%
Taylor expanded in x around 0 26.0%
associate-/r*26.0%
rec-exp26.0%
div-sub26.0%
rec-exp26.0%
tanh-def-a83.3%
Simplified83.3%
if 6.1999999999999995e40 < y Initial program 85.1%
Taylor expanded in x around 0 49.6%
+-commutative49.6%
fma-define49.6%
Simplified94.2%
Final simplification85.4%
(FPCore (x y z t) :precision binary64 (if (<= y 3100.0) x (if (<= y 1.6e+64) (* z (- (* y (tanh (/ t y))) x)) (fma z (- t x) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3100.0) {
tmp = x;
} else if (y <= 1.6e+64) {
tmp = z * ((y * tanh((t / y))) - x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 3100.0) tmp = x; elseif (y <= 1.6e+64) tmp = Float64(z * Float64(Float64(y * tanh(Float64(t / y))) - x)); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 3100.0], x, If[LessEqual[y, 1.6e+64], N[(z * N[(N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3100:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+64}:\\
\;\;\;\;z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 3100Initial program 95.1%
Taylor expanded in x around inf 64.1%
if 3100 < y < 1.60000000000000009e64Initial program 99.9%
Taylor expanded in x around 0 12.1%
+-commutative12.1%
fma-define12.1%
Simplified83.1%
Taylor expanded in z around inf 8.4%
neg-mul-18.4%
+-commutative8.4%
associate-/l*8.4%
div-sub8.4%
associate-/r*8.4%
Simplified65.9%
if 1.60000000000000009e64 < y Initial program 82.7%
Taylor expanded in y around inf 82.4%
+-commutative82.4%
fma-define82.4%
Simplified82.4%
Final simplification67.3%
(FPCore (x y z t) :precision binary64 (if (<= y 58000.0) x (if (<= y 1.02e+47) (* z (* y (tanh (/ t y)))) (fma z (- t x) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 58000.0) {
tmp = x;
} else if (y <= 1.02e+47) {
tmp = z * (y * tanh((t / y)));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 58000.0) tmp = x; elseif (y <= 1.02e+47) tmp = Float64(z * Float64(y * tanh(Float64(t / y)))); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 58000.0], x, If[LessEqual[y, 1.02e+47], N[(z * N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 58000:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+47}:\\
\;\;\;\;z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 58000Initial program 95.1%
Taylor expanded in x around inf 64.1%
if 58000 < y < 1.0199999999999999e47Initial program 99.8%
Taylor expanded in x around 0 7.8%
+-commutative7.8%
fma-define7.8%
Simplified73.7%
Taylor expanded in x around 0 1.1%
associate-*r*1.1%
associate-*r/1.1%
rec-exp1.1%
rec-exp1.1%
tanh-def-a56.1%
*-commutative56.1%
associate-*r*56.1%
Simplified56.1%
if 1.0199999999999999e47 < y Initial program 84.5%
Taylor expanded in y around inf 78.5%
+-commutative78.5%
fma-define78.5%
Simplified78.5%
Final simplification66.5%
(FPCore (x y z t) :precision binary64 (if (<= y 4.3e+153) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.3e+153) {
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 <= 4.3d+153) 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 <= 4.3e+153) {
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 <= 4.3e+153: 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 <= 4.3e+153) tmp = Float64(x + Float64(y * Float64(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 <= 4.3e+153) 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, 4.3e+153], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{+153}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.2999999999999998e153Initial program 94.7%
Taylor expanded in x around 0 25.4%
associate-/r*25.4%
rec-exp25.4%
div-sub25.4%
rec-exp25.4%
tanh-def-a81.9%
Simplified81.9%
if 4.2999999999999998e153 < y Initial program 77.2%
Taylor expanded in y around inf 95.5%
Final simplification83.0%
(FPCore (x y z t) :precision binary64 (if (<= y 3500.0) x (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3500.0) {
tmp = x;
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 3500.0) tmp = x; else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 3500.0], x, N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3500:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 3500Initial program 95.1%
Taylor expanded in x around inf 64.1%
if 3500 < y Initial program 86.9%
Taylor expanded in y around inf 71.2%
+-commutative71.2%
fma-define71.2%
Simplified71.2%
Final simplification65.7%
(FPCore (x y z t) :precision binary64 (if (<= y 1.1e+42) x (if (<= y 4e+191) (* x (- 1.0 z)) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.1e+42) {
tmp = x;
} else if (y <= 4e+191) {
tmp = x * (1.0 - z);
} else {
tmp = 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 <= 1.1d+42) then
tmp = x
else if (y <= 4d+191) then
tmp = x * (1.0d0 - z)
else
tmp = 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 <= 1.1e+42) {
tmp = x;
} else if (y <= 4e+191) {
tmp = x * (1.0 - z);
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.1e+42: tmp = x elif y <= 4e+191: tmp = x * (1.0 - z) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.1e+42) tmp = x; elseif (y <= 4e+191) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.1e+42) tmp = x; elseif (y <= 4e+191) tmp = x * (1.0 - z); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.1e+42], x, If[LessEqual[y, 4e+191], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{+42}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+191}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.1000000000000001e42Initial program 95.3%
Taylor expanded in x around inf 63.0%
if 1.1000000000000001e42 < y < 4.00000000000000029e191Initial program 92.4%
Taylor expanded in y around inf 66.3%
Taylor expanded in x around inf 56.0%
mul-1-neg56.0%
unsub-neg56.0%
Simplified56.0%
if 4.00000000000000029e191 < y Initial program 65.8%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 59.3%
Final simplification61.8%
(FPCore (x y z t) :precision binary64 (if (<= y 30000.0) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 30000.0) {
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 <= 30000.0d0) 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 <= 30000.0) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 30000.0: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 30000.0) 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 <= 30000.0) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 30000.0], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 30000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3e4Initial program 95.1%
Taylor expanded in x around inf 64.1%
if 3e4 < y Initial program 86.9%
Taylor expanded in y around inf 71.2%
Final simplification65.7%
(FPCore (x y z t) :precision binary64 (if (<= y 4.3e+37) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.3e+37) {
tmp = 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 <= 4.3d+37) then
tmp = 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 <= 4.3e+37) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.3e+37: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.3e+37) tmp = 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 <= 4.3e+37) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.3e+37], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 4.2999999999999997e37Initial program 95.3%
Taylor expanded in x around inf 63.0%
if 4.2999999999999997e37 < y Initial program 85.1%
Taylor expanded in y around inf 75.6%
Taylor expanded in x around inf 58.5%
mul-1-neg58.5%
unsub-neg58.5%
Simplified58.5%
Final simplification62.1%
(FPCore (x y z t) :precision binary64 (if (<= y 15000.0) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 15000.0) {
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 <= 15000.0d0) 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 <= 15000.0) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 15000.0: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 15000.0) 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 <= 15000.0) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 15000.0], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 15000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 15000Initial program 95.1%
Taylor expanded in x around inf 64.1%
if 15000 < y Initial program 86.9%
Taylor expanded in x around 0 29.8%
associate-/r*29.8%
rec-exp29.8%
div-sub29.8%
rec-exp29.8%
tanh-def-a76.8%
Simplified76.8%
Taylor expanded in y around inf 57.3%
+-commutative57.3%
*-commutative57.3%
Simplified57.3%
Final simplification62.5%
(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.3%
Taylor expanded in x around inf 59.1%
Final simplification59.1%
(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 2024095
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))