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


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


[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] Re: Trouble getting *collect* to work with derivatives.

2021-01-23 Thread Christian Seberino

>
> 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/6f836001-5abf-409e-aa45-14953697cce0n%40googlegroups.com.


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

2021-01-23 Thread Emmanuel Charpentier


I think that your code doesn’t do what you think it does. Note for example 
that your declarations are self-contradicting :

Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:function("xp yp zp tp f")
:var("x y z t v c")
:--
(xp, yp, zp, tp, f)
(x, y, z, t, v, c)
sage: xp.parent()
.NewSymbolicFunction'>
sage: xp = (x - v * t) / sqrt(1 - v^2 / c^2)
sage: xp.parent()
Symbolic Ring

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

HTH,
Le vendredi 22 janvier 2021 à 19:46:35 UTC+1, cseb...@gmail.com a écrit :

>
> 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/0ea1674e-c726-4a26-89d6-b851a99c8625n%40googlegroups.com.