Sponsored links: Algebra eBooks
 

Help Index

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

The Maxima on-line user's manual

Algebra Calculator

Search:

Quit

Function: quit () Terminates the Maxima session. Note that the function must be invoked as quit(); or quit()$, not quit by itself.

/*Name: GEROME P. MASIGLATSection: EF-2LCourse/College: BSCS/CASDate: July 31, 2013Exercise #4*//*GIVEN*/f(x):= x^6 - 7*(x^4) + 15*(x^2) - 9;
macheps:1;
x0: 1.3;
	x1: 1.4;
x2: 1.5;
/*FOR THE FIRST ITERATION*/i:1;
h0 : x1 - x0;
h1 : x2 - x1;
d0: (f(x1)-f(x0))/h0;
d1: (f(x2)-f(x1))/h1;
a: (d1-d0)/(h1+h0);
b: a*h1+d1;
c: f(x2);
d: sqrt(b^2-4*a*c);
if abs(b-d)<abs(b+d) then d:abs(d) else d:-(abs(d));
x3: x2+(-2*c/(b+d));
ea: abs((x3-x2)/x3)*100;
display("i	x1	x2	x3	h0	h1	d0	d1	a	b	c	d	ea");
/*Displays the values of iteration count 1*/display(i,	x0,	x1,	x2,	x3,	h0,	h1,	d0,	d1,	a,	b,	c,	d, ea);
/*FOR THE NEXT ITERATIONS*/for i:2 while ea>macheps do (	x0: x1,	x1: x2,	x2: x3,			/*COMPUTES THE NEEDED VALUES*/	h0:x1 - x0,	h1:x2 - x1,	d0: (f(x1)-f(x0))/h0,	d1: (f(x2)-f(x1))/h1,	a: (d1-d0)/(h1+h0),	b: a*h1+d1,	c: f(x2),	d: sqrt(b^2-4*a*c),	if abs(b-d)<abs(b+d) then d:abs(d) else d:-(abs(d)),	x3: x2+(-2*c/(b+d)),	ea: abs((x3-x2)/x3)*100,		/*IF THE EXACT ROOT IS FOUND*/	if f(x3)=0 then (display(x3), quit()), 	/*PRINTS THE VALUES FOR THE CURRENT ITERATION*/	display(i,	x0,	x1,	x2,	x3,	h0,	h1,	d0,	d1,	a,	b,	c,	d,	ea)		 );
/*PRINTS THE APPROXIMATE ROOT*/display("APPROXIMATE ROOT:", x3);

To stop a lengthy computation, type control-C. The default action is to return to the Maxima prompt. If *debugger-hook* is nil, control-C opens the Lisp debugger. See also debugging.

(%o1)                                true
(%i2) 

Related Examples