
(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 11 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 (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z)))))
(if (<= t_1 (- INFINITY))
(- (* z t) (* z x))
(if (<= t_1 5e+292) t_1 (+ x (* z (- t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (z * t) - (z * x);
} else if (t_1 <= 5e+292) {
tmp = t_1;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (y * z));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = (z * t) - (z * x);
} else if (t_1 <= 5e+292) {
tmp = t_1;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (y * z)) tmp = 0 if t_1 <= -math.inf: tmp = (z * t) - (z * x) elif t_1 <= 5e+292: tmp = t_1 else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(y * z))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(z * t) - Float64(z * x)); elseif (t_1 <= 5e+292) tmp = t_1; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z)); tmp = 0.0; if (t_1 <= -Inf) tmp = (z * t) - (z * x); elseif (t_1 <= 5e+292) tmp = t_1; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(z * t), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+292], t$95$1, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;z \cdot t - z \cdot x\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+292}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x + 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))))) < -inf.0Initial program 60.8%
Taylor expanded in x around 0 71.9%
+-commutative71.9%
associate-*r*0.0%
fma-define0.0%
Simplified26.3%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 99.9%
neg-mul-199.9%
sub-neg99.9%
Simplified99.9%
sub-neg99.9%
distribute-rgt-in100.0%
*-commutative100.0%
Applied egg-rr100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.9999999999999996e292Initial program 99.5%
if 4.9999999999999996e292 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 53.7%
Taylor expanded in y around inf 95.2%
Final simplification99.2%
(FPCore (x y z t) :precision binary64 (if (<= y 6.2e+178) (fma y (* z (- (tanh (/ t y)) (tanh (/ x y)))) x) (+ (* x (- 1.0 z)) (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.2e+178) {
tmp = fma(y, (z * (tanh((t / y)) - tanh((x / y)))), x);
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 6.2e+178) tmp = fma(y, Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x); else tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(z * t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.2e+178], N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{+178}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if y < 6.19999999999999982e178Initial program 96.2%
+-commutative96.2%
associate-*l*97.9%
fma-define97.9%
Simplified97.9%
if 6.19999999999999982e178 < y Initial program 72.7%
Taylor expanded in x around 0 57.2%
+-commutative57.2%
associate-*r*32.6%
fma-define32.6%
Simplified68.5%
Taylor expanded in y around inf 92.7%
Final simplification97.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 4.9e+42)
(+ x (* t_1 (* y z)))
(if (<= y 4.5e+222)
(+ (* x (- 1.0 z)) (* y (* z t_1)))
(+ x (* z (- t x)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 4.9e+42) {
tmp = x + (t_1 * (y * z));
} else if (y <= 4.5e+222) {
tmp = (x * (1.0 - z)) + (y * (z * t_1));
} 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) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 4.9d+42) then
tmp = x + (t_1 * (y * z))
else if (y <= 4.5d+222) then
tmp = (x * (1.0d0 - z)) + (y * (z * t_1))
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 t_1 = Math.tanh((t / y));
double tmp;
if (y <= 4.9e+42) {
tmp = x + (t_1 * (y * z));
} else if (y <= 4.5e+222) {
tmp = (x * (1.0 - z)) + (y * (z * t_1));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 4.9e+42: tmp = x + (t_1 * (y * z)) elif y <= 4.5e+222: tmp = (x * (1.0 - z)) + (y * (z * t_1)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 4.9e+42) tmp = Float64(x + Float64(t_1 * Float64(y * z))); elseif (y <= 4.5e+222) tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(y * Float64(z * t_1))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 4.9e+42) tmp = x + (t_1 * (y * z)); elseif (y <= 4.5e+222) tmp = (x * (1.0 - z)) + (y * (z * t_1)); else tmp = x + (z * (t - 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, 4.9e+42], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.5e+222], N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 4.9 \cdot 10^{+42}:\\
\;\;\;\;x + t\_1 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+222}:\\
\;\;\;\;x \cdot \left(1 - z\right) + y \cdot \left(z \cdot t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.9000000000000002e42Initial program 96.7%
Taylor expanded in x around 0 15.9%
associate-/r*15.9%
rec-exp15.9%
div-sub15.9%
rec-exp15.9%
tanh-def-a75.5%
Simplified75.5%
if 4.9000000000000002e42 < y < 4.49999999999999989e222Initial program 91.7%
Taylor expanded in x around 0 56.8%
+-commutative56.8%
associate-*r*42.5%
fma-define42.5%
Simplified77.3%
fma-undefine77.3%
associate-*l*88.7%
Applied egg-rr88.7%
if 4.49999999999999989e222 < y Initial program 58.6%
Taylor expanded in y around inf 100.0%
Final simplification78.7%
(FPCore (x y z t)
:precision binary64
(if (<= y 3.5e-12)
x
(if (<= y 1.45e+22)
(* z (- (* y (tanh (/ t y))) x))
(if (<= y 1.02e+40) x (+ (* x (- 1.0 z)) (* z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e-12) {
tmp = x;
} else if (y <= 1.45e+22) {
tmp = z * ((y * tanh((t / y))) - x);
} else if (y <= 1.02e+40) {
tmp = x;
} else {
tmp = (x * (1.0 - z)) + (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.5d-12) then
tmp = x
else if (y <= 1.45d+22) then
tmp = z * ((y * tanh((t / y))) - x)
else if (y <= 1.02d+40) then
tmp = x
else
tmp = (x * (1.0d0 - z)) + (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.5e-12) {
tmp = x;
} else if (y <= 1.45e+22) {
tmp = z * ((y * Math.tanh((t / y))) - x);
} else if (y <= 1.02e+40) {
tmp = x;
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.5e-12: tmp = x elif y <= 1.45e+22: tmp = z * ((y * math.tanh((t / y))) - x) elif y <= 1.02e+40: tmp = x else: tmp = (x * (1.0 - z)) + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.5e-12) tmp = x; elseif (y <= 1.45e+22) tmp = Float64(z * Float64(Float64(y * tanh(Float64(t / y))) - x)); elseif (y <= 1.02e+40) tmp = x; else tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.5e-12) tmp = x; elseif (y <= 1.45e+22) tmp = z * ((y * tanh((t / y))) - x); elseif (y <= 1.02e+40) tmp = x; else tmp = (x * (1.0 - z)) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.5e-12], x, If[LessEqual[y, 1.45e+22], N[(z * N[(N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.02e+40], x, N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{-12}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+22}:\\
\;\;\;\;z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right) - x\right)\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+40}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if y < 3.5e-12 or 1.45e22 < y < 1.02e40Initial program 96.5%
Taylor expanded in x around inf 63.3%
if 3.5e-12 < y < 1.45e22Initial program 100.0%
Taylor expanded in x around 0 8.7%
+-commutative8.7%
associate-*r*8.7%
fma-define8.7%
Simplified77.4%
Taylor expanded in z around inf 1.2%
neg-mul-11.2%
distribute-lft-in1.2%
associate-/l*1.2%
div-sub1.2%
associate-/r*1.2%
Simplified69.9%
if 1.02e40 < y Initial program 82.2%
Taylor expanded in x around 0 55.3%
+-commutative55.3%
associate-*r*36.7%
fma-define36.7%
Simplified71.8%
Taylor expanded in y around inf 84.5%
Final simplification67.6%
(FPCore (x y z t) :precision binary64 (if (<= y 6.5e+57) (+ x (* (tanh (/ t y)) (* y z))) (+ (* x (- 1.0 z)) (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.5e+57) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = (x * (1.0 - z)) + (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 <= 6.5d+57) then
tmp = x + (tanh((t / y)) * (y * z))
else
tmp = (x * (1.0d0 - z)) + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.5e+57) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 6.5e+57: tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = (x * (1.0 - z)) + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 6.5e+57) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 6.5e+57) tmp = x + (tanh((t / y)) * (y * z)); else tmp = (x * (1.0 - z)) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.5e+57], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{+57}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if y < 6.4999999999999997e57Initial program 96.7%
Taylor expanded in x around 0 15.9%
associate-/r*15.9%
rec-exp15.9%
div-sub15.9%
rec-exp15.9%
tanh-def-a75.6%
Simplified75.6%
if 6.4999999999999997e57 < y Initial program 81.9%
Taylor expanded in x around 0 56.3%
+-commutative56.3%
associate-*r*37.2%
fma-define37.2%
Simplified71.2%
Taylor expanded in y around inf 84.2%
Final simplification77.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* z t))))
(if (<= y 520000.0)
x
(if (<= y 1.08e+107)
t_1
(if (<= y 8e+157)
(* x (- 1.0 z))
(if (<= y 4e+190) t_1 (* z (- t x))))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (z * t);
double tmp;
if (y <= 520000.0) {
tmp = x;
} else if (y <= 1.08e+107) {
tmp = t_1;
} else if (y <= 8e+157) {
tmp = x * (1.0 - z);
} else if (y <= 4e+190) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_1 = x + (z * t)
if (y <= 520000.0d0) then
tmp = x
else if (y <= 1.08d+107) then
tmp = t_1
else if (y <= 8d+157) then
tmp = x * (1.0d0 - z)
else if (y <= 4d+190) then
tmp = t_1
else
tmp = z * (t - x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + (z * t);
double tmp;
if (y <= 520000.0) {
tmp = x;
} else if (y <= 1.08e+107) {
tmp = t_1;
} else if (y <= 8e+157) {
tmp = x * (1.0 - z);
} else if (y <= 4e+190) {
tmp = t_1;
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (z * t) tmp = 0 if y <= 520000.0: tmp = x elif y <= 1.08e+107: tmp = t_1 elif y <= 8e+157: tmp = x * (1.0 - z) elif y <= 4e+190: tmp = t_1 else: tmp = z * (t - x) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(z * t)) tmp = 0.0 if (y <= 520000.0) tmp = x; elseif (y <= 1.08e+107) tmp = t_1; elseif (y <= 8e+157) tmp = Float64(x * Float64(1.0 - z)); elseif (y <= 4e+190) tmp = t_1; else tmp = Float64(z * Float64(t - x)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (z * t); tmp = 0.0; if (y <= 520000.0) tmp = x; elseif (y <= 1.08e+107) tmp = t_1; elseif (y <= 8e+157) tmp = x * (1.0 - z); elseif (y <= 4e+190) tmp = t_1; else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 520000.0], x, If[LessEqual[y, 1.08e+107], t$95$1, If[LessEqual[y, 8e+157], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e+190], t$95$1, N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + z \cdot t\\
\mathbf{if}\;y \leq 520000:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{+107}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+157}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+190}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 5.2e5Initial program 97.0%
Taylor expanded in x around inf 62.9%
if 5.2e5 < y < 1.08000000000000002e107 or 7.99999999999999987e157 < y < 4.0000000000000003e190Initial program 96.4%
Taylor expanded in x around 0 33.9%
associate-/r*33.9%
rec-exp33.9%
div-sub33.9%
rec-exp33.9%
tanh-def-a86.1%
Simplified86.1%
Taylor expanded in y around inf 60.0%
+-commutative60.0%
*-commutative60.0%
Simplified60.0%
if 1.08000000000000002e107 < y < 7.99999999999999987e157Initial program 82.9%
Taylor expanded in y around inf 56.6%
Taylor expanded in x around inf 64.7%
neg-mul-164.7%
sub-neg64.7%
Simplified64.7%
if 4.0000000000000003e190 < y Initial program 65.9%
Taylor expanded in x around 0 51.3%
+-commutative51.3%
associate-*r*25.5%
fma-define25.5%
Simplified65.7%
Taylor expanded in y around inf 90.8%
Taylor expanded in z around inf 71.3%
neg-mul-171.3%
sub-neg71.3%
Simplified71.3%
Final simplification63.3%
(FPCore (x y z t) :precision binary64 (if (<= y 3.9e+83) x (if (<= y 5.2e+249) (* x (- 1.0 z)) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.9e+83) {
tmp = x;
} else if (y <= 5.2e+249) {
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 <= 3.9d+83) then
tmp = x
else if (y <= 5.2d+249) 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 <= 3.9e+83) {
tmp = x;
} else if (y <= 5.2e+249) {
tmp = x * (1.0 - z);
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.9e+83: tmp = x elif y <= 5.2e+249: tmp = x * (1.0 - z) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.9e+83) tmp = x; elseif (y <= 5.2e+249) 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 <= 3.9e+83) tmp = x; elseif (y <= 5.2e+249) tmp = x * (1.0 - z); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.9e+83], x, If[LessEqual[y, 5.2e+249], 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 3.9 \cdot 10^{+83}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{+249}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.9000000000000002e83Initial program 96.8%
Taylor expanded in x around inf 62.1%
if 3.9000000000000002e83 < y < 5.20000000000000038e249Initial program 90.9%
Taylor expanded in y around inf 70.3%
Taylor expanded in x around inf 59.1%
neg-mul-159.1%
sub-neg59.1%
Simplified59.1%
if 5.20000000000000038e249 < y Initial program 42.1%
Taylor expanded in x around 0 52.3%
+-commutative52.3%
associate-*r*10.7%
fma-define10.7%
Simplified41.3%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 90.6%
neg-mul-190.6%
sub-neg90.6%
Simplified90.6%
Final simplification62.8%
(FPCore (x y z t) :precision binary64 (if (<= y 5.1e+40) x (+ (* x (- 1.0 z)) (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.1e+40) {
tmp = x;
} else {
tmp = (x * (1.0 - z)) + (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.1d+40) then
tmp = x
else
tmp = (x * (1.0d0 - z)) + (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.1e+40) {
tmp = x;
} else {
tmp = (x * (1.0 - z)) + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 5.1e+40: tmp = x else: tmp = (x * (1.0 - z)) + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 5.1e+40) tmp = x; else tmp = Float64(Float64(x * Float64(1.0 - z)) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 5.1e+40) tmp = x; else tmp = (x * (1.0 - z)) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.1e+40], x, N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.1 \cdot 10^{+40}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\
\end{array}
\end{array}
if y < 5.09999999999999959e40Initial program 96.7%
Taylor expanded in x around inf 62.1%
if 5.09999999999999959e40 < y Initial program 82.2%
Taylor expanded in x around 0 55.3%
+-commutative55.3%
associate-*r*36.7%
fma-define36.7%
Simplified71.8%
Taylor expanded in y around inf 84.5%
Final simplification66.4%
(FPCore (x y z t) :precision binary64 (if (<= y 1.95e+40) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.95e+40) {
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 <= 1.95d+40) 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 <= 1.95e+40) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.95e+40: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.95e+40) 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 <= 1.95e+40) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.95e+40], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.95 \cdot 10^{+40}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.95e40Initial program 96.7%
Taylor expanded in x around inf 62.1%
if 1.95e40 < y Initial program 82.2%
Taylor expanded in y around inf 84.5%
Final simplification66.4%
(FPCore (x y z t) :precision binary64 (if (<= y 3.8e+83) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.8e+83) {
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 <= 3.8d+83) 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 <= 3.8e+83) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.8e+83: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.8e+83) 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 <= 3.8e+83) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.8e+83], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.8 \cdot 10^{+83}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 3.8000000000000002e83Initial program 96.8%
Taylor expanded in x around inf 62.1%
if 3.8000000000000002e83 < y Initial program 79.3%
Taylor expanded in y around inf 63.6%
Taylor expanded in x around inf 57.5%
neg-mul-157.5%
sub-neg57.5%
Simplified57.5%
Final simplification61.3%
(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.9%
Taylor expanded in x around inf 57.8%
Final simplification57.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 2024078
(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))))))