Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mystery of count_ in functions #167

Closed
tueda opened this issue Feb 1, 2017 · 0 comments
Closed

Mystery of count_ in functions #167

tueda opened this issue Feb 1, 2017 · 0 comments
Labels
bug Something isn't working

Comments

@tueda
Copy link
Collaborator

tueda commented Feb 1, 2017

Consider the following example:

S x;
CF f;
L F = 1 + x + x^2;
multiply f(count_(x,1));
P;
.end

The intention is that count_ would get the power counting of x for each term in the expression F so that the result would be F = f(0) + f(1)*x + f(2)*x^2. But this could be wrong because count_ may be evaluated in the argument of f. Then count_ get replaced with 0 because there is no x in the argument. The result should be F = f(0) + f(0)*x + f(0)*x^2.

Now the problem is: both expectations are wrong. One gets

FORM 4.1 (Jan 21 2017, v4.1-20131025-294-g43ddc01) 64-bits  Run: Wed Feb  1 16:16:03 2017

   F =
      f(1) + f(1)*x + f(1)*x^2;

Sounds like somehow count_ gets 1. What is the origin of this behaviour?

By the way, the intended result can be obtained by putting it into a $-variable:

S x;
CF f;
L F = 1 + x + x^2;
$x = f(count_(x,1));
multiply $x;
P;
.end

giving

FORM 4.1 (Jan 21 2017, v4.1-20131025-294-g43ddc01) 64-bits  Run: Wed Feb  1 16:20:06 2017

   F =
      f(0) + f(1)*x + f(2)*x^2;
@tueda tueda changed the title Mistery of count_ in functions Mystery of count_ in functions Feb 1, 2017
tueda added a commit that referenced this issue Feb 22, 2017
@tueda tueda added the bug Something isn't working label May 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant