How do you define a multivariable function? And how do you take its partial derivatives? And where else could I find this information? I have been trying to figure out breakout exercise 2 from Day 2, and I can't seem to be able to figure it out or figure out where I can find code from someone else who has done something similar.
Hi Adam,
You can do this by adding an independent variable to the Context and then just defining a formula as you would expect:
Context("Numeric")->variables->add( y => 'Real' ); $f = Compute( "sin(x y)" ); $fx = $f->D('x'); $fy = $f->D('y'); Context()->texStrings; BEGIN_TEXT If \(f(x,y) = $f\), then $BR \(f_x(x,y) = \) \{ $fx->ans_rule() \}$BR \(f_y(x,y) = \) \{ $fy->ans_rule() \} END_TEXT Context()->normalStrings; ANS( $fx->cmp() ); ANS( $fy->cmp() );
There is some information about this in the problem techniques documentation: http://webwork.maa.org/wiki/DifferentiatingFormulas, http://webwork.maa.org/wiki/VariablesOtherThanX.
Gavin