OK, I managed to get it done with ".subs_expr". Here is the output.

sage: var('x1,t1,x2,t2,dT,dt,u,c',domain=RR);assume(u>0);assume(c>u);
(x1, t1, x2, t2, dT, dt, u, c)
sage: T1 = (t1-((u*x1)/(c^2)))/sqrt(1-((u^2)/(c^2)))
sage: T2 = (t2-((u*x2)/(c^2)))/sqrt(1-((u^2)/(c^2)))
sage: dT = T2-T1
sage: dT.full_simplify()
-sqrt(c - u)*sqrt(c + u)*(c^2*t1 - c^2*t2 - u*x1 + u*x2)/(c^3 - c*u^2)
sage: dT.subs_expr(t2==dt+t1)
-(t1 - u*x1/c^2)/sqrt(-u^2/c^2 + 1) + (dt + t1 - u*x2/c^2)/sqrt(-u^2/
c^2 + 1)
sage: dT.subs_expr(t2==dt+t1).full_simplify()
sqrt(c - u)*sqrt(c + u)*(c^2*dt + u*x1 - u*x2)/(c^3 - c*u^2)


It was pretty difficult to find for a noob like me. I don't know if it
is in the tutorial, but it wasn't in the first part. I got bored and
stopped doing the tutorial when it got to math I didn't know. I had to
skim through the reference to find subs_expr.

On Jun 20, 12:16 pm, Jacare Omoplata <walkeystal...@gmail.com> wrote:
> I can also do this in Mathematica the following way,
>
> $Assumptions = True;
>
> T1 = (t1 - ((u x1)/c^2))/Sqrt[1 - (u^2/c^2)];
>
> T2 = (t2 - ((u x2)/c^2))/Sqrt[1 - (u^2/c^2)];
>
> dT = T2 - T1;
>
> FullSimplify[dT /. t2 -> dt + t1]
>
> (c^2*dt + u*(x1 - x2))/(c^2*Sqrt[1 - u^2/c^2])
>
> FullSimplify[dT /. t2 -> dt + t1, Element[c, Reals]]
>
> (c^2*dt + u*(x1 - x2))/(Sqrt[(c - u)*(c + u)]*Abs[c])
>
> $Assumptions = Element[c, Reals];
>
> FullSimplify[dT /. t2 -> dt + t1]
>
> (c^2*dt + u*(x1 - x2))/(Sqrt[(c - u)*(c + u)]*Abs[c])
>
> Still don't know how to do this in Sage :(
>
> On Jun 19, 1:32 pm, Jacare Omoplata <walkeystal...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I found out that in Mathematica this can be done by
> > PolynomialReduce[dT, dt, {t1, t2}]. Output given below.
>
> > In[26]:= FullSimplify[PolynomialReduce[dT, dt, {t1, t2}]]
>
> > Out[26]= {{1/Sqrt[1 - u^2/c^2]}, (u (x1 - x2))/(c^2 Sqrt[1 - u^2/
> > c^2])},
>
> > But I'd rather use Sage. Does Sage have a counterpart to this
> > Mathematica function? If not how do get the same result?
>
> > On Jun 19, 11:19 am, Jacare Omoplata <walkeystal...@gmail.com> wrote:
>
> > > The following are the expressions,
>
> > > sage: var('x1,t1,x2,t2,u,c',domain=RR);assume(u>0);assume(c>u);
> > > (x1, t1, x2, t2, u, c)
> > > sage: T1 = (t1-((u*x1)/(c^2)))/sqrt(1-((u^2)/(c^2)))
> > > sage: T2 = (t2-((u*x2)/(c^2)))/sqrt(1-((u^2)/(c^2)))
> > > sage: dT = T2-T1
> > > sage: dt = t2-t1
>
> > > Suppose I know that dT is in this form,
>
> > > dT = a*dt + b,
>
> > > Assuming I DID NOT know that,
> > > a = 1/sqrt(1-((u^2)/(c^2)))   ,
> > > b = (u*(x2 - x1))/((c^2)*sqrt(1-((u^2)/(c^2))))  ,
>
> > > is there any way I can find 'a' and 'b' using Sage?
>
> > > What if I didn't know that dT is in the form of a*dt + b, but just
> > > knew dT in terms of x1,t1,x2,t2,u and c ?
>
> > > Can I still express dT in terms of dt using sage?

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

Reply via email to