Вы находитесь на странице: 1из 24

maxima_e-book.

wxmx 1 / 24

wxMaxima (Software and its uses)


1 Introduction

1.1 What is Maxima?What is wxMaxima interface?diffrent types of cells in maxima

Maxima is a system for the manipulation of symbolic and numerical expressions, including
Laplaca transformations, ordinary differenial equations, systems of linear equations, po
Maxima yields high precision numerical results by using exact fractions, arbitrary-preci
Maxima can plot functions and data in two and three dimensions.

wxMaxima is a document based interface for the computer algebra system Maxima. wxMaxima
autocompletion, inline plots and simple animations. wxMaxima is distributed under the GP
provides the user with a graphical display and many features that make working with maxi

The use of cells is another important application that the software provides to arrange
It allows to to enter specific cell for titles, text, sections, subsections,image, input
work in an easily understandable form with a neat presentstion.

1.2 Who developed Maxima?(Historical background)


Maxima is based on a 1982 version of Macsyma, which was developed at MIT with funding fr
other government agencies. A version of Macsyma was maintained by Bill Schelter from 198
In 1998, Schelter obtained permission from the Department of Energy to release his versi

1.3 Basic Arithmetic

1.3.1 Arithmetic Operations

Addition

--> 65398+65465;
(%o4) 130863

Subtraction

--> 9878-674;
(%o5) 9204

Multiplication

--> 876*65;
(%o6) 56940

Division

--> 76/6;
38
(%o7)
3

--> float(764/78);
(%o8) 9.794871794871796

Power of a number

--> 76**65;
(%o9) 179012557914351244807992886175[63 digits]338615685204554867663884517376

--> 6**2;
(%o10) 36

Square root of a number

--> float (sqrt(367));


(%o11) 19.15724406066802
maxima_e-book.wxmx 2 / 24

--> sqrt(81);
(%o12) 9

1.4 Mathematical functions(in-built)

Function: abs (z)


The abs function represents the mathematical absolute value function and works for both numerical and symbolic values.
If the argument, z, is a real or complex number, abs returns the absolute value of z. If possible, symbolic expressions
using the absolute value function are also simplified.

Example:

--> abs(-11);
(%o2) 11

Function: ceiling (x)


When x is a real number, return the least integer that is greater than or equal to x.

Example:

--> ceiling(22/7);
(%o3) 4

Function: floor (x)


When x is a real number, return the largest integer that is less than or equal to x.

Example:

--> floor(22/7);
(%o4) 3

Function: max (x_1, …, x_n)


Return a simplified value for the maximum of the expressions x_1 through x_n.

Example:

--> max(7,2,9,23);
(%o5) 23

Function: min (x_1, …, x_n)


Return a simplified value for the minimum of the expressions x_1 through x_n.

Example:

--> min(4,90,45,1);
(%o6) 1

Function: round (x)


When x is a real number, returns the closest integer to x.

Example:

--> round(43.78);
(%o7) 44

Function: exp (x)


Represents the exponential function.

Example:

--> exp(54.9);
(%o8) 6.96252963165224 10 23

Function: log (x)


Represents the natural (base e) logarithm of x.

Example:

--> log(1);
(%o10) 0
maxima_e-book.wxmx 3 / 24

Printing precision

--> fpprintprec:7$/*float print precision*/


float(22/7);
(%o3) 3.142857

1.5 Defining variables and functions

Priliminary remark: To define a variable in Maxima you use the : operator.

Example:

--> a:2345;
(a) 2345

Priliminary remark: To define a function in Maxima you use the := operator.

Example:

--> f(x):=x^2-3*x+1;
(%o11) f x := x 2 − 3 x + 1

1.6 Evaluating Expressions

1.7 Lists

Lists are the basic building block for Maxima.

Function: makelist (expr, i, i_0, i_1)


Function: makelist (expr, x, list)
Constructs and returns a list, each element of which is generated from expr.
makelist (expr, i, i_0, i_1) returns a list, the j'th element of which is equal to
ev (expr, i=j) for j equal to i_0 through i_1.

makelist (expr, x, list) returns a list, the j'th element of which is equal to
ev (expr, x=list[j]) for j equal to 1 through length (list).

--> n:10;
(n) 10

--> L:makelist(2*n-1,n,1,26);
(L) [ 1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 , 17 , 19 , 21 , 23 , 25 , 27 , 29 , 31 , 33 , 35 , 37 , 39 , 41 , 43 , 45 , 47 , 49 , 51 ]

--> L[10];
(%o3) 19

--> M:makelist(n*2,n,30);
(M) [ 2 , 4 , 6 , 8 , 10 , 12 , 14 , 16 , 18 , 20 , 22 , 24 , 26 , 28 , 30 , 32 , 34 , 36 , 38 , 40 , 42 , 44 , 46 , 48 , 50 , 52 , 54 , 56 , 58 ,
60 ]

Lists can also be used to make drawing graphs for a set of values easier
maxima_e-book.wxmx 4 / 24

--> load(draw)$
wxdraw2d(grid=true,
color="purple",
points(L));

(%t7)

(%o7)

--> s:makelist([n,2*n-1],n,1,26);
(s) [ [ 1 , 1 ] , [ 2 , 3 ] , [ 3 , 5 ] , [ 4 , 7 ] , [ 5 , 9 ] , [ 6 , 11 ] , [ 7 , 13 ] , [ 8 , 15 ] , [ 9 , 17 ] , [ 10 , 19 ] , [ 11 , 21 ] , [ 12 ,
23 ] , [ 13 , 25 ] , [ 14 , 27 ] , [ 15 , 29 ] , [ 16 , 31 ] , [ 17 , 33 ] , [ 18 , 35 ] , [ 19 , 37 ] , [ 20 , 39 ] , [ 21 , 41 ] , [ 22 , 43 ] , [ 23 , 45
] , [ 24 , 47 ] , [ 25 , 49 ] , [ 26 , 51 ] ]

--> A:makelist(2*x,x,0.0,2);
(A) [ 0.0 , 2.0 , 4.0 ]

--> makelist([0.1*k,2*(0.1*k)],k,0,20);
(%o10) [ [ 0 , 0 ] , [ 0.1 , 0.2 ] , [ 0.2 , 0.4 ] , [ 0.3 , 0.6000000000000001 ] , [ 0.4 , 0.8 ] , [ 0.5 , 1.0 ] , [ 0.6000000000000001
, 1.2 ] , [ 0.7000000000000001 , 1.4 ] , [ 0.8 , 1.6 ] , [ 0.9 , 1.8 ] , [ 1.0 , 2.0 ] , [ 1.1 , 2.2 ] , [ 1.2 , 2.4 ] , [ 1.3 , 2.6 ] , [ 1.4 ,
2.8 ] , [ 1.5 , 3.0 ] , [ 1.6 , 3.2 ] , [ 1.7 , 3.4 ] , [ 1.8 , 3.6 ] , [ 1.9 , 3.8 ] , [ 2.0 , 4.0 ] ]

1.8 Trignometric functions and simplifications

Maxima has many trigonometric functions defined. Not all trigonometric identities are programmed, but it is possible for the
add many of them using the pattern matching capabilities of the system. The trigonometric functions defined in Maxima are: a
acoth, acsc, acsch, asec, asech, asin, asinh, atan, atanh, cos, cosh, cot, coth, csc, csch, sec, sech, sin, sinh, tan, and t
There are a number of commands especially for handling trigonometric functions, see trigexpand, trigreduce, and the switch t

Function: sin (x)


- Sine.

--> sin(%pi/4);
1
(%o13)
2

Function: cos (x)


- Cosine.

--> cos(%pi/2);
(%o14) 0

Function: tan (x)


- Tangent.
maxima_e-book.wxmx 5 / 24

--> tan(%pi/4);
(%o15) 1

Function: cot (x)


- Cotangent.

--> cot(%pi/3);
1
(%o17)
3

Function: csc (x)


- Cosecant.

--> csc(%pi/2);
(%o18) 1

Function: sec (x)


- Secant.

--> sec(%pi/6);
2
(%o19)
3

Function: trigexpand (expr)


Expands trigonometric and hyperbolic functions of sums of angles and of multiple angles occurring in expr.

--> trigexpand(sin(10*x+y));
(%o11) cos 10 x sin y + sin 10 x cos y

Function: trigreduce
trigreduce (expr, x)
trigreduce (expr)
Combines products and powers of trigonometric and hyperbolic sin's and cos's of x into those of multiples of x. It also trie
these functions when they occur in denominators. If x is omitted then all variables in expr are used.

--> trigreduce(sin(x)^2);/*double angle*/;


1 − cos 2 x
(%o1)
2

Function: expand
expand (expr)
expand (expr, p, n)
Expand expression expr. Products of sums and exponentiated sums are multiplied out, numerators of rational expressions which

--> expand((x+y+z)^2);
(%o5) z2 + 2 y z + 2 x z + y2 + 2 x y + x2

1.9 Solving Equations

Function: solve
solve (expr, x)
solve (expr)
solve ([eqn_1, …, eqn_n], [x_1, …, x_n])
Solves the algebraic equation expr for the variable x and returns a list of solution equations in x.
If expr is not an equation, the equation expr = 0 is assumed in its place.

--> solve(x^2-4*x+3);
(%o3) [x=3,x=1]

--> solve([sin(x)-x^2], [x]);


(%o1) [x=− sin x , x = sin x ]

2 A Programming approach

2.1 Input/Output functions

WAP to enter 2 numbers a & b and find a sum, difference, product and the remainder when a is divided by b.
maxima_e-book.wxmx 6 / 24

--> a:read("Enter a number")$


b:read("Enter another number")$
c:a+b$
d:a-b$
e:a*b$
f:mod(a,b)$
print("The sum of ",a," and",b,"is ",c)$
printf(true,"The difference between ~d and ~d is ~d",a,b,d)$
print("The product of ",a,"and ",b,"is ",e)$
prinr("The remainder of ",a," divided by ",b," is ",f)$
Enter a number 3;
Enter another number 5;
The sum of 3 and 5 is 8
The difference between 3 and 5 is −2
The product of 3 and 5 is 15

2.2 Conditional Structures

In conditional structures the given set of task is performed only if the condition is satisfied otherwise
performs a different action

2.2.1 if statement

Syntax:

if condition then
expression_1 /* Use and to print more than one statement */
else
expression_2$

Write a program to find greatest of two numbers

--> a:read("Enter a number");


b:read("Enter another no.");
if(a>b) then
print(a," is greater than ",b)
else
print(b," is greater than", a)$

Program to check if two numbers are co-prime or not

--> a:read("Enter a no.");


b:read("Enter another no.");
c:gcd(a,b);
if(c=1) then
printf(true,"~d and ~d are co-prime", a , b)
else
printf(true,"~d and ~d are not co-prime", a , b)$

Program to find a divides b

--> a:read("Enter a no.");


b:read("Enter another no.");
c:mod(a,b);
if(c=0) then
print(a,"divides",b)
else
print("Not divisible")$

2.2.2 else if statement

Syntax:

if cond_1 then
expr_1
else if cond_2 then /* Use words for logical operators */
expr_2
else
expr_3$

Program to find smallest of three numbers


maxima_e-book.wxmx 7 / 24

--> a:read("Enter a no.");


b:read("Enter another no.");
c:read("Enter another no.");
if (a<b) and (a<c) then
print(a," is the smallest")
else if (b<a) and (b<c) then
print(b," is the smallest")
else
print(c," is the smallest")$

Write a program to calculate % and grade of four subject marks using else if structure
Percentage Grade
90%-100% A
80%-89% B
70%-79% C
Below 70% FAIL

--> a:read("Enter a mark");


b:read("Enter second mark");
c:read("Enter third mark");
d:read("Enter fourth mark");
p:(a+b+c+d)/4$
print("Percentage is ",float(p))$
if(p>=90) and (p<=100) then
print("A Grade")
else if (p>=80 ) and (p<90) then
print("B Grade")
else if (p>=70) and (p<80) then
print("C Grade")
else
print("FAIL")$

2.3 Iterations

--> for i:1 thru 5 do disp(i)$


1
2
3
4
5

--> for i:5 step 4 thru 20 do disp(i)$


5
9
13
17

--> for i:1 unless i=6 do disp(i)$


1
2
3
4
5

--> for i:1 thru 20 while(i<=10) do disp(i)$


1
2
3
4
5
6
7
8
9
10

WAP to display even numbers between 10 and 20

--> for i:10 step 2 thru 20 do disp(i)$


10
12
14
16
18
20

WAP to find sum of numbers from 1 to 50


maxima_e-book.wxmx 8 / 24

--> sum:0$
for i:1 thru 50 do sum:sum+i$
print("Sum is",sum)$
Sum is 1275

WAP to print the multiplication table of 5

--> for i:1 thru 10 do print("5 x",i," =",i*5)$


5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50

WAP to check if agiven number is even or odd and print the next 20 even or odd numbers repectively

--> n:read("Enter a number")$


if(mod(n,2)=0)then
print("Even")
else
print("Odd")$
for i:n step 2 thru n+40 do disp(i)$
Enter a number 5;
Odd
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45

3 Functions

3.1 Even and Odd functions

Odd function: if f(-x)=- f(x) is said to be an odd function

even function : if f(x)= -f(x) is said to be an even function

Q: Check whether the given functions are even or odd or neither


1. f(x)=x^2-4x
preliminary remarks:first we plot the graph of the function to examine the symmetry and then verify it algebraically

--> f(x):= x^2 - 4*x;


(%o13) f x := x 2 − 4 x
maxima_e-book.wxmx 9 / 24

--> load(draw)$
wxdraw2d(user_preamble="set zeroaxis linetype 8; set xtics axis;set ytics axis;",
grid=true,
xrange=[-20,20],
yrange=[-20,20],
title="x^2-4*x",
color="purple",
explicit(x^2-4*x,x,-50,50));

(%t17)

(%o17)

To check whether the function is odd, even or neither

--> if is(f(-x)=-f(x))= True then print ("odd")


else if is(f(-x)=f(x))= True then print("even")
else print("neither even nor odd")$
neither even nor odd

f(x)=sinx

--> f(x):= sin(x)$


if is(f(-x)=-f(x))= True then print("odd")
else if is(f(-x)=f(x))= True then print("even")
else printf(true,"neither even nor odd")$
neither even nor odd

--> y(x):=sin(x);
(%o22) y x := sin x

--> is(y(-x)=y(x));
(%o23) false

--> is(y(-x)=-y(x));
(%o25) true
maxima_e-book.wxmx 10 / 24

--> wxdraw2d( grid=true, xaxis=true,


xaxis_width=1, xaxis_type=solid,
yaxis=true, yaxis_width=1, yaxis_type=solid,
yrange=[-1.5,1.5], nticks=100,
xrange=[-2.5*%pi,2.5*%pi],
explicit(y(x),x,-4*%pi,4*%pi));

(%t24)

(%o24)

3.2 Increasing and decreasing function

If f(x) is a function defined on an interval I and if x1 and x2 are any


two points in I, then the function f is said to be increasing on I if
f(x2) > f(x1) whenever x2 > x1. If f(x2) < f(x1) whenever x2 > x1,
then f is said to be decreasing on I. In this section we will familiarize
ourselves with increasing and decreasing functions.

Build a Maxima program that takes a function and an interval as input and gives an output
whether that function is increasing or decreasing in the given interval.

Priliminary remarks:
We will start at the lower limit of the interval and run the for loop till the upper limit and check if the value continuous
increases or decreases to conclude increasing or decreasing nature.
maxima_e-book.wxmx 11 / 24

--> F:read("Enter the function in terms of x")$


a:read("Enter the start range")$
b:read("Enter the end range")$
wxdraw2d(explicit(F,x,a,b))$
agi=1$
agd:1$
for i:a step 0.05 thru b-0.05 do(
if subst(i,x,F)>subst(i+0.05,x,F)then
agi:0,
if subst(i,x,F)<subst(i+0.05,x,F)then
agd:0);
if agi=1 then print("Increasing")
else if agd=1 then print("Decreasing")
else print("Neither Increasing nor Decreasing")$
Enter the function in terms of x x^3;
Enter the start range 9;
Enter the end range 12;

(%t38)

(%o41) done
Neither Increasing nor Decreasing
maxima_e-book.wxmx 12 / 24

--> f:read("Enter the function")$


a:read("Enter the lowest point of the interval")$
b:read("Enter the highest point of the inverval")$
wxdraw2d(explicit(f,x,a,b))$
agi:1$
agd:1$
for i:a step 0.05 thru b-0.05 do(
if subst(i,x,f)>subst(i+0.05,x,f) then agi:0,
if subst(i,x,f)<subst(i+0.05,x,f) then agd:0);
if agi=1 then print("increasing function")
else if agd=1 then print("decreasing function")
else print("Neither increasing nor decreasing")$
Enter the function x^3;
Enter the lowest point of the interval -6;
Enter the highest point of the inverval 4;

(%t46)

(%o49) done
increasing function

4 Plotting graphs

4.1 Point type options

putting numbers as values for each type

4.2 Point size options

Mark the points [0,0],[-π/2,0][π/2,0] correspondinf to sinx


maxima_e-book.wxmx 13 / 24

--> wxdraw2d(
grid=true,
title="three sine curves",
yrange=[-4,4],
point_size=1.5,
point_type=7,
color=black,
points([[-%pi/2,0],[0,0],[%pi/2,0]]),
label(["A(-%pi/2,0)",-%pi/2,1],["B(%pi/2,0)",%pi/2,-1]),
color=red,
key="y=sinx",
explicit(sin(x),x,-9,9),
color=green,
key="y=2sinx",
explicit(2*sin(x),x,-9,9),
color=violet,key="y=3sinx",
explicit(3*sin(x),x,-9,9));

(%t51)

(%o51)

Draw the parabola y=-x^2 and mark the points (0,0) when (-1,-1) and (1,-1)
maxima_e-book.wxmx 14 / 24

--> wxdraw2d(
grid=true,user_preamble="set zeroaxis linetype 1000;set xtics axis; set ytics axis;",
yrange=[-2,2],
color=red,
point_size=1,
point_type=7,
points([[0,0],[1,-1],[-1,-1]]),
label(["A(0,0)",0,.25],["B(1,-1)",1,-1.25],["C(-1,-1)",-1,-1.25]),
key="x^2",
explicit(-x**2,x,-2,2)
);

(%t52)

(%o52)
maxima_e-book.wxmx 15 / 24

--> wxdraw2d(
grid=true,
user_preamble="set zeroaxis linetype 1000;set xtics axis; set ytics axis;",
yrange=[-2,2],
color=black,
point_size=1,
point_type=7,
points([[0,0],[1,-1],[-1,-1]]),
color=purple,
label(["A",1,-1.25],["B",-1,-1.25]),
explicit(-x**2,x,-2,2),
color=green,
explicit(-1,x,-2,2)
);

(%t53)

(%o53)

4.3 Plotting different types of functions

4.3.1 Plotting piecewise functions


maxima_e-book.wxmx 16 / 24

--> load(draw)$
wxdraw2d(user_preamble="set zeroaxis linetype 8; set xtics axis;set ytics axis;set border 15;",
nticks=1000,
grid=true,
yrange=[-15,15],
xrange=[-4,4],
title="3-x^2 and 11-x^2",
color=blue,
line_width=2,
key="3-x^2",
explicit(3-x^2,x,-4,-2),
color=green,
point_type=7,
points([[-2,7]]),
key="11-x^2",
explicit(11-x^2,x,-2,4),
color=red,
explicit(x,x,-15,15)
);

(%t55)

(%o55)

4.3.2 Implicit functions


maxima_e-book.wxmx 17 / 24

--> wxdraw2d(user_preamble="set zeroaxis linetype 10;set xtics axis;set ytics axis",title="ASTROID",


color=dark-violet,
nticks=2000,
line_width=3,
key="x^(2/3)+y^(2/3)=4",
implicit(x^(2/3)+y^(2/3)=4,x,-15,15,y,-10,10)
);

(%t56)

(%o56)

4.3.3 Parametric function


maxima_e-book.wxmx 18 / 24

--> wxdraw2d(grid=true,user_preamble="set zeroaxis linetype 8;set xtics axis;set ytics axis;",


nticks=1000,
title="Parametric function",
key="2*(t-sin(t)),2*(1-cos(t))",
color=plum,
xrange=[-15,15],
yrange=[-15,15],
parametric(2*(t-sin(t)),2*(1-cos(t)),t,-5*%pi,5*%pi));

(%t57)

(%o57)

4.3.4 Polar functions(curve)

Q.r=sin3theta
maxima_e-book.wxmx 19 / 24

--> load(draw)$
wxdraw2d(title="3-LEAVED ROSE",
nticks=200, polar(sin(3*%theta),%theta,-4*%pi,4*%pi));

(%t59)

(%o59)

4.4 Plotting using makelist

--> L:makelist(2*n-1,n,1,26);
(L) [ 1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 , 17 , 19 , 21 , 23 , 25 , 27 , 29 , 31 , 33 , 35 , 37 , 39 , 41 , 43 , 45 , 47 , 49 , 51 ]

--> wxdraw2d(grid=true,
color="purple",
points(L));

(%t61)

(%o61)
maxima_e-book.wxmx 20 / 24

--> g(x):=x^2/2+5*x+%c;
x2
(%o62) g x := + 5 x + %c
2

--> F:makelist(explicit(g(x),x,-10,10),%c,-4,8)$;
wxdraw2d(color="purple",F,grid=true);

(%t64)

(%o64)

--> M:makelist([x,2*x],x,0.0,2.0,0.1);
(M) [ [ 0.0 , 0.0 ] , [ 0.1 , 0.2 ] , [ 0.2 , 0.4 ] , [ 0.3 , 0.6000000000000001 ] , [ 0.4 , 0.8 ] , [ 0.5 , 1.0 ] , [ 0.6 , 1.2 ] , [
0.7 , 1.4 ] , [ 0.7999999999999999 , 1.6 ] , [ 0.8999999999999999 , 1.8 ] , [ 0.9999999999999999 , 2.0 ] , [ 1.1 , 2.2 ] , [ 1.2 ,
2.4 ] , [ 1.3 , 2.6 ] , [ 1.4 , 2.8 ] , [ 1.5 , 3.0 ] , [ 1.6 , 3.200000000000001 ] , [ 1.7 , 3.400000000000001 ] , [ 1.8 ,
3.600000000000001 ] , [ 1.900000000000001 , 3.800000000000001 ] , [ 2.0 , 4.000000000000001 ] ]
maxima_e-book.wxmx 21 / 24

--> wxdraw2d(points(M));

(%t66)

(%o66)

5 Limits

Limits determined using built-in functions of maxima


Syntax: limit(function,var,limiting value)

--> limit(1/x,x,0);
(%o67) infinity

--> limit(1/sin(x),x,0);
(%o68) infinity

--> limit(x**3-x**2+x-1,x,10);
(%o69) 909

--> limit(x**3-x**2+x-1,x,50);
(%o70) 122549

--> limit(x**3-x**2+x-1,x,100);
(%o71) 990099

--> limit(x**3-x**2+x-1,x,1000);
(%o72) 999000999

--> limit(x**3-x**2+x-1,x,10000);
(%o73) 999900009999

--> limit(x**3-x**2+x-1,x,100000);
(%o74) 999990000099999

--> limit(x**3-x**2+x-1,x,1);
(%o75) 0

--> limit(x**3-x**2+x-1,x,11);
(%o76) 1220

--> limit(x**3-x**2+x-1,x,121);
(%o77) 1757040
maxima_e-book.wxmx 22 / 24

--> limit(x**3-x**2+x-1,x,10,minus);
(%o78) 909

--> limit(x**3-x**2+x-1,x,10,plus);
(%o79) 909

--> f(x):=(x^2+4)/(x-2)$
(print("x"," "," ","f(x)"),
for i:1 thru 10 do
(fun:float(2-1/(10**i)),
f:float(f(fun)),print(fun," ",f)));
x f(x)
1.9 − 76.09999999999992
1.99 − 796.0099999999993
1.999 − 7996.001000000882
1.9999 − 79996.00010000881
1.99999 − 799996.0000047591
1.999999 − 7999996.000659133
1.9999999 − 7.999999595329074 10 7
1.99999999 − 8.000000008619769 10 8
1.999999999 − 7.999999334077087 10 9
1.9999999999 − 7.999999337677087 10 10
(%o81) done

--> f(x):=(x^2+4)/(x-2)$
(print("x"," "," ","f(x)"),
for i:1 thru 10 do
(fun:float(2+1/(10**i)),
f:float(f(fun)),
print(fun," ",f)));
x f(x)
2.1 84.09999999999992
2.01 804.010000000017
2.001 8004.001000000881
2.0001 80004.00009983116
2.00001 800004.0000047591
2.000001 8000003.998882776
2.0000001 8.00000041309264 10 7
2.00000001 8.000000088619769 10 8
2.000000001 7.999999342077087 10 9
2.0000000001 7.999999338477087 10 10
(%o83) done

--> wxplot2d([(x^2+4)/(x-2)], [x,-5,5]);

(%t84)

(%o84)
maxima_e-book.wxmx 23 / 24

--> limit((x^2+4)/(x-2),x,2);
(%o85) infinity

--> limit((x^2+4)/(x-2),x,2,minus);
(%o86) −∞

--> limit((x^2+4)/(x-2),x,2,plus);
(%o87) ∞

--> wxplot2d([(x^2+4)/(x-2)],[x,-5,5]);

(%t88)

(%o88)

6 Continuity

A function is said to be continuous if:


a) f(x) is defined at x = a, i.e. f(a) exists.
b) lim x tends to a f(x) exists.
c) lim x tends to a f(x) = f(a).

--> f(x):=(x^2 - 9)/(x-3)$


s: read("Enter the value of x")$
c:limit(f(x),x,s);
r:limit(f(x),x,s,plus);
l:limit(f(x),x,s,minus);
if (r= c ) and (c=l) then
print(" f is continuous at x=",s)
else
print("f is not continuous")$
Enter the value of x 3;
(c) 6
(r) 6
(l) 6
f is continuous at x= 3

Conclusion: Note that as x approaches 3, (x^2 - 9)/(x-3) approaches 6,


proving that the function is continuous at x = 3.

7 Diffrentiability

A function is said to be diffrentiable if:


1.LHD exists
2.RHD exists
3.LHD=RHD for a given function f(x)
maxima_e-book.wxmx 24 / 24

The formula used is:


limx!x0
f(x) − f(x1)/x-x1

--> a:-2$
g1(x):= 3+x^2/2$
g2(x):= 7+x$
l:limit(ratsimp((g1(x)-g1(a))/(x-a)),x,a,minus);
r:limit(ratsimp((g2(x)-g1(a))/(x-a)),x,a,plus);
if(l=r) then
print("g is differentiable")
else
print("g is not differentiable")$
(l) −2
(r) 1
g is not differentiable

--> wxdraw2d(user_preamble="set zeroaxis linetype 1000; set xtics axis; set ytics axis;",
yrange=[-20,20], xrange=[-10,10],explicit(3+x^2/2,x,-10,-2),explicit(7+x,x,-2,10),points([[-2,5]]));

(%t101)

(%o101)

Concluding Remarks: Although the given function is not differentiable at x = −2, it is continuous for all
x. Now we will examine a piece-wise function that is continuous as well as differentiable everywhere.