But if log is not log: P -> R how can the simplifications be done?
Consider
log (x*y)
and when I write it I mean log to be of type P -> R, however I can't
say it to FriCAS. If I don't know anything about x and y (except the
are both R, x*y is P) then I leave this expression. However I actually
assume x and y to be in P and
log x + log y
can be used. How does FriCAS assure an expression to be valid if not
by types used?
OK, again. If you type
log(x*y)
then the interpreter has to turn this string of characters into a
sensible FriCAS object. Just think about what this could be.
It must live in some FriCAS domain. But which one? So the interpreter
tries to guess. there are 4 symbols log, x, *, y. Nothing is known about
x and y, so they are first interpreted as variables.
(1) -> x
(1) x
Type: Variable(x)
(2) -> y
(2) y
Type: Variable(y)
* is special. It has some default interpretation in the interpreter. In
particular it's know that it's an infix operator of type (D, D) -> D for
some D. Now what is the D? Input D would be something like Variable,
because x and y are. But then the result type D would also be Variable.
FriCAS knows that x*y is not a variable, so it looks for a superdomain P
of Variable that allows for a function *: (P, P)->P. Polynomial(Integer)
is such a domain.
(3) -> x*y
(3) x y
Type: Polynomial(Integer)
Then there is log. I am not sure how much the interpreter knows about
log, but the general idea is as with *. log looks like an operator so
the interpreter has to look for a function log: X -> Y for some X (that
must be a superdomain of P) and some Y. It detects that Expression
Integer (I'll abbreviate that as E) fits for X and Y.
(4) -> log(x*y)
(4) log(x y)
Type: Expression(Integer)
At this time log(x*y) is a proper thing that is of type
Expression(Integer). Everything is fine for FriCAS.
But as you see now, FriCAS considers x and y now as elements of type E.
If you haven't said anything about the type of x and y before you write
the log(x*y) expression, then now it is too late.
So let's go back. Suppose you have said
(1) -> x: Complex(Float)
Type: Void
(2) -> y: Complex(Float)
Type: Void
Now, you should be aware that x, y are like ordinary programming
variables. They are no longer indeterminates as before. FriCAS just
knows that they have a representation that is the same as for every
element of type Complex(Float). It just happens that for some strange
reason FriCAS allows you to declare the type of x and y, but don't give
a value. (I actually believe that this (mis-)feature should be removed
from the Interpreter.
Then it is clear that
(3) -> x*y
x is declared as being in Complex(Float) but has not been given a
value.
fails. The result should be Complex(Float), but if there are no values
then what would you expect FriCAS to do?
I'm sure you will have more questions.
Ralf
--
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.