Re: [sage-support] Calling Words in a function gives an error

2021-01-25 Thread Nils Bruin
On Monday, January 25, 2021 at 7:09:32 AM UTC-8 Nikos Apostolakis wrote:

> Dear Nils,
>
> [...] I think treating rational integers as integers is safe.  Actually 
> Sage does that
>
> sage: 8/2 in ZZ
> True
>
>
> So to have a function with integer input throw an error when you feed it a 
> rational integer, is surprising and counterintuitive.  To me at least.
>
> Ah right, Sage takes a rather liberal interpretation of "in" here: since 
the target is given, it's apparently read as "can 8/2 be converted to an 
integer". I'm neutral on what Words should do with its arguments.

-- 
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/7dd1068b-c03b-4955-b550-7e45bb5252a3n%40googlegroups.com.


Re: [sage-support] Re: Trouble getting *collect* to work with derivatives.

2021-01-25 Thread Nils Bruin
On Monday, January 25, 2021 at 7:16:00 AM UTC-8 ... wrote:

> Is this the same as derivative(f(xp(x, y, z, t), yp(x, y, z, t), zp(x, y, 
> z, t), tp(x, y, z, t)) , x, 2)?
>
> No, it is not. Look up "Multivariable Chain rule".

-- 
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/f1b2f629-fb33-4157-b591-289d29e464c9n%40googlegroups.com.


Re: [sage-support] Re: Trouble getting *collect* to work with derivatives.

2021-01-25 Thread Christian Seberino


>
> Secondly, what are you trying to collect? The D[0,0] terms or 
> f(xp, yp, zp, tp), x, 2) which are two different things? 


What is the difference between those 2?
 

> Given 
> what you are trying to do I guess it is the first one, in which 
> case you should have tried 
>
> sage: term = f(x,y,z,t).derivative(x,2).subs(x=xp,y=yp,z=zp,t=tp) 
>
>
Is this the same as derivative(f(xp(x, y, z, t), yp(x, y, z, t), zp(x, y, 
z, t), tp(x, y, z, t)) , x, 2)?

Thanks,

Chris

-- 
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/90dd8549-61b9-4f39-b20e-fb6875cd9a36n%40googlegroups.com.


Re: [sage-support] Calling Words in a function gives an error

2021-01-25 Thread Nikos Apostolakis
Dear Nils,

Thanks for the useful suggestions.

I probably used the wrong terminology, coercion vs conversion, sorry.  What
I meant is simply that almost everywhere on Sage 8/2 is accepted as input
to a function that takes integer arguments, as it should IMHO.  I
understand that preprocessing arguments in general may lead to trouble but
I think treating rational integers as integers is safe.  Actually Sage does
that

sage: 8/2 in ZZ
True


So to have a function with integer input throw an error when you feed it a
rational integer, is surprising and counterintuitive.  To me at least.

Best,
Nikos

On Sun, Jan 24, 2021 at 6:14 PM Nils Bruin  wrote:

> On Thursday, January 21, 2021 at 7:21:52 AM UTC-8 Nikos Apostolakis wrote:
>
>> Dear Vincent,
>>
>> Thank you very much, that fixes it.
>>
>> IMHO this is a bug though, or at least an inconsistent behavior.  Most of
>> the time Sage silently coerces things to the appropriate type so commands
>> just work.  For example:
>>
>
>
>>
>> sage: m = 11
>>> sage: l = (m-1)/2 -1
>>>
>> sage: l
>>> 4
>>> sage: range(5)[l]
>>> 4
>>
>>
>> There's a subtle difference here: The python interface here requires an
> index to be something that can be converted into an integer; i.e.,
> something for which the __int__ method does the right thing. "Coercion" in
> sage has a more restricted notion; see the docs. In sage, there is no
> coercion from QQ to ZZ, because there is no natural map from one to the
> other. There is a conversion, though, which is allowed to be a partial map.
>
> Generally, coercion maps only exist in one direction. Otherwise, things
> like ZZ(1)+QQ(2) whould have an ill-determined type.
>
> Whether "Words" should attempt to convert its second argument to an
> integer is a different matter. Generally it is best to start interface
> design by doing only a minimal amount of processing to the argument,
> because being "smart" for one thing can easily hide errors in another case.
>
> The error message that is currently given is perhaps a little generic, but
> it does clearly indicate that the arguments given to "Words" are
> problematic. Once you check that the *apparent* arguments work fine if
> entered directly, it's clear there's probably a type issue. If you use
> IPython's interactive debugger ("%debug") you can dive into the problematic
> code and query the arguments and their types directly, within the context
> where the error was raised. That can be a big time saver, because it can
> help you find the error without having to construct a stand-alone
> reproducible test case that you would need if you want to communicate the
> error to other people.
>
> --
> 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/01a9d1dc-c402-444e-81c8-e8aa86b2945an%40googlegroups.com
> 
> .
>


-- 
Οι ελαφροί ας με λέγουν ελαφρόν.
Στα σοβαρά πράγματα ήμουν πάντοτε
επιμελέστατος.

The frivolous can call me frivolous. In serious matters I've always been
most diligent.
  K. P. Kavafy

-- 
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/CAO2SUmLbq39SE4oqj%3DC1mC5Xwo4Led%2BO9vEUcpLjobebDEAr0w%40mail.gmail.com.