### Question:
Literal implements Comparable { public Literal scm(@Nonnull Literal that) { final Literal result = newInstance(this.size + that.size); int i = 0; int thisI = 0; int thatI = 0; Variable thisVariable = thisI < this.size ? this.variables[thisI] : null; Variable thatVariable = thatI < that.size ? that.variables[thatI] : null; while (thisVariable != null || thatVariable != null) { int c; if (thisVariable == null) { c = 1; } else if (thatVariable == null) { c = -1; } else { c = thisVariable.compareTo(thatVariable); } if (c < 0) { int thisPower = this.powers[thisI]; result.variables[i] = thisVariable; result.powers[i] = thisPower; result.degree += thisPower; i++; thisI++; thisVariable = thisI < size ? variables[thisI] : null; } else if (c > 0) { int thatPower = that.powers[thatI]; result.variables[i] = thatVariable; result.powers[i] = thatPower; result.degree += thatPower; i++; thatI++; thatVariable = thatI < that.size ? that.variables[thatI] : null; } else { int maxPower = Math.max(this.powers[thisI], that.powers[thatI]); result.variables[i] = thisVariable; result.powers[i] = maxPower; result.degree += maxPower; i++; thisI++; thatI++; thisVariable = thisI < this.size ? this.variables[thisI] : null; thatVariable = thatI < that.size ? that.variables[thatI] : null; } } result.resize(i); return result; } Literal();   Literal(int size); static Literal newInstance(); static Literal valueOf(Variable variable); static Literal valueOf(Variable variable, int power); static Literal valueOf(Monomial monomial); int size(); @Nonnull Variable getVariable(int i); int getPower(int i); Literal multiply(@Nonnull Literal that); Literal divide(Literal literal); @Nonnull Literal gcd(@Nonnull Literal that); Literal scm(@Nonnull Literal that); Generic[] productValue(); Power powerValue(); Variable variableValue(); Variable[] variables(); int degree(); int compareTo(@Nonnull Literal that); int compareTo(Object o); String toString(); String toJava(); void toMathML(MathML element, @Nullable Object data);  }### Answer:
@Test public void testScm() throws Exception { Expression e1 = Expression.valueOf("2+sin(2)"); Expression e2 = Expression.valueOf("3+cos(2)"); Literal l1 = Literal.valueOf(new DoubleVariable(new NumericWrapper(Real.valueOf(2d)))); Literal l2 = Literal.valueOf(new DoubleVariable(new NumericWrapper(Real.valueOf(4d)))); System.out.println(e1); System.out.println(e2); Literal result = Literal.newInstance(); System.out.println(-1 + " -> " + result); for (int i = 0; i < e1.size(); i++) { result = result.scm(e1.literal(i)); System.out.println(i + " -> " + result); } System.out.println(e1.literalScm()); System.out.println(e2.literalScm()); }