[NTG-context] Implicit plots/level curves possible?

Aditya Mahajan adityam at umich.edu
Mon Oct 8 23:25:24 CEST 2018


On Mon, 8 Oct 2018, Alan Braslau wrote:

> On Mon, 8 Oct 2018 16:00:10 -0400 (EDT)
> Aditya Mahajan <adityam at umich.edu> wrote:
>
>> On Sun, 7 Oct 2018, Hans Hagen wrote:
>>
>>> On 10/7/2018 7:14 PM, Alan Braslau wrote:
>>>> On Sun, 7 Oct 2018 17:25:35 +0200
>>>> "Mikael P. Sundqvist" <mickep at gmail.com> wrote:
>>>>
>>>>> ContourPlot[2 x^5 + x y + y^5 == 0, {x, 0, 2}, {y, -2, 1/2}]
>>>>
>>>> Brut force:
>>>> [...]
>>>>
>>> as this takes some time here's a cheat:
>>>
>>> \starttext
>>>
>>> \startbuffer[demo]
>>> [...]
>>> \stopbuffer
>>>
>>> \startTEXpage
>>>     \typesetbuffer[demo]
>>> \stopTEXpage
>>> \stoptext
>>>
>>> a next run the already prepared buffer will be taken unles it has been
>>> changed.
>>
>> I thought that this will also be a good usecase of showing Lua+MP
>> interaction. I wrote the code below following the metafun manual, but I cannot
>> get it to compile. What am I missing?
>>
>>
> You need to put it into the mp namespace:

Thanks. The metafun manual is confusing in this regard and I got 
the impression that any lua namespace could be used.

> (then eps should be made a linear function of xi)

Oh, I missed that. Thanks.

> (and, indeed this is much faster than calculating in MP)

Yes. Iterating over 10^6 values on a 1GHz computer should roughly take 
1ms in any reasonable programming language. Metapost for loops work with 
macro expansion, which can be very expensive for large loops.

Aditya


More information about the ntg-context mailing list