An assorted selection of the tests found in the Wester benchmark

1. Compute 50! : 
In> 50! 
 Out> 30414093201713378043612608166064768844377641568960512000000000000 

2. Compute the prime decomposition of 6!. : 
In> ans:=Factors(6!) 
 Out> {{2,4},{5,1},{3,2}} 
This list contains lists of two elements. This list should
be interpreted as 
In> PrettyForm(FW(ans)) 
 
 4        2
2  * 5 * 3 

Out> True 

3. Compute 1/2 + ... + 1/10. : 
In>  Sum(i,2,10,1/i) 
 Out> 4861/2520 

4. Compute a numerical approximation of e^(Pi*sqrt(163)) to 50 digits. : 
In> Precision(50) 
In> N(Exp(Pi*Sqrt(163))) 
 Out> 262537412640768743.99999999999925007259719818568885219682604177332393 

5. Compute an infinite decimal representation of 1/7 : 
In> Decimal(1/7) 
 Out> {0,{1,4,2,8,5,7}} 

6. Compute the first terms of the continued fraction of Pi. : 
In> PrettyForm(ContFrac(Pi())) 
 
                 1             
3 + ---------------------------
                   1           
    7 + -----------------------
                     1         
        15 + ------------------
                       1       
             1 + --------------
                          1    
                 292 + --------
                       1 + rest

Out> True 

7. Simplify sqrt(2*sqrt(3)+4). : 
In>  RadSimp(Sqrt(2*Sqrt(3)+4)) 
 Out> 1+Sqrt(3) 

8. Simplify sqrt(14+3*sqrt(3+2*sqrt(5-12*sqrt(3-2*sqrt(2))))). : 
In> RadSimp(Sqrt(14+3*Sqrt(3+2*Sqrt(5-12*Sqrt(3-2*Sqrt(2)))))) 
 Out> 3+Sqrt(2) 

9. Simplify 2*infinity-3. : 
In> 2*Infinity-3 
 Out> Infinity 
Infinity is also defined for comparisons like a < Infinity

10. Compute the normal form of (x^2-4)/(x^2+4x+4). : 
In>  PrettyForm(GcdReduce((x^2-4)/(x^2+4*x+4),x)) 
 
-2 + x
------
2 + x 

Out> True 

11. Expand (x+1)^5, then differentiate and factorize. : 
In>  ans:=Factors(D(x)Expand((x+1)^5)) 
In> PrettyForm(FW(ans)) 
 
         4    
( 1 + x )  * 5

Out> True 

12. Simplify sqrt(997) - (997^3)^(1/6). : 
In>  RadSimp(Sqrt(997)-997^3^(1/6)) 
 Out> 0 

13. Simplify sqrt(999983) - (999983^3)^(1/6). : 
In> RadSimp(Sqrt(999983)-999983^3^(1/6)) 
 Out> 0 

14. Recognize that (2^(1/3)+4^(1/3))^3-6*(2^(1/3)+4^(1/3)) - 6 is 0. : 
In> RadSimp((2^(1/3)+4^(1/3))^3-6*(2^(1/3)+4^(1/3))-6) 
 Out> 0 

15. Simplify log e^z into z only for -Pi < Im(z) <= Pi. : 
In> Simplify(Ln(Exp(z))) 
 Out> z 

16. Invert the 2x2 matrix [[a,b],[1,ab]].  : 
In>  A:={{a,b},{1,a*b}} 
In> ans:=Inverse(A) 
 Out> {{(a*b)/(b*a^2-b),(-b)/(b*a^2-b)},{-1/(b*a^2-b),a/(b*a^2-b)}} 
In> TableForm(Simplify(ans)) 
 {1/(a+ -1/a),1/(1-a^2)}
{1/(b-b*a^2),1/(b*a-b/a)}
Out> True 

17. Find the eigenvalues of the matrix [[5, -3, -7],[-2, 1, 2],[ 2, -3, -4]]. : 
In>  A:={{5,-3,-7},{-2,1,2},{2,-3,-4}} 
In> EigenValues(A) 
 Out> {1,3,-2} 

18. Compute the limit of (1-cos x)/x^2 when x goes to zero.  : 
In> Limit(x,0)(1-Cos(x))/x^2 
 Out> 1/2 

19. Compute the derivative of |x|. : 
In> D(x)Abs(x) 
 Out> Sign(x) 

20. Compute an antiderivative of |x|. : 
In> AntiDeriv(Abs(x),x) 
 Out> (Abs(x)*x)/2 

21. Compute the derivative of |x| (piecewise defined). : 
In> D(x)if(x<0)(-x)else x 
 Out>  if(x<0)-1else1 

22. Compute the antiderivative of |x| (piecewise defined). : 
In> AntiDeriv(if(x<0)(-x)else x,x) 
 Out> if(x<0)(-x^2/2)else x^2/2 

23. Compute the first terms of the Taylor expansion of 1/sqrt(1-v^2/c^2) at v=0.  : 
In> ans:=Taylor(v,0,4)Sqrt(1/(1-v^2/c^2)) 
In> ans:=Simplify(ans) 
In> PrettyForm(ans) 
 
       2          4
      v      3 * v 
1 + ------ + ------
         2        4
    2 * c    8 * c 

Out> True 

24. Compute the inverse of the square of the above expansion.  : 
In>  ans:=Taylor(v,0,4)(1/ans)^2 
In> PrettyForm(Simplify(ans)) 
 
     2
    v 
1 - --
     2
    c 

Out> True 

25. Compute the Taylor expansion of tan(x) at x=0 by dividing the expansion of sin(x) by that of cos(x).  : 
In>  ans1:=Taylor(x,0,5)Sin(x)/Cos(x) 
In> PrettyForm(ans1) 

     3        5
    x    2 * x 
x + -- + ------
    3      15  

In> ans2:=Taylor(x,0,5)Tan(x) 
In> PrettyForm(ans2) 

     3        5
    x    2 * x 
x + -- + ------
    3      15  

In> ans1-ans2 
 Out> 0 

26. Compute the Legendre polynomials directly. : 
In> 10#Legendre(0,_x)<--1 
In> 20#Legendre(n_IsInteger,_x)<--[Local(result);result:=[Local(x);Expand(1/(2^n*n!)*Deriv(x,n)Expand((x^2-1)^n,x));];Eval(result);] 
In> ForEach(item,Table(Legendre(i,x),i,0,4,1))PrettyForm(item) 

1


x


          2
-1 + 3 * x 
-----------
     2     


              3
-3 * x + 5 * x 
---------------
       2       


           2         4
3   -15 * x    35 * x 
- + -------- + -------
8      4          8   


27. Compute the Legendre polynomials recursively, using their recurrence of order 2.  : 
In> 10#LegendreRecursive(0,_x)<--1 
In> 20#LegendreRecursive(1,_x)<--x 
In> 30#LegendreRecursive(n_IsPositiveInteger,_x)<--Expand(((2*n-1)*x*LegendreRecursive(n-1,x)-(n-1)*LegendreRecursive(n-2,x))/n) 
In> ForEach(item,Table(LegendreRecursive(i,x),i,0,4,1))PrettyForm(item) 

1


x


          2
-1 + 3 * x 
-----------
     2     


              3
-3 * x + 5 * x 
---------------
       2       


           2         4
3   -15 * x    35 * x 
- + -------- + -------
8      4          8   


28. Evaluate the fourth Legendre polynomial at 1.  : 
In> Legendre(4,1) 
 Out> 1 

29. Define the polynomial p = sum( i=1..5, ai*x^i ).  : 
In> ans:=Sum(MakeVector(a,5)*FillList(x,5)^(1..5)) 
In> PrettyForm(ans) 

               2         3         4         5
a1 * x + a2 * x  + a3 * x  + a4 * x  + a5 * x 


30. Apply Horner's rule to the above polynomial. : 
In> ans:=Sum(MakeVector(a,5)*FillList(x,5)^(1..5)) 
In> PrettyForm(Horner(ans,x)) 

( ( ( ( a5 * x + a4 ) * x + a3 ) * x + a2 ) * x + a1 ) * x


31. Compute the first terms of the continued fraction of Pi.  : 
In> pi:=N(Pi,20) 
In> a:=ContFrac(pi,6) 
In> PrettyForm(a) 

                 1             
3 + ---------------------------
                   1           
    7 + -----------------------
                     1         
        15 + ------------------
                       1       
             1 + --------------
                          1    
                 292 + --------
                       1 + rest


32. Compute an infinite decimal representation of 1/7.  : 
In> Decimal(1/7) 
 Out> {0,{1,4,2,8,5,7}} 
This result means that the decimal expansion of 1/7 is
0.142857142857142....

33. Evaluate TRUE and FALSE.  : 
In> True And False 
 Out>  False 

34. Solve the equation tan(x) = 1.  : 
In>  Solve(Tan(x)==1,x) 
 Out> Pi/4 

35. Revert the Taylor expansion of sin(y) + cos(y) at y=0.  : 
In> t:=InverseTaylor(y,0,6)Sin(y)+Cos(y) 
In> PrettyForm(t) 

                 2                3                
        ( y - 1 )    2 * ( y - 1 )             4   
y - 1 + ---------- + -------------- + ( y - 1 )  + 
            2              3                       

              5
17 * ( y - 1 ) 
---------------
      10       

And check that it is in fact the inverse up to degree 5:
In> s:=Taylor(y,0,6)Sin(y)+Cos(y) 
In> BigOh(Subst(y,s)t,y,6) 
 Out> y 

36. Solve the linear (dependent) system x+y+z=6,2x+y+2z=10,x+3y+z=10. : 
In>  Solve({x+y+z==6,2*x+y+2*z==10,x+3*y+z==10},{x,y,z}) 
 Out> {{4-z,2,z}} 

37. Evaluate True And False : 
In> True And False 
 Out>  False 
In>  CanProve(True And False) 
 Out> False 

38. Simplify x or (not x) : 
In>  CanProve(x Or Not x) 
 Out> True 

39. Simplify x or y or (x and y) : 
In>  CanProve(x Or y Or x And y) 
 Out> x Or y 
39  examples done