Question: Question on array and recursion type of calculations in maple 11 tia sal2

Greetings All

Question on array and recursion type of calculations in maple 11 tia sal2

I have a procedure digitalrootxval which calculates part of the final x value

digitalrootxval := proc (n)
if n = 0 then
return 0
elif n = 1 then
return 1
else return modp(n-1, 9)+1
end if
end proc:

and I have two different procedure arrays that determine how the y value should be calculated. The first procedure array addfib:
which produces the array number sequence 0,1,4,5,8,9,12,13......
 
addfib := proc (n)
if n = 0 then
return 0
elif n = 1 then
return 1
elif n = 2 then
return 4
else return addfib(n-1)+addfib(n-2)-addfib(n-3)
end if
end proc:


The second is minusfib:
which produces the array number sequence 2,3,6,7,10,11.....

minusfib := proc (n)
if n = 0 then
return 2
elif n = 1 then
return 3
elif n = 2 then
return 6
else
return minusfib(n-1)+minusfib(n-2)-minusfib(n-3)
end if
end proc:

I'm having problems with these 2 things:

1) The recursion logic within the array for calculating Final y value:
k=0..13 (zero to any number)
k=0 then 0
k=1 then 1
If digitalrootxval(k) = addfib(k)
then y = (previous y value) y value(k-1) + fibonacci(k)
else if digitalrootxval = minusfib
then y = (previous y value) y value(k-1) - fibonacci(k)

2) The recursion logic within the array for calculating Final x value:
k=0..13 (zero to any number)
k=0 then 0
k=1 then 1
x = previous x value(k-1) + digitalrootxval(fibonacci(k+2)-1)


The below command is what I used to get part of the array but wasn't sure how to due the recursion within the array itself.

with(combinat, fibonacci);
array([seq([k, digitalrootxval(fibonacci(k+2)-1), addfib(k), minusfib(k)], k = 0 .. 7)])
[0,0,0,2]
[1,1,1,3]
[2,2,4,6]
[3,4,5,7]
[4,7,8,10]
[5,3,9,11]
[6,2,12,14]
[7,6,13,15]

Example of the output I'm trying to get:
k,digitalrootxval,finalxval,addfib,minusfib,finalyval
0,0,0,0,2,0
1,1,1,1,3,1
2,2,3,4,6,0
3,4,7,5,7,-2
4,7,14,8,10,1
5,3,17,9,11,6
6,2,19,12,14,-2
7,6,25,13,15,-15

Also how can I label/format the top of each column in an array to make it more readable or do I need turn the data into something else like a table and fomart it seperatly?

tia sal2

Please Wait...