Message Boards Message Boards

0
|
8752 Views
|
17 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Create a function that replicates this series?

Posted 8 years ago
POSTED BY: Lea Rebanks
17 Replies
Posted 8 years ago

Many thanks Martin again. Really Excellent.

POSTED BY: Lea Rebanks

Hi Lea

Even shorter:

Clear[c]

c[1] = 1;
c[2] = 7;

c[n_] := c[n] = 8 + 2 c[n - 1] - c[n - 2]

Table[c[k], {k, 1, 15}]
POSTED BY: Martin Bittcher
Posted 8 years ago

What Weil Aerts showed you is the "proper way" to go about looking for such a formula (graphing data and using one's experience about recognizing functions). However, an alternative that I just recently saw at Mathematica StackExchange is a "lazy person's way" (or "efficient person's way") which consists of going to https://oeis.org/ and typing in the sequence of numbers.

Typing you your sequence results in a(n) = 4n^2 - 6n + 3.

POSTED BY: Jim Baldwin

Disagree; NonlinearModelFit does not look for a formula, it will find you the coefficients once you give it a formula! FindSequenceFunction is the proper, which is specifically designed for sequences. ((non)linearmodelfit is designed for data with any step, and 99% of the time used for cases where there is no exact fit; i.e. to find the best fit).

POSTED BY: Sander Huisman
Posted 8 years ago

Many thanks Jim. Really Excellent.

POSTED BY: Lea Rebanks

Hi Lea Did you think of "functions that remember their values"? Then a[k] might be your choice.:

b[1] = 1;

b[2] = 7;

b[3] = 14;

b[n_] := b[n] = b[n - 1] + 8

a[1] = 1;

a[2] = 7;

a[n_] := a[n] = a[n - 1] + b[n]

POSTED BY: Martin Bittcher
Posted 8 years ago

Many thanks Martin. Really Excellent.

POSTED BY: Lea Rebanks

Create a function that replicates this series?

POSTED BY: Martin Bittcher
Posted 8 years ago
POSTED BY: Wiel Aerts
Posted 8 years ago

Very nice coding. Excellent. This method seems to do the trick & is accurate at the 1000th integer.

Many thanks. Lea...

POSTED BY: Lea Rebanks

Of course it would be accurate,fits is perfect. My solution is exact, will work for any integer, billion, trillion, google... . Moreover I gave you all the constant components, all the linear components and quadratic et cetera. What do you want more?

POSTED BY: Sander Huisman
Posted 8 years ago

Given that we have now found the function for the series

data = {1, 7, 21, 43, 73, 111, 157, 211, 273, 343, 421, 507, 601, 703, 813}
series[n_]:=3-6 n+4 n^2

If I create 2 different series as multiplications of this series - for example:-

series1[n_]:= (3-6 n+4 n^2) * 30
series2[n_]:= (3-6 n+4 n^2) * 47

I tried using

Intersection[ series1 , series2 ] 

with a million elements & found nothing.

Question - Is there one or more common values between series1 & series2 within the Integer domain from 1 to infinity?

Please could someone check & confirm whether any values are shared or not.

Many thanks for your help & attention. Lea...

POSTED BY: Lea Rebanks

It can be done like this:

seq = {1, 7, 21, 43, 73, 111, 157, 211, 273, 343, 421, 507, 601, 703, 813};
seqlen = Length[seq];
prefactors = CoefficientList[FindSequenceFunction[seq][x], x];
powers = Range[Length[prefactors]] - 1;
values = MapThread[#2 Range[seqlen]^#1 &, {powers, prefactors}];
values
Total[values]

{
    {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3},
    {-6,-12,-18,-24,-30,-36,-42,-48,-54,-60,-66,-72,-78,-84,-90},
    {4,16,36,64,100,144,196,256,324,400,484,576,676,784,900}
}

{1,7,21,43,73,111,157,211,273,343,421,507,601,703,813}
POSTED BY: Sander Huisman
Posted 8 years ago

Many thanks for your help Sander.

I see from your coding that the FindSequenceFunction[seq] gives

3 - 6 #1 + 4 #1^2 &

Which is the function I am after.. Many thanks for your help & attention. Lea...

POSTED BY: Lea Rebanks
Posted 8 years ago

Given that we have now found the function for the series

data = {1, 7, 21, 43, 73, 111, 157, 211, 273, 343, 421, 507, 601, 703, 813}
series[n_]:=3-6 n+4 n^2

If I create 2 different series as multiplications of this series - for example:-

series1[n_]:= (3-6 n+4 n^2) * 30
series2[n_]:= (3-6 n+4 n^2) * 47

I tried using

Intersection[ series1 , series2 ] 

with a million elements & found nothing.

Question - Is there one or more common values between series1 & series2 within the Integer domain from 1 to infinity?

Please could someone check & confirm whether any values are shared or not.

Many thanks for your help & attention. Lea...

POSTED BY: Lea Rebanks
Posted 8 years ago

Hi Bill,

Many thanks for the suggestion. But this is not the type of solution I am looking for.

I am looking for an approach by re-engineering the elements in this series by combining the vectors or arrays that make up this series progression. I can do this in Excel, but I am still struggling to effectively achieve this in Mathematica.

Do you have any other suggestions.

Many thanks for your help & attention, Lea...

POSTED BY: Lea Rebanks
Posted 8 years ago

Usually I start by graphing the available data.

data = {1, 7, 21, 43, 73, 111, 157, 211, 273, 343, 421, 507, 601, 703, 813};
ListPlot[data]

Hummm. Looks roughly like a parabola, but that is only a first guess.

Hint: Look at the documentation for Fit and see if that might let you find something interesting and useful.

That might be enough if you work quickly before someone blurts out the answer and spoils the learning opportunity.

POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract