Jump to content

How can I represent the following?

Featured Replies

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?

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

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

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.

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

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

I can only guess at what that means :D But thanks anyway :)

It says,

a[n+1] equals half a[n] if a[n] is in the even naturals, a[n+1] is undefined otherwise.

 

(I would have written undefined instead of the silly arrow notation but typing def throws up an error in these forums)

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

How would you write quotient in math? Just "quotient"? :D

 

But thanks anyway. Now, shouldn't we get back to the OP's question? That being how to represent a loop in math?

 

Cheers,

 

Gabe

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.

Wow...I never knew it was acceptable to use a programming language in math :D I'll be sure to inform my maths teacher that from now on I'm doing all my homework in C++:D

 

Cheers,

 

Gabe

  • Author

Thanks for the input guys.

 

It seems I wasn't being silly :)

One is never silly by being curious.

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.

I stand corrected :D

Archived

This topic is now archived and is closed to further replies.

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.