I'm looking for a tool (like Wolfram Alpha) that can calculate the result of $ B(P,N) $
Where $B(P,N)$ is a recursive function defined as follows:
$ \left\{\begin{matrix} B(P,N)=\frac{-(-1)^{\frac{N}{2^{P-1}}+\sum_{i=1}^{P-1}(\frac{-B(P-i,N)}{2^{i}})}+1}{2}\\ P\in \mathbb{N}_{>0}\\ N\in \mathbb{N} \end{matrix}\right. $
Note that $ \sum_{i=1}^{0}f(x)=0 $ summation is an empty sum, so:
$$ B(1,N)=\frac{-(-1)^{\frac{N}{2^{1-1}}+\sum_{i=1}^{0}(\frac{-B(0,N)}{2^{i}})}+1}{2}=\frac{-(-1)^{\frac{N}{2^{0}}+0}+1}{2}=\frac{-(-1)^{N}+1}{2} $$
I tried using Wolfram Alpha, but it didn't work.
I defined: $$ S(P,N) = \sum_{i=1}^P \frac{ B(P-i,N) }{2^i}$$ And rewrote your equations as: $$B(P,N) = \frac{1 - (-1)_{}^{ \frac{N}{2^{P-1}} - S(P-1,N)}}{2}$$ $$S(P,N) = \frac{B(P,N) + S(P-1,N)}{2}$$ Then I implemented them in Python with the following code:
When I tested it with this:
The output was as expected: