Re: Spurious whitespace when exporting CJK text as epub

luigi scarso <[email protected]> Wed, 29 Apr 2026 11:21:28 +0200
Newsgroups gmane.comp.tex.context
Message-ID <CAG5iGsAkZ7EVyWKrD-C0zKtdX8+AKVnyGON51bVc1W40R8zTwQ@mail.gmail.com>
On Wed, 22 Apr 2026 at 21:31, Hans Hagen <[email protected]> wrote:

> Hi Luigi,
>
>
> In the lib we have various comparisons (< = > and functions that use an
> eps and set functions). We use the filib library (not that large,
> cleaned up a bit) while you use gmp. How does the experimental stand
> alone metapost interval mode do a comparison?
>
>
mpfi ha a set of comparison functions, i.e.
 -- Function: int mpfi_cmp (mpfi_t OP1, mpfi_t OP2)
 -- Function: int mpfi_cmp_d (mpfi_t OP1, double OP2)
 -- Function: int mpfi_cmp_ui (mpfi_t OP1, unsigned long int OP2)
 -- Function: int mpfi_cmp_si (mpfi_t OP1, long int OP2)
 -- Function: int mpfi_cmp_z (mpfi_t OP1, mpz_t OP2)
 -- Function: int mpfi_cmp_q (mpfi_t OP1, mpq_t OP2)
 -- Function: int mpfi_cmp_fr (mpfi_t OP1, mpfr_t OP2)
     Compares OP1 and OP2.  Return a positive value if OP1 > OP2, zero
     if OP1 overlaps or contains OP2, and a negative value if OP1 < OP2.
     In case one of the operands is invalid (which is represented by at
     least one NaN endpoint), it returns 1, even if both are invalid.

In interval arithmetic <= is not a total order relation, it's a partial
order.


> Do you have an example where interval in mp makes sense? Of course it's
> kind of fun to play with these things, just to get an idea how it works.
>
>

I think interval arithmetic is quite unusual in itself, for example
> w=[-1,1]; w^2;
[0;1]
> w*w;
[-1;1]
> w^3;
[-1;1]
> w*w*w;
[-1;1]

and
> w=[0;2*pi]; sin(w);
[-1;1]
> w=[0;3*pi]; sin(w);
[-1;1]


> sin([0;2*pi])*sin([0;3*pi]);
[-1;1]
with the midpoints (if one thinks that "it's a calculation around the
midpoint of the interval")
> sin(pi)*sin(3/2*pi);
0
this seems ok, the midpoint of [-1;1] is 0, but
> sin([0;2*pi])+sin([0;3*pi]); sin(pi)+sin(3/2*pi);
[-2;2]
-1


The correct way to see it  is as set with operations, so f(w) is the image
of the interval w,
 w1 'op' w2 =  {  x 'op' y | x \in w1 and y \in w2} and  the "<=" is the
inclusion between two intervals.

So, no surprise if the "traditional" algorithms don't work with interval
arithmetic .

On the other end
> ([0;0.5])^2 ;
[0;0.25]
and we can think that in this case we gain precision (and with
> ([0;2])^2 ;
[0;4]
we lose precision)
so I think it might be appropriate to implement algorithms in metapost
and test whether they're "good enough" (i.e., robust to changes in their
parameters)
identifying the part where one loses precision.

(I have used
https://www.sollya.org/
for the examples)



> I suppose at some point you write some article about this (and gmp)?
>

yes.
At some point :-)

--
luigi

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : [email protected] / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________