Definice krokování derivace
(Na horní liště zvolte Kernel -> Evaluation -> Evaluate Notebook)

wasSpellCheckOn = Head[General::spell1] =!= $Off;

Off[General::spell1]

Clear[d];

Usage messages

WalkD::usage  =  "WalkD[expression, x] prints each of the steps \
in finding the derivative of the expression with respect to x, using d to \
represent differentiation. It prints the differentiation rule that is used at \
each step. The function outputs D[f, x].";

Function definitions

\(\(SpecificRules = {d[x_, x_] :> 1, 
          d[f_[x_], x_] :> ∂\_x f[x], 
          d[a_\^x_, x_] :> ∂\_x a\^x /; 
              FreeQ[a, x]};\)\)

ConstantRule = 
        d[c_, x_] :> 0 /; FreeQ[c, x];

The rule d[x_, x_] is repeated intentionally.

\(\(PowerRule = {d[x_, x_] :> 1, 
          d[x_\^a_, x_] :> 
            a\ x\^\(a - 1\) /; FreeQ[a, x]};\)\)

ProductRule = 
        d[f_ g_, x_] :> d[f, x] g + f d[g, x];

\(\(QuotientRule = 
        d[f_\/g_, 
            x_] :> \(d[f, x]\ g - f\ d[g, x]\)\/g\^2;\)\)

InverseFunctionRule=d[(f^((-1)))[x],x]:>(1/(f'[(f^((-1)))[x]]));

\(\(ChainRule = {d[f_\^a_, x_] :> 
            a\ f\^\(a - 1\)\ d[f, x] /; FreeQ[a, x], 
          d[a_\^f_, x_] :> Log[a]\ a\^f\ d[f, x] /; FreeQ[a, x], 
          d[f_[g_], 
              x_] :> \((∂\_x f[x] /. x -> g)\)\ d[
                g, x], d[f_\^g_, x_] :> 
            f\^g\ d[g\ Log[f], x]};\)\)

Drop the specific rules for generic cases.

Apply specific rules last when applying all at once.

Rule sets for applying the rules individually.

ListRules  =  ToExpression[RuleNames];

\(\(PrintRules\  := \ 
        CellPrint[
          Cell[BoxData[
              GridBox[Transpose[{
	
                    Prepend[\({"GeneralRules =" <> #1, \ ##2} &\)\  @@ \ 
                        Map["" <> \ # &, 
                          RuleNames], 
						\ "AllRules     = SpecificRules + GeneralRules"]}], 
	
                ColumnAlignments -> "", 
	
                RowSpacings -> {2, 
                    0.8}]], \ "Output"]];\)\)

\(WalkD[f_, x_] := 
      Module[{derivative}, 
        derivative = d[f, x]; 
		displayStart[
          derivative]; 
		While[\(! \((FreeQ[derivative, 
                d])\)\), 
			oldderivative = derivative; 
          k = 0; 
			While[
            oldderivative == 
              derivative, 
				\(k++\); 
				derivative = 
              derivative /. 
                ListRules[[k]]]; 
          displayRuleUsed[
            RuleNames[[
              k]]]; 
			displayDerivative[
            derivative]]; 
		∂\_x f]\)

\(RunD[f_, x_] := 
      Module[{derivative}, 
		derivative = d[f, x]; 
		displayStart[
          derivative]; 
        While[\(\(\)\(! \((FreeQ[derivative, d])\)\)\), 
          derivative = derivative /. AllRules; 
			displayDerivative[
            derivative]]; ∂\_x f]\)

\(displayStart[expr_]\  := 
	
      StylePrint[
        expr, "Output", 
			CellFrame -> {{0, 0}, {0, 
              3}}, 
			Background\  -> 
          RGBColor[0.8, \ 1. , \ 
            0.8], 
			CellGroupingRules -> "OutputGrouping", 
			CellMargins\  -> \ {{Inherited, \ Inherited}, {0, 
              Inherited}}, 
		CellEditDuplicate -> 
          False, 
		FontWeight -> Bold]\)

\(displayRuleUsed[expr_String]\  := 
	
      CellPrint[
        Cell[BoxData[expr], \ "Output", 
			Background\  -> 
            RGBColor[0.8, \ 1. , \ 0.8], \ 
          FontColor\  -> \ 
            RGBColor[0.6, \ 0, \ 
              0.6], 
			FontSlant\  -> \ "Italic", 
			\ \ CellFrame -> \ 
            False, 
				CellMargins -> {{Inherited, Inherited}, {0, 
                0}}, CellFrameMargins\  -> \ {{100, \ Inherited}, {0, \ 
                0}}, 
		CellEditDuplicate -> 
            False, 
		FontWeight -> Bold]]\)

\(displayDerivative[expr_] := 
	
      CellPrint[
        Cell[BoxData[
            RowBox[{InterpretationBox["=", Sequence[]], "    ", 
                MakeBoxes[expr, \ 
                  StandardForm]\ }]], \ "Output", 
			Background\  -> RGBColor[0.8, \ 1. , \ 0.8], \ 
          Evaluatable\  -> 
            False, 
				CellMargins -> {{Inherited, Inherited}, {0, 
                0}}, CellFrame -> False, 
		CellEditDuplicate -> 
            False, 
		FontWeight -> Bold]]\)

If[wasSpellCheckOn, On[General::spell1]]

Derivace

\(Př : \ 
        vypočítejte\ derivaci\ y = \(1 + sin \((x)\)\)\/\(1 - sin \((x)\)\)\)

D[((1 + Sin[x])/(1 - Sin[x])), x]

\(Výsledek\ \(cos \((x)\)\)\/\(1 - sin \((x)\)\) + \(cos \((x)\)\ \((1 + sin \((x)\))\)\)\/\((1 - sin \((x)\))\)\^2\ se\ dá\ ještě\ zjednodušit\)

Simplify[%] // TraditionalForm

Derivace krok po kroku

WalkD[((1 + Sin[x])/(1 - Sin[x])), x]

Simplify[%] // TraditionalForm

Funkce WalkD tedy zajistí výpočet derivace, \(přičemž\ zobrazí\ jednotlivé\ kroky\ a\ úpravy\), podle kterých postupovala .  Funkce RunD pracuje zcela stejně, ale nezobrazuje úpravy, podle kterých postupovala.