Question regarding the rat-function (and "CRE" in general)
Subject: Question regarding the rat-function (and "CRE" in general)
From: Stavros Macrakis
Date: Wed, 30 Nov 2011 14:51:31 -0500
On Wed, Nov 30, 2011 at 14:31, Oliver Kullmann <O.Kullmann at swansea.ac.uk>wrote:
> For example,
> `rat(x)- x' yields `rat(0)' which has a different internal
> representation than 0.
>
> However:
>
> (%i35) is(rat(x)-x=0);
>
"is" always converts CRE expressions (using ratdisrep) to the standard
Maxima general representation before comparing. So:
rat(x+y,x,y) => y+x ==ratdisrep=> y+x
rat(x+y,y,x) => x+y ==ratdisrep=> y+x
is(rat(x+y,x,y)=rat(x+y,y,x)) => true
Note, by the way, that rat(0) actually can have many different internal
representations, depending on the rat variables used:
(%i1) ?print(rat(0))$
((MRAT SIMP NIL NIL) 0 . 1)
(%i2) ?print(rat(0,x))$
((MRAT SIMP ($X) (#:X34107)) 0 . 1)
(%i3) ?print(rat(0,y))$
((MRAT SIMP ($Y) (#:X34107)) 0 . 1)
(%i4) ?print(rat(0,y,exp(y)))$
((MRAT SIMP ($Y ((MEXPT SIMP) $%E $Y)) (#:Y34113 #:X34107)) 0 . 1)
Only ratprint does not have the default-value, and it should not
> have any effect here? So is the documentation of rat outdated?
>
I am surprised that ratprint isn't true (by default) in your system. It is
in mine (Maxima 5.25.1 GCL Windows).
> (%i45) rat(x)-x;
> (%o45)/R/ 0
>
> So apparently /R/0 and 0 are "syntactically equal" ?
>
Not sure why you conclude this. Subtraction doesn't care about syntactic
equality. What is happening here is that CRE form is "contagious", so
rat(x)-x is equivalent to rat(x)-rat(x), thus the result /r/0.
> Finally, perhaps I can finally understand what "CRE" is?!?:
>
> Until now, I actually thought "CRE" would represent a general mathematical
> concept,
>
It is actually a pretty simple concept. A CRE is a rational function, a
ratio of two multivariate polynomials. Polynomials are represented in the
form sum(a[i]*x^i,i,0,...) where the coefficients a[i] are either numbers
or polynomials of this form not including the variable x. The variables x
(the 'kernels') can in theory be any expression in Maxima general
representation, but in practice consist of things that cannot be
represented as polynomials, e.g. special function calls like sin(x) and
non-integer exponentials like x^(1/3) or %e^x. Generally CRE's try to use
minimal fractional exponentials, e.g. x^(2/3)+x^(1/3) is represented as
q^2+q (q=x^(1/3)), but it is possible to generate things like q+r
(q=x^(2/3), r=x^(1/3)).
> This seems to be the only place where "CRE" is "explained". How is a user
> supposed
> to make sense of it??
>
The simple explanation is polynomials with polynomial coefficients.
> The documentation of rat also gives no clue why one should use "rat":
>
For efficiency in handling large expressions, mostly.
%i8) expand((x+y+1)^200)$
Evaluation took 1.9600 seconds (1.9600 elapsed)
(%i9) rat((x+y+1)^200)$
Evaluation took 0.0200 seconds (0.0200 elapsed)
Hope this helps,
-s