Define a constant that mimics the behavior of internal constants



Perhaps if you tell us *why *you want to do this, we can find a better
solution.

As Robert says, it's easy enough to define a new constant with a numerical
value.  But replicating the simplification rules would be a lot of trouble.
 It's easy enough to get sin(%2pi) => 0, but do you really want to
replicate the logic that gets sin(%2pi/3) => sqrt(3)/2; sin(x+%2pi/4) =>
cos(x); etc. etc.?

If it's a matter of displaying in a certain way, you could perhaps use
ratsubst?  For example:

       ratsubst(%2pi,2*%pi, sin(2*%pi/3+x)) => sin(%2pi/3+x)

But again, since we don't know why you're trying to do this, I don't know
if this helps at all.

            -s


On Wed, Sep 25, 2013 at 8:49 AM, Luj Omu <lujomu at gmail.com> wrote:

> Hello,
>
> I'd like to replicate the behavior of built-in constants like %pi or %e
> for custom constants. I.e. the constant should be displayed as a symbol by
> default and only be substituted by its numeric value upon request.
>
> E.g. for the custom constant %2pi = 2*%pi:
> The line "3 * %2pi;" should result in "3 %2pi;" and not in "6 %pi;".
> The line "3 * %2pi, numer;" should result in "18.84955592153876".
> The line "sin( %2pi);" should result in "0".
>
> I guess another way to frame this question would be: Where and how are the
> internal constants defined?
>
> Thanks!
> Luj Omu
> ______________________________**_________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/**mailman/listinfo/maxima<http://www.math.utexas.edu/mailman/listinfo/maxima>;
>