cas_setup([0,0,0,1,160,[1e-12,1e-15],12,[1,100,0,25],0,1,0,1]); // Default settings
/* I. Elementary Number Theory */
/* integers into products of powers of primes */
ifactor(12345) // A prime is an integer greater than 1 whose only positive factors are itself and 1.
ifactor(-24), ifactor(24!)
/* Greatest Common Divisor */
gcd(a,b) // The greatest common divisor of two integers is the largest integer that divides both integers evenly.
gcd(35, 15, 65)
gcd(2^14 + 3^8 + 5^9, 3^4 + 7^3), gcd(-104, 221)
/* Least Common Multiple */
lcm(a,b)
lcm(35, 15, 65)
lcm(6, 8); lcm(104, 221)
/* Factorials */
[a!, 0!, 3!, 7!, 10!] // Factorial is the function of a nonnegative integer n denoted by n! and defined for positive integers n as the product of all positive integers up to and including n; that is, n! = 1*2*3*4*...n. It is defined for zero by 0! = 1
/* Binomial Coefficients */
'(a + b)^n=sum((n!/(k!*(n-k)!))*(a^(n-k)*b^k),k,0,n)' // An expression of the form a + b is called a binomial. the formula that gives the expansion of (a + b)^n for any natural number n is
binomial(a,b) // binomial coefficients.
binomial(5,2)
binomial(a,5), factor(a!/(5!*(a-5)!))
/* Real Numbers */
/* Arithmetic. The real numbers include the integers and fractions (rational numbers), as well as irrational numbers such as sqrt(2) and pi that cannot be expressed as quotients of integers. */
9.6*pi - 2.7*pi // qpi(9.6*pi - 2.7*pi)
42*( 2/3 + 1/7 ) * sqrt(2)
(2/3) / (8/7)
/* changea floating point number to a rational number. */
exact(0.125) // rational
exact(4.72)
exact(6.9*pi)
exact(3.1416 )
/* Evaluating float at a rational number gives the floating point form of the number. */
approx(3927/1250, 1/8) // Numerical Approximations
/* Powers and Radicals Pag 34 */
[3^4, (2.5)^(4/5), 3^-4, 0.4^32] // To raise numbers to powers use ^ symbol
surd(0.008,3); surd(18.234,5); surd(24,2); surd(16/27,3); surd(16,4); surd(-8,3) // Radical notation for roots
autosimplify(2):; surd(16/27,3) // irrational number
autosimplify(2):; surd(16/27,3)
autosimplify(2):; surd(162*pi^6,4)
approx(3*pi*(2*pi^2)^(1/4)); approx(3*pi^(3/2)*surd(2,4))
autosimplify(0):; surd(162*pi^6,4)
autosimplify(1):; surd(162*pi^6,4)
autosimplify(2):; 1/sqrt(2) // Rationalizing a Denominator
autosimplify(0):; 1/sqrt(2)
autosimplify(2):; 1/(sqrt(2)+sqrt(3))
autosimplify(1):; 1/(sqrt(2)+sqrt(3))
autosimplify(2):; (sqrt(2)+sqrt(3))/(sqrt(5)-sqrt(7))
autosimplify(0):; (sqrt(2)+sqrt(3))/(sqrt(5)-sqrt(7))
autosimplify(0):; -1/2 * (sqrt(2) + sqrt(3)) * (sqrt(5) + sqrt(7))
/* Functions and Relations */
abs(a) // Absolute value
abs(-11.3)
max(a,b); min(a,b); // Maximum and Minimum
max( 12/3,-sqrt(63), 7.3 )
min( 12/3,-sqrt(63), 7.3 )
max( 27, 65/2, -14 )
min( 27, 65/2, -14 )
floor(5.6); ceil(5.6) // Greatest and Smallest Integer Functions
floor(43/5); ceil(43/5)
floor(-11.3); ceil(-11.3)
floor(pi+e); ceil(pi+e)
evalb( e^(i*pi) = -1 ) // Checking Equalities and Inequalities
evalb( pi=3.14 )
evalb( asin(sin(a)=a) )
asin(sin(a))
evalb( (9/8-8/9) = abs(9/8-8/9) )
evalb( pi^e-e^pi = abs(pi^e-e^pi) )
pi^e-e^pi = abs(pi^e-e^pi)
(9/8) < (8/9)
pi^e < e^pi
evalb(sqrt(2)^2=2)
(5^6 < 6^5) and (1=1); (5^6 > 6^5) and (1=1)
(5^6 < 6^5) or (1=1); (5^6 > 6^5) or (1=1)
(1 = 1) or (1=0)
( e^pi = pi^e ) and (0=0)
/* Union, Intersection, and Difference */
set[1,2,3] union set[a,b,c]
[1,2,3] union ([3,5] union [7])
[sqrt(2), pi, 3.9, r] union [a,b,c]
[1,2,3] intersect [2,4,6]
[1,2,3] intersect [a,b,c]
[a,b,c, d] intersect [d, ee, f]
set[]
[1,2,3] intersect []
[1,2,3] minus [2,4]
[1,2,3] minus [a,b,c]
[a,b,c,d] minus [d, ee, f]
/* Complex Numbers */
i
sqrt(-5)
i/(1+i)
abs(i) // Absolute Value
abs(1+i)
conj(a+i); conj(1+i)// Complex conjugate
re(1 + i); im(5 - 3*i) // Real and Imaginary Parts
6_ft + 8_ft; 10_m * 5_m // Arithmetic Operations with Units
6_ft * 8_ft
4_ft + 16_inch
convert(5.33333333333_ft,1_m) // Converting Units
4_d + 3_mn
convert(4.00208333333_d,1_s)
10_mile/15_s
convert((2/3)_(mile*s^-1.0),1_m/1_s)
convert(7_ft,1_inch)
convert(458.4_deg,1_rad)
convert(50_mile/1_h,1_km/1_h)
convert(47_lb,1_kg)
convert(8_rad,1_deg)
1440./pi
/* Algebra, Polynomials and Rational Expressions */
(3*x^2 + 3*x )+(8*x^2+7) // Sum
(3*x^2 + 3*x )/(8*x^2+7) // Quotients of Polynomials
((x + 1)^-1)*(x + 1)^-1 // Product
((x + 1)^-1)*(x - 1)^-1
expand(((x + 1)^-1)*(x - 1)^-1)
(3*x^2 + 3*x -1 )*(8*x^2+7)
(3*x^5 +3*x^3 -4*x^2 + 5)/(8*x^2 +7)
(3/64)*x-( ((21/64)*x - (17/2))/(8*x^2+7) ) + (3/8)*x^3 -1/2
sum(a[k]*x^k,k,0,5) // summation notation
ratnormal((8x^2 + 7 )^-1 * (x + 2x^2 + 7 )^-1)
x/(x^2-1) + (3*x-1)/(x^2-3*x+2)
factor(x/(x^2-1) + (3*x-1)/(x^2-3*x+2))
partfrac(36/((x-2)*((x-1)^2)*(x+1)^2)) // Partial Fractions
complex_mode(0):;partfrac((x^3+x^2+1)/(x*(x-1)*(x^2+x+1)*(x^2+1)^3))
partfrac( y/(((x-y)^2)*(x+1)))
partfrac(y/((x-y)^2*(x+1)),y)
partfrac(y/((x-y)^2*(x+1)),x)
cas_setup(0,0,0,1,160,[1e-12,1e-15],12,[1,100,0,25],0,1,0,1) // 9-th parameter increasing power flag
x^2 + 3*x + 5- 3*x^3 + 5*x^2 + 4*x^3 + 13 + 2*x^4
sort(5*t^2 + 3*x*t^2 - 16*t^5 + y^3 - 2*x*t^2 + 9,t)
sort(5*t^2 + 3*x*t^2 - 16*t^5 + y^3 - 2*x*t^2 + 9)
collect(5*t^2 + 3*x*t^2 - 16*t^5 + y^3 - 2*x*t^2 + 9,y)
5*x^5 + 5*x^4 - 10*x^3 - 10*x^2 + 5*x + 5; factor(5*x^5 + 5*x^4 - 10*x^3 - 10*x^2 + 5*x + 5)
1/16*x^2 -7/5*x + 1/6*i*x - 56/15*i; factor(1/16*x^2 -7/5*x + 1/6*i*x - 56/15*i)
expand((3*x+8*i)*(5*x-112)/240)
x^2 + 2*x - 3; subst( x^2 + 2*x - 3, x=a ) // Substituting for a Variable
subst( x + y, x=y+z )
subst( x^2 + 2*x - 3,x=y-z ); factor( y^2-2*y*z+2*y+z^2-2*z-3, y ); 2*y - 2*z + (y-z)^2 - 3
expand( 2*y - 2*z + (y-z)^2 - 3 )
preval(x,a,b) // Evaluating at Endpoints
preval(x^2 + 2*x - 3, x=3, x=5) // request x=
preval(x^2 + 2*x - 3, 3, 5)
preval(x^2 + 2*x - 3, a, b)
purge(x):; roots(5*x^2 + 2*x - 3, x ); solve(5*x^2 + 2*x - 3=0, x ) // multiplicity
list2exp([[3,9],[- 1,1]],x)
roots(x^2 + 1,x)
x^3 - 13/5*i*x^2 - 8*x^2 + 29/5*i*x + 81/5*x + 6*i - 18/5
solve(x^3 - 13/5*i*x^2 - 8*x^2 + 29/5*i*x + 81/5*x + 6*i - 18/5 =0,x)
roots(x^3 - 13/5*i*x^2 - 8*x^2 + 29/5*i*x + 81/5*x + 6*i - 18/5,x)
csolve(x^3 - 13/5*i*x^2 - 8*x^2 + 29/5*i*x + 81/5*x + 6*i - 18/5 =0,x)
5/2+(13/10*i) - 1/10*√(336 + 850*i)
5/2+(13/10*i) + 1/10*√(336 + 850*i)
assume(x, integer) // real
roots(x^3 - 13/5*i*x^2 - 8*x^2 + 29/5*i*x + 81/5*x + 6*i - 18/5,x);
1//roots(5*x^2+x+3); // bug
purge(x):;
2 // roots(ax^2 + b*x + c); // bug
solve(x^3 + 3*x + 1=0);
roots(a*x^2 + b*x + c);
csolve(x^3 + 3*x + 1=0); // exact
csolve(x^3 + 3*x + 1.0=0); // approx
roots(x^3 + 3*x + 1=0);
roots(x^4 + 3*x^3 - 2*x^2 + x + 1)
roots(x^3 - 8/3*x^2 - 5/3*x + 2)
factor(x^3 - 8/3*x^2 - 5/3*x + 2); expand((x-3)*(x+1)*(3*x-2)/3)
factors(x^3 - 8/3*x^2 - 5/3*x + 2)
csolve(x^3 -13/5*i*x^2 - 8*x^2 + 29/5*i*x + 81/5*x + 6*i -18/5=0)
factor(x^3 -13/5*i*x^2 - 8*x^2 + 29/5*i*x + 81/5*x + 6*i -18/5)
/* Equations with One Variable */
solve(5*x^2 + 3*x = 1)
expand(list[(-(sqrt(29))-3)/10,(sqrt(29)-3)/10])
solve(abs(3*x - 2) = 5)
purge(x)
solve(1/x + 1/y = 1, [x,y],'=') // no coloca restricciones
solve(1/x + 1/y = 1, x, '=')
solve(1/x + 1/y = 1, y, '=')
solve(1/x + 1/y + 1/z = 1, z, '=')
solve([x^2 + y^2 = 5, x^2 - y^2 = 1],[x,y],'=')
solve([x^2 + y^2 = 5, x^2 - y^2 = 1],[x,y])
autosimplify(0):;list2exp([[sqrt(3),sqrt(2)],[-(sqrt(3)),sqrt(2)],[sqrt(3),-(sqrt(2))],[-(sqrt(3)),-(sqrt(2))]],[x,y]);
list2exp(solve([x^2 + y^2 = 5, x^2 - y^2 = 1],[x,y]),[x,y])
/* Inequalities */
autosimplify(0):;solve(16 - 7*y >= 10*y - 4, y)
solve(x^3 + 1 > x^2 + x)
solve(x^2 + 2*x - 3 > 0, x)
solve(abs(2*x + 3) <= 1)
solve( (7-2*x)/(x-2)>=0,x)
a<x<b; ((x>a) and (x<b))
a<x<=b; ((x>a) and (x<=b))
a<=x<=b; ((x>=a) and (x<=b))
/* Defining Functions of One Variable // p 69 */
f(x) := a*x^2 + b*x + c;
[f(t), f(-6), f(17)]
f(x) := 5*x - 3;
solve(f(y)=0)
seq(x^2 + 3*x + 5,x,[0,1,2,3,4]); // To find the value of the expression x^2 + 3x + 5 at x = 0, 1, 2, 3, 4
seq(x=y+1,y,0,4)
subst(x^2 + 3*x + 5,[x=1,x=2,x=3,x=4,x=5])
/* Definning Functions of Several Variables */
f(x, y, z) := a*x + y^2 + 2*z
g(x, y) := 2*x + sin(3*x*y)
f(1, 2, 3)
g(1,2)
/* Piecewise-Defined Functions */
f(x):= piecewise(x<0,x+2,0<=x<=1,2, x>1, 2/x)
[f(-14), f(1/2), f(21)]
h(x):= (x - 1)/(x + 1)
purge(f), purge(h)//Removing Definitions