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+unsubscr...@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.

Reply via email to