CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: How to code summation function?

1. Junior Member Join Date
May 2011
Posts
3

## 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.  Reply With Quote

2. ## Re: How to code summation function?

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

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

## 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.  Reply With Quote

4. Junior Member 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!!  Reply With Quote

5. Member 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);
}
}```  Reply With Quote

6. Junior Member 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  Reply With Quote

#### Tags for this Thread

equation, function, summation #### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
• Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)