Grading 2nd order ODEs with constant coefficients (and real roots)


  • administrators

    This is written in pure Maple but hopefully you can see how this can be adapted for Maple T.A. I will try to find time to write this for Maple T.A. and post it below.

    First we create a second order differential equation with constant coefficients, then we use the Maple function dsolve and the DEtools package to get the complimentary function, the particular integral and the general solution.

    # second order linear differential equations with constant coefficients
    # real roots
    restart;
    ode:=diff(y(x),x,x)+3*diff(y(x),x)+2*y(x)=x^2;
    compFun:=subs({_C1=A,_C2=B},dsolve(lhs(ode)));
    partInt:=convert(DEtools[particularsol](ode,y(x)),trig);
    genSol:=subs({_C1=A,_C2=B},dsolve(ode));
    

    You can just check equivalence of the student's answer and the above expressions but this can cause problems with the coefficients in the complimentary function and the general solution. The standard approach to dealing with this is to run various checks to see if the student's solution is a solution in various cases, to make sure there are two coefficients and that the solutions are suitably general. i.e. not y(x)=0.

    Here's the grading code for the three expressions (again, this is in Maple and you will need to convert the variables to $ variables for Maple T.A.).

    compFunGrade:=evalb(
    evalb(convert(simplify(expand(simplify(subs(compFun,lhs(ode)), symbolic)), symbolic), expln) = 0)
    and
    subs(x=0,rhs(compFun))<>0
    and
    simplify(subs(x=0,rhs(compFun))/subs(x=1,rhs(compFun)),symbolic)<>0
    and
    nops(indets(rhs(genSol),name) minus {x})=2
    );
    
    partIntGrade:=evalb(
    evalb(convert(simplify(expand(simplify(subs(partInt,lhs(ode))-rhs(ode), symbolic)), symbolic), expln)=0)
    and
    subs(x=0,rhs(partInt))<>0
    );
    
    genSolGrade:=evalb(
    evalb(convert(simplify(expand(simplify(subs(genSol,lhs(ode))-rhs(ode), symbolic)), symbolic), expln) = 0)
    and
    subs(x=0,rhs(genSol))<>0
    and
    simplify(subs(x=0,rhs(genSol))/subs(x=1,rhs(genSol)),symbolic)<>0
    and
    nops(indets(rhs(genSol),name) minus {x})=2
    );

    The result of these should be true.


Log in to reply