How to code summation function?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: How to code summation function?

  1. #1
    Join Date
    May 2011
    Posts
    3

    Question How to code summation function?

    Hello, I am new to programming

    Can you please help me make code on C# for the equation on the attachment.! any help will be greatly appreciated.


    Thank you in advance.
    Attached Images Attached Images

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,101

    Re: How to code summation function?

    That's nice, why not go to rentacoder.com.

  3. #3
    Join Date
    May 2011
    Location
    Washington State
    Posts
    220

    Red face Re: How to code summation function?

    If you understand that equation, you are way ahead of the game on most of us (I presume, sorry if there are more of you out there that do infact understand it, kudos if you do!). Look up aritcles on c# math library, besides that, just know it uses ( ) to help order mathmatical operations, * = times, / = divide, + = plus, - = minus, ^ = power of ... think thats about all i can provide.

  4. #4
    Join Date
    May 2011
    Posts
    3

    Re: How to code summation function?

    Thanks a lot guys for your input.
    Well i could do with just a simple general solution for coding a summation notation.

    sorry for the complex equation.!!

    thanks again!!

  5. #5
    Join Date
    May 2011
    Location
    Washington State
    Posts
    220

    Re: How to code summation function?

    You don't have to apologize for the complex formula... if you understand what a summation notation is, you could just describe how you figure it out in english, then maybe I (or somebody else here) could translate what it would take in C#.

    All I could find on 'summation' google wise were things similar to just summing sequential set of values, like...

    Code:
    /*
    C#: The Complete Reference 
    by Herbert Schildt 
    
    Publisher: Osborne/McGraw-Hill (March 8, 2002)
    ISBN: 0072134852
    */
    // Use byte. 
     
    using System; 
     
    public class Use_byte {    
      public static void Main() {    
        byte x; 
        int sum; 
     
        sum = 0; 
        for(x = 1; x <= 100; x++) 
          sum = sum + x; 
     
        Console.WriteLine("Summation of 100 is " + sum); 
      }    
    }

  6. #6
    Join Date
    May 2011
    Posts
    3

    Re: How to code summation function?

    Thanks..!!

    I want to get a value at every iteration,
    e.g. if the loop runs for 10 times, i want to get the resultant then add it to a constant
    so at every iteration, the program will return (loop value + constant)

    The code is for least squares method, curve fitting

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center