Implicit Function as an Equation

An equation implicitly defining a function

Complete Code

Download file: EquationImplicitFunction.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

loadMacros(
    'PGstandard.pl',             'PGML.pl',
    'parserImplicitEquation.pl', 'PGcourse.pl'
);

Preamble

The macro parserImplicitEquation.pl allows the entry of equations.

Context('ImplicitEquation');
Context()->{error}{msg}{"Can't find any solutions to your equation"} = ' ';
Context()->{error}{msg}{"Can't generate enough valid points for comparison"} =
    ' ';

Context()->variables->set(
    x => { limits => [ -6, 11 ] },
    y => { limits => [ -6, 11 ] },
);

$a = random(1, 5);
$b = random(1, 5);
$r = random(2, 5);
$p = Compute("($a,$b)");

$answer = ImplicitEquation(
    "(x-$a)^2 + (y-$b)^2 = $r^2",
    solutions => [
        [ $a,                    $b + $r ],
        [ $a,                    $b - $r ],
        [ $a + $r,               $b ],
        [ $a - $r,               $b ],
        [ $a + $r * sqrt(2) / 2, $b + $r * sqrt(2) / 2 ],
    ]
);

Setup

Some error messages are prevented by redefining them to be a blank string ’ ’ (notice the space). Since the circle defined by the implicit equation in this problem will always be contained in a rectangle with two opposite corners at the points (-4, -4) and (10, 10), the limits for the variables x and y are set to to contain this rectangle. The ImplicitEquation object allows any number of solutions to be specified. Specifying additional solutions should improve the accuracy of the answer evaluator.

Note that if the equation is linear, for example of the form x = 3, 4x + 3y = 12, or 4x + 3y + 5z = 21, then the parserImplicitPlane.pl macro should be used instead.

BEGIN_PGML
Enter an equation for a circle in the [`xy`]-plane of radius [`[$r]`] centered
at [`[$p]`].

[_]{$answer}{25}
END_PGML

Statement

This is the problem statement in PGML.
BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();

Solution

A solution should be provided here.