Package testderiv %% Test the derivative program. Import "deriv". ==================================================== %% Simplify tests ==================================================== Let ShowSimplify(e). = Writeln[$(e), " = ", $(simplify e)]. %Let Execute Writeln["Simplify tests\n--------------"]. ShowSimplify constant(2) + constant(5). ShowSimplify constant(2) + constant(5) + constant(6). ShowSimplify xx + constant(0). ShowSimplify constant(0) + xx. Writeln. %Execute ==================================================== %% Substitute tests ==================================================== Let ShowSubst(a,e). = Writeln["substitute ", $(a), " for x in ", $(e), " yields ", $(substitute a e)]. %Let Execute Writeln["Substitute tests\n----------------"]. ShowSubst(constant(3), xx + xx). ShowSubst(xx + xx, xx + (constant 1)). Writeln. %Execute ==================================================== %% Deriv tests ==================================================== Let ShowDeriv(e). = Writeln["(", $(e), ")' = ", $ deriv(e)]. %Let Execute Writeln["Deriv tests\n----------"]. ShowDeriv constant(4) + xx. ShowDeriv xx + xx. %Execute %Package