Wxmaxima File - WXMX
Wxmaxima File - WXMX
Wxmaxima File - WXMX
wxmx 1 / 24
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.
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
--> sqrt(81);
(%o12) 9
Example:
--> abs(-11);
(%o2) 11
Example:
--> ceiling(22/7);
(%o3) 4
Example:
--> floor(22/7);
(%o4) 3
Example:
--> max(7,2,9,23);
(%o5) 23
Example:
--> min(4,90,45,1);
(%o6) 1
Example:
--> round(43.78);
(%o7) 44
Example:
--> exp(54.9);
(%o8) 6.96252963165224 10 23
Example:
--> log(1);
(%o10) 0
maxima_e-book.wxmx 3 / 24
Printing precision
Example:
--> a:2345;
(a) 2345
Example:
--> f(x):=x^2-3*x+1;
(%o11) f x := x 2 − 3 x + 1
1.7 Lists
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 ] ]
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
--> sin(%pi/4);
1
(%o13)
2
--> cos(%pi/2);
(%o14) 0
--> tan(%pi/4);
(%o15) 1
--> cot(%pi/3);
1
(%o17)
3
--> csc(%pi/2);
(%o18) 1
--> sec(%pi/6);
2
(%o19)
3
--> 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.
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
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]
2 A Programming approach
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
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$
Syntax:
if cond_1 then
expr_1
else if cond_2 then /* Use words for logical operators */
expr_2
else
expr_3$
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
2.3 Iterations
--> sum:0$
for i:1 thru 50 do sum:sum+i$
print("Sum is",sum)$
Sum is 1275
WAP to check if agiven number is even or odd and print the next 20 even or odd numbers repectively
3 Functions
--> 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)
f(x)=sinx
--> 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
(%t24)
(%o24)
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
(%t38)
(%o41) done
Neither Increasing nor Decreasing
maxima_e-book.wxmx 12 / 24
(%t46)
(%o49) done
increasing function
4 Plotting graphs
--> 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)
--> 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)
(%t56)
(%o56)
(%t57)
(%o57)
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)
--> 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
--> 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
(%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
7 Diffrentiability
--> 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.