PREP 2014 Question Authoring - Archived

Multivariable functions

Multivariable functions

by Adam Graham-Squire -
Number of replies: 1
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.
In reply to Adam Graham-Squire

Re: Multivariable functions

by Gavin LaRose -

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');
If \(f(x,y) = $f\), then $BR
\(f_x(x,y) = \) \{ $fx->ans_rule() \}$BR
\(f_y(x,y) = \) \{ $fy->ans_rule() \}
ANS( $fx->cmp() );
ANS( $fy->cmp() );

There is some information about this in the problem techniques documentation:,