On Thu, Nov 18, 2010 at 5:32 PM, A. Jorge Garcia <calcp...@aol.com> wrote: > My Discrete Math students today came up with an observation: The > average of any 3 consecutive terms of an arithmetic sequence equals > the middle term. So, I thought we'd show off some CAS in SAGE (this > class uses python primarily) and wrote the following in my SAGE > notebook: > > var('c,d') > term1 = c+(n-1)*d > term2 = c+(n+1)*d > sum = term1+term2 > avg = expand(sum/2) > show(term1) > show(term2) > show(sum) > show(avg) > > and got the following output > c+(n-1)*d > c+(n+1)*d > 2*c+2*n*d > c+n*d > > So, I thought we'd try something similar with geometric sequences: > var('c,d') > term1 =a*r**(n-1) > term2 = a*r*(n+1) > prod = term1*term2 > avg = simplify(sqrt(prod)) > show(term1) > show(term2) > show(sum) > show(avg) > > however, I got the following output > a*r**(n-1) > a*r*(n+1) > a**2*r**(2*n) > sqrt(a**2*r**(2*n)) > > I couldn't get the final result to reduce to a*r**n, is there a way to > do this?
Perhaps add some assumptions as to the positivity of your variables, e.g. sage: var('a,r,n') (a, r, n) sage: assume(a>0) sage: assume(r>0) sage: assume(n>0) sage: sqrt(a**2*r**(2*n)) sqrt(a^2*r^(2*n)) sage: simplify(sqrt(a**2*r**(2*n))) r^n*a - Robert -- You received this message because you are subscribed to the Google Groups "sage-edu" group. To post to this group, send email to sage-...@googlegroups.com. To unsubscribe from this group, send email to sage-edu+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-edu?hl=en.