d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Series
Add Reply New Topic New Poll
Member
Posts: 11,153
Joined: Aug 23 2008
Gold: 4,230.00
Oct 7 2018 12:05am
I have to code something that results in the following output:

7, 9, 14, 20, 27, 33, 42, 52, 63, 73, 86, ...

I can't find the pattern in the series though.

Is there a method in solving series? or is it just an intuition/trial and error thing?
Member
Posts: 5,838
Joined: Nov 19 2007
Gold: 240.00
Oct 7 2018 08:18am
Study the differences until a periodic pattern appears, this works most of the time
7, 9, 14, 20, 27, 33, 42, 52, 63, 73, 86
2, 5, 6, 7, 6, 9, 10, 11, 10, 13
3, 1, 1, -1,3, 1, 1, -1,3

then make up some function to go back up to the original sequence, here's a matlab example



here m runs through 7, 9, 14, 20, 27, 33, 42, 52, 63, 73, 86...

There might be easier functions that satisfy your sequence but this one is already pretty elementary...


In case you don't know matlab, don't pay attention to the int16 thing, it's just conversion to integers and does nothing else, x is i taken modulo 4, and everything else is pretty straightforward...


This post was edited by Hanako on Oct 7 2018 08:21am
Member
Posts: 5,838
Joined: Nov 19 2007
Gold: 240.00
Oct 7 2018 10:02am
Come to think of it, perhaps this is easier to understand

The nth term of your sequence is given by:



The ceiling [] rounds up every fraction to the nearest integer
if n = 1 in the above formula, the sum is 0 by convention and u_1 is just 7
Member
Posts: 11,153
Joined: Aug 23 2008
Gold: 4,230.00
Oct 7 2018 03:59pm
every image you inserted seems to be broken
Member
Posts: 5,838
Joined: Nov 19 2007
Gold: 240.00
Oct 7 2018 11:47pm
Quote (kasey21 @ 7 Oct 2018 23:59)
every image you inserted seems to be broken


An easy algorithm is

x = 7

for k running through 0 to N-2 [ = whatever number of terms you want to reach in your series] :

x = x + 2 + 3*ceiling(k/4) + ceiling( (k-1)/4 ) + ceiling( (k-2)/4 ) - ceiling( (k-3)/4 )

endfor


ceiling rounds up (e.g. ceiling(7.452341) = 8, ceiling(7)=7)

x will run through 7, 9, 14, 20, 27, 33, 42, 52, 63, 73, 86...
if N is 4, N-2 = 2 and x will stop at the 4th term 20

The broken images is probably an issue on your end I guess
Member
Posts: 11,153
Joined: Aug 23 2008
Gold: 4,230.00
Oct 12 2018 12:48pm
Quote (Hanako @ Oct 8 2018 07:47am)
An easy algorithm is

x = 7

for k running through 0 to N-2 [ = whatever number of terms you want to reach in your series] :

x = x + 2 + 3*ceiling(k/4) + ceiling( (k-1)/4 ) + ceiling( (k-2)/4 ) - ceiling( (k-3)/4 )

endfor


ceiling rounds up (e.g. ceiling(7.452341) = 8, ceiling(7)=7)

x will run through 7, 9, 14, 20, 27, 33, 42, 52, 63, 73, 86...
if N is 4, N-2 = 2 and x will stop at the 4th term 20

The broken images is probably an issue on your end I guess


hey thanks for the help. Although how to solve the series went over my head, it helped me see a different pattern in:
7, 9, 14, 20, 27, 33, 42, 52, 63, 73, 86
2, 5, 6, 7, 6, 9, 10, 11, 10, 13
basically instead of one long function that you have I used 2 functions. as the pattern is when k is odd (and starts at 0) it adds delta that increases by 2 each time. and when k is even it adds a different delta that adds 4 to itself when k mod 4 = 0. I never took any type of math that dealt with series so the notation you provided was a little confusing but appreciated nonetheless.

This post was edited by kasey21 on Oct 12 2018 12:49pm
Member
Posts: 5,838
Joined: Nov 19 2007
Gold: 240.00
Oct 12 2018 01:19pm
I don't think your professor expected you to "solve" the series with an explicit expression anyway since it would be more costly than the recursive algorithms obtained directly from studying the patterns.

There's a fun fact though, I guess every series such as yours which, when "differentiated" n times yields a periodic pattern of length L can be effectively "solved" for, by being broken down in L polynomials of degree <=k.

In your particular case

7, 9, 14, 20, 27, 33, 42, 52, 63, 73, 86
2, 5, 6, 7, 6, 9, 10, 11, 10, 13
3, 1, 1, -1,3, 1, 1, -1,3

differentiating 2 times yields a periodic pattern of length 4 : 3,1,1,-1

and the series is given by 4 polynomials of degree 2, each of them giving the cases 0, 1, 2, 3 mod 4, respectively:

3 - 4X + 8X^2 yields the 1st, 5th, 9th, 13th, etc. (i.e. = 1 mod 4) terms of your series when X = 1, 2, 3, ...
in other words,
u_{1+4n} = 3 - 4n + 8n^2 gives 7, 27, 63...

1 + 8X^2 yields the 2nd, 6th, 10th, etc. (2 mod 4)
u_{2+4n} = 1 + 8n^2 gives 9, 33, 73

2 + 4X + 8X^2 yields the 3rd, 7th, 11th, etc (3 mod 4)
u_{3+4n} = 2 +4n +8n^2 gives 14, 42, 86...

and the last one giving the 4th, 8th, 12th,... (4 mod 4) is 4 + 8X + 8X^2
u_{4+4n} = 4 +8n +8n^2 gives 20, 52...

with these formulas you can compute any number of the series without going through all of them, though you probably don't need this

This post was edited by Hanako on Oct 12 2018 01:37pm
Go Back To Homework Help Topic List
Add Reply New Topic New Poll