--- loncom/homework/functionplotresponse.pm 2010/11/07 12:28:28 1.27 +++ loncom/homework/functionplotresponse.pm 2010/11/07 13:15:28 1.28 @@ -1,7 +1,7 @@ # LearningOnline Network with CAPA # option list style responses # -# $Id: functionplotresponse.pm,v 1.27 2010/11/07 12:28:28 www Exp $ +# $Id: functionplotresponse.pm,v 1.28 2010/11/07 13:15:28 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -591,15 +591,19 @@ sub populate_arrays { $xiold=$xi; # Function value $Apache::functionplotresponse::func[$xi]=&cubic_hermite($t,@yparms); +# Chain rule # dy/dx=dy/dt/(dx/dt) my $dxdt=&ddt_cubic_hermite($t,@xparms); if ($dxdt) { $Apache::functionplotresponse::dfuncdx[$xi]=&ddt_cubic_hermite($t,@yparms)/$dxdt; } -# d^2y/dx^2 +# Faa di Bruno +# d^2y/dx^2=(d^2y/dt^2)/(dx/dt)^2+(dy/dt)/(d^2x/dt^2) my $d2xdt2=&d2dt2_cubic_hermite($t,@xparms); - if ($d2xdt2) { - $Apache::functionplotresponse::d2funcdx2[$xi]=&d2dt2_cubic_hermite($t,@yparms)/$d2xdt2; + if (($dxdt) && ($d2xdt2)) { + $Apache::functionplotresponse::d2funcdx2[$xi]= + &d2dt2_cubic_hermite($t,@yparms)/($dxdt*$dxdt) + +&ddt_cubic_hermite($t,@yparms)/$d2xdt2; } } }