# SolutionForEquation1

## Answer is Any Solution For an Equation

Click to enlarge

This PG code shows how to check whether the student's answer is a solution to an equation.

PG problem file Explanation

Problem tagging:

```DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"parserSolutionFor.pl",
);

TEXT(beginproblem());
```

Initialization: We must load `parserSolutionFor.pl`.

```Context("Vector");

\$r = random(3,6,1);

\$answer = SolutionFor("x^2+y^2+z^2=\$r^2", [\$r,0,0] );
```

Setup: We use `SolutionFor(equation, point)` to define this MathObject. For more details and options, see the POD documentation

```Context()->texStrings;
BEGIN_TEXT
A solution to the equation \( \$answer->{f} \)
is \( (x,y,z) = \)
\{ ans_rule(20) \}
END_TEXT
Context()->normalStrings;
```

Main Text: To print the formula in the MathObject, we use `->f`.

```\$showPartialCorrectAnswers = 1;

```

```Context()->texStrings;
BEGIN_SOLUTION
\${PAR}SOLUTION:\${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();
```

Solution: