# Pattern matching for capturing exponent degrees does not work?

I have a function works like this:

f[{m_, n_}] := Assuming[m > 0 && n > 0, Simplify[{n, Sqrt[n m]}]]
finalT = NestList[f, {T3, (T1 T2)^(1/2)}, 25]


Which will return result like this:

finalT[[All, 2]] I wonder how to capture those exponent degrees in finalT[[All, 2]], like $(T_1 T_2)^\frac{1}{2} \rightarrow \frac{1}{2}$. I have tried

Exponent[finalT[[All, 2]], (T1 T2)]
Cases[finalT[[All, 2]], (T1 T2)^n]


both of them did not work. The first return a list of $0$s and the second returns an empty list. How can I achieve my goal? I am using Mathematica 11.

• If you want to include the case n==1 then use Cases[finalT, (T1 T2)^n_. :> n, Infinity]; if not, then Cases[finalT, (T1 T2)^n_ :> n, Infinity] Feb 12, 2017 at 13:56
• @BobHanlon use -1 instead of Infinity, shorter to write, same effect. :) Feb 12, 2017 at 16:13
• @rcollyer - Thanks Feb 12, 2017 at 16:18

You have to use finalT[[All, 2]] // FullForm to find the correct pattern:

Cases[
Simplify[finalT[[All, 2]], Assumptions -> {T1 > 0, T2 > 0, T3 > 0}],
Power[Times[T1, T2], Rational[x_, y_]] -> {x/y}, {0, Infinity}]

(*
{{1/2}, {1/4}, {3/8}, {5/16}, {11/32}, {21/64}, {43/128}, {85/256}, {171/512},
{341/1024}, {683/2048}, {1365/4096}, {2731/8192}, {5461/16384}, {10923/32768},
{21845/65536}, {43691/131072}, {87381/262144}, {174763/524288}, {349525/1048576},
{699051/2097152}, {1398101/4194304}, {2796203/8388608}, {5592405/16777216},
{11184811/33554432}, {22369621/67108864}}
*)

f[{m_, n_}] := Assuming[m > 0 && n > 0, Simplify[{n, Sqrt[n m]}]]

finalT = NestList[f, {T3, (T1 T2)^(1/2)}, 25]


Below is a look at the FullForm for a subset of FinalT

Map[{FullForm[#[]], FullForm[#[]]} &, finalT[[1 ;; 11]]] // Grid There are two groups of exponents, one for the product of T1*T2 and another for T3.

We can extract those two groups as follows:

powerList = Module[
{
powers
},
powers = Cases[finalT, Rational[x_, y_], Infinity];
{powers[[1 ;; -2 ;; 2]], powers[[2 ;; -2 ;; 2]]}
];


This looks like the following for the same subset

Grid@Transpose@{powerList[[1, 1 ;; 11]], powerList[[2, 1 ;; 11]]} 