Computer Literacy 1 / BMEEPAGG101

Illustrating implicit functions

Exercise:

  1. Draw a circle centred on the origin!
  2. PRACTICE: Draw a circle whose centre can be specified!
  3. PRACTICE: Draw an ellipse!

Prepraration

It is true for all three problems that x and y cannot be expressed from each other, and that several y values can be assigned to one x value and vice versa. To solve the problem, we first need to derive the formulas, which we can then enter into the Excel spreadsheet. The derivation is shown for the circle centred on the origin.

The equation of a circle centred on the origin:
  R² = x² + y²,
where R is the radius of the circle. We can observe that the circle can be parametrized by the central angle φ and the distance r between the origin and the point. Thus, we can also describe it in polar coordinate system:
  r(φ) = R.

In relation to φ you can now express x and y :
  x(φ) = r(φ) ⋅ cos(φ),
  y(φ) = r(φ) ⋅ sin(φ),   0 ≤ φ ≤ 2π
Since all points are now specifically the same distance from the origin, r(φ) is a constant and can be replaced by R.

HINT: The above relations apply not only to the circle, but also to any other function that is similarly parameterized by a distance from the origin and an angle. See: parametric mapping of the Cardioid curve.

The steps to solve the exercise:

  1. adding φ values uniformly between 0 and 2π
  2. adding r values for each φ (now constant R)
  3. calculating x and y from r and φ

Exercise 1: Circle centered on the origin

In the solution we need to take a cell for the parameter R, and then we need three columns: φ, x, y. We need to decide how many points we want to display, i.e. how many values of φ we want to add. Let this number now be n = 20.

How can we add values uniformly between 0 and 2π?
Suppose we want to divide the circle into n parts. One solution is to give a number to each point from 0 to (n-1) (thus dividing the circle into exactly n parts). Then express the angle associated with each point by its row number and n. One interval of division means 2π/n angles, so the i-th point will have the angle i⋅2π/n.

HINT: Why is the tw parentheses needed in PI()? Because every Excel function should be referred to with two parentheses after the function name. This is a special built-in Excel function that has no input parameters, so we don't write anything in the parentheses.

HINT: Why is @ needed in front of i? Since the new dynamic formulas in Excel, we can use the @ sign to indicate if we only need the range element in the row. Now we want to refer to the value of cell B5 in cell C5, so we need the @.

The COS() and SIN() Excel functions expect the angles to be in radians, so there is nothing else to do but substitute them into the x and y formulas.

All that's left is the illustration. We want to display the points in the x-y coordinate system, so we have calculated the x and y coordinates of each point.

The diagram has several problems: it is not circular and it is not closed. We can make the diagram proportional by scaling it. Change the height/width until the grid becomes square. Now the x and y divisions are equal. The other problem can be solved by inserting an extra row in the table, i.e. adding a point with the index n. This will have the same angle as point 0, thus closing the circle.

Exercise 2: Circle with arbitrary centre (practice exercise)

To solve this problem, another derivation is needed, since so far we have derived the formulae for the circle centred on the origin. General equation of the circle:
  R² = (x-xo)² + (y-yo)²,
where (xo,yo) are the coordinates of the centre of the circle.

If we offset each point of the circle by the coordinates of its centre, we again get a circle centered on the origin and the previous relations become true:
  x(φ) - xo = r(φ) ⋅ cos(φ),
  y(φ) - yo = r(φ) ⋅ sin(φ),   0 ≤ φ ≤ 2π

From here, and using that the radius remains constant:
  x(φ) = R ⋅ cos(φ) + xo,
  y(φ) = R ⋅ sin(φ) + yo,   0 ≤ φ ≤ 2π

The solution of the problem is similar to the previous one, the difference is that instead of one, there are 3 parameters: R, xo, yo.

HINT: If we want to solve this exercise in the same Excel document as the other one, but on a different tab, we cannot rename the cell corresponding to the radius value to rr again, because that name is already taken. We can't call it R2 either, because it is also taken, pointing to cell R2. You can use an absolute reference instead of a name, or you can call it "radius". Similarly, columns i and phi should be given a new name, or referred to by relative reference.

To double check, we can display the centre of the circle too.

Exercise 3: Ellipse (practice exercise)

To solve the problem, you need the formula for the ellipse. The formula can be found by searching the internet. The steps are similar to the above.