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. #1
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913

    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. #2
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198

    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.
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  3. #3
    Registered User toaster's Avatar
    Join Date
    Apr 2002
    Posts
    161
    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.
    think only with code.
    write only with source.

  4. #4
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    WHAT DOES THAT E(greek sigama) ACTUALLY DO IN MATH?!?!?! I'VE LOOKED EVERYWHERE AND THEY GIVE ME GARBAGE ANSWERS?!!!!!!!!!!!!!!


    boo hooo

  5. #5
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    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 ()
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  6. #6
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    wtf? 0+1 is not 10!
    help?

  7. #7
    Microsoft. Who? MethodMan's Avatar
    Join Date
    Mar 2002
    Posts
    1,198
    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)
    -MethodMan-

    Your Move:Life is a game, Play it; Life is a challenge, Meet it; Life is an opportunity, capture it.

    Homepage: http://www.freewebs.com/andy_moog/home.html

  8. #8
    Registered User toaster's Avatar
    Join Date
    Apr 2002
    Posts
    161

    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/
    think only with code.
    write only with source.

  9. #9
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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. #10
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    > 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. #11
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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. #12
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    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. #13
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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. #14
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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. #15
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    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.
    Truth is a malleable commodity - Dick Cheney

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help using arrays and loops for math
    By LLINE in forum C++ Programming
    Replies: 3
    Last Post: 06-09-2008, 05:09 AM
  2. how to use operator+() in this code?
    By barlas in forum C++ Programming
    Replies: 10
    Last Post: 07-09-2005, 08:22 PM
  3. Help with C++ Math
    By aonic in forum C++ Programming
    Replies: 4
    Last Post: 01-29-2005, 04:40 AM
  4. toughest math course
    By axon in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 10-28-2003, 10:06 PM
  5. help with arrays and loops
    By jdiazj1 in forum C Programming
    Replies: 4
    Last Post: 11-24-2001, 04:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21