Answer is a Solution to an Equation

The answer is a solution to an equation.

Complete Code

Download file: AnswerIsSolutionToEquation.pg

POD for Macro Files

PG problem file

Explanation

DOCUMENT();

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

Preamble

We need to include the macros file parserSolutionFor.pl

Context('Vector')->variables->are(x => 'Real', y => 'Real');

$f = SolutionFor("x^2 = cos(y)", "(1,0)");
#$f = SolutionFor("x^2 - y = 0", [ 2, 4 ]);
#$f = SolutionFor("x^2 - y = 0", Point(4, 2), vars => [ 'y', 'x' ]);

BEGIN_PGML
A solution to [`[@ $f->{f} @]`] is [`(x,y) =`] [___]{$f}
END_PGML

ENDDOCUMENT();

Setup

The routine SolutionFor(‘equation’,point,options) takes an equation, a point that satisfies that equation, and options such as vars=>['y','x'] in case you want to change the order in which the variables appear in order pairs (the default is lexicographic ordering of the variables). section = statement