# Expressing loops etc. in math.

This is a discussion on Expressing loops etc. in math. within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Well I'm still working on that universal equation thing. I have a series of equations, all related - like a ...

1. ## Expressing loops etc. in math.

Well I'm still working on that universal equation thing. I have a series of equations, all related - like a series of steps to take - one follows the other. I calculate the value of a variable, r, based on x. If r is equal to 1, then I finish up the calculation because I know everything is set up right. If not, then I want to increase d by 1, and then repeat the calculation. Is there a standard mathematical way of expressing this?

And one more question: In multivariable-differential calculus, if your calculating dy/dx as x->0, couldn't you just add one to the exponent of each x in the equation of change in y/change in x? It seems to work and is a lot simpler than waht my book says.

2. ## Re: Expressing loops etc. in math.

Originally posted by Sean
Well I'm still working on that universal equation thing. I have a series of equations, all related - like a series of steps to take - one follows the other. I calculate the value of a variable, r, based on x. If r is equal to 1, then I finish up the calculation because I know everything is set up right. If not, then I want to increase d by 1, and then repeat the calculation. Is there a standard mathematical way of expressing this?

And one more question: In multivariable-differential calculus, if your calculating dy/dx as x->0, couldn't you just add one to the exponent of each x in the equation of change in y/change in x? It seems to work and is a lot simpler than waht my book says.
I dont know the answer to the first question, but the second one sounds familiar, what section is it under, so I can take a look, I may be able to help out a little more.

3. express loops mathematically?

remember the "E" thingy as in:
Code:
```n<stuff
E( stuff )
n=0```
as to make a mathematical formula out of your problem, I'm unable to do right now since I'm currently brain dead. I'll try to respond again when my headache is over.

4. WHAT DOES THAT E(greek sigama) ACTUALLY DO IN MATH?!?!?! I'VE LOOKED EVERYWHERE AND THEY GIVE ME GARBAGE ANSWERS?!!!!!!!!!!!!!!

boo hooo

5. Originally posted by Xterria
WHAT DOES THAT E(greek sigama) ACTUALLY DO IN MATH?!?!?! I'VE LOOKED EVERYWHERE AND THEY GIVE ME GARBAGE ANSWERS?!!!!!!!!!!!!!!

boo hooo

It symbolizes sum.
So
n = 0
E (n = n+1)
n = 10

so a sum from 0 to 10, substituting n into the equation in ()

6. wtf? 0+1 is not 10!
help?

7. Originally posted by Xterria
wtf? 0+1 is not 10!
help?

You start with n = 0, and you go up to n = 10

so the equation is n = n+1, or u can say k = n +1
so k = 1 (n=0), 2 (n = 1), 3 (n = 2)

8. ## Re: Expressing loops etc. in math.

Originally posted by Sean
Well I'm still working on that universal equation thing. I have a series of equations, all related - like a series of steps to take - one follows the other. I calculate the value of a variable, r, based on x. If r is equal to 1, then I finish up the calculation because I know everything is set up right. If not, then I want to increase d by 1, and then repeat the calculation. Is there a standard mathematical way of expressing this?

And one more question: In multivariable-differential calculus, if your calculating dy/dx as x->0, couldn't you just add one to the exponent of each x in the equation of change in y/change in x? It seems to work and is a lot simpler than waht my book says.
that's a hectic thing to follow. I should take back my words I said when I was in pain. first I do believe anything, but limited, expressed in programming can be translated into mathematical terms. however, making formulas can be quite fustrating at times. since I do not exactly know how the calculations are, I can try with the series and a function and play around with it and add other terms if necessary. maybe I can start by making the function control how the series goes (all those complex algorithms). I might as well not continue with the stuff I do not understand that I am saying.

anyway, with the limts that u were talking about, the values get closer and closer to a value (for when very precise values are needed). I forget but Dalton might be one of the first to start the idea with limits or something. the book is a reference telling you exactly how the thing works. shortcuts? I think there are plenty for this but sometimes they don't work for certain problems.

I think I need to rest before I continue (this is what vacation does to people).

reference I suggest:

http://mathworld.wolfram.com/

also, these guys (professionals) might help out at :

http://www.mathforum.org/dr.math/

9. Exterria - it symbolizes sum, but it's usually only used with differentiation. For example, if you have a series (pretend that any number preceded by a \ is subscript), you can get the sum. Say n is as follows: n \1 = 1, n\2 = 2 n\3 = 4, n\4 = 8 n\5 = 16.
En (with a superscript 1 and a subscript 5 below it) would equal 1 + 2 + 4 + 8 + 16 = 31.

I've considered using that in a variety of ways, but what I need to do is perform all the calulations with d=1, and if r != 1 then I need to increment d and do all the calculations again. It's a series of equations that all follow off from eachother.

10. > but it's usually only used with differentiation.

You mean integration? (since, AFAIK, the integral symbol's meant to look like an S, for Sum)

11. And also, no, 0+1 does not equal 10, but it would if we could get a mathematical loop in there - that's the kind of loop I'm talking about just to repeat I can just put another equation in there easily to increment d. (i.e. d=d+d) ^=delta. So does anyone know of any place they've seen of repeating a calculation? Sigma is close but it's just not quite solving the problem the ways I've tried it. Thanks for the help so far though.

12. You mean such like this?

Code:
```Pre: true
Post: {r == 1}

d = ?
r = ?
while (r != 1) do
begin
r = f(x)
{(r == 1 || r != 1) <-> true}
if (r == 1)
{r == 1}
break;
else
{r != 1}
d = d + 1
end
{r == 1}```
This is not complete, since there is no information available about variable d.

>In multivariable-differential calculus, if your calculating dy/dx as
>x->0, couldn't you just add one to the exponent of each x in the
>equation of change in y/change in x?

?

y = x^n
dy/dx = n x^(n-1)

13. First answer: I mean pure mathematical - no programming.

Second answer: My fault actually - I meant single-variable. I actually didn't need to post that - I had it right here in my book! Thanks anyway.

14. One other thing.... well two other things:

1) Are there just 4 degrees of equations, or is their an infinite amount?

2) If it is just four, I could write out the equation for times, and then have some way of testing the value of a variable, like the if statement, but again, it would have to be completely mathematical.

And in response to the original question's answers - I was thinking about the sum thing - if I summed all the possibilties, divided them by four (again - dependant on there only being four degrees), that would just be the average. But if I could get an equation that modified the average dependant on the degree, then it would work. Anyone?

15. Shiro, I think you're mixing languages. No "begin" or "end" in C++, also need some ;'s at the end of statements.
As far as the math, no idea.

Page 1 of 2 12 Last