Logarithms

Laws of logarithms

Complete Code

Download file: Logarithms.pg

PG problem file

Explanation

DOCUMENT();

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

Preamble

These standard macros need to be loaded.
Context()->variables->are(x => 'Real', y => 'Real', z => 'Real');
Context()->variables->set(x => { limits => [ 2, 3 ] });
Context()->variables->set(y => { limits => [ 2, 3 ] });
Context()->variables->set(z => { limits => [ 2, 3 ] });

$a = random(20, 40);
$b = random(20, 40);
do { $c = random(20, 40); } until $c != $b;

# TeX
$answer = Compute("$a * ln(x) + $b * ln(y) - $c * ln(z)");

Context()->operators->undefine('/', '^', '**');
Context()->functions->undefine('sqrt');

Setup

Add the variables x, y, and z to the context and set their limits to be [2, 3] since logarithms are not defined on the default domain [-1, 1]. After defining $answer, undefine certain operators and functions so that students will have to give their answer in the desired form. Since the answer requires multiplication, students cannot be prevented from entering an answer such as ln(x*x*x...) instead of $a * ln(x). However, by choosing large values for $a, $b, $c such answers can be strongly discouraged. (Note that this can be done using Bizarro arithmetic and a custom answer checker.)

BEGIN_PGML
Using laws of logarithms, write the expression below using sums or differences
of logarithmic expressions which do not contain the logarithms of products,
quotients, or powers.

[``\ln\left(\frac{x^{[$a]} y^{[$b]}}{z^{[$c]}}\right) =``] [_]{$answer}{20}
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.