0
$\begingroup$

I've been noodling around with primitive Pythagorean triples. One of the 'branches' of the ternary tree that generates all possible PPTs from the initial parent PPT 3,4,5 is given by

Subscript[a, i + 1] = 
 Subscript[a, i] - 2*Subscript[b, i] + 2*Subscript[c, i]; 
Subscript[b, i + 1] = 
 2*Subscript[a, i] - Subscript[b, i] + 2*Subscript[c, i]; 
Subscript[c, i + 1] = 
 2*Subscript[a, i] - 2*Subscript[b, i] + 3*Subscript[c, i];

I want to make a table where each row of 3 numbers, starting with the (given) root PPT Subscript[a, 1]=3,Subscript[b, 1]=4,Subscript[c, 1]=5, is produced by the application of those formulas to the row immediately preceding so that {3,4,5}->{5,12,13}->{7,24,25}->{9,40,41} etc, giving

table={{3,4,5},{5,12,13},{7,24,25},{9,40,41},{...}}

How do I do this?

$\endgroup$
6
  • $\begingroup$ Take a look at NestList. $\endgroup$
    – Kuba
    Commented May 7, 2019 at 22:55
  • $\begingroup$ Hi @Kuba. Yep, I suspect that'll do it. Appreciated. $\endgroup$ Commented May 7, 2019 at 23:06
  • $\begingroup$ Hi @Kuba. OK, obviously being stupid here. I need more help... I get what NestList is doing in principle, but not sure how to make it into the Table I'm after. a = 3; b = 4; c = 5; NestList[{a - 2 b + 2 c, 2 a - b + 2 c, 2 a - 2 b + 3 c} &, 0, 4] just produces strings of identical digits, for example. $\endgroup$ Commented May 7, 2019 at 23:17
  • $\begingroup$ try NestList[{#[[1]]-2#[[2]]+2#[[3]],2#[[1]]-#[[2]]+2#[[3]],2#[[1]]-2#[[2]]+3#[[3]]}&,{3,4,5},3] $\endgroup$
    – ZaMoC
    Commented May 7, 2019 at 23:21
  • 1
    $\begingroup$ That works, so I'll take it! Haven;'t go the hang of using # yet, but if it ain't broke... Thanks @J42161217. (Got it now!) $\endgroup$ Commented May 7, 2019 at 23:23

0

Browse other questions tagged or ask your own question.