
(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 (* z (- t x)))
(t_2 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z)))))
(if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+304) t_2 t_1))))
double code(double x, double y, double z, double t) {
double t_1 = z * (t - x);
double t_2 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 2e+304) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = z * (t - x);
double t_2 = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (y * z));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 2e+304) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (t - x) t_2 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (y * z)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 2e+304: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(t - x)) t_2 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(y * z))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 2e+304) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (t - x); t_2 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 2e+304) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+304], t$95$2, t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(t - x\right)\\
t_2 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+304}:\\
\;\;\;\;t\_2\\
\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.9999999999999999e304 < (+.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
/-lowering-/.f64N/A
--lowering--.f6453.7%
Simplified53.7%
Taylor expanded in z around inf
*-lowering-*.f64N/A
--lowering--.f64100.0%
Simplified100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 1.9999999999999999e304Initial program 99.5%
Final simplification99.5%
(FPCore (x y z t) :precision binary64 (fma (* y (- (tanh (/ t y)) (tanh (/ x y)))) z x))
double code(double x, double y, double z, double t) {
return fma((y * (tanh((t / y)) - tanh((x / y)))), z, x);
}
function code(x, y, z, t) return fma(Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), z, x) end
code[x_, y_, z_, t_] := N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right)
\end{array}
Initial program 94.3%
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
fma-defineN/A
fma-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6498.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x y z t) :precision binary64 (+ x (* (* y (- (tanh (/ t y)) (tanh (/ x y)))) z)))
double code(double x, double y, double z, double t) {
return x + ((y * (tanh((t / y)) - tanh((x / y)))) * z);
}
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 * (tanh((t / y)) - tanh((x / y)))) * z)
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * (Math.tanh((t / y)) - Math.tanh((x / y)))) * z);
}
def code(x, y, z, t): return x + ((y * (math.tanh((t / y)) - math.tanh((x / y)))) * z)
function code(x, y, z, t) return Float64(x + Float64(Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))) * z)) end
function tmp = code(x, y, z, t) tmp = x + ((y * (tanh((t / y)) - tanh((x / y)))) * z); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \cdot z
\end{array}
Initial program 94.3%
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6498.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x y z t)
:precision binary64
(if (<= y 2.9e-104)
x
(if (<= y 5e+123)
(+ x (* (* y z) (- (tanh (/ t y)) (/ x y))))
(+ x (* z (- t x))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.9e-104) {
tmp = x;
} else if (y <= 5e+123) {
tmp = x + ((y * z) * (tanh((t / y)) - (x / 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.9d-104) then
tmp = x
else if (y <= 5d+123) then
tmp = x + ((y * z) * (tanh((t / y)) - (x / 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.9e-104) {
tmp = x;
} else if (y <= 5e+123) {
tmp = x + ((y * z) * (Math.tanh((t / y)) - (x / y)));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.9e-104: tmp = x elif y <= 5e+123: tmp = x + ((y * z) * (math.tanh((t / y)) - (x / y))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.9e-104) tmp = x; elseif (y <= 5e+123) tmp = Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - Float64(x / 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.9e-104) tmp = x; elseif (y <= 5e+123) tmp = x + ((y * z) * (tanh((t / y)) - (x / y))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.9e-104], x, If[LessEqual[y, 5e+123], N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / 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.9 \cdot 10^{-104}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+123}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.9000000000000001e-104Initial program 93.8%
Taylor expanded in x around inf
Simplified63.9%
if 2.9000000000000001e-104 < y < 4.99999999999999974e123Initial program 99.8%
Taylor expanded in x around 0
/-lowering-/.f6478.1%
Simplified78.1%
if 4.99999999999999974e123 < y Initial program 90.8%
Taylor expanded in y around inf
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f6482.3%
Simplified82.3%
(FPCore (x y z t) :precision binary64 (if (<= y 4.8e+130) x (if (<= y 4.8e+151) (- 0.0 (* x z)) (if (<= y 1.7e+223) x (* t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.8e+130) {
tmp = x;
} else if (y <= 4.8e+151) {
tmp = 0.0 - (x * z);
} else if (y <= 1.7e+223) {
tmp = x;
} else {
tmp = t * 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.8d+130) then
tmp = x
else if (y <= 4.8d+151) then
tmp = 0.0d0 - (x * z)
else if (y <= 1.7d+223) then
tmp = x
else
tmp = t * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.8e+130) {
tmp = x;
} else if (y <= 4.8e+151) {
tmp = 0.0 - (x * z);
} else if (y <= 1.7e+223) {
tmp = x;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.8e+130: tmp = x elif y <= 4.8e+151: tmp = 0.0 - (x * z) elif y <= 1.7e+223: tmp = x else: tmp = t * z return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.8e+130) tmp = x; elseif (y <= 4.8e+151) tmp = Float64(0.0 - Float64(x * z)); elseif (y <= 1.7e+223) tmp = x; else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.8e+130) tmp = x; elseif (y <= 4.8e+151) tmp = 0.0 - (x * z); elseif (y <= 1.7e+223) tmp = x; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.8e+130], x, If[LessEqual[y, 4.8e+151], N[(0.0 - N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.7e+223], x, N[(t * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{+130}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+151}:\\
\;\;\;\;0 - x \cdot z\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+223}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if y < 4.80000000000000048e130 or 4.8000000000000002e151 < y < 1.6999999999999999e223Initial program 95.3%
Taylor expanded in x around inf
Simplified62.7%
if 4.80000000000000048e130 < y < 4.8000000000000002e151Initial program 68.5%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6452.9%
Simplified52.9%
Taylor expanded in x around inf
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6484.4%
Simplified84.4%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-sub0N/A
--lowering--.f6467.6%
Simplified67.6%
if 1.6999999999999999e223 < y Initial program 90.7%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6477.6%
Simplified77.6%
Taylor expanded in x around 0
*-commutativeN/A
*-lowering-*.f6449.5%
Simplified49.5%
Final simplification61.7%
(FPCore (x y z t) :precision binary64 (if (<= y 2.1e+15) x (if (<= y 1.5e+223) (* x (- 1.0 z)) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.1e+15) {
tmp = x;
} else if (y <= 1.5e+223) {
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 <= 2.1d+15) then
tmp = x
else if (y <= 1.5d+223) 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 <= 2.1e+15) {
tmp = x;
} else if (y <= 1.5e+223) {
tmp = x * (1.0 - z);
} else {
tmp = z * (t - x);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.1e+15: tmp = x elif y <= 1.5e+223: tmp = x * (1.0 - z) else: tmp = z * (t - x) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.1e+15) tmp = x; elseif (y <= 1.5e+223) 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 <= 2.1e+15) tmp = x; elseif (y <= 1.5e+223) tmp = x * (1.0 - z); else tmp = z * (t - x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.1e+15], x, If[LessEqual[y, 1.5e+223], 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 2.1 \cdot 10^{+15}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+223}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.1e15Initial program 94.5%
Taylor expanded in x around inf
Simplified63.1%
if 2.1e15 < y < 1.50000000000000001e223Initial program 94.9%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6473.3%
Simplified73.3%
Taylor expanded in x around inf
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6470.6%
Simplified70.6%
if 1.50000000000000001e223 < y Initial program 90.7%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6477.6%
Simplified77.6%
Taylor expanded in z around inf
*-lowering-*.f64N/A
--lowering--.f6464.3%
Simplified64.3%
(FPCore (x y z t) :precision binary64 (if (<= y 4.8e+14) x (if (<= y 1.85e+296) (* x (- 1.0 z)) (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.8e+14) {
tmp = x;
} else if (y <= 1.85e+296) {
tmp = x * (1.0 - z);
} else {
tmp = t * 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.8d+14) then
tmp = x
else if (y <= 1.85d+296) then
tmp = x * (1.0d0 - z)
else
tmp = t * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.8e+14) {
tmp = x;
} else if (y <= 1.85e+296) {
tmp = x * (1.0 - z);
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 4.8e+14: tmp = x elif y <= 1.85e+296: tmp = x * (1.0 - z) else: tmp = t * z return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 4.8e+14) tmp = x; elseif (y <= 1.85e+296) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.8e+14) tmp = x; elseif (y <= 1.85e+296) tmp = x * (1.0 - z); else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.8e+14], x, If[LessEqual[y, 1.85e+296], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(t * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{+14}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+296}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if y < 4.8e14Initial program 94.5%
Taylor expanded in x around inf
Simplified63.1%
if 4.8e14 < y < 1.84999999999999983e296Initial program 94.7%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6474.7%
Simplified74.7%
Taylor expanded in x around inf
*-lowering-*.f64N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f6462.4%
Simplified62.4%
if 1.84999999999999983e296 < y Initial program 76.3%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6476.3%
Simplified76.3%
Taylor expanded in x around 0
*-commutativeN/A
*-lowering-*.f6477.0%
Simplified77.0%
Final simplification63.2%
(FPCore (x y z t) :precision binary64 (if (<= y 3.35e+15) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.35e+15) {
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 <= 3.35d+15) 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 <= 3.35e+15) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.35e+15: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.35e+15) 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 <= 3.35e+15) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.35e+15], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.35 \cdot 10^{+15}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.35e15Initial program 94.5%
Taylor expanded in x around inf
Simplified63.1%
if 3.35e15 < y Initial program 93.4%
Taylor expanded in y around inf
+-lowering-+.f64N/A
*-lowering-*.f64N/A
--lowering--.f6481.3%
Simplified81.3%
(FPCore (x y z t) :precision binary64 (if (<= y 1.15e+15) x (+ x (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.15e+15) {
tmp = x;
} else {
tmp = x + (t * 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 <= 1.15d+15) then
tmp = x
else
tmp = x + (t * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.15e+15) {
tmp = x;
} else {
tmp = x + (t * z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.15e+15: tmp = x else: tmp = x + (t * z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.15e+15) tmp = x; else tmp = Float64(x + Float64(t * z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.15e+15) tmp = x; else tmp = x + (t * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.15e+15], x, N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.15 \cdot 10^{+15}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + t \cdot z\\
\end{array}
\end{array}
if y < 1.15e15Initial program 94.5%
Taylor expanded in x around inf
Simplified63.1%
if 1.15e15 < y Initial program 93.4%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6474.8%
Simplified74.8%
Taylor expanded in t around inf
*-commutativeN/A
*-lowering-*.f6468.9%
Simplified68.9%
Final simplification64.5%
(FPCore (x y z t) :precision binary64 (if (<= y 7e+223) x (* t z)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7e+223) {
tmp = x;
} else {
tmp = t * 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 <= 7d+223) then
tmp = x
else
tmp = t * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7e+223) {
tmp = x;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 7e+223: tmp = x else: tmp = t * z return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 7e+223) tmp = x; else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 7e+223) tmp = x; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 7e+223], x, N[(t * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{+223}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if y < 7.0000000000000002e223Initial program 94.6%
Taylor expanded in x around inf
Simplified61.6%
if 7.0000000000000002e223 < y Initial program 90.7%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6477.6%
Simplified77.6%
Taylor expanded in x around 0
*-commutativeN/A
*-lowering-*.f6449.5%
Simplified49.5%
Final simplification60.6%
(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 94.3%
Taylor expanded in x around inf
Simplified58.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 2024138
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))