Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

## #26 2013-07-23 23:31:10

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

Is the formula same as filling it up with trapeziums?

How much n do you want me to take?

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #27 2013-07-23 23:32:17

bobbym

Online

### Re: An Integral and the Computer

Yes, they are rectangles with a triangle on top.

To know n beforehand we must have an error estimate.

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #28 2013-07-24 00:46:07

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

Hmm...

How to have that?

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #29 2013-07-24 04:31:35

bobbym

Online

### Re: An Integral and the Computer

with that we can answer the question.

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #30 2013-07-24 11:26:08

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

But we still do not know n!

How did you come up with that formula?

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #31 2013-07-24 11:28:02

bobbym

Online

### Re: An Integral and the Computer

Those are well known from books on numerical analysis and elsewhere. I believe it is derived from the Taylor series. We are going to compute n using that formula!

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #32 2013-07-24 11:28:41

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

Define error before that.

Its sad to note that I cannot differentiate cos(x)^100

Last edited by Agnishom (2013-07-24 11:29:54)

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #33 2013-07-24 11:29:33

bobbym

Online

### Re: An Integral and the Computer

You have defined it!

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #34 2013-07-24 11:32:48

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

I do not understand the formula at post 29, what did you put between f''()

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #35 2013-07-24 11:37:17

bobbym

Online

### Re: An Integral and the Computer

Hi;

That is xi, it represents a number between a and b that makes errror a maximum.

For the sake of speed, I will differentiate it for you.

Remember we are in computer land here, not in the real world. Throw your pencil and paper out the window but make sure you do not hit anybody with them.

Maxima or any other CAS can get that second derivative immediately and in this field you are encouraged to use it. If you can not do the differentiation what then? We will talk about that at the end. Let us not be slowed down by side issues of differentiation or computing numbers. These are tasks unrelated to what the question is.

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #36 2013-07-24 11:59:14

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

I wrote the function and I am getting 0.12501848174018745

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #37 2013-07-24 12:02:24

bobbym

Online

### Re: An Integral and the Computer

Hi Agnishom;

You are a fireball! But do not get ahead of me so fast.

What function?

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #38 2013-07-24 12:04:01

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

#### Code:

```>>> from math import cos
>>> def integrate(f, a, b, n):
s = 0
for k in xrange(1, n):
s += f(a + ((k*(b-a))/n))
s += 0.5*(f(a) + f(b))
s *= (b-a)/n
return s
>>> f = lambda x: (cos(x))**100
>>> integrate(f, 0, (3.141592653589793/4),1000)
0.12501848174018745```

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #39 2013-07-24 12:08:09

bobbym

Online

### Re: An Integral and the Computer

Haha!

You went to Wikipedia! That is the code for the above formula I gave you.

Let me rant a bit...

Post that in help me and I will work with you on it there.But let us proceed quickly and smoothly to our goal of getting a trapezoid rule answer.

You have asked me to teach you, I will give you the tricks of the trade. So far only two others have been able to follow them. We will now find out how crazy you really are. Are you prepared to take the red pill, to go down the rabbit hole?

If yes, then lets see why that code works?!

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #40 2013-07-24 12:11:23

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

Haha!

You went to Wikipedia! That is the code for the above formula I gave you.

-_-
No, I wrote it all by myself. I even made a few mistakes and had to correct it with a few tries.

Yes, I am prepared for the red pill. Please continue...

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #41 2013-07-24 12:17:33

bobbym

Online

### Re: An Integral and the Computer

That is very good!

Since you have programmed the trapezoid rule, you understand it better than most mathematicians. That will make many angry at me. But it is not my opinion but the opinion of Doron Zeilberger.

Then we can proceed with the question how do I know how many n to use?

I gave you this formula,

and the somewhat enigmatic statement

That is xi, it represents a number between a and b that makes errror a maximum.

How do we use that?

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #42 2013-07-24 12:21:02

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

#### bobbym wrote:

You have defined it!

Nope. I have not. What is error?

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #43 2013-07-24 12:30:10

bobbym

Online

### Re: An Integral and the Computer

You said 4 significant figures. Since we have an estimate given for the integral, that implies an error of .00005

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #44 2013-07-24 12:31:30

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #45 2013-07-24 12:35:09

bobbym

Online

### Re: An Integral and the Computer

xi is a value in the closed interval a,b that maximizes the value of error. Let's see how to compute that.

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #46 2013-07-24 12:37:31

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

Hmm

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #47 2013-07-24 12:55:15

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

It looks terrible..

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #48 2013-07-24 13:07:42

bobbym

Online

### Re: An Integral and the Computer

Yes and the error estimate is wildly inaccurate so we will do it the old fashioned way. When you ran your routine for n = 4 what did you get?

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.

## #49 2013-07-24 13:09:48

Agnishom
Real Member

Offline

### Re: An Integral and the Computer

I did not run the routine for n=4 ever

'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.'
'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'
'The whole person changes, why can't a habit?' -Alokananda

## #50 2013-07-24 13:12:51

bobbym

Online

### Re: An Integral and the Computer

Can you do it now?

In mathematics, you don't understand things. You just get used to them.
Some cause happiness wherever they go; others, whenever they go.
If you can not overcome with talent...overcome with effort.