lib/integral.js
function(expr, context, subIntegral) {
      if(expr.type === 'FunctionNode' && expr.args[0].equals(context.variable)) {
        switch(expr.name) {
          case "sin":
            return new OperatorNode('-', 'unaryMinus', [
              new FunctionNode("cos", [context.variable])
            ]);
          case "cos":
            return new FunctionNode("sin", [context.variable]);
          case "tan":
            //log(abs(sec(x)))
            return new FunctionNode('log', [
              new FunctionNode('abs', [
                new FunctionNode('sec', [context.variable])
              ])
            ]);
          case "sec":
            //log(abs(sec(x) + tan(x)))
            return new FunctionNode('log', [
              new FunctionNode('abs', [
                new OperatorNode('+', 'add', [
                  new FunctionNode('sec', [context.variable]),
                  new FunctionNode('tan', [context.variable])
                ])
              ])
            ]);
          case "csc":
            //log(abs(sec(x) + tan(x)))
            return new FunctionNode('log', [
              new FunctionNode('abs', [
                new OperatorNode('-', 'subtract', [
                  new FunctionNode('csc', [context.variable]),
                  new FunctionNode('cot', [context.variable])
                ])
              ])
            ]);
          case "cot":
            //log(abs(sec(x) + tan(x)))
            return new FunctionNode('log', [
              new FunctionNode('abs', [
                new FunctionNode('sin', [context.variable])
              ])
            ]);
          default:
            return null;
        }
      }
    }
function(expr, context, subIntegral) {
      if(expr.type === 'FunctionNode' && expr.args[0].equals(context.variable)) {
        switch(expr.name) {
          case "sin":
            return new OperatorNode('-', 'unaryMinus', [
              new FunctionNode("cos", [context.variable])
            ]);
          case "cos":
            return new FunctionNode("sin", [context.variable]);
          case "tan":
            //log(abs(sec(x)))
            return new FunctionNode('log', [
              new FunctionNode('abs', [
                new FunctionNode('sec', [context.variable])
              ])
            ]);
          case "sec":
            //log(abs(sec(x) + tan(x)))
            return new FunctionNode('log', [
              new FunctionNode('abs', [
                new OperatorNode('+', 'add', [
                  new FunctionNode('sec', [context.variable]),
                  new FunctionNode('tan', [context.variable])
                ])
              ])
            ]);
          case "csc":
            //log(abs(sec(x) + tan(x)))
            return new FunctionNode('log', [
              new FunctionNode('abs', [
                new OperatorNode('-', 'subtract', [
                  new FunctionNode('csc', [context.variable]),
                  new FunctionNode('cot', [context.variable])
                ])
              ])
            ]);
          case "cot":
            //log(abs(sec(x) + tan(x)))
            return new FunctionNode('log', [
              new FunctionNode('abs', [
                new FunctionNode('sin', [context.variable])
              ])
            ]);
          default:
            return null;
        }
      }
    }
integral(sin(x), x) = -cos(x) integral(cos(x), x) = sin(x) integral(tan(x), x) = log(abs(sec(x))) integral(sec(x), x) = log(abs(sec(x) + tan(x))) integral(csc(x), x) = log(abs(csc(x) - cot(x))) integral(cot(x), x) = log(abs(sin(x)))