The same thing happens after :
sage: def foo(x): ....: return RR(N(-1/2*pi*(tan(1/2*pi*tanh(x))^2 + 1)*(tanh(x)^2 - 1)/tan(1/2*pi*tanh(x)), digits=30)) ....: sage: foo <function foo at 0x7fe472aab250> sage: plot(foo, (1, 30)) Launched png viewer for Graphics object consisting of 1 graphics primitive Le mardi 6 décembre 2022 à 14:23:48 UTC+1, Emmanuel Charpentier a écrit : > Le mardi 6 décembre 2022 à 14:16:56 UTC+1, dim…@gmail.com a écrit : > > It's plotting via matplotlib, perhaps that's why the precision setting is >> ignored (or pehaps something like RDF is hardcoded in Sage plotting code) >> > That wouldn’t explain why the specification included in the lambda > expression in the third example isn’t accepted : matplotlib should see > the RR values returned by it (which *do* accept the precision > specification). > > >> >> On Tue, Dec 6, 2022 at 12:53 PM Emmanuel Charpentier < >> emanuel.c...@gmail.com> wrote: >> >>> Question already asked on |`ask.sagemath.org`]( >>> https://ask.sagemath.org/question/64934/plotting-ill-conditionned-function/), >>> >>> where it didn't attract a lot of attention... >>> >>> Let >>> >>> ``` >>> sage: f(x)=log(tan(pi/2*tanh(x))).diff(x) ; f >>> x |--> -1/2*pi*(tan(1/2*pi*tanh(x))^2 + 1)*(tanh(x)^2 - >>> 1)/tan(1/2*pi*tanh(x)) >>> ``` >>> >>> It can be shown (see Juanjo's answer [here]( >>> https://ask.sagemath.org/question/64794/inconsistentincorrect-value-of-limit-involving-tan-and-tanh/)) >>> >>> that this finction's limit at `x=oo` is 2. >>> >>> A couple CASes are wrong about it : >>> >>> ``` >>> sage: f(x).limit(x=oo) >>> 0 >>> sage: f(x).limit(x=oo, algorithm="maxima") >>> 0 >>> ``` >>> >>> A couple get it right : >>> >>> ``` >>> sage: f(x).limit(x=oo, algorithm="giac") >>> 2 >>> sage: f(x).limit(x=oo, algorithm="mathematica_free") >>> 2 >>> ``` >>> >>> And Sympy currently never returns. >>> >>> A "naïve" way to explore this is to assess the situation is to look for >>> numerical values : >>> >>> ``` >>> plot(f, (1, 30)) >>> ``` >>> [image: tmp_bnpx6r7n.png] >>> >>> This plot hints at ill-conditionong of the epression of the function. >>> And it turns out that this ill-conditioning can be overcome by specifying >>> an "absurd" precision : >>> >>> ``` >>> sage: f(30).n() >>> -0.000000000000000 >>> sage: f(30).n(digits=30) >>> 1.99999483984586167962667231030 >>> ``` >>> >>> But `plot` seems to *ignore* this specification : >>> >>> ``` >>> sage: plot(lambda u:f(u).n(digits=30), (1, 30)) >>> ``` >>> >>> [image: tmp_jeq3c8ko.png] >>> >>> We can try to "isolate" the precision specification in a Python >>> function, which seems to work : >>> >>> ``` >>> sage: def foo(x): return RR(f(x).n(digits=30)) >>> sage: foo(30) >>> 1.99999483984586 >>> ``` >>> >>> but is still defeated byr the inner gears of `plot` : >>> >>> ``` >>> sage: plot(foo, (1, 30)) >>> ``` >>> >>> [image: tmp_dg2gelpc.png] >>> >>> Why, Ô why ??? >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "sage-support" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to sage-support...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/sage-support/db271244-0ad7-4484-8a46-bdc4b1edd0f0n%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/sage-support/db271244-0ad7-4484-8a46-bdc4b1edd0f0n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/de783db9-35b4-47a4-88ba-064a1f67f532n%40googlegroups.com.