Showing posts with label maths. Show all posts
Showing posts with label maths. Show all posts

Thursday, January 9, 2025

Visualisation of Irrational nature of Pi


Visualisation of Irrational nature of Pi

Here’s a corrected version of the HTML/JavaScript:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Visualization of π</title>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background: black;
        }
        canvas {
            display: block;
        }
    </style>
</head>
<body>
    <canvas id="animationCanvas"></canvas>

    <script>
        const canvas = document.getElementById('animationCanvas');
        const ctx = canvas.getContext('2d');

        // Resize canvas to fill the window
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;

        const centerX = canvas.width / 2;
        const centerY = canvas.height / 2;
        const radius = Math.min(centerX, centerY) * 0.4;

        let theta = 0; // Initialize theta

        // Function to calculate e^(i*angle)
        function expComplex(angle) {
            return {
                real: Math.cos(angle),
                imag: Math.sin(angle)
            };
        }

        function z(theta) {
            const z1 = expComplex(theta);
            const z2 = expComplex(Math.PI * theta);
            return {
                real: z1.real + z2.real,
                imag: z1.imag + z2.imag
            };
        }

        function drawFrame() {
            ctx.clearRect(0, 0, canvas.width, canvas.height);

            const points = [];
            for (let i = 0; i < 1000; i++) {
                const angle = (i / 1000) * theta;
                const { real, imag } = z(angle);
                points.push({
                    x: centerX + real * radius,
                    y: centerY + imag * radius
                });
            }

            // Draw the path
            ctx.beginPath();
            ctx.moveTo(points[0].x, points[0].y);
            points.forEach(point => ctx.lineTo(point.x, point.y));
            ctx.strokeStyle = 'white';
            ctx.lineWidth = 1;
            ctx.stroke();

            // Draw the current point
            const { real, imag } = z(theta);
            ctx.beginPath();
            ctx.arc(centerX + real * radius, centerY + imag * radius, 5, 0, 2 * Math.PI);
            ctx.fillStyle = 'red';
            ctx.fill();
        }

        function animate() {
            theta += 0.02; // Increment theta for animation
            drawFrame();
            requestAnimationFrame(animate);
        }

        // Start animation
        animate();

        // Resize canvas dynamically
        window.addEventListener('resize', () => {
            canvas.width = window.innerWidth;
            canvas.height = window.innerHeight;
        });
    </script>
</body>
</html>

Explanation

  1. Complex Arithmetic Simulation:

    • The function expComplex computes eiθe^{i\theta} using trigonometric functions (cos and sin).
    • The z function combines eθie^{\theta i} and eθπie^{\theta \pi i} by summing their real and imaginary parts.
  2. Dynamic Drawing:

    • The path updates with 1000 points as theta increases, creating a dynamic pattern.
  3. Compatibility:

    • Ensures smooth animations with requestAnimationFrame.

Visualization of π

This animation visualizes the formula:

z(θ) = eθi + eθπi

It represents the sum of two complex exponentials, creating a fascinating pattern in the complex plane.

Copy this code into an .html file and open it in your browser. It should now display the intended animated visualization!

Thursday, July 16, 2020

Perfect Numbers

Perfect numbers

Any positive integer that is equal to the sum of its distinct proper factors (factors other than the number itself).
Example: 6 (proper factors: 1,2,3) is a Perfect number because 1+2+3=6.
Example: 28 (proper factors: 1,2,4,7,14) is also a Perfect number, because 1+2+4+7+14=28.
Euclid proved that 2n-1(2n-1) is an even perfect number when 2n-1 is a Mersenne prime. These are now called Euclid numbers and Euler proved that all even Perfect numbers are of this form for some positive prime number n. Thus, 6, 28, 496 are Perfect and correspond to values of 3, 7, and 31 for 2n-1 in the formula.
This table shows the results for n=1 to 13 which include the first five Perfect numbers:
n2n-12n-1(2n-1)Perfect?Comment
111Non is not prime
236Yesn is prime, 2n-1 is prime
3728Yesn is prime, 2n-1 is prime
415120Non is not prime
531496Yesn is prime, 2n-1 is prime
6632016Non is not prime
71278128Yesn is prime, 2n-1 is prime
8 to 10......Nonot prime
1120472096128Non is prime, but 2n-1 is not prime
1240958386560Non is not prime
13819133550336Yesn is prime, 2n-1 is prime
Whether there are infinitely many even Perfect numbers or any odd perfect numbers remain unsolved questions.

Thursday, July 9, 2020

Important facts about Trapezoid or Trapezium

A trapezoid is a 4-sided flat shape with straight sides that has a pair of opposite sides parallel (marked with arrows below):

trapezoid Isosceles trapezoid
Trapezoid Isosceles Trapezoid

A trapezoid:

right arrowhas a pair of parallel sides
right arrow

is an isosceles trapezoid when it has equal angles from a parallel side

right arrowis called a "trapezium" in the UK (see below)

 

trapezoid base leg and altitude

The parallel sides are the "bases"

The other two sides are the "legs"

The distance (at right angles) from one base to the other is called the "altitude"

Area of a Trapezoid

trapezoid a, b, h 

The Area is the average of the two base lengths times the altitude:

Area = a+b2 × h

Example: A trapezoid's two bases are 6 m and 4m, and it is 3m high. What is its Area?

Area  =  6 m + 4 m2 × 3 m  =  5 m × 3 m  =  15 m2

The Area of Polygon by Drawing tool is helpful when you can draw your Trapezoid.

Perimeter of a Trapezoid

The Perimeter is the distance around the edges.

trapezoid perimeter a+b+c+d 

The Perimeter is the sum of all side lengths:

Perimeter = a+b+c+d

Example: A trapezoid has side lengths of 5 cm, 12 cm, 4 cm and 15 cm, what is its Perimeter?

Perimeter = 5 cm + 12 cm + 4 cm + 15 cm = 36 cm

Median of a Trapezoid

trapezoid median half-way between a and b 

The median (also called a midline or midsegment) is a line segment half-way between the two bases.

The median's length is the average of the two base lengths:

m = a+b2

You can calculate the area when you know the median, it is just the median times the height:

Area = mh

Trapezium

trapezium (UK: trapezoid) is a quadrilateral with NO parallel sides.

The US and UK have their definitions swapped over, like this:

 TrapezoidTrapezium
US:a pair of parallel sidesNO parallel sides
UK:NO parallel sidesa pair of parallel sides

Sunday, July 5, 2020

Average word problems with solution Grade 6 and Grade 7

Solutions

Problem 1 :

A student was asked to find the arithmetic mean of the numbers 3, 11, 7, 9, 5, 3, 8, 19, 17, 21, 14 and x. He found the mean to be 12. What should be the number in place of x ?    

Solution : 

Given : Average of 3, 11, 7, 9, 5, 3, 8, 19, 17, 21, 14 and x is 12. 

That is,

Sum of all the given numbers / number of numbers  =  12

(3 + 11 + 7 + 9 + 5 + 3 + 8 + 19 + 17 + 21 + 14 + x) / 12  =  12

(117 + x) / 12  =  12

Multiply both sides by 12. 

(117 + x)  =  12 ⋅ 12

117 + x  =  144

Subtract 117 from both sides. 

x  =  27

So, the number should be in the place of 'x' is 27. 

Problem 2 :

The average age of 30 kids is 9 years. If the teacher's age is included, the average age becomes 10 years. Find the teacher's age.   

Solution : 

Given : The average age of 30 kids is 9 years.

That is, 

Total age of 30 kids / 30  =  9

Multiply both sides by 30. 

Total age of 30 kids  =  9 ⋅ 30

Total age of 30 kids  =  270

Given : If the teacher's age is included, the average age becomes 10 years

That is, 

(Total age of 30 kids  + Age of the teacher) / 31  =  10

(270  + Age of the teacher) / 31  =  10

Multiply both sides by 31. 

270  + Age of the teacher  =  10 ⋅ 31

270  + Age of the teacher  =  310

Subtract 270 from both sides.

Age of the teacher  =  40 years

Problem 3 :

The average of 6 numbers is 8. What is the 7th number , so that the average becomes 10 ?   

Solution : 

Given : The average 6 numbers is 8.

That is, 

Sum of 6 numbers / 6  =  8

Multiply both sides by 6. 

Sum of 6 numbers  =  8 ⋅ 6

Sum of 6 numbers  =  48

Given : If the 7th number is included, the average becomes 10. 

That is, 

(Sum of 6 numbers  + 7th number) / 7  =  10

(48  + 7th number) / 7  =  10

Multiply both sides by 7. 

48  + 7th number  =  10 ⋅ 7

48 + 7th number  =  70

Subtract 48 from both sides.

7th number  =  22

Problem 4 :

David's average score in the last 9 tests is 80. What should be his score in his next test, so that his average score will be 82 ?   

Solution : 

Given : The average score of 9 tests is 80.

That is, 

Sum of scores in 9 tests / 9  =  80

Multiply both sides by 9. 

Sum of scores in 9 tests  =  80 ⋅ 9

Sum of scores in 9 tests  =  720

Let "x" be his score in his next test. 

Given : Average score of 10 tests is 82.

Then, we have, 

(Sum of scores in 9 tests  + x) / 10  =  82

(720  + x) / 10  =  82

Multiply both sides by 10. 

720 + x  =  82 ⋅ 10

720 + x  =  820

Subtract 720 from both sides.

x  =  100

So, David score in the next test should be 100. 

Problem 5 :

In Kevin's opinion, his weight is greater than 65 kg but less than 72 kg. His brother does not agree with Kevin and he thinks that Kevin's weight is greater than 60 kg but less than 70 kg. His mother's view is that his weight is less than 68 kg. If all of them are correct in their estimation, what is the average of different probable weights of Kevin ?   

Solution : 

Let Kevin's weight be "x" kg.

According to Kevin, we have

65 < x < 72

According to Kevin's brother, we have

60 < x < 70

According to Kevin's mother, we have

< 68

The values of 'x' which satisfy all the above inequalities are 66 and 67. 

So, the different probable weights of Kevin are 66 kg and 67 kg. 

Average of 66 and 67  =  (66 + 67) / 2

Average of 66 and 67  =  133 / 2

Average of 66 and 67  =  66.5

So, the average of different probable weights of Kevin is 66.5 kg.