01204472/การทดลองการคำนวณจำนวนจริง
หน้านี้เป็นรายละเอียดการทดลองเกี่ยวกับข้อจำกัดในการคำนวณด้วยจำนวนจริงบนคอมพิวเตอร์ ประกอบการเรียนวิชา 01204472
เนื้อหา
ขอบเขตของตัวเลข
1.1 ทดลองหาค่าต่ำสุดที่จำนวนจริงในภาษาที่ใช้สามารถเก็บได้ (ที่มากกว่า 0)
1.2 เนื่องจากรูปแบบในการเก็บจำนวนจริงจะเก็บหลักและเลขนัยสำคัญ ให้เขียนโปรแกรมเพื่อหาจำนวนหลักของเลขนัยสำคัญ (hint: สามารถปรับแก้จากโปรแกรมในข้อ 1.1 ได้ไม่ยากนัก)
1.3 จากคำตอบในข้อ 1.1 และ 1.2 ลองเทียบตารางในมาตรฐาน IEEE 754 ว่าการเก็บข้อมูลจำนวนจริงของภาษาที่ใช้เก็บด้วยรูปแบบใด
ทดลองประมาณค่า
ในการเรียนครั้งก่อนเราเห็นตัวอย่างของการทราบ derivative ของฟังก์ชันที่ต้องการหาค่าต่ำสุด อย่างไรก็ตาม ถ้าเราสามารถทำได้แค่คำนวณค่าฟังก์ชัน แต่เราต้องการใช้งานค่า derivative ที่จุดต่าง ๆ เราจะทำอย่างไร?
ให้ฟังก์ชัน และจำนวนจริง เราต้องการประมาณค่า
เราจะพิจารณาการประมาณค่าสองแบบ โดยทั้งคู่จะมีพารามิเตอร์ แทนความละเอียด
- แบบที่ 1 ประมาณด้วย
- แบบที่ 2 ประมาณด้วย
ในการทดลองสำหรับแต่ละฟังก์ชันต่อไปนี้ ให้วาดกราฟเปรียบเทียบความผิดพลาดของการประมาณแบบที่ 1 และแบบที่ 2 โดยให้เปลี่ยนตามค่า โดยมากให้ k มีค่าตั้งแต่ 1 ถึง 500 ก็น่าจะเห็นความแตกต่าง
- หมายเหตุ 1: ในการสร้างตัวแปร k อย่าลืมว่าต้องให้มีค่าเป็นจำนวนจริง โดยสั่ง k = arange(1.,500.,1) จากนั้นลองสั่ง 1/k เพื่อดูอาร์เรย์ของค่า ที่ได้
- หมายเหตุ 2: ใน pylab เมื่อต้องการลบกราฟ สั่ง clf()
2.1 ให้ ให้ประมาณค่าของ ที่ (สำหรับข้อนี้ คำตอบที่ถูกต้องคืออะไร?)
2.2 ให้ ให้ประมาณค่าของ ที่ (สำหรับข้อนี้ คำตอบที่ถูกต้องคืออะไร?)
2.3 ให้ ให้ประมาณค่าของ ที่ (สำหรับข้อนี้ คำตอบที่ถูกต้องคืออะไร?) สังเกตว่าเราคิดมุมเป็นหน่วยเรเดียล
2.4 ให้ ให้ประมาณค่าของ ที่ (สำหรับข้อนี้คำตอบที่ถูกต้องคืออะไร?)
ความละเอียดกับการประมาณค่า
2.5 (a) ใช้การประมาณค่าแบบที่ 2 กับฟังก์ชันจากข้อ 2.4 ให้ใช้ค่า k ระหว่าง 5000 ถึง 10000 (โดยอาจจะเพิ่มค่าทีละ 100) จากนั้นเขียนกราฟแสดง error
2.5 (b) ทำตามข้อ 2.5(a) แต่ให้ใช้ค่า k ระหว่าง 10000 ถึง 20000 ให้วาดกราฟในอีกรูปหนึ่งแยกกัน จากนั้นให้เปรียบเทียบลักษณะของกราฟทั้งสองเพื่อให้เห็นลักษณะการเปลี่ยนแปลงของค่า error
- หมายเหตุ เราจะสร้างรูปกราฟ (figure) ใหม่โดยสั่ง figure() เมื่อสั่งแล้ว figure ปัจจุบันจะย้ายไปอีกรูปกราฟหนึ่ง
2.6 ใช้การประมาณค่าแบบที่ 2 กับฟังก์ชันจากข้อ 2.4 ให้เพิ่มค่า ขึ้นเรื่อย (นั่นคือการเพิ่มความละเอียด) จากนั้นให้หาขอบเขตที่การเพิ่มค่า ทำให้เราสังเกตเห็น error ที่ไม่ได้เกิดจากอัลกอริทึม (error ถ้าพิจารณาจากกราฟ ให้อธิบายว่าส่วนใดคือ error ที่เกิดจากอัลกอริทึมที่ใช้ประมาณ อะไรไม่ใช่)
2.7 ใช้การประมาณค่าแบบที่ 2 กับฟังก์ชันจากข้อ 2.2 ให้เพิ่มค่า ขึ้นเรื่อย (นั่นคือการเพิ่มความละเอียด) จา� ... \n
Student Goes From Homeless to Harvard
Despite being abandoned to homelessness by her parents, Dawn Loggins worked as a high school custodian by day and studied hard by night to become the first person from her school to ever be admitted to Harvard.
[Student Goes From Homeless to Harvard]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]
13 Things You Should Do To Live Life Without Regrets
A study that was performed on elderly individuals a few years back, has shown that during old age, there are many people who regret the things they didnt have the courage to do as opposed to only a few who had regrets about the things theyve done.
[13 Things You Should Do To Live Life Without Regrets]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]
Reuse of Wastewater May Improve Drinking Water Supply
With recent advances in technology and design, treating municipal wastewater and reusing it for drinking water, irrigation, industry, and other applications could significantly increase the nations total available water resources, particularly in coastal areas facing water shortages, says a new report from the National Research Council.
[Reuse of Wastewater May Improve Drinking Water Supply]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]
Stop Using The Wrong Type of Intelligence
A man should hear a little music, read a little poetry, and see a fine picture every day of his life, in order that worldly cares may not obliterate the sense of the beautiful which God has implanted in the human soul. Johann Wolfgang von Goethe
[Stop Using The Wrong Type of Intelligence]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]
Googles Jolly Good Fellow on Inner Peace
Chade-Meng Tan (widely known as Meng) was among the earliest engineers to be hired at Google. When Google allowed engineers to spend 20% of their time pursuing their passion, Meng decided to spend his time on a cause dear to his heart: Launching a conspiracy to bring about world peace. Meng believes that world peace can be achieved -- but only if people cultivate the conditions for inner peace within themselves.
[Googles Jolly Good Fellow on Inner Peace]
[GoodvilleNews.com - good, positive news, inspirational stories, articles]