On 11/18/2010 07:32 PM, A. Jorge Garcia 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?
Evaluating var('a n r') assume(a > 0) avg = sqrt(a**2 * r**(2 * n)) avg.simplify_radical() I get r^n*a You can also use the simplify_full method. -- 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.