## PREP 2014 Question Authoring - Archived

by Joel Trussell -
Number of replies: 1
In electrical engineering, we usually require answers involving sinusoidal functions to be written as a cosine with phase, e.g, v(t) = A*cos(2*pi*F*t + phi). Of course, the answer a*cos(2*pi*F*t) + b*sin(2*pi*F*t) will give the same numerical result (for proper a and b). Can I force the form of the answer to be in the cosine with phase form? I realize the I could ask specifically for the magnitude, frequency and phase, but for solutions of DE's with decaying exponential envelopes, this gives more information than I wish.

### Re: answer in required form

by Paul Pearson -
Hi Joel,

Your question is on stuff that we will cover in detail in the next two weeks.  Yes, you can do things like disable (or undefine or redefine) certain functions in webwork.  One way to disable a function is described on the wiki

http://webwork.maa.org/wiki/DisableFunctions

For example, you can disable the absolute value and the square root using

Context()->functions->disable("abs","sqrt");

In your case, you would probably want to disable sine, tangent, and all the co- functions except for cosine, which could be accomplished with

###  begin code snippet

Context("Numeric")->variables->are(t=>"Real");
Context()->functions->disable("sin","tan","csc","sec","cot");

$A = ??; # replace ?? by some value$F = ??; # replace ?? by some value
$phi = ??; # replace ?? by some value$answer = Compute("$A * cos(2*pi*$F * t + \$phi)");

### end code snippet

If you write a question like this, make sure to include instructions for the students in the text of the problem that says something like "Enter your answer using a single cosine function and no other trig functions." or "Enter your answer in the form $$A \cos(\omega t + \phi)$$ for some constants $$A$$, $$\omega$$, and $$\phi$$."

Best regards,

Paul Pearson