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.

f(x):=-0.5*(x^2) + 2.5*x + 4.5;
macheps:0.01;
lower: 5;
upper: 10;
i:1;
newroot: upper - ((f(upper)*(lower-upper))/(f(lower)-f(upper)));
ea: 100;
/*Displays the values of iteration count 1*/display(i);
display(lower);
display(upper);
display(newroot);
display(ea);
/*loops starting at i=2,terminates when ea is less than macheps*/for i:2 while ea>macheps do (		/*stores the value of newroot into old root 	before newroot changes value*/	oldroot:newroot,		/*Executes if there is an exact root	(supposedly )terminates the program*/	if f(lower)*f(newroot)=0 then (display(newroot), quit()) 		/*replaces the upper bound with the value of newroot*/	elseif f(lower)*f(newroot)<0 then upper:newroot 		/*replaces the lower bound with the value of newroot*/	elseif f(lower)*f(newroot)>0 then lower:newroot,		/*computes for the new values of ea and root*/	newroot: upper - ((f(upper)*(lower-upper))/(f(lower)-f(upper))),	ea: (abs((newroot-oldroot)/newroot))*100,		/*displays the values of iteration count i*/	display(i),	display(lower),	display(upper),	display(newroot),	display(ea)		 );
/*displays the approximate root*/approximate_root:newroot;
display(approximate_root);

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