(1) -> q i == subscript('q, [i::OutputForm])
                                           Type: Void
(2) -> p i == subscript('p, [i::OutputForm])
                                           Type: Void
(3) -> [p k for k in 1..3]
   Compiling function p with type PositiveInteger -> Symbol

   (3)  [p ,p ,p ]
          1  2  3
                                           Type: List(Symbol)
(4) -> PoissonBracket(f, g) == D(f, q 1) * D(g, p 1) - D(f, p 1) * D(g, q 1)
                                           Type: Void
(5) -> Hamiltonian == (p 1)^2 + (q 1)^2
                                           Type: Void
(6) -> PoissonBracket(p 1, Hamiltonian)
   Compiling function q with type PositiveInteger -> Symbol
   Compiling body of rule Hamiltonian to compute value of type
      Polynomial(Integer)
   Compiling function PoissonBracket with type (Symbol,Polynomial(
      Integer)) -> Polynomial(Integer)

   (6)  - 2q
            1
                                           Type: Polynomial(Integer)

q i == subscript(q, [1::OutputForm])

since it is recursion (no wonder though). Is there a way to have a
single notion "q" for several entities?

Well, now you just see two q, but they mean different things. The first q is a function Integer -> Symbol. OK, more exactly, I should have defined

  q(i:Integer):Symbol == subscript('q, [i::OutputForm])

Now we come to the subscript function. It's of type

  (Symbol, List(OutputForm) -> Symbol

So if you write q as it's first argument, it must be of type Symbol, otherwise it would be rejected as an argument of subscript. So the q of type Integer->Symbol is clearly not of type Symbol, so it is ruled out or rather the error message shows you that there is no function subscript with the argument types that you have supplied.

But what is the q then in the argument of subscript? In my definition above, I've made it more explicit. I've prepended it with ' which means that the thing following it is considered a symbol, i.e. something that has no meaning and is different from the q of type Integer->Symbol.

Does it make things more clear to you?

Ralf

PS: I still hate Expression(?) since with a little more thought one can almost always do better (and in the end faster). You should just use it for initial experiments until you understand the type system in more detail. If you stop learning FriCAS at the level of Expression, you are not using FriCAS to its full power and are rather on equal footing with other typeless CAS.

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to