
(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}
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 2.2e+203) (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))) (- (+ x (* z t)) (* z x))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.2e+203) {
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
} else {
tmp = (x + (z * t)) - (z * x);
}
return tmp;
}
NOTE: y should be positive before calling this function
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.2d+203) then
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
else
tmp = (x + (z * t)) - (z * x)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.2e+203) {
tmp = x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
} else {
tmp = (x + (z * t)) - (z * x);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 2.2e+203: tmp = x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y))))) else: tmp = (x + (z * t)) - (z * x) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 2.2e+203) tmp = Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))); else tmp = Float64(Float64(x + Float64(z * t)) - Float64(z * x)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.2e+203) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); else tmp = (x + (z * t)) - (z * x); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 2.2e+203], 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], N[(N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.2 \cdot 10^{+203}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + z \cdot t\right) - z \cdot x\\
\end{array}
\end{array}
if y < 2.20000000000000004e203Initial program 96.0%
associate-*l*97.3%
Simplified97.3%
if 2.20000000000000004e203 < y Initial program 77.2%
associate-*l*86.0%
Simplified86.0%
Taylor expanded in x around 0 67.1%
*-commutative67.1%
mul-1-neg67.1%
unsub-neg67.1%
Simplified76.6%
Taylor expanded in y around inf 100.0%
Final simplification97.5%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
y = abs(y);
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
y = abs(y) function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 94.4%
+-commutative94.4%
*-commutative94.4%
associate-*l*97.8%
fma-def97.8%
Simplified97.8%
Final simplification97.8%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.14e+86) (+ x (* (tanh (/ t y)) (* z y))) (- (+ x (* z t)) (* z x))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.14e+86) {
tmp = x + (tanh((t / y)) * (z * y));
} else {
tmp = (x + (z * t)) - (z * x);
}
return tmp;
}
NOTE: y should be positive before calling this function
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.14d+86) then
tmp = x + (tanh((t / y)) * (z * y))
else
tmp = (x + (z * t)) - (z * x)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.14e+86) {
tmp = x + (Math.tanh((t / y)) * (z * y));
} else {
tmp = (x + (z * t)) - (z * x);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.14e+86: tmp = x + (math.tanh((t / y)) * (z * y)) else: tmp = (x + (z * t)) - (z * x) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.14e+86) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(z * y))); else tmp = Float64(Float64(x + Float64(z * t)) - Float64(z * x)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.14e+86) tmp = x + (tanh((t / y)) * (z * y)); else tmp = (x + (z * t)) - (z * x); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1.14e+86], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.14 \cdot 10^{+86}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + z \cdot t\right) - z \cdot x\\
\end{array}
\end{array}
if y < 1.14e86Initial program 96.4%
associate-*l*97.7%
Simplified97.7%
Taylor expanded in x around 0 27.4%
*-commutative27.4%
associate-*r*27.2%
associate-/r*27.2%
div-sub27.2%
rec-exp27.2%
rec-exp27.2%
Simplified82.7%
if 1.14e86 < y Initial program 86.5%
associate-*l*90.8%
Simplified90.8%
Taylor expanded in x around 0 54.6%
*-commutative54.6%
mul-1-neg54.6%
unsub-neg54.6%
Simplified72.6%
Taylor expanded in y around inf 92.7%
Final simplification84.7%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(if (<= y 6.4e-35)
x
(if (<= y 1.02e+42)
(+ x (* z (- t x)))
(if (<= y 2e+85) x (- (+ x (* z t)) (* z x))))))y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.4e-35) {
tmp = x;
} else if (y <= 1.02e+42) {
tmp = x + (z * (t - x));
} else if (y <= 2e+85) {
tmp = x;
} else {
tmp = (x + (z * t)) - (z * x);
}
return tmp;
}
NOTE: y should be positive before calling this function
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.4d-35) then
tmp = x
else if (y <= 1.02d+42) then
tmp = x + (z * (t - x))
else if (y <= 2d+85) then
tmp = x
else
tmp = (x + (z * t)) - (z * x)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.4e-35) {
tmp = x;
} else if (y <= 1.02e+42) {
tmp = x + (z * (t - x));
} else if (y <= 2e+85) {
tmp = x;
} else {
tmp = (x + (z * t)) - (z * x);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 6.4e-35: tmp = x elif y <= 1.02e+42: tmp = x + (z * (t - x)) elif y <= 2e+85: tmp = x else: tmp = (x + (z * t)) - (z * x) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 6.4e-35) tmp = x; elseif (y <= 1.02e+42) tmp = Float64(x + Float64(z * Float64(t - x))); elseif (y <= 2e+85) tmp = x; else tmp = Float64(Float64(x + Float64(z * t)) - Float64(z * x)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 6.4e-35) tmp = x; elseif (y <= 1.02e+42) tmp = x + (z * (t - x)); elseif (y <= 2e+85) tmp = x; else tmp = (x + (z * t)) - (z * x); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 6.4e-35], x, If[LessEqual[y, 1.02e+42], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2e+85], x, N[(N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.4 \cdot 10^{-35}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+42}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+85}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(x + z \cdot t\right) - z \cdot x\\
\end{array}
\end{array}
if y < 6.3999999999999996e-35 or 1.01999999999999996e42 < y < 2e85Initial program 96.0%
+-commutative96.0%
*-commutative96.0%
associate-*l*98.2%
fma-def98.2%
Simplified98.2%
Taylor expanded in z around 0 72.6%
if 6.3999999999999996e-35 < y < 1.01999999999999996e42Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
associate-*l*99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around inf 64.1%
if 2e85 < y Initial program 86.5%
associate-*l*90.8%
Simplified90.8%
Taylor expanded in x around 0 54.6%
*-commutative54.6%
mul-1-neg54.6%
unsub-neg54.6%
Simplified72.6%
Taylor expanded in y around inf 92.7%
Final simplification76.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 4.1e-35) x (if (or (<= y 1.8e+42) (not (<= y 2e+85))) (+ x (* z (- t x))) x)))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.1e-35) {
tmp = x;
} else if ((y <= 1.8e+42) || !(y <= 2e+85)) {
tmp = x + (z * (t - x));
} else {
tmp = x;
}
return tmp;
}
NOTE: y should be positive before calling this function
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.1d-35) then
tmp = x
else if ((y <= 1.8d+42) .or. (.not. (y <= 2d+85))) then
tmp = x + (z * (t - x))
else
tmp = x
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.1e-35) {
tmp = x;
} else if ((y <= 1.8e+42) || !(y <= 2e+85)) {
tmp = x + (z * (t - x));
} else {
tmp = x;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 4.1e-35: tmp = x elif (y <= 1.8e+42) or not (y <= 2e+85): tmp = x + (z * (t - x)) else: tmp = x return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 4.1e-35) tmp = x; elseif ((y <= 1.8e+42) || !(y <= 2e+85)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = x; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.1e-35) tmp = x; elseif ((y <= 1.8e+42) || ~((y <= 2e+85))) tmp = x + (z * (t - x)); else tmp = x; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 4.1e-35], x, If[Or[LessEqual[y, 1.8e+42], N[Not[LessEqual[y, 2e+85]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.1 \cdot 10^{-35}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+42} \lor \neg \left(y \leq 2 \cdot 10^{+85}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < 4.10000000000000026e-35 or 1.8e42 < y < 2e85Initial program 96.0%
+-commutative96.0%
*-commutative96.0%
associate-*l*98.2%
fma-def98.2%
Simplified98.2%
Taylor expanded in z around 0 72.6%
if 4.10000000000000026e-35 < y < 1.8e42 or 2e85 < y Initial program 89.9%
+-commutative89.9%
*-commutative89.9%
associate-*l*97.0%
fma-def97.0%
Simplified97.0%
Taylor expanded in y around inf 85.4%
Final simplification76.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 4.6e+85) x (if (or (<= y 4e+135) (not (<= y 1.4e+160))) (* z (- t x)) x)))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.6e+85) {
tmp = x;
} else if ((y <= 4e+135) || !(y <= 1.4e+160)) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
NOTE: y should be positive before calling this function
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.6d+85) then
tmp = x
else if ((y <= 4d+135) .or. (.not. (y <= 1.4d+160))) then
tmp = z * (t - x)
else
tmp = x
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.6e+85) {
tmp = x;
} else if ((y <= 4e+135) || !(y <= 1.4e+160)) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 4.6e+85: tmp = x elif (y <= 4e+135) or not (y <= 1.4e+160): tmp = z * (t - x) else: tmp = x return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 4.6e+85) tmp = x; elseif ((y <= 4e+135) || !(y <= 1.4e+160)) tmp = Float64(z * Float64(t - x)); else tmp = x; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.6e+85) tmp = x; elseif ((y <= 4e+135) || ~((y <= 1.4e+160))) tmp = z * (t - x); else tmp = x; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 4.6e+85], x, If[Or[LessEqual[y, 4e+135], N[Not[LessEqual[y, 1.4e+160]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.6 \cdot 10^{+85}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+135} \lor \neg \left(y \leq 1.4 \cdot 10^{+160}\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < 4.5999999999999998e85 or 3.99999999999999985e135 < y < 1.4e160Initial program 96.4%
+-commutative96.4%
*-commutative96.4%
associate-*l*98.3%
fma-def98.3%
Simplified98.3%
Taylor expanded in z around 0 70.4%
if 4.5999999999999998e85 < y < 3.99999999999999985e135 or 1.4e160 < y Initial program 84.8%
+-commutative84.8%
*-commutative84.8%
associate-*l*95.5%
fma-def95.5%
Simplified95.5%
Taylor expanded in y around inf 93.8%
Taylor expanded in z around inf 70.0%
Final simplification70.4%
NOTE: y should be positive before calling this function
(FPCore (x y z t)
:precision binary64
(if (<= y 0.017)
x
(if (or (<= y 5.8e+161) (not (<= y 3.6e+188)))
(+ x (* z t))
(* z (- t x)))))y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 0.017) {
tmp = x;
} else if ((y <= 5.8e+161) || !(y <= 3.6e+188)) {
tmp = x + (z * t);
} else {
tmp = z * (t - x);
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= 0.017d0) then
tmp = x
else if ((y <= 5.8d+161) .or. (.not. (y <= 3.6d+188))) then
tmp = x + (z * t)
else
tmp = z * (t - x)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 0.017) {
tmp = x;
} else if ((y <= 5.8e+161) || !(y <= 3.6e+188)) {
tmp = x + (z * t);
} else {
tmp = z * (t - x);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 0.017: tmp = x elif (y <= 5.8e+161) or not (y <= 3.6e+188): tmp = x + (z * t) else: tmp = z * (t - x) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 0.017) tmp = x; elseif ((y <= 5.8e+161) || !(y <= 3.6e+188)) tmp = Float64(x + Float64(z * t)); else tmp = Float64(z * Float64(t - x)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 0.017) tmp = x; elseif ((y <= 5.8e+161) || ~((y <= 3.6e+188))) tmp = x + (z * t); else tmp = z * (t - x); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 0.017], x, If[Or[LessEqual[y, 5.8e+161], N[Not[LessEqual[y, 3.6e+188]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.017:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+161} \lor \neg \left(y \leq 3.6 \cdot 10^{+188}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 0.017000000000000001Initial program 95.9%
+-commutative95.9%
*-commutative95.9%
associate-*l*98.1%
fma-def98.1%
Simplified98.1%
Taylor expanded in z around 0 71.4%
if 0.017000000000000001 < y < 5.80000000000000032e161 or 3.60000000000000021e188 < y Initial program 92.5%
associate-*l*94.3%
Simplified94.3%
Taylor expanded in x around 0 35.2%
*-commutative35.2%
associate-*r*34.8%
associate-/r*34.8%
div-sub34.8%
rec-exp34.8%
rec-exp34.8%
Simplified71.5%
Taylor expanded in y around inf 66.2%
if 5.80000000000000032e161 < y < 3.60000000000000021e188Initial program 79.0%
+-commutative79.0%
*-commutative79.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 89.0%
Final simplification70.7%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.05e+162) x (if (<= y 1.2e+194) (* z (- x)) (if (<= y 4.4e+207) x (* z t)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.05e+162) {
tmp = x;
} else if (y <= 1.2e+194) {
tmp = z * -x;
} else if (y <= 4.4e+207) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
NOTE: y should be positive before calling this function
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.05d+162) then
tmp = x
else if (y <= 1.2d+194) then
tmp = z * -x
else if (y <= 4.4d+207) then
tmp = x
else
tmp = z * t
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.05e+162) {
tmp = x;
} else if (y <= 1.2e+194) {
tmp = z * -x;
} else if (y <= 4.4e+207) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.05e+162: tmp = x elif y <= 1.2e+194: tmp = z * -x elif y <= 4.4e+207: tmp = x else: tmp = z * t return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.05e+162) tmp = x; elseif (y <= 1.2e+194) tmp = Float64(z * Float64(-x)); elseif (y <= 4.4e+207) tmp = x; else tmp = Float64(z * t); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.05e+162) tmp = x; elseif (y <= 1.2e+194) tmp = z * -x; elseif (y <= 4.4e+207) tmp = x; else tmp = z * t; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1.05e+162], x, If[LessEqual[y, 1.2e+194], N[(z * (-x)), $MachinePrecision], If[LessEqual[y, 4.4e+207], x, N[(z * t), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.05 \cdot 10^{+162}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+194}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+207}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 1.05e162 or 1.2e194 < y < 4.40000000000000017e207Initial program 96.7%
+-commutative96.7%
*-commutative96.7%
associate-*l*98.4%
fma-def98.4%
Simplified98.4%
Taylor expanded in z around 0 68.4%
if 1.05e162 < y < 1.2e194Initial program 81.1%
+-commutative81.1%
*-commutative81.1%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
Taylor expanded in z around inf 90.1%
Taylor expanded in t around 0 41.5%
associate-*r*41.5%
mul-1-neg41.5%
Simplified41.5%
if 4.40000000000000017e207 < y Initial program 76.1%
associate-*l*85.3%
Simplified85.3%
Taylor expanded in x around 0 65.5%
*-commutative65.5%
mul-1-neg65.5%
unsub-neg65.5%
Simplified75.4%
Taylor expanded in y around inf 100.0%
Taylor expanded in t around inf 43.1%
*-commutative43.1%
Simplified43.1%
Final simplification65.4%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 5.8e+178) x (* z t)))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.8e+178) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
NOTE: y should be positive before calling this function
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.8d+178) then
tmp = x
else
tmp = z * t
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.8e+178) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 5.8e+178: tmp = x else: tmp = z * t return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 5.8e+178) tmp = x; else tmp = Float64(z * t); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 5.8e+178) tmp = x; else tmp = z * t; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 5.8e+178], x, N[(z * t), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.8 \cdot 10^{+178}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 5.8000000000000001e178Initial program 96.2%
+-commutative96.2%
*-commutative96.2%
associate-*l*98.4%
fma-def98.4%
Simplified98.4%
Taylor expanded in z around 0 67.7%
if 5.8000000000000001e178 < y Initial program 80.3%
associate-*l*89.9%
Simplified89.9%
Taylor expanded in x around 0 62.6%
*-commutative62.6%
mul-1-neg62.6%
unsub-neg62.6%
Simplified76.4%
Taylor expanded in y around inf 96.9%
Taylor expanded in t around inf 47.5%
*-commutative47.5%
Simplified47.5%
Final simplification65.4%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 x)
y = abs(y);
double code(double x, double y, double z, double t) {
return x;
}
NOTE: y should be positive before calling this function
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
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
return x;
}
y = abs(y) def code(x, y, z, t): return x
y = abs(y) function code(x, y, z, t) return x end
y = abs(y) function tmp = code(x, y, z, t) tmp = x; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := x
\begin{array}{l}
y = |y|\\
\\
x
\end{array}
Initial program 94.4%
+-commutative94.4%
*-commutative94.4%
associate-*l*97.8%
fma-def97.8%
Simplified97.8%
Taylor expanded in z around 0 63.0%
Final simplification63.0%
(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 2023207
(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))))))