CAS with Geogebra

or, What's my radius?

April 02, 2024 · John Peach

Geogebra is a great tool for working with geometric objects, but it also has a computer algebra system (CAS) built in. There are other more capable computer algebra systems such as wxMaxima and Wolfram Language, but this might work for solving a simple algebraic-geometry problem.

Here’s the problem to solve: A circle touches the function f(x)=xx3f(x) = x - x^3​ in two places, the origin and one other point. What’s the radius of the circle?

circle-problem
Figure 1.

Circle radius problem.

At the two points where the circle touches the function, lines perpendicular to the tangents and drawn from those two points will intersect at the center of the circle. What’s a tangent? Imagine a straight line that just touches the function at one point, and has the same slope that the function has at that point. To calculate the slope we need to find the derivative of the function.

The derivative

The derivative of a function is defined as f(x)f'(x) where

f(x)=limΔx0f(x+Δx)f(x)Δx.f'(x) = \lim_{\Delta x \rightarrow 0} \frac{f(x + \Delta x) - f(x)}{\Delta x}.

What this means is that you should choose some small number Δx\Delta x and calculate the value of the function at the point xx but shifted by Δx\Delta x, and then subtract the value of f(x)f(x), or the change in yy values. Divide by the difference in the xx values, which is Δx\Delta x to give the rise over the run, or the slope of the function at the point xx​.

derivative-calculation
Figure 2.

Calcluating the derivative.

Now, let the step Δx\Delta x shrink down to practically nothing and see what the rise over the run is for Δx0\Delta x \approx 0 to get the slope of the function at a point, which is also the derivative of the function. Let’s see how this works for the cubic function f(x)=xx3f(x) = x - x^3.

f(x)=limΔx0((x+Δx)(x+Δx)3)(xx3)Δx=limΔx0((x+Δx)(x3+3x2Δx+3xΔx2+Δx3))(xx3)Δx=limΔx0((Δx)(3x2Δx+3xΔx2+Δx3))Δx=limΔx013x23xΔxΔx2=13x2.\begin{aligned} f'(x) &= \lim_{\Delta x \rightarrow 0} \frac{((x + \Delta x) - (x + \Delta x)^3) - (x - x^3)}{\Delta x} \\ &= \lim_{\Delta x \rightarrow 0} \frac{((x + \Delta x) - (x^3 + 3x^2 \Delta x + 3x \Delta x^2 + \Delta x^3)) - (x - x^3)}{\Delta x} \\ &= \lim_{\Delta x \rightarrow 0} \frac{((\Delta x) - (3x^2 \Delta x + 3x \Delta x^2 + \Delta x^3))}{\Delta x} \\ &= \lim_{\Delta x \rightarrow 0} 1 - 3x^2 - 3x \Delta x - \Delta x^2 \\ &= 1 - 3x^2. \end{aligned}

In the first line, we just substituted x+Δxx + \Delta x for xx in the function, subtracted f(x)f(x) and divided the whole thing by Δx\Delta x. The second line is the same, but with the cubic term expanded, and in the third line we subtract f(x)f(x) from f(x+Δx)f(x + \Delta x) which cancels out the term xx3x - x^3 everywhere, leaving only terms that have Δx\Delta x in them.

In the fourth line, we divide by Δx\Delta x which leaves two terms without Δx\Delta x, and two with. Finally, taking the limit as Δx\Delta x gets close to zero, the last two terms become zero leaving only f(x)=13x2f'(x) = 1 - 3x^2.

If you want Geogebra to do the expansion of (x+Δx)3(x + \Delta x)^3, use Expand((x+d)^3) and remember that dd is being used in place of Δx\Delta x.

In Geogebra, define the function f(x)f(x) which draws the green curve. Let the Geogebra CAS calculate the derivative, f(x)f'(x) which it calls g(x)g(x)​ and draws as the orange curve. At the origin, f(0)=0,f(0) = 0, f(0)=1f'(0) = 1 and the orange curve reaches a maximum of one at that point. This means that a line tangent to f(x)f(x) at the origin has a slope of one, so for every unit change along the xx-axis there’s an equal unit rise along the yy-axis, which is shown in the light gray dotted line.

derivative-and-slope
Figure 3.

The function, derivative, tangent and perpendicular.

Two lines are perpendicular to each other if their slopes are negative inverses of each other. We often use the letter mm to denote the slope of a line, so the tangent at f(0)f(0) has slope m=1m = 1, and a perpendicular will have slope m=11=1m = - \frac{1}{1} = -1​. The perpendicular through the origin is shown in the darker dotted line.

Defining the problem

The center of the circle is somewhere on the line y=xy = -x and the distance from the center to the two points of contact with the function f=xx3f = x - x^3 is the radius, rr. We need to find the point GG that represents the second point on the circle and the function.

circle-center
Figure 4.

The center of the circle.

Since FF is on the line y=xy = -x, then the coordinates of FF are (xF,xF)(x_F,-x_F) and distance from FF to the origin is r=xF2+(xF)2=2xFr = \sqrt{x_F^2 + (-x_F)^2} = \sqrt{2}x_F. The point GG has coordinates (xG,xGxG3)(x_G, x_G - x_G^3) and the slope of the perpendicular through GG is

m=113xG2.m = -\frac{1}{1 - 3x_G^2}.

The equation of a line through GG with slope mm is

(yyG)=m(xxG)y=m(xxG)+yG.\begin{aligned} (y-y_G) &= m(x - x_G) \\ y &= m(x - x_G) + y_G. \\ \end{aligned}

Substituting for the slope mm,

y=113xG2(xxG)+yGy = -\frac{1}{1 - 3x_G^2}(x - x_G) + y_G

and then for yGy_G,

y=113xG2(xxG)+(xG3xG2).y = -\frac{1}{1 - 3x_G^2}(x - x_G) + (x_G - 3x_G^2).

At the point of intersection yy equals yFy_F which is xF-x_F​ so the equation becomes

xF=113xG2(xFxG)+(xG3xG2).-x_F = -\frac{1}{1 - 3x_G^2}(x_F - x_G) + (x_G - 3x_G^2).

Since there are two unknowns, xFx_F and xGx_G we’ll need another equation, which is the equation for the radius. Using the Pythagorean theorem,

r=2xF=(xFxG)2+(yFyG)2=(xFxG)2+(xF(xG3xG2))2.\begin{aligned} r &= \sqrt{2}x_F = \sqrt{(x_F - x_G)^2 + (y_F - y_G)^2} \\ &= \sqrt{(x_F - x_G)^2 + (-x_F - (x_G - 3x_G^2))^2}. \end{aligned}

Squaring both sides,

2xF2=(xFxG)2+(xF(xG3xG2))2.2x_F^2 = (x_F - x_G)^2 + (-x_F - (x_G - 3x_G^2))^2.

Now we have two equations and two unknowns, so we should be able to find a solution. Finding a closed form, or analytic solution is probably not possible, so we may have to settle for a numerical approximation.

The Geogebra solution

To solve the two equations simultaneously, enter the following in Geogebra:

solution-at-origin
Figure 5.

The Geogebra solution.

and it gives a solution where both xFx_F and xGx_G are at the origin. In this case, the radius is zero, but obviously there’s another solution where xG>xFx_G > x_F.

The wxMaxima solution

The Geogebra CAS wasn’t able to provide a second solution for the point GG, but with a bit of rearrangement of the equations, wxMaxima found a solution for xFx_F. Besides the cubic equation f(x)f(x) and the derivative f(x)=df(x)f'(x) = df(x), the equation for a line perpendicular to ff at any point x0x_0 can be defined as

L(x,x0)=1df(x0)(xx0)+f(x0)L(x,x_0) = -\frac{1}{df(x_0)}(x-x_0) + f(x_0)

which is the y=m(xx0)+y0y = m(x-x_0) + y_0 form for a line. With this, we can define the line through the origin as L1(x)=L(x,0)L_1(x) = L(x,0) which intersects the line through the point GG at the point FF. The distances from FF to the origin and FF to GG are the radius rr of the circle which we can define as

d1(x0)=x02+L1(x0)2d2(x0,x1)=(x0x1)2+(L1(x0)f(x1))2.\begin{aligned} d_1(x_0) &= x_0^2 + L_1(x_0)^2 \\ d_2(x_0,x_1) &= (x_0 - x_1)^2 + (L_1(x_0) - f(x_1))^2. \end{aligned}

In both, we didn’t take square roots but will require that they are equal (and equal to r2r^2). For d1d_1, the distance is from the point x0x_0 to the origin, so we’re effectively subtracting 00 from both the xx and yy terms. In the second equation, d2d_2 is the distance from FF to some point GG on the cubic function. The coordinates of FF are (x0,L1(x0))(x_0,L_1(x_0)) and the coordinates for GG are (x1,f(x1))(x_1, f(x_1)).

Entering these equations into wxMaxima and then asking for a solution gives this result:

maxima-solution
Figure 6.

The wxMaxima solution.

There are two real roots to the problem from symmetry because the circle could have been flipped about the line y=xy=x, which is why xFx_F is shown as a negative number here. Numerically, xF0.4745772664643349x_F \approx 0.4745772664643349, and the radius of the circle is r=2xF0.6711536066278128r = \sqrt{2}x_F \approx 0.6711536066278128​.

So, the Geogebra CAS wasn’t able to find two solutions, but the wxMaxima CAS found xFx_F. Notice that the solution for xGx_G contains %i\%i, meaning that the point lies in the complex plane. Since the equation is a high order polynomial and there are only three real solutions, we should expect the remaining solutions to be complex. (In fact, there are four real solutions because the point at the origin is included in both the positive and negative solutions for xFx_F.)

We’ll leave this problem here, but you could continue the exploration by finding the area of the circle, and the solution for xGx_G.

curiosity-killed-cats

Software

Image credits