Jump to content

How can I represent the following?


meatbag

Recommended Posts

I know this is a stupid question but Im going to ask it anyway :)

 

Ive written an iterative algorithm in C (programming language) and wondered how to represent this in maths. For example,

 

int main(void)
{
int x;
for(x=40; x>0; x/=2)
{
	process(x);
}

return 0;
}

 

So each of the following is put into the equation...

40
20
10
5
2
1

 

Basically all I want to know is what do you use in maths to represent equating a formula with a range of input values?

Link to comment
Share on other sites

Well, there isn't exactly anything like that (by the way, it's called looping) in math that I know of. The closest one can get (to my limited knowledge) is with the Product or Sum. But then again, there may be other methods I'm not aware of. Quite frankly, I'm curious myself, I've often wondered about this.

 

Cheers,

 

Gabe

Link to comment
Share on other sites

Doesn't that require you to define [math]a_0[/math] in advance?

 

Ok, so what? The point is that the series I gave follows exactly what the OP wants. You can take any [math]a_0[/math] you want, it is will still halve the number every step in the series. It performs exactly what the OP wanted.

Link to comment
Share on other sites

Not exactly. You have to state that [math]a \in N[/math]. I'm not sure how you do that with an entire series, since we haven't covered series at school yet, but you get the point. Also, apart from the fact that I believe the OP wanted to know how to represent a loop in math, in the OP's example, [math]a_0=40[/math], not one. So while your series will hold the same numbers, it will hold them in the wrong order.

 

I don't know the solutions to these problems, I'm just pointing out the problems themselves.

 

Cheers,

 

Gabe

Link to comment
Share on other sites

Well if you want to be really fussy then: [math]a_{n+1} =

\begin{cases}

\frac{1}{2} a_n & a_n \in \mathbb{N}_{\mbox{even}} \\

a_{n+1} \uparrow & \mbox{otherwise}

\end{cases}[/math]

Which never did give the sequence in the wrong order.

Edited by the tree
Link to comment
Share on other sites

I see, thanks for the clarification. But the OP uses integer division, so if [math]a_n[/math] is not an even natural, [math]a_{n+1}[/math] shouldn't be undefined. For example, if [math]a_n=5[/math], then [math]a_{n+1}=2[/math]...how would you write that? Does 5/2 equal 2 in N?

 

Cheers,

 

Gabe

Link to comment
Share on other sites

All my notes involving looping algorithms are just written in pseudo code. Iterative formulae seem more obvious but neither is really more mathsy than the other.

Maths, contrary to popular belief, isn't a language. While there's specific mathematical notation for a lot of things, there isn't for most and it's perfectly acceptable to write in English or use pseudocode or a formal programming language.

Link to comment
Share on other sites

One is never silly by being curious.

With the significant exception of being curious about what happens when you stick a fork into toaster shortly after having showered and holding a copper wire that is wrapped around everyone you've ever loved. That would be silly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.