Help determining an equation that describes a pattern

  • Context: Undergrad 
  • Thread starter Thread starter Ouka
  • Start date Start date
Click For Summary
SUMMARY

The discussion centers on creating a mathematical equation to describe a specific pattern for a programming task. The pattern involves assigning values to 'x' based on ranges of 'n', with alternating differences of 92 and 89. User Ouka seeks assistance in formulating a sigma equation, while Warren suggests an alternative approach using a Python function to achieve the same result without the need for complex calculus. The proposed function efficiently calculates 'x' based on the input 'n' through a simple iterative process.

PREREQUISITES
  • Understanding of basic calculus concepts, particularly sigma notation.
  • Familiarity with Python programming and function definitions.
  • Knowledge of iterative algorithms and conditional statements.
  • Ability to analyze and interpret mathematical patterns.
NEXT STEPS
  • Research sigma notation and its applications in mathematical equations.
  • Learn about Python's iterative structures and how to implement them effectively.
  • Explore mathematical modeling techniques for pattern recognition.
  • Study algorithms for optimizing performance in programming tasks.
USEFUL FOR

Mathematicians, software developers, and anyone involved in algorithm design or mathematical modeling who needs to translate patterns into functional code.

Ouka
Messages
1
Reaction score
0
Hi all,

Been a looooong time since I had to use calculus for anything, but I distinctly remember failing this section of the course miserably. I can describe a pattern but for the life of me I can't write an equation that describes the pattern I see.

For a program I'm wrtting for work I need to write an equation that will describe the following pattern:

If n = 1 to 93 then x = 1
(diff = 92)
If n = 94 to 183 then x = 2
(diff = 89)
If n = 184 to 276 then x = 3
(diff = 92)
If n = 277 to 366 then x = 4
(diff = 89)
and so on and so forth...

ANy help would be greatly appriciated. I know it's possible to write a sigma equation to describe this sort of pattern, but like I said I failed this section of my calculus course miserably! Never thought I'd actually use it again!

--Ouka
 
Physics news on Phys.org
Is there some reason you need to actually create an equation to describe this? Since you're writing a computer program, why can't you do something like this?

Code:
def f(n):
	acc = 0
	i = 0
	x = 0
	while (acc < n):
		if (i == 0):
			acc = acc + 93
		else:
			acc = acc + 90
		
		i = (i + 1) % 2
		x = x + 1
		
	return x

- Warren
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
963
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 18 ·
Replies
18
Views
3K
Replies
2
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K