Re: [sage-support] Plot doesn't respect numerical precision specification.

2022-12-06 Thread Dima Pasechnik
On Tue, Dec 6, 2022 at 3:40 PM Dima Pasechnik  wrote:

> even more fun can be had by trying to plot the symbolic derivative of the
> function at hand. It's just making no sense at all what I see...
>

regarding the original function, perhaps plot is trying to do a numeric
derivative of it, but it's so bad that it gets confused...


>
>
> On Tue, Dec 6, 2022 at 1:41 PM Dima Pasechnik  wrote:
>
>> I can only say that the precision settings are ignored somewhere, so you
>> get e.g. with digits=20, not 30, the following:
>> sage: 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
>> : =20))
>> :
>> sage: [foo(t) for t in [1..30]]
>> [1.93774723784661,
>>  1.96821438642349,
>>  1.99513501225342,
>>  1.99933077915401,
>>  1.0923138260,
>>  1.8771214757,
>>  1.9833695304,
>>  1.9977492984,
>>  1.9996954002,
>>  1.587773,
>>  1.944087,
>>  1.992499,
>>  1.996552,
>>  2.042880,
>>  1.864906,
>>  1.9996835578,
>>  1.9995885087,
>>  2.0113072913,
>>  2.1042817460,
>>  2.3433318607,
>>  1.99883239681839,
>>  1.99062668609516,
>>  1.94465796436172,
>>  2.14811194088516,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000]
>>
>> or wihout digits set:
>> sage: [foo(t) for t in [1..30]]
>> [1.93774723784661,
>>  1.96821438642349,
>>  1.99513501225340,
>>  1.99933077915395,
>>  1.0923138165,
>>  1.8771213936,
>>  1.9833692570,
>>  1.9977472377,
>>  1.9996716508,
>>  1.9996314183,
>>  1.9991577607,
>>  1.9955972581,
>>  1.8381431810,
>>  1.2717313233,
>>  1.99985733718347,
>>  1.99771319132044,
>>  2.00589700214384,
>>  1.91808127189615,
>>  1.23125745353424,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000,
>>  -0.000]
>>
>> if it were able to use the 30 digits, we would not have seen that drop
>> down of the function graph to 0 somewhere just before 20.
>>
>>
>> On Tue, Dec 6, 2022 at 1:28 PM Emmanuel Charpentier <
>> emanuel.charpent...@gmail.com> wrote:
>>
>>> 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
>>> 
>>> 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.000
>> sage: f(30).n(digits=30)
>> 1.9483984586167962667231030
>> ```
>>
>> But `plot` seems 

Re: [sage-support] Plot doesn't respect numerical precision specification.

2022-12-06 Thread Dima Pasechnik
even more fun can be had by trying to plot the symbolic derivative of the
function at hand. It's just making no sense at all what I see...


On Tue, Dec 6, 2022 at 1:41 PM Dima Pasechnik  wrote:

> I can only say that the precision settings are ignored somewhere, so you
> get e.g. with digits=20, not 30, the following:
> sage: 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
> : =20))
> :
> sage: [foo(t) for t in [1..30]]
> [1.93774723784661,
>  1.96821438642349,
>  1.99513501225342,
>  1.99933077915401,
>  1.0923138260,
>  1.8771214757,
>  1.9833695304,
>  1.9977492984,
>  1.9996954002,
>  1.587773,
>  1.944087,
>  1.992499,
>  1.996552,
>  2.042880,
>  1.864906,
>  1.9996835578,
>  1.9995885087,
>  2.0113072913,
>  2.1042817460,
>  2.3433318607,
>  1.99883239681839,
>  1.99062668609516,
>  1.94465796436172,
>  2.14811194088516,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000]
>
> or wihout digits set:
> sage: [foo(t) for t in [1..30]]
> [1.93774723784661,
>  1.96821438642349,
>  1.99513501225340,
>  1.99933077915395,
>  1.0923138165,
>  1.8771213936,
>  1.9833692570,
>  1.9977472377,
>  1.9996716508,
>  1.9996314183,
>  1.9991577607,
>  1.9955972581,
>  1.8381431810,
>  1.2717313233,
>  1.99985733718347,
>  1.99771319132044,
>  2.00589700214384,
>  1.91808127189615,
>  1.23125745353424,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000,
>  -0.000]
>
> if it were able to use the 30 digits, we would not have seen that drop
> down of the function graph to 0 somewhere just before 20.
>
>
> On Tue, Dec 6, 2022 at 1:28 PM Emmanuel Charpentier <
> emanuel.charpent...@gmail.com> wrote:
>
>> 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
>> 
>> 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.000
> sage: f(30).n(digits=30)
> 1.9483984586167962667231030
> ```
>
> 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)
> 

Re: [sage-support] Plot doesn't respect numerical precision specification.

2022-12-06 Thread Oscar Benjamin
On Tue, 6 Dec 2022 at 12:53, Emmanuel Charpentier
 wrote:
>
>
> And Sympy currently never returns.

With current SymPy master it takes 6 seconds:

In [1]: %time log(tan(pi/2*tanh(x))).diff(x).limit(x, oo)
CPU times: user 5.73 s, sys: 24 ms, total: 5.75 s
Wall time: 5.75 s
Out[1]: 2

The fix was part of a GSOC project this summer and will be in SymPy 1.12:
https://github.com/sympy/sympy/pull/23844

--
Oscar

-- 
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/CAHVvXxSvaiH1mKt4kNgfs%2Bndhf22B2Hsvyav0tTHwpFC6Oq9Uw%40mail.gmail.com.


Re: [sage-support] Plot doesn't respect numerical precision specification.

2022-12-06 Thread Dima Pasechnik
I can only say that the precision settings are ignored somewhere, so you
get e.g. with digits=20, not 30, the following:
sage: 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
: =20))
:
sage: [foo(t) for t in [1..30]]
[1.93774723784661,
 1.96821438642349,
 1.99513501225342,
 1.99933077915401,
 1.0923138260,
 1.8771214757,
 1.9833695304,
 1.9977492984,
 1.9996954002,
 1.587773,
 1.944087,
 1.992499,
 1.996552,
 2.042880,
 1.864906,
 1.9996835578,
 1.9995885087,
 2.0113072913,
 2.1042817460,
 2.3433318607,
 1.99883239681839,
 1.99062668609516,
 1.94465796436172,
 2.14811194088516,
 -0.000,
 -0.000,
 -0.000,
 -0.000,
 -0.000,
 -0.000]

or wihout digits set:
sage: [foo(t) for t in [1..30]]
[1.93774723784661,
 1.96821438642349,
 1.99513501225340,
 1.99933077915395,
 1.0923138165,
 1.8771213936,
 1.9833692570,
 1.9977472377,
 1.9996716508,
 1.9996314183,
 1.9991577607,
 1.9955972581,
 1.8381431810,
 1.2717313233,
 1.99985733718347,
 1.99771319132044,
 2.00589700214384,
 1.91808127189615,
 1.23125745353424,
 -0.000,
 -0.000,
 -0.000,
 -0.000,
 -0.000,
 -0.000,
 -0.000,
 -0.000,
 -0.000,
 -0.000,
 -0.000]

if it were able to use the 30 digits, we would not have seen that drop down
of the function graph to 0 somewhere just before 20.


On Tue, Dec 6, 2022 at 1:28 PM Emmanuel Charpentier <
emanuel.charpent...@gmail.com> wrote:

> 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
> 
> 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.000
 sage: f(30).n(digits=30)
 1.9483984586167962667231030
 ```

 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.9483984586
 ```

 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.

Re: [sage-support] Plot doesn't respect numerical precision specification.

2022-12-06 Thread Emmanuel Charpentier


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

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.000
>>> sage: f(30).n(digits=30)
>>> 1.9483984586167962667231030
>>> ```
>>>
>>> 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.9483984586
>>> ```
>>>
>>> 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
>>>  
>>> 
>>> .
>>>
>> ​
>

-- 
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.


Re: [sage-support] Plot doesn't respect numerical precision specification.

2022-12-06 Thread Emmanuel Charpentier


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.000
>> sage: f(30).n(digits=30)
>> 1.9483984586167962667231030
>> ```
>>
>> 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.9483984586
>> ```
>>
>> 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
>>  
>> 
>> .
>>
> ​

-- 
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/d4815776-3bbd-44b1-bc46-cfc423cdedf4n%40googlegroups.com.


Re: [sage-support] Plot doesn't respect numerical precision specification.

2022-12-06 Thread Dima Pasechnik
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)


On Tue, Dec 6, 2022 at 12:53 PM Emmanuel Charpentier <
emanuel.charpent...@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.000
> sage: f(30).n(digits=30)
> 1.9483984586167962667231030
> ```
>
> 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.9483984586
> ```
>
> 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
> 
> .
>

-- 
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/CAAWYfq2wmF1jUH85LVFzjO33LxBr%2BxvSg4dYJ9mSSxNwXzz4FA%40mail.gmail.com.


Re: [sage-support] Plot is maybe too good :)

2013-11-03 Thread Christophe Bal
Hello,
I think also that there is a problem.

More simply, something like


--
var('a')
plot(a^2==3,a,1,7)
--

should work like

---
var('a')
plot(bool(a^2==3),a,1,7)
---

But the plot function doesn't support booleans.
Just try this.

--
var('a')
plot(a^2=3,a,1,7)
--

Best regards.
Christophe.

-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [sage-support] Plot the zeros of a complex function

2013-06-10 Thread William Stein
On Sun, Jun 9, 2013 at 3:25 PM,  computational.gr...@gmail.com wrote:
 Suppose I have a complex function f(z) with a continuous family of zeros 
 (e.g., f(z)=z-|z|)

 Is there a way to easily plot the set of zeros of f in sage, regardless of 
 how complicated the function f is?


You might find complex_plot useful.  For example, for

f(z) = z - abs(z)
complex_plot(f, (-3,3), (-3,3))

you'll see a *black line* at the zero set of f(z).

In the notebook you mind find an interact like this useful:


z = var('z')
@interact
def _(f = z-abs(z), B=(2..10)):
show(complex_plot(f, (-B,B), (-B,B)))

Or just click on

http://sagecell.sagemath.org/?q=cdcdd7e5-73b4-4c87-87e2-1be300f86674

 --
 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 post to this group, send email to sage-support@googlegroups.com.
 Visit this group at http://groups.google.com/group/sage-support?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.





-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Plot the zeros of a complex function

2013-06-10 Thread computational . group
Thanks, this is exactly what I was looking for!

In fact, I had tried out complex_plot but I must have been using a 
different color function or something, because the roots were much less 
apparent to me. Not sure why I couldn't figure this out on my own...

I suppose I have two follow-up questions now:
1. how can I improve the precision of the zero set (it seems to be drawn in 
low resolution right now)
2. what is the best way to turn off the other colors (draw non-zeros as 
white)

On Monday, June 10, 2013 10:02:12 AM UTC-5, William wrote:

 On Sun, Jun 9, 2013 at 3:25 PM,  computati...@gmail.com javascript: 
 wrote: 
  Suppose I have a complex function f(z) with a continuous family of zeros 
 (e.g., f(z)=z-|z|) 
  
  Is there a way to easily plot the set of zeros of f in sage, regardless 
 of how complicated the function f is? 
  

 You might find complex_plot useful.  For example, for 

 f(z) = z - abs(z) 
 complex_plot(f, (-3,3), (-3,3)) 

 you'll see a *black line* at the zero set of f(z). 

 In the notebook you mind find an interact like this useful: 


 z = var('z') 
 @interact 
 def _(f = z-abs(z), B=(2..10)): 
 show(complex_plot(f, (-B,B), (-B,B))) 

 Or just click on 

 http://sagecell.sagemath.org/?q=cdcdd7e5-73b4-4c87-87e2-1be300f86674 

  -- 
  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 javascript:. 
  To post to this group, send email to 
  sage-s...@googlegroups.comjavascript:. 

  Visit this group at http://groups.google.com/group/sage-support?hl=en. 
  For more options, visit https://groups.google.com/groups/opt_out. 
  
  



 -- 
 William Stein 
 Professor of Mathematics 
 University of Washington 
 http://wstein.org 


-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Plot the zeros of a complex function

2013-06-10 Thread William Stein
On Mon, Jun 10, 2013 at 9:09 AM,  computational.gr...@gmail.com wrote:
 Thanks, this is exactly what I was looking for!

 In fact, I had tried out complex_plot but I must have been using a different
 color function or something, because the roots were much less apparent to
 me. Not sure why I couldn't figure this out on my own...

 I suppose I have two follow-up questions now:
 1. how can I improve the precision of the zero set (it seems to be drawn in
 low resolution right now)

Use plot_points:

f(z) = z - abs(z)
complex_plot(f, (-3,3), (-3,3), plot_points=200)

 2. what is the best way to turn off the other colors (draw non-zeros as
 white)

I don't know if this is possible or implemented at present.


 On Monday, June 10, 2013 10:02:12 AM UTC-5, William wrote:

 On Sun, Jun 9, 2013 at 3:25 PM,  computati...@gmail.com wrote:
  Suppose I have a complex function f(z) with a continuous family of zeros
  (e.g., f(z)=z-|z|)
 
  Is there a way to easily plot the set of zeros of f in sage, regardless
  of how complicated the function f is?
 

 You might find complex_plot useful.  For example, for

 f(z) = z - abs(z)
 complex_plot(f, (-3,3), (-3,3))

 you'll see a *black line* at the zero set of f(z).

 In the notebook you mind find an interact like this useful:


 z = var('z')
 @interact
 def _(f = z-abs(z), B=(2..10)):
 show(complex_plot(f, (-B,B), (-B,B)))

 Or just click on

 http://sagecell.sagemath.org/?q=cdcdd7e5-73b4-4c87-87e2-1be300f86674

  --
  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 post to this group, send email to sage-s...@googlegroups.com.
  Visit this group at http://groups.google.com/group/sage-support?hl=en.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 



 --
 William Stein
 Professor of Mathematics
 University of Washington
 http://wstein.org

 --
 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 post to this group, send email to sage-support@googlegroups.com.
 Visit this group at http://groups.google.com/group/sage-support?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.





-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Plot the zeros of a complex function

2013-06-10 Thread computational . group
Ah, that's unfortunate. Might be a fun summer project to try to implement, 
if I knew where to start.

On another note: I really like the @interact annotation. I'm messing around 
with it, because I would like to add another parameter to my plot - an 
integer representing an index in a discrete family of functions. But I keep 
getting python errors about my expression not being symbolic when I try to 
include an integer parameter (like n = var('n'), then passing in n=2). Any 
tips?

On Monday, June 10, 2013 11:13:41 AM UTC-5, William wrote:

 On Mon, Jun 10, 2013 at 9:09 AM,  computati...@gmail.com javascript: 
 wrote: 
  Thanks, this is exactly what I was looking for! 
  
  In fact, I had tried out complex_plot but I must have been using a 
 different 
  color function or something, because the roots were much less apparent 
 to 
  me. Not sure why I couldn't figure this out on my own... 
  
  I suppose I have two follow-up questions now: 
  1. how can I improve the precision of the zero set (it seems to be drawn 
 in 
  low resolution right now) 

 Use plot_points: 

 f(z) = z - abs(z) 
 complex_plot(f, (-3,3), (-3,3), plot_points=200) 

  2. what is the best way to turn off the other colors (draw non-zeros 
 as 
  white) 

 I don't know if this is possible or implemented at present. 

  
  On Monday, June 10, 2013 10:02:12 AM UTC-5, William wrote: 
  
  On Sun, Jun 9, 2013 at 3:25 PM,  computati...@gmail.com wrote: 
   Suppose I have a complex function f(z) with a continuous family of 
 zeros 
   (e.g., f(z)=z-|z|) 
   
   Is there a way to easily plot the set of zeros of f in sage, 
 regardless 
   of how complicated the function f is? 
   
  
  You might find complex_plot useful.  For example, for 
  
  f(z) = z - abs(z) 
  complex_plot(f, (-3,3), (-3,3)) 
  
  you'll see a *black line* at the zero set of f(z). 
  
  In the notebook you mind find an interact like this useful: 
  
  
  z = var('z') 
  @interact 
  def _(f = z-abs(z), B=(2..10)): 
  show(complex_plot(f, (-B,B), (-B,B))) 
  
  Or just click on 
  
  http://sagecell.sagemath.org/?q=cdcdd7e5-73b4-4c87-87e2-1be300f86674 
  
   -- 
   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 post to this group, send email to sage-s...@googlegroups.com. 
   Visit this group at http://groups.google.com/group/sage-support?hl=en. 

   For more options, visit https://groups.google.com/groups/opt_out. 
   
   
  
  
  
  -- 
  William Stein 
  Professor of Mathematics 
  University of Washington 
  http://wstein.org 
  
  -- 
  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 javascript:. 
  To post to this group, send email to 
  sage-s...@googlegroups.comjavascript:. 

  Visit this group at http://groups.google.com/group/sage-support?hl=en. 
  For more options, visit https://groups.google.com/groups/opt_out. 
  
  



 -- 
 William Stein 
 Professor of Mathematics 
 University of Washington 
 http://wstein.org 


-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Plot the zeros of a complex function

2013-06-10 Thread computational . group
Okay, so the following works:

z = var('z')
n = 2
@interact
def _(f = ((z+1)^n-abs(z^n+1)), B=(2..10)):
show(complex_plot(f, (-B,B), (-B,B)))

But the following doesn't:

z = var('z')

@interact
def _(f = ((z+1)^n-abs(z^n+1)), n = (2..10), B=(2..10)):
show(complex_plot(f, (-B,B), (-B,B)))

On Monday, June 10, 2013 11:33:01 AM UTC-5, William wrote:

 On Mon, Jun 10, 2013 at 9:24 AM,  computati...@gmail.com javascript: 
 wrote: 
  Ah, that's unfortunate. Might be a fun summer project to try to 
 implement, 
  if I knew where to start. 

 1. http://www.sagemath.org/development.html 

 2. SAGE_ROOT/devel/sage/sage/plot/complex_plot.pyx  which I found by 
 doing search_src('complex_plot') 

  On another note: I really like the @interact annotation. I'm messing 
 around 
  with it, because I would like to add another parameter to my plot - an 
  integer representing an index in a discrete family of functions. But I 
 keep 
  getting python errors about my expression not being symbolic when I try 
 to 
  include an integer parameter (like n = var('n'), then passing in n=2). 
 Any 
  tips? 

 Just put 

   n = 2 

 instead?  You have to post code for a more useful answer 

  
  On Monday, June 10, 2013 11:13:41 AM UTC-5, William wrote: 
  
  On Mon, Jun 10, 2013 at 9:09 AM,  computati...@gmail.com wrote: 
   Thanks, this is exactly what I was looking for! 
   
   In fact, I had tried out complex_plot but I must have been using a 
   different 
   color function or something, because the roots were much less 
 apparent 
   to 
   me. Not sure why I couldn't figure this out on my own... 
   
   I suppose I have two follow-up questions now: 
   1. how can I improve the precision of the zero set (it seems to be 
 drawn 
   in 
   low resolution right now) 
  
  Use plot_points: 
  
  f(z) = z - abs(z) 
  complex_plot(f, (-3,3), (-3,3), plot_points=200) 
  
   2. what is the best way to turn off the other colors (draw 
 non-zeros 
   as 
   white) 
  
  I don't know if this is possible or implemented at present. 
  
   
   On Monday, June 10, 2013 10:02:12 AM UTC-5, William wrote: 
   
   On Sun, Jun 9, 2013 at 3:25 PM,  computati...@gmail.com wrote: 
Suppose I have a complex function f(z) with a continuous family of 
zeros 
(e.g., f(z)=z-|z|) 

Is there a way to easily plot the set of zeros of f in sage, 
regardless 
of how complicated the function f is? 

   
   You might find complex_plot useful.  For example, for 
   
   f(z) = z - abs(z) 
   complex_plot(f, (-3,3), (-3,3)) 
   
   you'll see a *black line* at the zero set of f(z). 
   
   In the notebook you mind find an interact like this useful: 
   
   
   z = var('z') 
   @interact 
   def _(f = z-abs(z), B=(2..10)): 
   show(complex_plot(f, (-B,B), (-B,B))) 
   
   Or just click on 
   
   http://sagecell.sagemath.org/?q=cdcdd7e5-73b4-4c87-87e2-1be300f86674 
   
-- 
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 post to this group, send email to sage-s...@googlegroups.com. 
Visit this group at 
http://groups.google.com/group/sage-support?hl=en. 
For more options, visit https://groups.google.com/groups/opt_out. 


   
   
   
   -- 
   William Stein 
   Professor of Mathematics 
   University of Washington 
   http://wstein.org 
   
   -- 
   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 post to this group, send email to sage-s...@googlegroups.com. 
   Visit this group at http://groups.google.com/group/sage-support?hl=en. 

   For more options, visit https://groups.google.com/groups/opt_out. 
   
   
  
  
  
  -- 
  William Stein 
  Professor of Mathematics 
  University of Washington 
  http://wstein.org 
  
  -- 
  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 javascript:. 
  To post to this group, send email to 
  sage-s...@googlegroups.comjavascript:. 

  Visit this group at http://groups.google.com/group/sage-support?hl=en. 
  For more options, visit https://groups.google.com/groups/opt_out. 
  
  



 -- 
 William Stein 
 Professor of Mathematics 
 University of Washington 
 http://wstein.org 


-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at 

Re: [sage-support] Plot the zeros of a complex function

2013-06-10 Thread William Stein
On Mon, Jun 10, 2013 at 9:24 AM,  computational.gr...@gmail.com wrote:
 Ah, that's unfortunate. Might be a fun summer project to try to implement,
 if I knew where to start.

1. http://www.sagemath.org/development.html

2. SAGE_ROOT/devel/sage/sage/plot/complex_plot.pyx  which I found by
doing search_src('complex_plot')

 On another note: I really like the @interact annotation. I'm messing around
 with it, because I would like to add another parameter to my plot - an
 integer representing an index in a discrete family of functions. But I keep
 getting python errors about my expression not being symbolic when I try to
 include an integer parameter (like n = var('n'), then passing in n=2). Any
 tips?

Just put

  n = 2

instead?  You have to post code for a more useful answer


 On Monday, June 10, 2013 11:13:41 AM UTC-5, William wrote:

 On Mon, Jun 10, 2013 at 9:09 AM,  computati...@gmail.com wrote:
  Thanks, this is exactly what I was looking for!
 
  In fact, I had tried out complex_plot but I must have been using a
  different
  color function or something, because the roots were much less apparent
  to
  me. Not sure why I couldn't figure this out on my own...
 
  I suppose I have two follow-up questions now:
  1. how can I improve the precision of the zero set (it seems to be drawn
  in
  low resolution right now)

 Use plot_points:

 f(z) = z - abs(z)
 complex_plot(f, (-3,3), (-3,3), plot_points=200)

  2. what is the best way to turn off the other colors (draw non-zeros
  as
  white)

 I don't know if this is possible or implemented at present.

 
  On Monday, June 10, 2013 10:02:12 AM UTC-5, William wrote:
 
  On Sun, Jun 9, 2013 at 3:25 PM,  computati...@gmail.com wrote:
   Suppose I have a complex function f(z) with a continuous family of
   zeros
   (e.g., f(z)=z-|z|)
  
   Is there a way to easily plot the set of zeros of f in sage,
   regardless
   of how complicated the function f is?
  
 
  You might find complex_plot useful.  For example, for
 
  f(z) = z - abs(z)
  complex_plot(f, (-3,3), (-3,3))
 
  you'll see a *black line* at the zero set of f(z).
 
  In the notebook you mind find an interact like this useful:
 
 
  z = var('z')
  @interact
  def _(f = z-abs(z), B=(2..10)):
  show(complex_plot(f, (-B,B), (-B,B)))
 
  Or just click on
 
  http://sagecell.sagemath.org/?q=cdcdd7e5-73b4-4c87-87e2-1be300f86674
 
   --
   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 post to this group, send email to sage-s...@googlegroups.com.
   Visit this group at
   http://groups.google.com/group/sage-support?hl=en.
   For more options, visit https://groups.google.com/groups/opt_out.
  
  
 
 
 
  --
  William Stein
  Professor of Mathematics
  University of Washington
  http://wstein.org
 
  --
  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 post to this group, send email to sage-s...@googlegroups.com.
  Visit this group at http://groups.google.com/group/sage-support?hl=en.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 



 --
 William Stein
 Professor of Mathematics
 University of Washington
 http://wstein.org

 --
 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 post to this group, send email to sage-support@googlegroups.com.
 Visit this group at http://groups.google.com/group/sage-support?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.





-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
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 post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sage-support] Plot the zeros of a complex function

2013-06-10 Thread William Stein
Try this:

z,n = var('z,n')

@interact
def _(f = ((z+1)^n-abs(z^n+1)), n = (2..10), B=(2..10)):
f = f.subs(n=n)
show(f)
show(complex_plot(f, (-B,B), (-B,B)))

On Mon, Jun 10, 2013 at 9:42 AM,  computational.gr...@gmail.com wrote:
 Okay, so the following works:


 z = var('z')
 n = 2
 @interact
 def _(f = ((z+1)^n-abs(z^n+1)), B=(2..10)):
 show(complex_plot(f, (-B,B), (-B,B)))

 But the following doesn't:


 z = var('z')

 @interact
 def _(f = ((z+1)^n-abs(z^n+1)), n = (2..10), B=(2..10)):
 show(complex_plot(f, (-B,B), (-B,B)))

 On Monday, June 10, 2013 11:33:01 AM UTC-5, William wrote:

 On Mon, Jun 10, 2013 at 9:24 AM,  computati...@gmail.com wrote:
  Ah, that's unfortunate. Might be a fun summer project to try to
  implement,
  if I knew where to start.

 1. http://www.sagemath.org/development.html

 2. SAGE_ROOT/devel/sage/sage/plot/complex_plot.pyx  which I found by
 doing search_src('complex_plot')

  On another note: I really like the @interact annotation. I'm messing
  around
  with it, because I would like to add another parameter to my plot - an
  integer representing an index in a discrete family of functions. But I
  keep
  getting python errors about my expression not being symbolic when I try
  to
  include an integer parameter (like n = var('n'), then passing in n=2).
  Any
  tips?

 Just put

   n = 2

 instead?  You have to post code for a more useful answer

 
  On Monday, June 10, 2013 11:13:41 AM UTC-5, William wrote:
 
  On Mon, Jun 10, 2013 at 9:09 AM,  computati...@gmail.com wrote:
   Thanks, this is exactly what I was looking for!
  
   In fact, I had tried out complex_plot but I must have been using a
   different
   color function or something, because the roots were much less
   apparent
   to
   me. Not sure why I couldn't figure this out on my own...
  
   I suppose I have two follow-up questions now:
   1. how can I improve the precision of the zero set (it seems to be
   drawn
   in
   low resolution right now)
 
  Use plot_points:
 
  f(z) = z - abs(z)
  complex_plot(f, (-3,3), (-3,3), plot_points=200)
 
   2. what is the best way to turn off the other colors (draw
   non-zeros
   as
   white)
 
  I don't know if this is possible or implemented at present.
 
  
   On Monday, June 10, 2013 10:02:12 AM UTC-5, William wrote:
  
   On Sun, Jun 9, 2013 at 3:25 PM,  computati...@gmail.com wrote:
Suppose I have a complex function f(z) with a continuous family of
zeros
(e.g., f(z)=z-|z|)
   
Is there a way to easily plot the set of zeros of f in sage,
regardless
of how complicated the function f is?
   
  
   You might find complex_plot useful.  For example, for
  
   f(z) = z - abs(z)
   complex_plot(f, (-3,3), (-3,3))
  
   you'll see a *black line* at the zero set of f(z).
  
   In the notebook you mind find an interact like this useful:
  
  
   z = var('z')
   @interact
   def _(f = z-abs(z), B=(2..10)):
   show(complex_plot(f, (-B,B), (-B,B)))
  
   Or just click on
  
   http://sagecell.sagemath.org/?q=cdcdd7e5-73b4-4c87-87e2-1be300f86674
  
--
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 post to this group, send email to sage-s...@googlegroups.com.
Visit this group at
http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
   
   
  
  
  
   --
   William Stein
   Professor of Mathematics
   University of Washington
   http://wstein.org
  
   --
   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 post to this group, send email to sage-s...@googlegroups.com.
   Visit this group at
   http://groups.google.com/group/sage-support?hl=en.
   For more options, visit https://groups.google.com/groups/opt_out.
  
  
 
 
 
  --
  William Stein
  Professor of Mathematics
  University of Washington
  http://wstein.org
 
  --
  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 post to this group, send email to sage-s...@googlegroups.com.
  Visit this group at http://groups.google.com/group/sage-support?hl=en.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 



 --
 William Stein
 Professor of Mathematics
 University of Washington
 http://wstein.org

 --
 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 post to this 

Re: [sage-support] Plot the zeros of a complex function

2013-06-10 Thread computational . group
Looks great, thanks for all the help!
I'll see about messing around with complex_plot a bit to support pure zero 
plots, if it amounts to something I'll get back in touch...

On Monday, June 10, 2013 11:55:28 AM UTC-5, William wrote:

 Try this: 

 z,n = var('z,n') 

 @interact 
 def _(f = ((z+1)^n-abs(z^n+1)), n = (2..10), B=(2..10)): 
 f = f.subs(n=n) 
 show(f) 
 show(complex_plot(f, (-B,B), (-B,B))) 

 On Mon, Jun 10, 2013 at 9:42 AM,  computati...@gmail.com javascript: 
 wrote: 
  Okay, so the following works: 
  
  
  z = var('z') 
  n = 2 
  @interact 
  def _(f = ((z+1)^n-abs(z^n+1)), B=(2..10)): 
  show(complex_plot(f, (-B,B), (-B,B))) 
  
  But the following doesn't: 
  
  
  z = var('z') 
  
  @interact 
  def _(f = ((z+1)^n-abs(z^n+1)), n = (2..10), B=(2..10)): 
  show(complex_plot(f, (-B,B), (-B,B))) 
  
  On Monday, June 10, 2013 11:33:01 AM UTC-5, William wrote: 
  
  On Mon, Jun 10, 2013 at 9:24 AM,  computati...@gmail.com wrote: 
   Ah, that's unfortunate. Might be a fun summer project to try to 
   implement, 
   if I knew where to start. 
  
  1. http://www.sagemath.org/development.html 
  
  2. SAGE_ROOT/devel/sage/sage/plot/complex_plot.pyx  which I found by 
  doing search_src('complex_plot') 
  
   On another note: I really like the @interact annotation. I'm messing 
   around 
   with it, because I would like to add another parameter to my plot - 
 an 
   integer representing an index in a discrete family of functions. But 
 I 
   keep 
   getting python errors about my expression not being symbolic when I 
 try 
   to 
   include an integer parameter (like n = var('n'), then passing in 
 n=2). 
   Any 
   tips? 
  
  Just put 
  
n = 2 
  
  instead?  You have to post code for a more useful answer 
  
   
   On Monday, June 10, 2013 11:13:41 AM UTC-5, William wrote: 
   
   On Mon, Jun 10, 2013 at 9:09 AM,  computati...@gmail.com wrote: 
Thanks, this is exactly what I was looking for! 

In fact, I had tried out complex_plot but I must have been using a 
different 
color function or something, because the roots were much less 
apparent 
to 
me. Not sure why I couldn't figure this out on my own... 

I suppose I have two follow-up questions now: 
1. how can I improve the precision of the zero set (it seems to be 
drawn 
in 
low resolution right now) 
   
   Use plot_points: 
   
   f(z) = z - abs(z) 
   complex_plot(f, (-3,3), (-3,3), plot_points=200) 
   
2. what is the best way to turn off the other colors (draw 
non-zeros 
as 
white) 
   
   I don't know if this is possible or implemented at present. 
   

On Monday, June 10, 2013 10:02:12 AM UTC-5, William wrote: 

On Sun, Jun 9, 2013 at 3:25 PM,  computati...@gmail.com wrote: 
 Suppose I have a complex function f(z) with a continuous family 
 of 
 zeros 
 (e.g., f(z)=z-|z|) 
 
 Is there a way to easily plot the set of zeros of f in sage, 
 regardless 
 of how complicated the function f is? 
 

You might find complex_plot useful.  For example, for 

f(z) = z - abs(z) 
complex_plot(f, (-3,3), (-3,3)) 

you'll see a *black line* at the zero set of f(z). 

In the notebook you mind find an interact like this useful: 


z = var('z') 
@interact 
def _(f = z-abs(z), B=(2..10)): 
show(complex_plot(f, (-B,B), (-B,B))) 

Or just click on 


 http://sagecell.sagemath.org/?q=cdcdd7e5-73b4-4c87-87e2-1be300f86674 

 -- 
 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 post to this group, send email to sage-s...@googlegroups.com. 

 Visit this group at 
 http://groups.google.com/group/sage-support?hl=en. 
 For more options, visit 
 https://groups.google.com/groups/opt_out. 
 
 



-- 
William Stein 
Professor of Mathematics 
University of Washington 
http://wstein.org 

-- 
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 post to this group, send email to sage-s...@googlegroups.com. 
Visit this group at 
http://groups.google.com/group/sage-support?hl=en. 
For more options, visit https://groups.google.com/groups/opt_out. 


   
   
   
   -- 
   William Stein 
   Professor of Mathematics 
   University of Washington 
   http://wstein.org 
   
   -- 
   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 
 

Re: [sage-support] plot color computet by function

2012-08-24 Thread David Joyner
On Wed, Aug 22, 2012 at 12:15 PM, danjo86 dan...@sommerfeld-timmaspe.de wrote:
 Hey,

  i need some help. I try to definde the mandelbrotset with colors defined by 
 following function:

 sage: def mandel(x,y):
   v=[];c=x+y*i;z=c;v.append(z)
   for m in range(30):
   if abs(z)2:
   z=z^2+c;v.append(z);color=exp(-m)
   return color


I don't know the answer to your question but I don't see the purpose of
v.append(z);. Maybe it is a formatting issue that was lost in the email,
but it seems to play no role in your function. Or am I missing something?



 Then i typed: plot3d(0,(x,-2,2),(y,-2,2),rgbcolor=hue(mandel))

 Now i get TypeError?
 May anyone has an idea?

 Thanks for help
 Danjo

 --
 You received this message because you are subscribed to the Google Groups 
 sage-support group.
 To post to this group, send email to sage-support@googlegroups.com.
 To unsubscribe from this group, send email to 
 sage-support+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/sage-support?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




Re: [sage-support] plot(): no ticks and arrow on axes?

2011-01-31 Thread Renato Budinich
On Mon, Jan 31, 2011 at 12:48 AM, Francois Maltey fmal...@nerim.fr wrote:

 Renato a écrit :

  Hello, I can't understand how the ticks option works in plot()... I
 want to have no ticks or labels on the axis.

 Also, is it possible to show the arrows on the axis? like this:
 http://www.homeschoolmath.net/blog/few-complex-numbers.gif

 I'm using latest version of sage



 Search ticks and axes in plot? and copy/paste the examples :

 plot(sin(pi*x), (x, -8, 8), ticks=[[],[]], axes=false)
 + arrow((-8,0),(8,0), color=black)
 + arrow((0,-1),(0,1), color=black)


 If you want a grid add a function as

 def grid (xmin, xmax, ymin, ymax) :
   linesYcst = add (line ([(xmin, k), (xmax, k)]) for k in [ceil (ymin)..
 floor(ymax)])
   linesXcst = add (line ([(k, ymin), (k, ymax)]) for k in [ceil (xmin)..
 floor(xmax)])
   return linesXcst+linesYcst

 read the help about line2d? and find the right options !

 Then add to your (almost) last plot : + grid (the right area)

 F.




many thanks

renato

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] plot(): no ticks and arrow on axes?

2011-01-30 Thread Francois Maltey

Renato a écrit :

Hello, I can't understand how the ticks option works in plot()... I
want to have no ticks or labels on the axis.

Also, is it possible to show the arrows on the axis? like this:
http://www.homeschoolmath.net/blog/few-complex-numbers.gif

I'm using latest version of sage
  


Search ticks and axes in plot? and copy/paste the examples :

plot(sin(pi*x), (x, -8, 8), ticks=[[],[]], axes=false)
+ arrow((-8,0),(8,0), color=black)
+ arrow((0,-1),(0,1), color=black)


If you want a grid add a function as

def grid (xmin, xmax, ymin, ymax) :
   linesYcst = add (line ([(xmin, k), (xmax, k)]) for k in [ceil 
(ymin).. floor(ymax)])
   linesXcst = add (line ([(k, ymin), (k, ymax)]) for k in [ceil 
(xmin).. floor(xmax)])

   return linesXcst+linesYcst

read the help about line2d? and find the right options !

Then add to your (almost) last plot : + grid (the right area)

F.


--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] plot problem

2011-01-18 Thread Robert Bradshaw
On Tue, Jan 18, 2011 at 2:35 PM, Daniel Harris
mail.dhar...@googlemail.com wrote:
 Hello everybody

 I am just looking at sketching graphs and I came across a problem that
 has me stumped.  The graph I am trying to sketch is

 (x-3) / ( (x+1) * (x-2) )

 now I have plotted the graph in sage on my TI-83 and at wolfram and
 they all different.  Now I am thinking is sage right and the others
 wrong? or have I made an error inputting the equation?

 I would certainly welcome some help on the issue

What range are you plotting over? -1  x  1? -5  x  5? This could
make a big difference on what the graph looks like. Likewise, what is
the scale of the y-axis? I don't think Sage yet tries to remove the
asymptotes at -1 and 2 from the plot.

- Robert

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] plot problem

2011-01-18 Thread Daniel Harris
On Tue, Jan 18, 2011 at 10:51 PM, Robert Bradshaw
rober...@math.washington.edu wrote:
 On Tue, Jan 18, 2011 at 2:35 PM, Daniel Harris
 mail.dhar...@googlemail.com wrote:
 Hello everybody

 I am just looking at sketching graphs and I came across a problem that
 has me stumped.  The graph I am trying to sketch is

 (x-3) / ( (x+1) * (x-2) )

 now I have plotted the graph in sage on my TI-83 and at wolfram and
 they all different.  Now I am thinking is sage right and the others
 wrong? or have I made an error inputting the equation?

 I would certainly welcome some help on the issue

 What range are you plotting over? -1  x  1? -5  x  5? This could
 make a big difference on what the graph looks like. Likewise, what is
 the scale of the y-axis? I don't think Sage yet tries to remove the
 asymptotes at -1 and 2 from the plot.


-1.5   x  3 the y peak at x=2 is the part that bothers me.  It
doesnt seem to show up on my calc or wolfram alpha?

Dan

 - Robert

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to 
 sage-support+unsubscr...@googlegroups.com
 For more options, visit this group at 
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] plot

2010-04-22 Thread Mike Hansen
On Thu, Apr 22, 2010 at 2:46 AM, pallab pallabb...@gmail.com wrote:
 How to specify variables in a plot. Say I want something  like,

 At=S*x
 S=4
 plot(At,0,2)

Note that when you assign S=4 it doesn't change the value of S in At.


 Question is that how to instruct Sage that I want to plot against 'x'.
 In Mathematica this is conveniently done by

 Plot[At,{x,0,2}]

You can do this by

sage: var('S, x')
(S, x)
sage: At = S*x; At
S*x
sage: At.subs(S=4)
4*x
sage: plot(At.subs(S=4), (x,0,2))

--Mike

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] plot/show bug in plotting of DiGraphs for macs?

2010-01-24 Thread Minh Nguyen
Hi David,

On Mon, Jan 25, 2010 at 11:08 AM, David Joyner wdjoy...@gmail.com wrote:

SNIP

 Is this a bug?

I don't think so. Using www.sagenb.org, I got plots [1] of the given
digraphs. On bsd.math, I got similar results [2]. In both cases, some
of the images are cropped so some part of a vertex is cut off. Ticket
#7299 [3] is meant to fix the image cropping issue.


[1] http://www.sagenb.org/home/pub/1409

[2] 
http://sage.math.washington.edu/home/mvngu/doc/screenshots/wdjoyner-2010-01-25/

[3] http://trac.sagemath.org/sage_trac/ticket/7299

-- 
Regards
Minh Van Nguyen

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org