## WeBWorK Main Forum

### answer contains derivatives and integrals ### answer contains derivatives and integrals

by Joel Trussell -
Number of replies: 3
A collage in ECE would like to ask the students to derive the differential equation for a simple circuit. The usual answer for this is something like that in the attached file. Is there a way the students can enter derivatives or indefinite integrals in their answer - such a way that it can be checked? ### Re: answer contains derivatives and integrals

by Michael Gage -
You could easily check the last question (with the values in the box).  We've had good luck checking purely symbolic (but more math related) questions which could probably handle questions b -- d.  (see image attached)

Possibly even question (a) could be handled but I would suggest that might be better suited to an essay question to be graded by hand.  ### Re: answer contains derivatives and integrals

by Joel Trussell -
I could handle all the symbolic variables except the operators. image attached. How do I insert images into the message window?

the code is
DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"parserFunction.pl",
"PGcourse.pl",
"PG.pl",
);

TEXT(beginproblem());

#############################
#  Setup

## required to use step function
step => {
class => 'Parser::Legacy::Numeric',
perl => 'Parser::Legacy::Numeric::do_step'
},
);
t=>"Real", C=>"Real", L=>"Real",  R=>"Real",  I=>"Real",  Vs=>"Real", w=>"Real",
V0=>"Real"
);

# Change tolerance to account for difference in Matlab and Webwork computations
# I don't know the problem yet

Context()->flags->set(
tolerance => 0.001,
tolType => "absolute",
);
parserFunction("u(t)" => "step(t)");

$answer = Formula("L")->reduce;$answer = Formula("1/C")->reduce;

$answer = Formula("R")->reduce;$answer = Formula("R*I + j*w*L*I - j*I/(w*C)")->reduce;
$answer = Formula("V0*exp(j*pi/3)")->reduce;$answer = Formula("V0*exp(j*pi/3)/(R +  j*w*L - j/(w*C))")->reduce;

#############################
#  Main text

Context()->texStrings;
BEGIN_TEXT
This is a test problem
$PAR \{image("RLC_Series_Circuit.png",height=>140, width=>270)\}$BR
Problem is related to Problem x.xx  in the text (for ECE303).
$PAR$PAR For the above circuit, with $$v_s(t) = V_0 cos(\omega t + \pi/3)$$ Volts, write the voltage loop equation in terms of the current $$i(t)$$, using the symbolic values $$R$$, $$L$$, $$C$$, $$v_s(t)$$.

$BR $$\Large{ v_s(t) = }$$ \{ ans_rule(10) \}$$\Large{ \frac{di(t)}{dt} }$$ + \{ ans_rule(10) \}$$\Large{ \int i(t) dt }$$ + \{ ans_rule(10) \}$$\Large{ i(t) }$$ \{ AnswerFormatHelp("formulas") \}$PAR Write the corresponding phasor-domain equation. Use upper case I for the phasor current $$\tilde{I}$$ and $$w$$ for the frequency $$\omega$$.

$BR $$Vs =$$ \{ ans_rule(40) \} \{ AnswerFormatHelp("formulas") \}$PAR Write the phasor representation of the voltage source $$v_s(t) = V_0 cos(\omega t + \pi/3)$$ Use Vs for the phasor $$\tilde{V}_s$$

$BR $$Vs =$$ \{ ans_rule(40) \} \{ AnswerFormatHelp("formulas") \}$PAR Using the phasor representation of the voltage source, solve the phasor equation to obtain an expression for the phasor current, I.

$BR $$I =$$ \{ ans_rule(40) \} \{ AnswerFormatHelp("formulas") \} END_TEXT Context()->normalStrings; ############################ # Answers$showPartialCorrectAnswers = 1;

ANS( $answer->cmp() ); ANS($answer->cmp() );
ANS( $answer->cmp() ); ANS($answer->cmp() );
ANS( $answer->cmp() ); ANS($answer->cmp() );

COMMENT("MathObject version.");

SOLUTION(EV3(<<'END_SOLUTION'));

END_SOLUTION

ENDDOCUMENT();  