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

2021-01-24 Thread Emmanuel Charpentier


Sage has recently acquired a large set of tools relative to manifolds 
. A look at these tools and related 
tutorials/references may be in order…

HTH,
Le samedi 23 janvier 2021 à 23:17:26 UTC+1, cseb...@gmail.com a écrit :

> What you intend to do isn’t really clear… Could you try and clear your 
>> goals ?
>>
> Emmanuel  
>
> Thanks so much for your help.  I'm trying to show that the wave equation (
> https://en.wikipedia.org/wiki/Wave_equation)
> is invariant under a certain coordinate transformation called the Lorentz 
> transformation (special relativity).
>
> I represent the function that obeys the wave equation in the primed 
> coordinate system by f(xp, yp, zp, tp).
>
> I also represent the primed coordinates by the coordinates in the unprimed 
> coordinate system.
> Therefore,   f(xp, yp, zp, tp) =  f(xp(x, y, z, t), yp(x, y, z, t), zp(x, 
> y, z, t), tp(x, y, z, t)).
>
> I then find a bunch of derivates of f(xp(x, y, z, t), yp(x, y, z, t), 
> zp(x, y, z, t), tp(x, y, z, t)) and try to collect terms.
>
> All the coordinates should be real numbers.
>
> Does that explain everything?
>
>
>  
>

-- 
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/068e5ac0-1d78-453f-a465-bc84e1d1fc90n%40googlegroups.com.


[sage-support] Sage Crash Report

2021-01-24 Thread Mathieu Dutour


-- 
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/CADm_teOrk03gf8bzyUxtvt9m16wEAP3%2BOsfkzxbjSjz4VN9bKw%40mail.gmail.com.
***

IPython post-mortem report

{'commit_hash': 'd0b255042',
 'commit_source': 'installation',
 'default_encoding': 'utf-8',
 'ipython_path': 
'/home/mathieu/opt/SageMath/local/lib/python3.8/site-packages/IPython',
 'ipython_version': '7.13.0',
 'os_name': 'posix',
 'platform': 'Linux-5.8.0-38-generic-x86_64-with-glibc2.2.5',
 'sys_executable': '/home/mathieu/opt/SageMath/local/bin/python3',
 'sys_platform': 'linux',
 'sys_version': '3.8.5 (default, Oct 25 2020, 14:39:21) \n[GCC 9.2.0]'}

***



***

Crash traceback:

---
---
ImportError  Python 3.8.5: /home/mathieu/opt/SageMath/local/bin/python3
   Sun Jan 24 17:19:52 2021
A problem occurred executing Python code.  Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
~/opt/SageMath/src/bin/sage-ipython in 
  1 #!/usr/bin/env sage-python
  2 # -*- coding: utf-8 -*-
  3 """
  4 Sage IPython startup script.
  5 """
  6 
  7 # Display startup banner. Do this before anything else to give the user
  8 # early feedback that Sage is starting.
  9 from sage.misc.banner import banner
 10 banner()
 11 
 12 from sage.repl.interpreter import SageTerminalApp
 13 
 14 app = SageTerminalApp.instance()
---> 15 app.initialize()
global app.initialize = >
 16 app.start()


 in initialize(self=, argv=None)

~/opt/SageMath/local/lib/python3.8/site-packages/traitlets/config/application.py
 in catch_config_error(method=, 
app=, *args=(None,), **kwargs={})
 72 TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR = False
 73 else:
 74 raise ValueError("Unsupported value for environment variable: 
'TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR' is set to '%s' which is none of 
 {'0', '1', 'false', 'true', ''}."% _envvar )
 75 
 76 
 77 @decorator
 78 def catch_config_error(method, app, *args, **kwargs):
 79 """Method decorator for catching invalid config 
(Trait/ArgumentErrors) during init.
 80 
 81 On a TraitError (generally caused by bad config), this will print 
the trait's
 82 message, and exit the app.
 83 
 84 For use on init methods, to prevent invoking excepthook on invalid 
input.
 85 """
 86 try:
---> 87 return method(app, *args, **kwargs)
method = 
app = 
args = (None,)
kwargs = {}
 88 except (TraitError, ArgumentError) as e:
 89 app.print_help()
 90 app.log.fatal("Bad config encountered during initialization:")
 91 app.log.fatal(str(e))
 92 app.log.debug("Config at the time: %s", app.config)
 93 app.exit(1)
 94 
 95 
 96 class ApplicationError(Exception):
 97 pass
 98 
 99 
100 class LevelFormatter(logging.Formatter):
101 """Formatter with additional `highlevel` record
102 

~/opt/SageMath/local/lib/python3.8/site-packages/IPython/terminal/ipapp.py in 
initialize(self=, argv=None)
302 
303 return super(TerminalIPythonApp, self).parse_command_line(argv)
304 
305 @catch_config_error
306 def initialize(self, argv=None):
307 """Do actions after construct, but before starting the app."""
308 super(TerminalIPythonApp, self).initialize(argv)
309 if self.subapp is not None:
310 # don't bother initializing further, starting subapp
311 return
312 # print self.extra_args
313 if self.extra_args and not self.something_to_run:
314 self.file_to_run = self.extra_args[0]
315 self.init_path()
316 # create the shell
--> 317 self.init_shell()
self.init_shell = >
318 # and draw the banner
319 self.init_banner()
320 # Now a variety of things that happen after the banner is 
printed.
321 self.init_gui_pylab()
322 self.init_extensions()
323 self.init_code()
324 
325 def init_shell(self):
326 """initialize the InteractiveShell instance"""
327 # Create an Interact

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

2021-01-24 Thread Christian Seberino
Emmanuel

But my question is more simple than that. I just want to know why the
collect method was not able to collect all the terms with the given second
derivative.

On Sun, Jan 24, 2021, 2:15 AM Emmanuel Charpentier <
emanuel.charpent...@gmail.com> wrote:

> Sage has recently acquired a large set of tools relative to manifolds
> . A look at these tools and related
> tutorials/references may be in order…
>
> HTH,
> ​
> Le samedi 23 janvier 2021 à 23:17:26 UTC+1, cseb...@gmail.com a écrit :
>
>> What you intend to do isn’t really clear… Could you try and clear your
>>> goals ?
>>>
>> Emmanuel
>>
>> Thanks so much for your help.  I'm trying to show that the wave equation (
>> https://en.wikipedia.org/wiki/Wave_equation)
>> is invariant under a certain coordinate transformation called the Lorentz
>> transformation (special relativity).
>>
>> I represent the function that obeys the wave equation in the primed
>> coordinate system by f(xp, yp, zp, tp).
>>
>> I also represent the primed coordinates by the coordinates in the
>> unprimed coordinate system.
>> Therefore,   f(xp, yp, zp, tp) =  f(xp(x, y, z, t), yp(x, y, z, t), zp(x,
>> y, z, t), tp(x, y, z, t)).
>>
>> I then find a bunch of derivates of f(xp(x, y, z, t), yp(x, y, z, t),
>> zp(x, y, z, t), tp(x, y, z, t)) and try to collect terms.
>>
>> All the coordinates should be real numbers.
>>
>> Does that explain everything?
>>
>>
>>
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sage-support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sage-support/TDseIA1M7vY/unsubscribe.
> To unsubscribe from this group and all its topics, 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/068e5ac0-1d78-453f-a465-bc84e1d1fc90n%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/CAG5-5iKn4APn1FRBfXoxeyzbcCDdLFyqssehxuNYQJ5f0yzi7w%40mail.gmail.com.


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

2021-01-24 Thread Emmanuel Charpentier


Probably because “the given second derivative” has a “computed operator”…

BTW : 

var("x,y,z,t,v,c")
f=function("f")
xp=(t-v*x)/sqrt(1-v^2/c^2)
yp=y
zp=z
tp=(t-v*x/c^2)/sqrt(1-v^2/c^2)
foo=(sum(map(lambda u:derivative(f(xp,yp,zp,tp),u,2), (x, y, 
z)))-derivative(f(xp,yp,zp,tp),t,2)/c^2).factor()
view(foo.simplify_full())

does partially what you mean…
Le dimanche 24 janvier 2021 à 17:36:44 UTC+1, cseb...@gmail.com a écrit :

> Emmanuel
>
> But my question is more simple than that. I just want to know why the 
> collect method was not able to collect all the terms with the given second 
> derivative.
>
> On Sun, Jan 24, 2021, 2:15 AM Emmanuel Charpentier  
> wrote:
>
>> Sage has recently acquired a large set of tools relative to manifolds 
>> . A look at these tools and related 
>> tutorials/references may be in order…
>>
>> HTH,
>> Le samedi 23 janvier 2021 à 23:17:26 UTC+1, cseb...@gmail.com a écrit :
>>
>>> What you intend to do isn’t really clear… Could you try and clear your 
 goals ?

>>> Emmanuel  
>>>
>>> Thanks so much for your help.  I'm trying to show that the wave equation 
>>> (https://en.wikipedia.org/wiki/Wave_equation)
>>> is invariant under a certain coordinate transformation called the 
>>> Lorentz transformation (special relativity).
>>>
>>> I represent the function that obeys the wave equation in the primed 
>>> coordinate system by f(xp, yp, zp, tp).
>>>
>>> I also represent the primed coordinates by the coordinates in the 
>>> unprimed coordinate system.
>>> Therefore,   f(xp, yp, zp, tp) =  f(xp(x, y, z, t), yp(x, y, z, t), 
>>> zp(x, y, z, t), tp(x, y, z, t)).
>>>
>>> I then find a bunch of derivates of f(xp(x, y, z, t), yp(x, y, z, t), 
>>> zp(x, y, z, t), tp(x, y, z, t)) and try to collect terms.
>>>
>>> All the coordinates should be real numbers.
>>>
>>> Does that explain everything?
>>>
>>>
>>>  
>>>
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "sage-support" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/sage-support/TDseIA1M7vY/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> sage-support...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sage-support/068e5ac0-1d78-453f-a465-bc84e1d1fc90n%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/ee8a8ac7-0505-4b3d-bd57-f4d7f01aa3c6n%40googlegroups.com.


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

2021-01-24 Thread Vincent Delecroix

Dear Christian,

Given the specifications, I suspect that the function collect
only works for variables. And indeed

sage: expr = (x+y)*(z+t) + (x+y)*(1+z^2) + 2 



sage: expr 



(z^2 + 1)*(x + y) + (t + z)*(x + y) + 2
sage: expr.collect(x+y) 



(z^2 + 1)*(x + y) + (t + z)*(x + y) + 2

Instead of

(z^2 + t + z + 1)*(x + y) + 2

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? 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)

Finally, note also that there is some factorization happening in
your expression e, so before doing anything do

sage: e = e.expand()

Now, the only way I found to make it work was to implement my
own collecting routine (see attachment). With the function
implemented in the file that walks along the expression you
obtain

sage: L = my_collect(e, term)
sage: len(L)
2
sage: L[1]   # the terms linear in D[0,0](f)(xp, yp, zp, tp)
v^2/(c^2*(v^2/c^2 - 1)) - 1/(v^2/c^2 - 1)

The above term is one as can be checked with

sage: L[1].simplify_full() 



1

Best
Vincent

Le 24/01/2021 à 17:23, Christian Seberino a écrit :

Emmanuel

But my question is more simple than that. I just want to know why the
collect method was not able to collect all the terms with the given second
derivative.

On Sun, Jan 24, 2021, 2:15 AM Emmanuel Charpentier <
emanuel.charpent...@gmail.com> wrote:


Sage has recently acquired a large set of tools relative to manifolds
. A look at these tools and related
tutorials/references may be in order…

HTH,
​
Le samedi 23 janvier 2021 à 23:17:26 UTC+1, cseb...@gmail.com a écrit :


What you intend to do isn’t really clear… Could you try and clear your

goals ?


Emmanuel

Thanks so much for your help.  I'm trying to show that the wave equation (
https://en.wikipedia.org/wiki/Wave_equation)
is invariant under a certain coordinate transformation called the Lorentz
transformation (special relativity).

I represent the function that obeys the wave equation in the primed
coordinate system by f(xp, yp, zp, tp).

I also represent the primed coordinates by the coordinates in the
unprimed coordinate system.
Therefore,   f(xp, yp, zp, tp) =  f(xp(x, y, z, t), yp(x, y, z, t), zp(x,
y, z, t), tp(x, y, z, t)).

I then find a bunch of derivates of f(xp(x, y, z, t), yp(x, y, z, t),
zp(x, y, z, t), tp(x, y, z, t)) and try to collect terms.

All the coordinates should be real numbers.

Does that explain everything?





--
You received this message because you are subscribed to a topic in the
Google Groups "sage-support" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/sage-support/TDseIA1M7vY/unsubscribe.
To unsubscribe from this group and all its topics, 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/068e5ac0-1d78-453f-a465-bc84e1d1fc90n%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/eeb79950-4893-3933-4687-4bf7fa40533b%40gmail.com.
from operator import pow
from sage.symbolic.operators import add_vararg, mul_vararg

def my_collect(expression, X): 
r"""
Collect the coefficients of ``X`` inside ``expression`` as a list.

EXAMPLES::

sage: x, y, z, t = SR.var('x, y, z, t')
sage: my_collect((x+y)**2 + x*t*(x+y)*z + 2, x+y)
[2, t*x*z, 1]
"""
if expression.operator() != add_vararg: 
# if the expression is not a sum returns it in full
return [expression] 

# walk around the terms of the sum
ans = [SR.zero()]
for subexpression in expression.operands(): 
if subexpression.operator() == mul_vararg: 
# subexpression is a product in which X might be involved
exponent = 0
coefficient = SR.one()
for term in subexpression.operands():
if term == X:
exponent += 1
elif term.operator() == pow and term.operands()[0] == X:
exponent += term.operands()[1]
else:
coefficient *= term
elif subexpression.operator() == pow and subexpression.operands()[0] == X:
# subexpression is a power of X
exponent = subexpression.operands()[1]
coefficient = 1
else:
# subexpression is degree zero in X
exponent = 0
coefficient = subexpression

  

Re: [sage-support] Sage Crash Report

2021-01-24 Thread Dima Pasechnik
at the bottom of the log you see

ImportError: 
/home/mathieu/opt/SageMath/local/lib/python3.8/site-packages/sage/matrix/matrix_modn_sparse.cpython-38-x86_64-linux-gnu.so:
undefined symbol:
_ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEB5cxx11Ev


which is an indication that something went wrong with linking givaro.
E.g. you might be linking to a system-wide
installed givaro, but it's expected to be the one built by Sage -
whether the latter is the case can be found out in the top-level
config.log.

What is the output of

ldd 
/home/mathieu/opt/SageMath/local/lib/python3.8/site-packages/sage/matrix/matrix_modn_sparse.cpython-38-x86_64-linux-gnu.so

?


On Sun, Jan 24, 2021 at 4:22 PM Mathieu Dutour  wrote:
>
>
> --
> 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/CADm_teOrk03gf8bzyUxtvt9m16wEAP3%2BOsfkzxbjSjz4VN9bKw%40mail.gmail.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/CAAWYfq0t31jRmd00TZ%3DMCD_ROqjb8i-Jm358NPXSur62WWhhLQ%40mail.gmail.com.


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

2021-01-24 Thread Nils Bruin
I suspect you want to collect wrt. the second partial derivatives of 
f(x,y,z,t) with respect to x,y,z,t ; evaluated at xp,yp,zp,tp. Those are 
not the same as the partial second derivatives of f(xp,yp,zp,tp) with 
respect to (x,y,z,t). If you inspect what derivative(f(xp, yp, zp, tp), x, 
2) gives you, you'll see it's a complicated expression. "collecting" 
relative to it doesn't make sense from first principles and if you try to 
make the notion precise you'll find there are fundamental ambiguities that 
prevent it from being a well-defined operation in general.

The operation you probably intend is quite doable, though. You first have 
to construct the expressions that you want to collect relative to:

V=[x,y,z,t] 
Ds=[derivative(f(x,y,z,t),V[i],V[j])({x:xp,y:yp,z:zp,t:tp}) for j in 
range(4) for i in range(j+1)]

You can inspect the entries in Ds: these are all just purely expressions of 
the form D[i,j](f), so from the perspective of expression manipulations 
such as "subs" and "collect" and "coeffient", they are "atomic": they 
behave as polynomial variables themselves. For instance, we could replace 
them by actual, named variables to exhibit this. We'll call these variables 
D00,...,D33:

Dvars=[SR.symbol('D{}{}'.format(i,j))  for j in range(4) for i in 
range(j+1)]

We can substitute those:

eD=e.subs(dict(zip(Ds,Dvars)));eD 
D11 + D22 + (D00/sqrt(-v^2/c^2 + 1) - D03*v/(c^2*sqrt(-v^2/c^2 + 
1)))/sqrt(-v^2/c^2 + 1) - v*(D03/sqrt(-v^2/c^2 + 1) - 
D33*v/(c^2*sqrt(-v^2/c^2 + 1)))/(c^2*sqrt(-v^2/c^2 + 1)) - 
((D00*v/sqrt(-v^2/c^2 + 1) - D03/sqrt(-v^2/c^2 + 1))*v/sqrt(-v^2/c^2 + 1) - 
(D03*v/sqrt(-v^2/c^2 + 1) - D33/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1))/c^2

And we can check this is correct by substituting back and comparing (many 
CAS packages have rough edges in this area, where they'll allow you to do 
something but not necessarily do what you thought you would do; so checking 
is good!)

 bool(eD.subs(dict(zip(Dvars,Ds))) == e) 
True 

Note that multivariate calculus books describe the linear algebra that 
partial derivatives obey under these kinds of operations. That would allow 
you to get this expression eD right away.
On Friday, January 22, 2021 at 10:46:35 AM UTC-8 cseb...@gmail.com wrote:

>
> I'm trying to collect all the terms in an expression with the same
> second partial derivative but it doesn't seem to be working.
> I can't figure out why.
>
> Here is my code
>
> # 
>
> function("xp yp zp tp f")
> var("x y z t v c")
>
> xp = (x - v * t) / sqrt(1 - v^2 / c^2)
> yp = y
> zp = z
> tp = (t - v * x / c^2) / sqrt(1 - v^2 / c^2)
>
> e = derivative(f(xp, yp, zp, tp), x, 2) + derivative(f(xp, yp, zp, tp), y, 
> 2) + derivative(f(xp, yp, zp, tp), z, 2) - derivative(f(xp, yp, zp, tp), t, 
> 2) / c^2
>
> e.collect(derivative(f(xp, yp, zp, tp), x, 2))
>
> #  
>
> Here is the output.  I added spaces at a subtraction to make it easy to see
> there are TWO of those D[0, 0](f) terms (each at the beginning of the 
> sections).
>
> (D[0, 0](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t - 
> v*x/c^2)/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1) - v*D[0, 3](f)(-(t*v - 
> x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + 
> 1))/(c^2*sqrt(-v^2/c^2 + 1)))/sqrt(-v^2/c^2 + 1) - v*(D[0, 3](f)(-(t*v - 
> x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + 
> 1))/sqrt(-v^2/c^2 + 1) - v*D[3, 3](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, 
> (t - v*x/c^2)/sqrt(-v^2/c^2 + 1))/(c^2*sqrt(-v^2/c^2 + 
> 1)))/(c^2*sqrt(-v^2/c^2 + 1)) 
>
> - 
>
> ((v*D[0, 0](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t - 
> v*x/c^2)/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1) - D[0, 3](f)(-(t*v - 
> x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + 
> 1))/sqrt(-v^2/c^2 + 1))*v/sqrt(-v^2/c^2 + 1) - (v*D[0, 3](f)(-(t*v - 
> x)/sqrt(-v^2/c^2 + 1), y, z, (t - v*x/c^2)/sqrt(-v^2/c^2 + 
> 1))/sqrt(-v^2/c^2 + 1) - D[3, 3](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t 
> - v*x/c^2)/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1))/sqrt(-v^2/c^2 + 1))/c^2 
> + D[1, 1](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, z, (t - 
> v*x/c^2)/sqrt(-v^2/c^2 + 1)) + D[2, 2](f)(-(t*v - x)/sqrt(-v^2/c^2 + 1), y, 
> z, (t - v*x/c^2)/sqrt(-v^2/c^2 + 1)) 
>
>
>

-- 
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/50191e08-64e7-4026-aade-6905a4ba04a9n%40googlegroups.com.


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

2021-01-24 Thread Nils Bruin
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.


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

2021-01-24 Thread Christian Seberino
What are computed operators?  Are those the D[0, 0] things? How avoid
those? Is that same as second derivative of 1st variable?

On Sun, Jan 24, 2021, 11:33 AM Emmanuel Charpentier <
emanuel.charpent...@gmail.com> wrote:

> Probably because “the given second derivative” has a “computed operator”…
>
> BTW :
>
> var("x,y,z,t,v,c")
> f=function("f")
> xp=(t-v*x)/sqrt(1-v^2/c^2)
> yp=y
> zp=z
> tp=(t-v*x/c^2)/sqrt(1-v^2/c^2)
> foo=(sum(map(lambda u:derivative(f(xp,yp,zp,tp),u,2), (x, y, 
> z)))-derivative(f(xp,yp,zp,tp),t,2)/c^2).factor()
> view(foo.simplify_full())
>
> does partially what you mean…
> Le dimanche 24 janvier 2021 à 17:36:44 UTC+1, cseb...@gmail.com a écrit :
>
>> Emmanuel
>>
>> But my question is more simple than that. I just want to know why the
>> collect method was not able to collect all the terms with the given second
>> derivative.
>>
>> On Sun, Jan 24, 2021, 2:15 AM Emmanuel Charpentier <
>> emanuel.c...@gmail.com> wrote:
>>
>>> Sage has recently acquired a large set of tools relative to manifolds
>>> . A look at these tools and related
>>> tutorials/references may be in order…
>>>
>>> HTH,
>>> ​
>>> Le samedi 23 janvier 2021 à 23:17:26 UTC+1, cseb...@gmail.com a écrit :
>>>
 What you intend to do isn’t really clear… Could you try and clear your
> goals ?
>
 Emmanuel

 Thanks so much for your help.  I'm trying to show that the wave
 equation (https://en.wikipedia.org/wiki/Wave_equation)
 is invariant under a certain coordinate transformation called the
 Lorentz transformation (special relativity).

 I represent the function that obeys the wave equation in the primed
 coordinate system by f(xp, yp, zp, tp).

 I also represent the primed coordinates by the coordinates in the
 unprimed coordinate system.
 Therefore,   f(xp, yp, zp, tp) =  f(xp(x, y, z, t), yp(x, y, z, t),
 zp(x, y, z, t), tp(x, y, z, t)).

 I then find a bunch of derivates of f(xp(x, y, z, t), yp(x, y, z, t),
 zp(x, y, z, t), tp(x, y, z, t)) and try to collect terms.

 All the coordinates should be real numbers.

 Does that explain everything?




>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "sage-support" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/sage-support/TDseIA1M7vY/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> sage-support...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/sage-support/068e5ac0-1d78-453f-a465-bc84e1d1fc90n%40googlegroups.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sage-support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sage-support/TDseIA1M7vY/unsubscribe.
> To unsubscribe from this group and all its topics, 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/ee8a8ac7-0505-4b3d-bd57-f4d7f01aa3c6n%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/CAG5-5iJxkz2oj9viMoaLa4AcbFe1QuCLGp1YCfY%3Dg7SkbexgBg%40mail.gmail.com.