Difference between revisions of "DomainRange1"

From WeBWorK_wiki
Jump to navigation Jump to search
(Hide link to non-PGML file on GitHub.)
(add historical tag and give links to newer problems.)
 
Line 1: Line 1:
  +
{{historical}}
  +
  +
<p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Algebra/DomainRange.html a newer version of this problem]</p>
  +
 
<h2>Domain and Range of a Function</h2>
 
<h2>Domain and Range of a Function</h2>
   

Latest revision as of 06:54, 18 July 2023

This article has been retained as a historical document. It is not up-to-date and the formatting may be lacking. Use the information herein with caution.

This problem has been replaced with a newer version of this problem

Domain and Range of a Function

Click to enlarge

This PG code shows how to evaluate answers that are inequalities which use different variables.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
  'PGstandard.pl',
  'MathObjects.pl',
  'contextInequalities.pl',
  'PGML.pl',
  'PGcourse.pl'
);

TEXT(beginproblem());

Initialization: We must load contextInequalities.pl.

$f = Compute('sqrt(x-4)');

Context('Inequalities-Only')->variables->are(x=>'Real');
Context()->flags->set(formatStudentAnswer=>'parsed');

$domain = Compute('x >= 4');

# the context needs to change for the range
Context('Inequalities-Only')->variables->are(y=>'Real');
Context()->flags->set(formatStudentAnswer=>'parsed');
$range  = Compute('y >= 0');

Setup: We specify the context in a way that requires students to enter their answer using inequalities and the variable x. If we had used Context("Inequalities") instead, then students would also be able to enter answers using interval notation. For more details, please see contextInequalities.pl

We use formatStudentAnswer=>'parsed' and Compute() so that the student's answer are left as fractions rather than reduced to decimals.

For the domain, since the variable is now y, we must reset the context and the variable so that students must enter the variable y in their answer.

BEGIN_PGML
Suppose [` f(x) = [$f] `].  Enter inequalities for the
domain and range of [` f `].

- Domain: [_______]{$domain}

- Range: [_________________]{$range}

[@ helpLink('inequalities') @]*
END_PGML

Main Text:

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

Solution:

Templates by Subject Area