You are Here: Home >< Maths

# Maple code for simpsons rule watch

1. Hi I'm trying to evaluate the following:

int((x^3-5.15*x^2+8.55*x-4.5045),x=1..2);

My current code is:

restart;

f:=x->int((x^3-5.15*x^2+8.55*x-4.5045),x=1..2);

> simp:=proc(func,x0,xn,xi,n)
> local h,i, summ;
>
> h:=xn-x0/n:
> summ:=int(h/3*(f(x0)+f(xn)+(4*f(xi))+2*f(xi) )):
> for i from 1 to n-1 by 2 do
>
> xi:=x0+i*h:
>
> summ:=summ+4*f(xi):
> od:
> summ:=h/3*summ;
> end:
> for i from 2 to n-2 by 2 do
>
> xi:=x0+i*h:
> summ=summ+2*f(xi):
> od;
>
>
Error, final value in for loop must be numeric or character

Im hoping someone could please tell me what the problem is,

Regards
2. f:=x->int(evalf(x^3-5.15*n^2+8.55*x-4,5045),x=1..2):
> simp:=proc(func,x0,xn,n)
> local summ, h, i,x:
> x0:=1:
> xn:=2:
> n:=8:
> h:=xn-x0/n:
> summ:=f(x0)+f(xn):
>
> for i from 1 to n-1 by 2 do
>
> x[i]:=x0+(i*h):
> summ:=summ+4*f(x[i]):
> od:
>
> for i from 2 to n-2 by 2 do
>
> x[i]:=x0+(i*h):
> summ:=summ+2*f(x[i]):
> od:
>
> summ:=h/3*summ;
> end:

So I've had another go, got this far and now I'm stuck again, how do i get the answer of the integral out?
3. do you have to use code? (worksheet mode etc)

why don`t you (if you don`t have to use code) put (as written):

with(Student[Calculus1]):

better still, make the 2nd line begin with:
ApproximateIntTutor(f(x),x=a..b)
this gives a graphical display where you can choose which rule to use, and to plot whatever function you wish...
4. Yes, we have to use a code, cant use maples built in problem solvers.

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: April 14, 2013
Today on TSR

### The most controversial member on TSR?

Who do you think it is...

### Uni strikes! How do they affect you?

Discussions on TSR

• Latest
Poll
Useful resources

## Make your revision easier

### Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

### How to use LaTex

Writing equations the easy way

### Study habits of A* students

Top tips from students who have already aced their exams

Can you help? Study help unanswered threads

## Groups associated with this forum:

View associated groups
Discussions on TSR

• Latest

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE