I'm running into a strange problem. I want to implement a product in Maple with skipping some factors. For example (a very simplified one):
$$\prod_{\stackrel{k=1}{k \not= 3}}^{5} (x-k) = (x-1)(x-2)(x-4)(x-5).$$
In Maple I wrote
product(ifelse(k <> 3, x - k, 1), k = 1 .. 5)
But I get
(x - 1)*(x - 2)*(x - 3)*(x - 4)*(x - 5).
In other words, the ifthen seems to evaluate to true all the time.
I tested a little further and got those results:
product(i = 1, i = 1 .. 1);
1 = 1
product(evalb(i = 1), i = 1 .. 1);
false
So even when I force the evaluation with evalb I never get a true. The type of the index variable k is an ordinary symbol and outside of the product-context, comparing a symbol does work:
k := 1;
k := 1
k = 1;
1 = 1
evalb(k = 1);
true
What am I doing wrong here?
Best regards!
productin your example. But that's not such a robust approach in general, and can get messy with nested products. Also, you are computing an exact result with multiplication of finitely many terms (and the end-points of the index are numeric). So this is not a "symbolic product", with an answer of a closed formula that might attain for some example for k=1..N with N unassigned. Somulreally is the appropriate choice, notproduct. – acer Jun 15 '22 at 20:57