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

You are not logged in.

- Topics: Active | Unanswered

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'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

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.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

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'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

I already do:

with that we can answer the question.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

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'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

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.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

Define error before that.

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

*Last edited by Agnishom (2013-07-23 13:29:54)*

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

You have defined it!

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

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

Please help me with differentiating cos(x)^100

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

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.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

I wrote the function and I am getting 0.12501848174018745

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

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.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

```
>>> 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
```

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

Haha!

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

Let me rant a bit...

Please help me with differentiating cos(x)^100

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.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

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...

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

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.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

bobbym wrote:

You have defined it!

Nope. I have not. What is error?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

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.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

Ok, what about xi?

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

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.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

Hmm

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

It looks terrible..

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

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.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline

I did not run the routine for n=4 ever

'God exists because Mathematics is consistent, and the devil exists because we cannot prove it'

I'm not crazy, my mother had me tested.

Offline

**bobbym****bumpkin**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 108,728

Can you do it now?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.**** Always satisfy the Prime Directive of getting the right answer above all else.**

Offline