Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

#51 2013-07-24 13:14:20

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Code:

>>> integrate(f, 0, (3.141592653589793/4),4)
0.12645766198987884

Sweet Jesus, its still good enough


'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'
'Who are you to judge everything?' -Alokananda

#52 2013-07-24 13:17:39

bobbym
Administrator

Offline

Re: An Integral and the Computer

Now for 5?


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#53 2013-07-24 13:29:58

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Code:

>>> for i in xrange(5,11):
    print integrate(f, 0, (3.141592653589793/4),i)

    
0.125091274611
0.125020215482
0.125018499911
0.125018481816
0.12501848174
0.12501848174

smile


'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'
'Who are you to judge everything?' -Alokananda

#54 2013-07-24 13:33:32

bobbym
Administrator

Offline

Re: An Integral and the Computer

Hi;

You can empirically see that after n = 6 you have the 4 significant digits you require so that is the answer.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#55 2013-07-24 13:35:16

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Yes. That is what I was planning to do.


'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'
'Who are you to judge everything?' -Alokananda

#56 2013-07-24 13:38:17

bobbym
Administrator

Offline

Re: An Integral and the Computer

When you get time check this page because your code is slightly off. There are implementations there that will help,

http://en.wikipedia.org/wiki/Trapezoidal_rule


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#57 2013-07-24 13:46:56

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Why should it be off?

Thats just the 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'
'Who are you to judge everything?' -Alokananda

#58 2013-07-24 13:54:28

bobbym
Administrator

Offline

Re: An Integral and the Computer

You are probably out of alignment.

Try your formula out on this

f(x) = x^9 between 0 and 10 with 100000 intervals.

You should get 1000000000.75

After you do that I will show you one last thing that is really cute.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#59 2013-07-24 14:00:26

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Yes. The correct answer should be 10^9.

Whats wrong with my code?


'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'
'Who are you to judge everything?' -Alokananda

#60 2013-07-24 14:03:24

bobbym
Administrator

Offline

Re: An Integral and the Computer

What did you get?


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#61 2013-07-24 14:11:10

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

1000000000.7500005


'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'
'Who are you to judge everything?' -Alokananda

#62 2013-07-24 14:26:05

bobbym
Administrator

Offline

Re: An Integral and the Computer

That is correct!

This is a plot of what the trapezoid rule is doing for n = 10:

Notice it sometimes went over and sometimes under. The second trapezoid is almost perfect.


Uploaded Images
View Image: 2013-07-23_210011.gif      


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#63 2013-07-24 14:54:31

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

What about post 58?

OK, see you later, gotta go to school

Last edited by Agnishom (2013-07-24 15:06:32)


'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'
'Who are you to judge everything?' -Alokananda

#64 2013-07-24 15:15:20

bobbym
Administrator

Offline

Re: An Integral and the Computer

Have a good day at school and study hard.

Post #62 was the cute thing. The program not only does the calculation but shows graphically what it did.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#65 2013-07-24 22:39:49

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Thanks. School was good.

Why is that error occuring?


'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'
'Who are you to judge everything?' -Alokananda

#66 2013-07-24 22:41:44

bobbym
Administrator

Offline

Re: An Integral and the Computer

What error? I do not understand.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#67 2013-07-24 22:46:06

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Read post 58 to 61


'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'
'Who are you to judge everything?' -Alokananda

#68 2013-07-24 22:47:39

bobbym
Administrator

Offline

Re: An Integral and the Computer

Hi;

It is possible there is a small problem with your code ( ever seen any code without bugs ?). But for the purposes of this discussion it worked well enough so I am happy.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#69 2013-07-24 22:56:57

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Ofcourse there is some problem. Tell me where it is


'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'
'Who are you to judge everything?' -Alokananda

#70 2013-07-25 00:42:27

bobbym
Administrator

Offline

Re: An Integral and the Computer

What do you get for this problem here with n = 3


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#71 2013-07-25 01:38:21

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Which problem? I am getting confused..


'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'
'Who are you to judge everything?' -Alokananda

#72 2013-07-25 01:39:51

bobbym
Administrator

Offline

Re: An Integral and the Computer

The one that guy from India with the beard posted.


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#73 2013-07-25 02:56:35

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Code:

>>> for n in xrange(1,21):
    integrate(f, 0, (3.141592653589793/4),n)

    
0.3926990816987245
0.19649262597124922
0.13907218235606786
0.12645766198987884
0.12509127461149278
0.12502021548220082
0.12501849991109948
0.12501848181618283
0.12501848174029692
0.12501848174018745
0.12501848174018715
0.12501848174018718
0.12501848174018754
0.12501848174018773
0.12501848174018718
0.12501848174018768
0.12501848174018726
0.12501848174018754
0.12501848174018723
0.1250184817401873

'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'
'Who are you to judge everything?' -Alokananda

#74 2013-07-25 03:05:47

bobbym
Administrator

Offline

Re: An Integral and the Computer

I am getting for n = 3, 0.15605651313635455


In mathematics, you don't understand things. You just get used to them.
I have the result, but I do not yet know how to get it.
All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

#75 2013-07-25 03:08:52

Agnishom
Real Member
Award: Wink Sherlock

Offline

Re: An Integral and the Computer

Why?

In that case, don't you think mine is better!


'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'
'Who are you to judge everything?' -Alokananda

Board footer

Powered by FluxBB