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' ]);

Setup

The function 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).

BEGIN_PGML
A solution to [`[@ $f->{f} @]`] is [`(x,y) =`] [___]{$f}
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.