Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.
Sedo.com

Hey Geniuses! Math problem...

Status
Not open for further replies.

Mr.Domains

DNF Addict
Legacy Exclusive Member
Joined
Sep 29, 2004
Messages
1,417
Reaction score
29
Okay, I know there are some REALLY brainy people on here, and this kind of thing makes my brain ache, (I'm a programmer, but more on the creative side than with numbers).

I need an equation to generate a Math Pattern, (probably a fairly simple one, but not immediately recognizable like 2,4,6,8... or 10,20,30,40...).

I need a pattern that starts:

10, around (14-18), around (22-25), around (30-40), then onwards exponentially...
(It shouldn't be an immediately obvious pattern to joe average though...) :?:
 

Mr.Domains

DNF Addict
Legacy Exclusive Member
Joined
Sep 29, 2004
Messages
1,417
Reaction score
29
I quite like this pattern, (I just can't work out what the formula is)... :blush:

1. 10
2. 14 (prev + 4)
3. 19 (prev + 5)
4. 25 (prev + 6)
5. 32 (prev + 7)
6. 40 (prev + 8)
7. 49 (prev + 9)
8. 59 (prev + 10)
8. 70 (prev + 11)
10. 82 (prev + 12)
11. 95 (prev + 13)
12. 109 (prev + 14)
 

Skinny

Level 5
Legacy Platinum Member
Joined
Jan 23, 2007
Messages
273
Reaction score
36
Edit: never mind, Johnn beat me to it.

I was trying to do a proper mathematical function f(x) = something; but I couldn't get it, but if you are using a programming language
you should be able to implement Johnn's solution which was more elegant than mine.

Skinny
 

vital

FF
Legacy Exclusive Member
Joined
Jan 12, 2011
Messages
682
Reaction score
40
Hey,

I think it's a kind of recurrence, so it could be something like:
Code:
a[SUB]n+1 = [/SUB]a[SUB]n[/SUB] + k + n
init:
Code:
a[SUB]0 [/SUB]= 10
k = 4;

C snippet:
Code:
a = 10;
k = 4;
    
while( a < LIMIT )
    a += k++;
 

Gerry

Dances With Dogs
Legacy Exclusive Member
Joined
Dec 3, 2006
Messages
14,985
Reaction score
1,302
I think this is the formula NASA uses to plot proper angles on spacecraft re-entering earth's atmosphere.
 

Mr.Domains

DNF Addict
Legacy Exclusive Member
Joined
Sep 29, 2004
Messages
1,417
Reaction score
29
Thanks Johnn, Skinny, vital, Gerry and asfas - you guys are great!

I didn't realize how bad my math sucks until I tried to use it for more than just straightforward multiplication or division ... still, it has been 20 years since I left school, :p

I actually need it as an equation rather than a loop, because I need to be able to calculate what the Nth number would be, but another member (asfas) PM'ed me to say I could use:

y = (x*x + 5*x + 14) / 2

Looks about right, although I haven't tested it yet. Thanks for all your help!
 

Johnn

Level 14
Legacy Exclusive Member
Joined
Apr 13, 2004
Messages
15,997
Reaction score
1,415
You cannot produce multiple results with just one equation.
What are you trying to do with: Excel or programming.
Be specific and we should be able to come up with the solution.
 

Theo

Account Terminated
Joined
Feb 28, 2004
Messages
30,317
Reaction score
2,217
Just don't try to divide by zero because your computer will explode.
 

vital

FF
Legacy Exclusive Member
Joined
Jan 12, 2011
Messages
682
Reaction score
40
It's called dynamic programming - you need previous results, but it's exactly what recurrences do.

Code:
a[SUB]0[/SUB] = 10, k = 4

a[SUB]1[/SUB] = a[SUB]0[/SUB] + k + 0 = 10 + 4 + 0 = 14
a[SUB]2[/SUB] = a[SUB]1[/SUB] + k + 1 = 14 + 4 + 1 = 19
a[SUB]3[/SUB] = a[SUB]2[/SUB] + k + 2 = 19 + 4 + 2 = 25
...
a[SUB]n+1 = [/SUB]a[SUB]n[/SUB] + k + n

The formula you posted is right, and code using the formula (y = (x*x + 5*x + 14) / 2)
produces sequence you wanted:
Code:
7
10
14
19
25
32
40
49
59
70
82
iterating x from 1 to 10.
 

Mr.Domains

DNF Addict
Legacy Exclusive Member
Joined
Sep 29, 2004
Messages
1,417
Reaction score
29
You cannot produce multiple results with just one equation.

Of course you can, the result of "y" depends on "x", in this equation: y = (x*x + 5*x + 14) / 2

$x = 1; $y = 10;
$x = 2; $y = 14;

The formula you posted is right, and code using the formula produces sequence you wanted:

Cool, thanks!

Be specific and we should be able to come up with the solution.

I want to charge users an incrementing amount for upgrades, level 1 costs $10, level 2 costs $14, level 3 costs $19, and so on... ideally I'd even have the increments increase slightly more rapidly, (10, 16, 24-ish, etc if anyone cares to fine tune it), but this is close enough. Cheers!

(Unfortunately it's virtual credits, like forum $'s, not real cash!) :uhoh:
 
Last edited:
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Sedo - it.com Premiums

IT.com

Premium Members

MariaBuy

Our Mods' Businesses

UrlPick.com

*the exceptional businesses of our esteemed moderators

Top Bottom