Re: [EXTERNAL] Re: 1-button calculator ~ "all elementary fns from a single operator"

Stavros Macrakis <[email protected]> Sun, 3 May 2026 13:18:16 -0400
Newsgroups gmane.comp.mathematics.maxima.general
Message-ID <CACLVabUPPWMNPBTizA1B53WAEp6wh9KDZfY1L=BMN6ZEJ170sg@mail.gmail.com>
Thanks for sharing the Python code. It is strange that the author calls
straightforward macro-expansion a "compiler", but I guess these days you
can get a degree in CS without taking a compiler class....

This translates easily into Mazima (see end of post). Careful! This does
*not* guarantee the *minimal* EML expression, or even a reasonable
approximation to it. For example, *exp(x)-log(y)* is minimally expressed as
*e(x,y)*, not

*e(e(1,e(e(1,e(x,1)),1)),*
*  e(e(1,e(e(1,y),1)),1)*


which is what you get by direct expansion.

What next? "optimizers" for eml expressions?

I still don't see the point. How is it helpful to write *x^(2/3)* as

E(E(E(E(1,
        E(E(1,
            E(1,
              E(E(1,

E(E(E(1,E(E(1,E(1,E(E(1,E(E(1,E(E(1,1),1)),E(E(E(1,E(E(1,E(1,E(E(1,1),1))),1)),E(1,1)),1))),1))),1)),
                      E(E(E(1,E(E(1,E(1,E(E(1,1),1))),1)),
                          E(E(1,
                              E(E(1,
                                  E(E(E(1,E(E(1,E(1,E(E(1,1),1))),1)),
                                      E(E(1,
                                          E(E(1,
                                              E(E(1,E(E(1,1),1)),

E(E(E(1,E(E(1,E(1,E(E(1,1),1))),1)),

E(E(E(1,E(E(1,1),1)),E(E(E(1,E(E(1,E(1,E(E(1,1),1))),1)),E(1,1)),1)),1)),1))),1)),1)),1)),1)),

1)),1)),1)),1))),1)),E(E(E(1,E(E(1,E(1,E(E(1,1),1))),1)),E(E(1,E(E(1,E(1,E(E(1,x),1))),1)),1)),1)),1),1)


--------------------------

 /* write expression using eml */

eml_exp(z):= e(z, 1) ;
eml_log(z):= e(1, eml_exp(e(1, z))) ;
eml_zero():= eml_log(1) ;
eml_sub(a, b):= e(eml_log(a), eml_exp(b)) ;
eml_neg(z):= eml_sub(eml_zero(), z) ;
eml_add(a, b):= eml_sub(a, eml_neg(b)) ;
eml_inv(z):= eml_exp(eml_neg(eml_log(z))) ;
eml_mul(a, b):= eml_exp(eml_add(eml_log(a), eml_log(b))) ;
eml_div(a, b):= eml_mul(a, eml_inv(b)) ;
eml_pow(a, b):= eml_exp(eml_mul(b, eml_log(a))) ;
eml_one():= 1;
eml_two():= eml_add(1, 1);
eml_double(z):= eml_add(z, z);


/* expand back */

eml(a,b):=eexp(a)-elog(b);
eexp(a):=if a=inf then inf elseif a=minf then 0 else exp(a);
elog(a):= if a=inf then inf elseif a=0 then minf else log(a);

load("opsubst");
expand_eml(expr) := block([sub: opsubst('eml,'e,expr)], ev(sub,nouns));


On Sun, May 3, 2026 at 12:33 PM Henry Baker <[email protected]> wrote:

> OK, I looked at the Python3 code for the EML compiler, and it looks like
> it would be trivial to translate its formulae into Maxima using pattern
> matching.
>
> For example, here are some of the Python3 functions:
>
> def EML(a, b): return f"EML[{a},{b}]"
> def eml_exp(z): return EML(z, "1") # Exp[z]
> def eml_log(z): return EML("1", eml_exp(EML("1", z))) # Log[z]
> def eml_zero(): return eml_log("1") # 0 = Log[1]
> def eml_sub(a, b): return EML(eml_log(a), eml_exp(b)) # a - b
> def eml_neg(z): return eml_sub(eml_zero(), z) # -z
> def eml_add(a, b): return eml_sub(a, eml_neg(b)) # a + b
> def eml_inv(z): return eml_exp(eml_neg(eml_log(z))) # 1/z
> def eml_mul(a, b): return eml_exp(eml_add(eml_log(a), eml_log(b))) # a*b
> def eml_div(a, b): return eml_mul(a, eml_inv(b)) # a/b
> def eml_pow(a, b): return eml_exp(eml_mul(b, eml_log(a))) # a^b
> def eml_one(): return "1"
> def eml_two(): return eml_add("1", "1")
> def eml_double(z): return eml_add(z, z)
>
> Thus, in Maxima
> matchdeclare(z,all);
> tellsimp(exp(z),EML(z,1));
> tellsimp(log(z),EML(1,exp(EML(1,z))));
>
> However, such a pattern-matching compiler would have a bigger problem with
> sums and products, and an even bigger problem with converting constants --
> e.g., integers, rationals, floats.
>
> The good news: EML compiling and simplification provide a pretty decent
> workout for Maxima, and would likely make some pretty good test cases
> and/or benchmarks.
>
> -----Original Message-----
> From: Henry Baker <[email protected]>
> Sent: May 2, 2026 8:53 AM
> To: Przemek Klosowski via Maxima-discuss <
> [email protected]>
> Subject: Re: [Maxima-discuss] [EXTERNAL] Re: 1-button calculator ~ "all
> elementary fns from a single operator"
>
> OK, I downloaded the "EML compiler" from here:
>
> https://github.com/VA00/SymbolicRegressionPackage/tree/master
>
> The EML compiler requires python3 &amp; numpy (and probably other stuff
> that I might already have installed).
>
> I then did a trivial script to convert from Mathematica expressions to
> Maxima expressions.
>
> EML requires that log(0)=minf, so I defined mylog(x):=if (x=0) then minf
> else log(x), and used mylog(x) instead of log(x) in the definition of eml.
>
> However, I now require that %e^minf = 0.
>
> What is the magic in Maxima to make this happen? I did "? minf", but that
> didn't provide any help.
>
> -----Original Message-----
> From: Henry Baker
> Sent: May 1, 2026 11:23 AM
> To: Przemek Klosowski via Maxima-discuss
> Subject: Re: [Maxima-discuss] [EXTERNAL] Re: 1-button calculator ~ "all
> elementary fns from a single operator"
>
> Obviously, Google was confused.
>
> Q: If z = exp(x)-log(y), then x = log(z + log(y)) might look a tad better
> ? Is this log(z+log(y)) function universal in the same sense as eml() ?
>
> Q: if we have a 1BC expression for f(x)=y, can we then trivially compute
> x=f^-1(y) ?
>
> Q: The 1BC paper seems to want to rely on functions defined over the
> reals; I suspect that functions defined over the complex numbers might give
> additional 1BC results that might be prettier ? Perhaps the constant %pi*%i
> might work to force things into the complex plane ?
>
> Q: I've always had a fondness for asinh(x), as it is bijective onto the
> reals, and has many of the same properties/characteristics as "gradual
> underflow" floating point numbers. I'm wondering if it could be part of a
> universal 1BC function ?
>
> -----Original Message-----
> From: Przemek Klosowski via Maxima-discuss
> Sent: May 1, 2026 9:24 AM
> To:
> Subject: Re: [Maxima-discuss] [EXTERNAL] Re: 1-button calculator ~ "all
> elementary fns from a single operator"
>
> > BTW, Google just told me that the obvious differential equation for >
> eml(x,y) is
> >
> > dy/dx = y*exp(x)
>
> (%i1) eq:'diff(y,x)=y*exp(x);
> dy x
> (%o1) ── = %e y
> dx
> (%i2) ode2(eq,y,x);
> x
> %e
> (%o2) y = %e %c
>
> what am I missing?
>
>
>
> _______________________________________________
> Maxima-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/maxima-discuss
>
>
>
>
> _______________________________________________
> Maxima-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/maxima-discuss
>
>
>
>
> _______________________________________________
> Maxima-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/maxima-discuss
>
>
>
>
> _______________________________________________
> Maxima-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/maxima-discuss
>

_______________________________________________
Maxima-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maxima-discuss