Math Is Fun Forum

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

You are not logged in.

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

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

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'
I'm not crazy, my mother had me tested.

Offline

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

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

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

Offline

#28 2013-07-23 02:46:07

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

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'
I'm not crazy, my mother had me tested.

Offline

#29 2013-07-23 06:31:35

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: An Integral and the Computer

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

#30 2013-07-23 13:26:08

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

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'
I'm not crazy, my mother had me tested.

Offline

#31 2013-07-23 13:28:02

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

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

Offline

#32 2013-07-23 13:28:41

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

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-23 13: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'
I'm not crazy, my mother had me tested.

Offline

#33 2013-07-23 13:29:33

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: An Integral and the Computer

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

#34 2013-07-23 13:32:48

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: An Integral and the Computer

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

Please help me with differentiating cos(x)^100


'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

#35 2013-07-23 13:37:17

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

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

Offline

#36 2013-07-23 13:59:14

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

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'
I'm not crazy, my mother had me tested.

Offline

#37 2013-07-23 14:02:24

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

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

Offline

#38 2013-07-23 14:04:01

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: An Integral and the Computer

>>> 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'
I'm not crazy, my mother had me tested.

Offline

#39 2013-07-23 14:08:09

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

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

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

#40 2013-07-23 14:11:23

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

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'
I'm not crazy, my mother had me tested.

Offline

#41 2013-07-23 14:17:33

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

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

Offline

#42 2013-07-23 14:21:02

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

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'
I'm not crazy, my mother had me tested.

Offline

#43 2013-07-23 14:30:10

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

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

Offline

#44 2013-07-23 14:31:30

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

Re: An Integral and the Computer

Ok, what about xi?


'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

#45 2013-07-23 14:35:09

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

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

Offline

#46 2013-07-23 14:37:31

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

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'
I'm not crazy, my mother had me tested.

Offline

#47 2013-07-23 14:55:15

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

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'
I'm not crazy, my mother had me tested.

Offline

#48 2013-07-23 15:07:42

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

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

Offline

#49 2013-07-23 15:09:48

Agnishom
Real Member
From: Riemann Sphere
Registered: 2011-01-29
Posts: 24,974
Website

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'
I'm not crazy, my mother had me tested.

Offline

#50 2013-07-23 15:12:51

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: An Integral and the Computer

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

Board footer

Powered by FluxBB