Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,672 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 3,719 people online right now. Registration is fast and FREE... Join Now!




c++ source code for simpson's 3/8 rule

 
Reply to this topicStart new topic

c++ source code for simpson's 3/8 rule, c++ code

eestudent2006
post 2 May, 2006 - 07:14 AM
Post #1


New D.I.C Head

*
Joined: 2 May, 2006
Posts: 2


My Contributions


Can anyone help me with a source code for simpson's 3/8 rule for microsoft visual?
User is offlineProfile CardPM

Go to the top of the page


runtime error
post 2 May, 2006 - 08:16 PM
Post #2


Lucky.Code

Group Icon
Joined: 19 Mar, 2001
Posts: 624



Dream Kudos: 3
My Contributions


sure we can probably help you with a source code for simpson's 3/8 rule for microsoft visual. Just show it to us and we'll help you with it.


OH WAIT... were you asking us to code it for you? HAHAHAHA gee I hope not cause that would be a silly thing to ask since we don't do assignment or even personal projects for people here.

Read the rules please.

This post has been edited by runtime error: 2 May, 2006 - 08:18 PM
User is offlineProfile CardPM

Go to the top of the page

skyhawk133
post 2 May, 2006 - 09:21 PM
Post #3


Head DIC Head

Group Icon
Joined: 17 Mar, 2001
Posts: 14,829



Thanked 45 times

Dream Kudos: 1650

Expert In: Web Development

My Contributions


No need to be mean about it, they are easy to miss.
User is offlineProfile CardPM

Go to the top of the page

poke_blade
post 2 May, 2006 - 11:30 PM
Post #4


New D.I.C Head

*
Joined: 26 Feb, 2006
Posts: 21



Dream Kudos: 10
My Contributions


According to simpsons 3/8 rule there must be atleast 3 intervals which means atleast 4 values of x.
If n is the no of intervas
If the user enters n<3 give an error mess and exit.
If n>=3 except x's upto n+1
Tell the user to enter the function y(see note).
then calculate y0,y1,.....yn[use arrays]
The rule says that
xn
⌡ y dx=3h/8[y0+3y1+3y2+2y3+....+2yn-3+3yn-2+3yn-1+yn]
x0

[⌠-Integration]
to do this you have to have an array with values [1,3,3,2]
go on multiplying them to y0,y1,...yn-4 in a cyclic loop.
Then do this 2yn-3+3yn-2+3yn-1+yn and add them all.
so you will be getting the sum in the bracket.
you know h(accept it from user).
Hence you will get the result.
[
Note:-
when you get the function y from user store it in a string.
You need to write a evaluation tree to find the values of y0,y1,..yn
for the values of x0,x1,..xn
]

This post has been edited by poke_blade: 2 May, 2006 - 11:40 PM
User is offlineProfile CardPM

Go to the top of the page

eestudent2006
post 3 May, 2006 - 08:12 AM
Post #5


New D.I.C Head

*
Joined: 2 May, 2006
Posts: 2


My Contributions


This is what I have so far.


using namespace std;
#include <stdio.h>
#include <math.h>

int main()
{
def f(x):
return sin(x);
}

{
def simpson_rule:
c=(a+b)/2.0;
h=(b-a);
return h*[(f(a)+3.0*f(b)+3.0*f©+f(d))/8.0];
}

This post has been edited by eestudent2006: 3 May, 2006 - 08:18 AM
User is offlineProfile CardPM

Go to the top of the page

palomaqui
post 12 Dec, 2006 - 01:30 PM
Post #6


New D.I.C Head

*
Joined: 12 Dec, 2006
Posts: 1


My Contributions


can anyone help me to code Simpson's Algortthm?
User is offlineProfile CardPM

Go to the top of the page

Xing
post 12 Dec, 2006 - 06:10 PM
Post #7


D.I.C Addict

Group Icon
Joined: 22 Jul, 2006
Posts: 723



Thanked 2 times

Dream Kudos: 1575
My Contributions


QUOTE(palomaqui @ 13 Dec, 2006 - 03:00 AM) *

can anyone help me to code Simpson's Algortthm?

http://en.wikipedia.org/wiki/Adaptive_Simpson's_method
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 07:18AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month