Warning: this is an htmlized version!
The original is across this link,
and the conversion rules are here.
#######
#
# E-scripts about Maxima.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/maxima.e>
#           or at <http://angg.twu.net/e/maxima.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######





# «.maxima-debs»		(to "maxima-debs")
# «.maxima-emacs»		(to "maxima-emacs")
# «.empty-PS2-problem»		(to "empty-PS2-problem")
# «.maxima-deb-src»		(to "maxima-deb-src")
# «.mailing-lists»		(to "mailing-lists")
# «.producing-eps»		(to "producing-eps")
# «.draw2d»			(to "draw2d")
# «.eepitch-region»		(to "eepitch-region")
# «.casting-spels»		(to "casting-spels")
# «.lisp»			(to "lisp")
# «.dispfun»			(to "dispfun")
# «.command-line»		(to "command-line")
# «.grind»			(to "grind")
# «.init-file»			(to "init-file")
# «.syntax»			(to "syntax")
# «.gurro-book»			(to "gurro-book")
# «.maxima-cvs»			(to "maxima-cvs")
# «.hollow-points»		(to "hollow-points")
# «.draw-apply»			(to "draw-apply")
# «.riemann»			(to "riemann")
# «.maxima-gpdraw»		(to "maxima-gpdraw")
# «.implicit»			(to "implicit")
# «.listify»			(to "listify")
# «.torus-with-flux»		(to "torus-with-flux")
# «.lambda»			(to "lambda")
# «.seq»			(to "seq")
# «.n^2+n+41»			(to "n^2+n+41")
# «.expand-and-ev»		(to "expand-and-ev")
# «.2010.1-C2-P1»		(to "2010.1-C2-P1")
# «.2010.1-C2-trab-area»	(to "2010.1-C2-trab-area")
# «.inverse-transformations»	(to "inverse-transformations")



# http://en.wikipedia.org/wiki/Maxima_%28software%29
# http://math-blog.com/2007/06/02/3-awesome-free-math-programs/
# http://math-blog.com/2007/06/04/a-10-minute-tutorial-for-solving-math-problems-with-maxima/

apti maxima-emacs maxima-doc maxima-src gnuplot-x11 gnuplot-doc





#####
#
# maxima-debs
# 2008jun09
#
#####

# «maxima-debs»  (to ".maxima-debs")
# (find-zsh "availabledebs | sort | grep maxima")

apti maxima maxima-share maxima-doc maxima-emacs maxima-src gnuplot-x11
apti xmaxima wxmaxima
apti libgmp3c2

# /usr/lib/maxima/5.10.0/binary-gcl/maxima: error while loading shared
# libraries: libgmp.so.3: cannot open shared object file: No such file
# or directory
# (find-dmissing "libgmp.so")
# (eev "apti libgmp3c2")

# (find-status   "maxima")
# (find-vldifile "maxima.list")
# (find-udfile   "maxima/")
# (find-status   "maxima-share")
# (find-vldifile "maxima-share.list")
# (find-udfile   "maxima-share/")
# (find-status   "maxima-doc")
# (find-vldifile "maxima-doc.list")
# (find-udfile   "maxima-doc/")
# (find-status   "maxima-emacs")
# (find-vldifile "maxima-emacs.list")
# (find-udfile   "maxima-emacs/")
# (find-status   "maxima-src")
# (find-vldifile "maxima-src.list")
# (find-udfile   "maxima-src/")

# (find-status   "xmaxima")
# (find-vldifile "xmaxima.list")
# (find-udfile   "xmaxima/")
# (find-status   "wxmaxima")
# (find-vldifile "wxmaxima.list")
# (find-udfile   "wxmaxima/")
# file:///usr/share/doc/xmaxima/

# (code-c-d "maximasrc" "/usr/share/maxima/5.10.0/src/")
# (find-maximasrcfile "")

# (find-man "1 maxima")
# (find-man "1L maxima")



#####
#
# maxima-emacs
# 2008jun09
#
#####

# «maxima-emacs»  (to ".maxima-emacs")
# (find-zsh "dmissing site-lisp/maxima")
# (find-status   "maxima-emacs")
# (find-vldifile "maxima-emacs.list")
# (find-udfile   "maxima-emacs/")

# (code-c-d "maximael" "/usr/share/emacs/site-lisp/maxima/")
# (find-maximaelfile "")
# (find-maximaelgrep "grep -nH -e defun *")

# (find-maximaelfile "bookmode.el")
# (find-maximaelfile "emaxima.el")
# (find-maximaelfile "emaxima.lisp")
# (find-maximaelfile "maxima-font-lock.el")
# (find-maximaelfile "maxima.el")
# (find-maximaelfile "smart-complete.el")
# (find-maximaelfile "sshell.el")

# (require 'maxima)
# (maxima-mode)
# (fundamental-mode)




#####
#
# Problem with the empty PS2 prompt
# 2009jul12
#
#####

# «empty-PS2-problem»  (to ".empty-PS2-problem")
# (find-bashnode "Bourne Shell Variables" "`PS2'")
# (find-es "bash" "bash-3.2-info")
# (find-eapropos "comint")
# (find-eapropos "comint" "comint-prompt-regexp")
# (find-evariable 'comint-use-prompt-regexp)
# (find-evariable 'comint-use-prompt-regexp)
# (find-efunction 'comint-send-input)
# (find-maximafile "")
# (find-maximagrep "grep -niH -e prompt *")
# (find-maximagrep "grep -nH -e prompt *")
# (find-maximagrep "grep -niH -e incomplete *")
# (find-maximagrep "grep -niH -e input *")
# (find-maximagrep "grep -niH -e format *")
# (find-maximagrep "grep -niH -e interact *")
# (find-maximaelgrep "grep -nH -e inferior-maxima-prompt *")
# (find-maximaelgrep "grep -nH -e wait *")
# (find-es "lisp" "dpans2texi")

<edrx> hello... I am trying to run in a comint buffer a program -
       Maxima - that has the empty string as its $PS2-ish prompt,
       and so every time that I issue an incomplete command in
       maxima emacs (sort of) freezes waiting for a prompt, and I
       have to break its waiting loop with a C-g... how do I
       disbale the wait-for-a-prompt feature in a comint buffer?

# (find-node "(xmaxima)Openmath plots")
# (find-xmaximanode "Openmath plots")

# (find-zsh "dmissing xmaxima")





#####
#
# maxima (from the debian sources)
# 2009jul12
#
#####

# «maxima-deb-src»  (to ".maxima-deb-src")
# http://ftp.debian.org/debian/pool/main/m/maxima/
# http://ftp.debian.org/debian/pool/main/m/maxima/maxima_5.13.0-3.1.dsc
# http://ftp.debian.org/debian/pool/main/m/maxima/maxima_5.13.0-3.1.diff.gz
# http://ftp.debian.org/debian/pool/main/m/maxima/maxima_5.13.0.orig.tar.gz
#*
rm -Rv ~/usrc/maxima/
mkdir  ~/usrc/maxima/
cd $S/http/ftp.debian.org/debian/pool/main/m/maxima/
cp -v maxima_5.13.0* ~/usrc/maxima/
cd     ~/usrc/maxima/
dpkg-source -sn -x maxima_5.13.0-3.1.dsc
cd     ~/usrc/maxima/maxima-5.13.0/
dpkg-buildpackage -us -uc -b -rfakeroot     |& tee odb

#*
# (find-fline "~/usrc/maxima/")
* (eepitch-shell)
cd ~/usrc/maxima/
sudo dpkg -i *.deb

#*
# (code-c-d "maximasrc" "~/usrc/maxima/maxima-5.13.0/")
# (find-maximasrcfile "")

# http://ftp.debian.org/debian/pool/main/m/maxima/
# http://ftp.debian.org/debian/pool/main/m/maxima/maxima_5.17.1-1.dsc
# http://ftp.debian.org/debian/pool/main/m/maxima/maxima_5.17.1-1.diff.gz
# http://ftp.debian.org/debian/pool/main/m/maxima/maxima_5.17.1.orig.tar.gz
#*
rm -Rv ~/usrc/maxima/
mkdir  ~/usrc/maxima/
cd $S/http/ftp.debian.org/debian/pool/main/m/maxima/
cp -v maxima_5.17.1* ~/usrc/maxima/
cd     ~/usrc/maxima/
dpkg-source -sn -x maxima_5.17.1-1.dsc
cd     ~/usrc/maxima/maxima-5.17.1/
dpkg-buildpackage -us -uc -b -rfakeroot     |& tee odb

#*
# (find-fline "~/usrc/maxima/")
* (eepitch-shell)
cd ~/usrc/maxima/
sudo dpkg -i *.deb

#*
# (code-c-d "maximasrc" "~/usrc/maxima/maxima-5.17.1/")
# (find-maximasrcsh "find * -type f | sort")
# (find-maximasrcfile "")
# (find-maximasrcfile "share/calculus/pade2.mac")
# (find-maximasrcfile "src/buildq.lisp")
# (find-maximasrcfile "src/nparse.lisp")
# (find-maximasrcfile "src/nparse.lisp" "recognize '#' comments")
# (find-maximasrcfile "src/nparse.lisp" "The Expression Parser")
# (find-maximasrcfile "tests/wester_problems/test_indefinite_integrals.mac")

# (find-maximanode "Functions and Variables for Expressions" "infix")
# (find-maximanode "Syntax")






# (find-maximanode "Functions and Variables for Series" "Function: revert")






# (find-node "(maxima)Introduction to Maxima")
# (find-node "(maxima)Introduction to Maxima" "integrate (1/(1 + x^3), x);")
# (find-node "(maxima)Introduction to Command Line" "integrate (x^2, x, x0, x1);")
# (find-node "(maxima)Comments")
# (find-node "(maxima)Introduction to Integration")


# (find-man "1 maxima")
# (find-man "1L maxima")

(defun eepitch-maxima () (interactive)
  (eepitch-comint "maxima" "maxima"))

(defun eepitch-maxima () (interactive)
  (eepitch '(maxima)))



* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
maxima
factor(10!);
expand ((x + y)^6);
factor (x^6 - 1);
quit();

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
factor(10!);
expand ((x + y)^6);
factor (x^6 - 1);
quit();

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
? integ
6 5

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
u: expand ((x + y)^6);
diff (u, x);
factor (%o2);
cos(%pi);
exp(%i*%pi);
u: expand ((x + y)^6);
diff (%, x);
integrate (1/(1 + x^3), x);
linsolve ([3*x + 4*y = 7, 2*x + a*y = 13], [x, y]);
solve (x^3 - 3*x^2 + 5*x = 15, x);
eq_1: x^2 + 3*x*y + y^2 = 0$
eq_2: 3*x + y = 1$
solve ([eq_1, eq_2]);
eq_1: x^2 + 3*x*y + y^2 = 0$
eq_2: 3*x + y = 1$
solve ([eq_1, eq_2]);
kill(labels);
plot2d (sin(x)/x, [x, -20, 20]);
plot2d ([atan(x), erf(x), tanh(x)], [x, -5, 5]);
plot3d (sin(sqrt(x^2 + y^2))/sqrt(x^2 + y^2), [x, -12, 12], [y, -12, 12]);
** foo


# (find-node "(maxima)Lisp and Maxima")
# (find-node "(maxima)Documentation")
# (find-node "(maxima)Definitions for Help")
# (find-node "(maxima)Source Level Debugging")
# (find-node "(maxima)Function and Variable Index")
# (find-node "(maxima)Definitions for Equations" "Function: allroots")

:lisp (+ 1 2)
:lisp ; (+ 1 2)



* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
p(x) := 2 - x^2;
r(x) := 2*x - 1;
s(x) := 1/2 * (cos (%pi/2 * x)) - 3/2;
P(a, b) := integrate(p(x), x, a, b);
R(a, b) := integrate(r(x), x, a, b);
S(a, b) := integrate(s(x), x, a, b);
s(0);
s(-1);
s(-2);
P(-2, 1);                       /*  3 */
           S(-2, 0);            /* -3 */
                      R(0, 1);  /*  0 */
P(-2, 1) - S(-2, 0) - R(0, 1);

integrate(sin(2*x), x);
integrate(sin(2*x - 4), x);
integrate(sin(2*x^2), x);
integrate(sin(x)^1 * cos(x)^3, x);
integrate(sin(x)^2 * cos(x)^3, x);
integrate(sin(x)^3 * cos(x)^3, x);
integrate(sin(x)^4 * cos(x)^3, x);
integrate(sqrt(1 - x^2), x);
integrate(sqrt(1 - x^2), x, -1, 1);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(draw);
draw3d(xu_grid      = 50,
       yv_grid      = 15,
       surface_hide = true,
       /* terminal     = eps, */
         parametric_surface(cos(a)*(3+b*cos(a/2)),
                            sin(a)*(3+b*cos(a/2)),
                            b*sin(a/2), a,-%pi,%pi,b,-1,1
                           )
      );

*;; (find-maximanode "Comments")
*;; (find-maximanode "Functions and Variables for Contexts")
*;; (find-maximanode "Function")
a: 22;
b: 33;
a + b;
p

;; (find-maximanode "Lisp and Maxima")
;; (find-maximanode "Functions and Variables for Help")
;; (find-maximaelfile "")
;; (find-maximaelfile "maxima.el")
;; (find-maximaelfile "sshell.el")

factor(10!);
expand ((x + y)^6);
factor (x^6 - 1);
quit();




#####
#
# mailing lists
# 2009jul12
#
#####

# «mailing-lists»  (to ".mailing-lists")
# http://maxima.sourceforge.net/maximalist.html
# http://maxima.sourceforge.net/compalg.html




#####
#
# producing .eps files
# 2009sep16
#
#####

# «producing-eps»  (to ".producing-eps")
# http://maxima-project.org/wiki/index.php?title=Gallery
# http://www.math.utexas.edu/pipermail/maxima/2008/010300.html
# http://www.telefonica.net/web2/biomates/maxima/gpdraw/
# (find-node "(maxima)Functions and Variables for draw" "eps_height")
# http://www.telefonica.net/web2/biomates/index.html
# http://www.telefonica.net/web2/biomates/maxima/gpdraw/index.html
# http://www.telefonica.net/web2/biomates/maxima/gpdraw/func2d/index.html

;; (find-angg ".emacs" "eepitch-region")
;; (define-key eev-mode-map [f8]   'eepitch-this-line-or-region)

;; (find-maximanode-draw nil '(ee-write (point-min) (point-max) "" "" "/tmp/o"))
;; (find-sh "grep '^ --' /tmp/o | awk -F: '{print $2}' | awk '{print $1}' | sort | uniq")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(draw);

draw2d(explicit(u^2,u,-3,3));

draw2d(explicit(x^3,x,-1,1),
       xaxis       = true,
       xaxis_color = blue,
       yaxis       = true,
       yaxis_width = 2,
       yaxis_type  = solid,
       yaxis_color = "#f3b507");

draw2d(
   transparent = true,
   explicit(sin(x),x,0,10),
   rectangle([1,-1/2],[4,1/2]),
   yaxis_secondary = true,
   ytics_secondary = true,
   color = blue,
   explicit(100*sin(x+0.3)+2,x,0,10),
   rectangle([5,-30],[8,60])
   )$

draw2d(
   /* activate both secondary axes */
   xtics_secondary = auto,
   ytics_secondary = auto,

   /* red curve is plotted against secondary x-axis and primary y-axis */
   xaxis_secondary = true,
   color = red,
   key = "top x, left y",
   explicit(sin(x),x,0,20),

   /* blue curve is plotted against primary x-axis and secondary y-axis */
   xaxis_secondary = false,
   yaxis_secondary = true,
   color = blue,
   key = "bottom x, right y",
   explicit(100*sin(x+0.3)+2,x,0,10),
   terminal = wxt) $

draw2d(color = green,
           explicit(u^2,u,-2,2), 
           explicit(sin(z),z,2,6),
       /* terminal  = png, */ 
       title     = "My 1st title");

draw2d(/* terminal   = eps_color, */
       key        = "Exponential func",
       color      = blue,
       line_width = 4,
            explicit(exp(x),x,-1,3),
       line_width = 2,
       color      = "#00ff00",   /* green, in hexadecimal */
       key        = "Cubic poly",
            explicit(%pi*x^3+sqrt(2)*x^2+10,x,0,3),
       xlabel     = "Horizontal axis",
       ylabel     = "Vertical axis");

draw2d(/* the rational function */
       grid   = true,
       key    = "y = x^2/(x-2)",
       yrange = [-10,20],
       color  = red,
         explicit(x^2/(x-2),x,-9,15),

       /* asymptotes */
       key       = "",
       line_type = dots,
       color     = blue,
         explicit(x+2,x,-9,15),
       nticks = 70,
         parametric(2,t,t,-10,20),

       /* labels and arrows */
       head_length = 0.3,
       color     = black,
       line_type   = solid,
           vector([5.35,2.45],[-1.53,3.25]),
           vector([-1,7.5],[3,0]),
       label_alignment = left,
           label(["y = x+2",6,2.5]),
       label_alignment = right,
           label(["x = 2",-1.7,7.5])    );

draw2d(/* terminal   = png */
       logy=true,
       xlabel = "x",
       ylabel = "log(y)",
       color  = red,
         explicit(exp(x),x,0.1,20),
       axis_top   = false,
       axis_right = false,
       grid       = true,
       title      = "Logarithmic scale");

draw2d(
  xlabel = "Default tics",
  ylabel = "No tics",
  ytics  = 'none,
  explicit(x^3,x,-1,1)  );

draw2d(
  xlabel = "Start-increment-end",
  ylabel = "Tics intervals 0.25",
  xtics  = [-3/4,1/8,3/4],
  ytics  = 1/4,
  explicit(x^3,x,-1,1)  );

draw2d(
  xlabel     = "User selected tics on axis",
  ylabel     = "Rotated labeled tics",
  xtics      = {-1/2,-1/4,3/4}, /* set of numbers */
  xtics_axis = true,            /* plot tics on x-axis */
  ytics      = {["High",0.75],["Medium",0],["Low",-0.75]},
  ytics_rotate = true,
  grid       = true,
  explicit(x^3,x,-1,1)  );

load(distrib)$
draw2d(terminal    = eps_color,
       title       = "Normal probability",
       grid        = true,
       axis_top    = false,
       axis_right  = false,
       filled_func = true,
       fill_color  = "light-blue",
       key         = "Pr(-1 < X < 0)",
       explicit(pdf_normal(x,0,1),x,-1,0),
       key         = "Pr(1 < X <2)",
       fill_color  = "dark-blue",
       explicit(pdf_normal(x,0,1),x,1,2),
       filled_func = false,
       color       = red,
       key         = "Normal density N(0,1)",
       explicit(pdf_normal(x,0,1),x,-3,3)  );

draw2d(fill_color  = grey,
       filled_func = sin(x),
       explicit(-sin(x),x,0,%pi),
       fill_color  = cyan,
       explicit(-sin(x),x,%pi,2*%pi));

f1: 2*x^2-5*x+3$
f2: -8*x^2-x+30$
[x1,x2]: map('rhs, solve(f1=f2));
draw2d(title       = "Region bounded by two functions",
       fill_color  = grey,
       filled_func = f2,
       explicit(f1,x,x1,x2),
       filled_func = false,
       xaxis       = true,
       xtics_axis  = true,
       yaxis       = true,
       line_width  = 2,
       key         = string(f1),
       color       = red,
       explicit(f1,x,-3,3),
       key         = string(f2),
       color       = blue,
       explicit(f2,x,-3,3) );

draw2d(bars([1,5,0.2],[2,7,0.2],[3,-4,0.1],[4,-2,1],[5,3,1]),
       xaxis = true,
       xtics = {["Ford",1],["Opel",2],["Citroen",3],["Toyota",4],["Teletransportation",5]} );

draw2d(key          = "Group A",
       fill_color   = blue,
    /* fill_density = 0.2, */
       bars([0.8,5,0.4],[1.8,7,0.4],[2.8,-4,0.4]),
       key          = "Group B",
       fill_color   = red,
    /* fill_density = 0.6, */
       line_width   = 4,
       bars([1.2,4,0.4],[2.2,-2,0.4],[3.2,5,0.4]),
       xaxis = true);






#####
#
# eepitch-region
# 2009sep21
#
#####

# «eepitch-region»  (to ".eepitch-region")
# (find-angg ".emacs" "eepitch-region")




#####
#
# draw2d
# 2009sep21
#
#####

# «draw2d»  (to ".draw2d")
# (find-status   "gnuplot")
# (find-vldifile "gnuplot.list")
# (find-udfile   "gnuplot/")
# (find-node "(maxima)draw")
# http://maxima.cvs.sourceforge.net/viewvc/maxima/maxima/share/draw/
# http://maxima.cvs.sourceforge.net/viewvc/maxima/maxima/

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rv /tmp/draw/
mkdir  /tmp/draw/
cd     /tmp/draw/
cvs     -d:pserver:anonymous@cvs.maxima.sourceforge.net:/cvsroot/maxima login 

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(draw);
draw2d(explicit(x^3, x, -1, -1),
       xaxis       = true,
       xaxis_color = blue,
       yaxis       = true,
       yaxis_width = 2,
       yaxis_type  = solid,
       yaxis_color = "#f3b507");






#####
#
# Casting SPELs
# 2009sep16
#
#####

# «casting-spels»  (to ".casting-spels")
# http://www.telefonica.net/web2/biomates/maxima/casting/csintro.htm
# http://www.telefonica.net/web2/biomates/maxima/casting/cs1.htm
# http://www.telefonica.net/web2/biomates/maxima/casting/cs2.htm
# http://www.telefonica.net/web2/biomates/maxima/casting/cs3.htm
# http://www.telefonica.net/web2/biomates/maxima/casting/cs4.htm
# http://www.telefonica.net/web2/biomates/maxima/casting/cs5.htm
# http://www.telefonica.net/web2/biomates/maxima/casting/cs6.htm
# http://www.telefonica.net/web2/biomates/maxima/casting/cs7.htm

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
objects: '[whiskey_bottle, bucket, chain, frog]$
map: '[[living_room,
        "you are in the living_room of a wizards house.
         there is a wizard snoring loudly on the couch. ",
        [west, door, garden],
        [upstairs, stairway, attic] ],
       [garden,
        "you are in a beautiful garden.
         there is a well in front of you. ",
        [east, door, living_room] ],
       [attic,
        "you are in the attic of the wizards house.
         there is a giant welding torch in the corner. ",
        [downstairs, stairway, living_room] ]]$
map;
*
object_locations: '[[whiskey_bottle, living_room],
                    [bucket, living_room],
                    [chain, garden],
                    [frog, garden]]$
location: 'living_room$
*
describe_location(location, map):= second( assoc_(location, map))$
*
assoc_(key,alist):= block(
  [ result:false ],
  for elem in alist do
  if key=first(elem) then return(result:elem),
  result )$
*
describe_location(location,map);
*
describe_path(path):=
   sconcat("there is a ", path[2], " going ", path[1], " from here. ")$
*
describe_path('[west, door, garden]);
*
describe_paths(location,map)=
   apply( sconcat, map( describe_path,rest( assoc_(location,map),2 ) ) )$
describe_paths(location,map);
*
is_at(obj,loc,obj_loc):= block(
   [ tmp:assoc_(obj,obj_loc) ],
   listp(tmp) and is(second(tmp)=loc) )$
*
is_at('bucket,'living_room,object_locations);
describe_floor(loc,objs,obj_loc):=
   apply( sconcat,
          map( lambda([x],sconcat("you see a ",x," on the floor. ")),
               sublist( objs, lambda([x],is_at(x,loc,obj_loc)) ) ))$
describe_floor('living_room,objects,object_locations);
l_o_o_k():=
   sconcat( describe_location(location,map),
            describe_paths(location,map),
            describe_floor(location,objects,object_locations) )$
nofix("look")$
"look"():= l_o_o_k()$
look;




#####
#
# Lisp
# 2009oct03
#
#####

# «lisp»  (to ".lisp")
# (find-maximanode "Lisp and Maxima")
# (find-maximanode "Lisp and Maxima" "mfuncall")
# (find-maximanode "Lisp and Maxima" "`#$<expr>$'")
# (find-maximanode "Function")
# (find-maximanode "Macros" "`splice (<x>)'")
# (find-node "(ansicl)Top")
# (find-es "lisp" "dpans2texi")
# (find-node "(ansicl)Backquote")
# (find-elnode "Building Lists" "Function: number-sequence")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(draw);
to_lisp();
  (+ 1 2)
  #$draw3d$
  (to-maxima)
:lisp #$[x, y, z]$
:lisp (displa '((MLIST SIMP) $X $Y $Z))
:lisp (msetq $foo #$[x, y]$)
foo: [x, y];
foo(x,y) := x*y;
foo;
:lisp (mfuncall '$foo 'a 'b)
:lisp (number-sequence 0 7)




#####
#
# dispfun
# 2009oct06
#
#####

# «dispfun»  (to ".dispfun")
# (find-maximanode "Functions and Variables for Function Definition")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
L : [1, 5, -10.2, 4, 3];
apply (min, L);
*
F (x) := x / 1729;
fname : F;
dispfun (F);
dispfun (fname);
apply (dispfun, [fname]);
*
demoivre;
demoivre (exp (%i * x));
apply (demoivre, [exp (%i * x)]);
apply ('demoivre, [exp (%i * x)]);
*
lambda ([x], if x < 0 then throw(x) else f(x));
g(l) := catch (map (''%, l));
g ([1, 2, 3, 7]);
g ([1, 2, -3, 7]);
*
expr : cos(y) - sin(x);
define (F1 (x, y), expr);
F1 (a, b);
F2 (x, y) := expr;
F2 (a, b);
*
define (G1 (x, y), x.y - y.x);
define (G2 [x, y], x.y - y.x);
*
define (H ([L]), '(apply ("+", L)));
H (a, b, c);
*
[F : I, u : x];
funmake (F, [u]);
define (funmake (F, [u]), cos(u) + 1);
define (arraymake (F, [u]), cos(u) + 1);
define (foo (x, y), bar (y, x));
define (ev (foo (x, y)), sin(x) - cos(y));
*
define_variable (foo, true, boolean);
foo;
foo: false;
foo: %pi;
foo;
*
define_variable (bar, 2, integer);
qput (bar, prime_test, value_check);
prime_test (y) := if not primep(y) then error (y, "is not prime.");
bar: 1439;
bar: 1440;
bar;
*
define_variable (baz_quux, 'baz_quux, any_check);
F: lambda ([y], if y # 'baz_quux then error ("Cannot assign to `baz_quux'."));
qput (baz_quux, ''F, value_check);
baz_quux: 'baz_quux;
baz_quux: sqrt(2);
baz_quux;
*
m(x, y) ::= x^(-y);
f(x, y) :=  x^(-y);
g[x, y] :=  x^(-y);
h[x](y) :=  x^(-y);
i[8](y) :=  8^(-y);
dispfun (m, f, g, h, h[5], h[10], i[8]);
*
 ''%;
*
F_1 (x) := x - 100;
F_2 (x, y) := x / y;
define (F_3 (x), sqrt (x));
G_1 [x] := x - 100;
G_2 [x, y] := x / y;
define (G_3 [x], sqrt (x));
H_1 [x] (y) := x^y;
functions;
arrays;
*
F (x, y) := y^2 - x^2;
funmake (F, [a + 1, b + 1]);
''%;
*
G (x) ::= (x - 1)/2;
funmake (G, [u]);
''%;
*
H [a] (x) := (x - 1)^a;
funmake (H [n], [%e]);
''%;
funmake ('(H [n]), [%e]);
''%;
*
funmake (A, [u]);
''%;
*
det(a,b,c) := b^2 -4*a*c;
(x : 8, y : 10, z : 12);
f : det;
funmake (f, [x, y, z]);
''%;
*
funmake (sin, [%pi / 2]);
*
f: lambda ([x], x^2);
f(a);
lambda ([x], x^2) (a);
apply (lambda ([x], x^2), [a]);
map (lambda ([x], x^2), [a, b, c, d, e]);
a: %pi$
b: %e$
g: lambda ([a], a*b);
b: %gamma$
g(1/2);
g2: lambda ([a], a*''b);
b: %e$
g2(1/2);
h: lambda ([a, b], h2: lambda ([a], a*b), h2(1/2));
h(%pi, %gamma);
i: lambda ([a], lambda ([x], a*x));
i(1/2);
i2: lambda([a], buildq([a: a], lambda([x], a*x)));
i2(1/2);
i2(1/2)(%pi);
*
f : lambda ([aa, bb, [cc]], aa * cc + bb);
f (foo, %i, 17, 29, 256);
g : lambda ([[aa]], apply ("+", aa));
g (17, 29, x, y, z, %e);
*
foo (x) := 1 - x;
foo (100);
block (local (foo), foo (x) := 2 * x, foo (100));
foo (100);
*
f (x) := h (x) / g (x);
g (x) ::= block (print ("x + 99 is equal to", x), return (x + 99));
h (x) ::= block (print ("x - 99 is equal to", x), return (x - 99));
macroexpansion: false;
f (a * b);
dispfun (f);
f (a * b);
*
f (x) := h (x) / g (x);
g (x) ::= block (print ("x + 99 is equal to", x), return (x + 99));
h (x) ::= block (print ("x - 99 is equal to", x), return (x - 99));
macroexpansion: expand;
f (a * b);
dispfun (f);
f (a * b);
*
f (x) := h (x) / g (x);
g (x) ::= block (print ("x + 99 is equal to", x), return (x + 99));
h (x) ::= block (print ("x - 99 is equal to", x), return (x - 99));
macroexpansion: displace;
f (a * b);
dispfun (f);
f (a * b);




#####
#
# Command line
# 2009oct06
#
#####

# «command-line»  (to ".command-line")
# (find-maximanode "Functions and Variables for Command Line" "`%', `%%', and `%th'")
# (find-maximanode "Functions and Variables for Command Line" "`%t'")
# (find-maximanode "Functions and Variables for Expressions" "`%t1', `%t2', ...")
# (find-maximanode "Functions and Variables for Input and Output" "`_', `%%', and `%th'")




#####
#
# grind
# 2009oct06
#
#####

# «grind»  (to ".grind")
# (find-maximanode "Functions and Variables for Input and Output" "grind (<expr>)")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
cholesky (A):= block ([n : length (A), L : copymatrix (A),
  p : makelist (0, i, 1, length (A))], for i thru n do
  for j : i thru n do
  (x : L[i, j], x : x - sum (L[j, k] * L[i, k], k, 1, i - 1),
  if i = j then p[i] : 1 / sqrt(x) else L[j, i] : x * p[i]),
  for i thru n do L[i, i] : 1 / p[i],
  for i thru n do for j : i + 1 thru n do L[i, j] : 0, L)$
grind (cholesky);


makelist
thru
map
vector

# (find-maximanode "Introduction to Expressions")
# (find-maximanode "Functions and Variables for Program Flow" "Special operator: do")
# (find-maximanode "Functions and Variables for Program Flow" "Function: map")
# (find-maximanode "Functions and Variables for Program Flow" "Function: maplist")
# (find-maximanode "Introduction to Lists")
# (find-maximanode "Functions and Variables for Lists")
# (find-maximanode "Functions and Variables for Lists" "Function: append")
# (find-maximanode "Functions and Variables for Lists" "Function: cons")
# (find-maximanode "Functions and Variables for Lists" "Function: create_list")
# (find-maximanode "Functions and Variables for Lists" "Function: makelist")
# (find-maximanode "Function and Variable Index" "* for:")

# (find-maximanode "Functions and Variables for Miscellaneous Options" "Function: args")
# (find-maximanode "Functions and Variables for Miscellaneous Options" "infolists")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
example(append);



#####
#
# init file
# 2009oct06
#
#####

# «init-file»  (to ".init-file")
# (find-maximanode "Introduction for Runtime Environment" "maxima-init.mac")
# (find-maximanode "Functions and Variables for Runtime Environment" "maxima_userdir")




#####
#
# Syntax
# 2009oct06
#
#####

# «syntax»  (to ".syntax")
# (find-maximanode "Introduction to Expressions")
# (find-maximanode "Nouns and Verbs")
# (find-maximanode "Identifiers")
# (find-maximanode "Strings")
# (find-maximanode "Syntax")
# (find-maximanode "General operators" "Operator: ::=")







#####
#
# Gilberto Urroz's draft Maxima book
# 2009sep16
#
#####

# «gurro-book»  (to ".gurro-book")
# (find-sh "lynx -dump http://www.neng.usu.edu/cee/faculty/gurro/Maxima.html")
# http://www.neng.usu.edu/cee/faculty/gurro/Maxima.html
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/Maxima0.8.2_Notes.pdf
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/MaximaBookChapter1.pdf
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/MaximaBookChapter2.pdf
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/MaximaBookChapter3.pdf
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/MaximaBookChapter4.pdf
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/MaximaBookChapter4.pdf
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/MaximaBookChapter5.pdf
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/MaximaBookChapter6.pdf
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/MaximaBookChapter7.pdf
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/MaximaBookChapter8.pdf
# http://www.neng.usu.edu/cee/faculty/gurro/Software_Calculators/Maxima_Docs/MyMaximaBook/MaximaBookChapter9.pdf

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd
find snarf/http/www.neng.usu.edu/cee/faculty/gurro/
tar -cvzf /tmp/2009oct06.tgz snarf/http/www.neng.usu.edu/cee/faculty/gurro/
cp     -v /tmp/2009oct06.tgz /tmp/pen/




#####
#
# Maxima from the CVS
# 2009sep22
#
#####

# «maxima-cvs»  (to ".maxima-cvs")
# http://maxima.sourceforge.net/download.html
# http://sourceforge.net/scm/?type=cvs&group_id=4933
# http://p.sf.net/sourceforge/cvs
# http://maxima.cvs.sourceforge.net/maxima
#*
rm -Rv ~/usrc/maxima-cvs/
mkdir  ~/usrc/maxima-cvs/
cd     ~/usrc/maxima-cvs/
tar -C ~/usrc/maxima-cvs/ -xvzf ~/tmp/maxima-cvs.tgz

cvs     -d:pserver:anonymous@maxima.cvs.sourceforge.net:/cvsroot/maxima login
cvs -z3 -d:pserver:anonymous@maxima.cvs.sourceforge.net:/cvsroot/maxima \
  co -P maxima

tar -cvzf ~/tmp/maxima-cvs.tgz .

#*
# (code-c-d "maximacvs"    "~/usrc/maxima-cvs/")
# (code-c-d "maximacvssrc" "~/usrc/maxima-cvs/maxima/")
# (find-maximacvssrcfile "")
# (find-maximacvssrcfile "bootstrap")
# (code-c-d "maximasrc" "~/usrc/maxima/maxima-5.17.1/")
# (find-maximasrcsh "find * -type f | sort")
# (find-maximasrcfile "")
# (find-maximasrcfile "odb")
# (find-maximasrcfile "debian/rules" "build-stamp:")
# (find-maximasrcfile "debian/rules" "install-stamp:")
# (find-maximasrcfile "INSTALL")

rm -Rv ~/usrc/maxima-cvs/
mkdir  ~/usrc/maxima-cvs/
cd     ~/usrc/maxima-cvs/
tar -C ~/usrc/maxima-cvs/ -xvzf ~/tmp/maxima-cvs.tgz
cd     ~/usrc/maxima-cvs/maxima/

# sh bootstrap         |& tee ob

aclocal-1.9
# automake-1.9
automake-1.9  --add-missing --copy
autoconf

#  --prefix=/usr \
#  --libexec=/usr/lib \
#  --mandir=/usr/share/man \
#  --infodir=/usr/share/info \

D=$HOME/usrc/maxima-cvs

GCL_ANSI=t ./configure --enable-gcl \
  $(gcl -batch -eval '#-native-reloc(princ "--enable-gcl-alt-link")(bye)') \
  --prefix=$D/usr \
  --libexec=$D/usr/lib \
  --mandir=$D/usr/share/man \
  --infodir=$D/usr/share/info \
    |& tee oc

GCL_ANSI=t make            |& tee om
GCL_ANSI=t make install    |& tee omi

#*
# (find-maximacvsfile "")
# (find-maximacvsfile "usr/share/info/")
# (find-maximacvssh "find usr | sort")
# (find-fline "~/usrc/maxima-cvs/usr/bin/")
(defun eepitch-maximacvs () (interactive)
  (eepitch-comint "maximacvs" "~/usrc/maxima-cvs/usr/bin/maxima"))

* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
load(draw);
draw3d(
   terminal   = screen,
   color      = blue,
   nticks     = 60,
   line_width = 3,
   enhanced3d = (u-1)^2,
   parametric(cos(5*u)^2,sin(7*u),u-2,u,0,2));

/* Multiple windows. */
draw2d(explicit(x^5,x,-2,2), terminal=[screen, 3]);
draw2d(explicit(x^2,x,-2,2), terminal=[screen, 0]);

/* An animated gif file. */
draw(
  delay     = 100,
  file_name = "/tmp/zzz",
  terminal  = 'animated_gif,
  gr2d(explicit(x^2,x,-1,1)),
  gr2d(explicit(x^3,x,-1,1)),
  gr2d(explicit(x^4,x,-1,1)));

*;; file:///tmp/zzz.gif

draw3d(enhanced3d = sin(u)+cos(v),
       /* terminal   = eps_color, */
       terminal   = screen,
       palette    = [8,4,3],
       eps_height = 15,
       eps_width  = 15,
       parametric_surface(cos(u)+.5*cos(u)*cos(v),
                          sin(u)+.5*sin(u)*cos(v),
                          .5*sin(v),
                          u, -%pi, %pi,
                          v, -%pi, %pi),
       parametric_surface(1+cos(u)+.5*cos(u)*cos(v),
                          .5*sin(v),
                          sin(u)+.5*sin(u)*cos(v),
                          u, -%pi, %pi,
                          v, -%pi, %pi));

psner http://www.telefonica.net/web2/biomates/maxima/gpdraw/ -np
#     http://www.telefonica.net/web2/biomates/maxima/gpdraw/index.html



#####
#
# hollow points
# 2009oct06
#
#####

# «hollow-points»  (to ".hollow-points")
# (find-maximacvsnode "Functions and Variables for draw" "Graphic option: point_type")
# (find-maximacvsnode "Functions and Variables for draw" "set_draw_defaults")

* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(draw);
F1(x) := -x^2 / 2;
F2(x) := -(x-4)^2 / 2;
F(x) := if x <= 2 then F1(x) else F2(x);
f1(x) := diff(F1(x), 'x);
f2(x) := diff(F2(x), 'x);
f(x) := if x <= 2 then f1(x) else f2(x);
set_draw_defaults(terminal = screen,
       xaxis = true,
       yaxis = true,
       xaxis_type = solid,
       yaxis_type = solid,
       xrange        = [-2, 7],
       yrange        = [-5, 4]);
draw2d(explicit(F(x),   x, -2, 7),
       explicit(F(x)+2, x, -2, 7));
draw2d(explicit(f1(x),  x, -2, 2),
       explicit(f2(x),  x,  2, 7),
       point_size = 3,
       point_type = circle,
       points([[2, f1(2)]]),
       point_type = filled_circle,
       points([[2, f2(2)]]));

*;; «draw-apply»  (to ".draw-apply")
*;; (find-maximacvssrcfile "share/draw/draw.lisp" "defun $draw")

* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
load(draw);
f1(x) := -x/2;
f2(x) := 2 - x/2;
Open(x, y)   := [point_size = 3, point_type = circle,        points([[x, y]])];
Closed(x, y) := [point_size = 3, point_type = filled_circle, points([[x, y]])];
Curves       :  [explicit(f1(x),  x, -2, 2), explicit(f2(x),  x,  2, 7)];
Switch       :  append(Open(2, f1(2)), Closed(2, f2(2)));
apply(draw2d, append(Curves, Switch));
  



#####
#
# Riemann integral
# 2009nov03
#
#####

# «riemann»  (to ".riemann")
# (find-maximacvsnode "Functions and Variables for draw" "option: points_joined")

* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
load(draw);
f(x) := exp(-x^2);
Curve : [explicit(f(x), x, -2, 2)];
Xaxis : [explicit(0, x, -2, 2)];
Block_options : [points_joined = true, point_type = none, line_type = solid];
Block_lines(x0, x1, y) := [points([[x0, 0], [x0, y], [x1, y], [x1, 0]])];
Block(x0, x1, y) := append(Block_options, Block_lines(x0, x1, y));
apply(draw2d, append(Curve, Xaxis, Block(-1, -0.5, f(-1)), Block(0, 0.5, f(0.5)))); 





#####
#
# Extra documentation for the "draw" package
# 2009oct13
#
#####

# «maxima-gpdraw»  (to ".maxima-gpdraw")
# (find-angg ".emacs" "maxima-gpdraw")




#####
#
# Implicit functions
# 2010mar15
#
#####

# «implicit»  (to ".implicit")
# (find-maximagpdraww3m "implic/index.html")
* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
load(draw);
draw2d(/* terminal  = eps, */
       grid      = true,
       line_type = solid,
       key       = "y^2=x^3-2*x+1",
         implicit(y^2=x^3-2*x+1, x, -4,4, y, -4,4),
       line_type = dots,
       key       = "x^3+y^3 = 3*x*y^2-x-1",
         implicit(x^3+y^3 = 3*x*y^2-x-1, x, -4,4, y, -4,4),
       title     = "Two implicit functions" );




#####
#
# Contour plots
# 2010mar15
#
#####

# (find-maximagpdraww3m "contours/index.html")
* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
load(draw);
draw3d(color = green,
         explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
       yv_grid = 10,
       color   = red,
         explicit(x+y,x,0,2,y,-5,5),
       contour_levels = 15,
       contour        = base,
       surface_hide   = true) ;
draw3d(title    = "This is the last contours example",
         explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
       contour_levels = 15,
       contour        = map,
       surface_hide   = true) ;
draw3d(title    = "This is the last contours example",
         explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
       contour_levels = 15,
       contour        = map,
       surface_hide   = true) ;
draw3d(explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
       contour_levels = 15,
       contour        = base,
       surface_hide   = true) ;
draw3d(explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
       contour_levels = 15,
       contour        = base,
       surface_hide   = false) ;
draw3d(explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3),
       contour_levels = 15,
       contour        = map) ;
draw3d(explicit((y^4)-(y^2-x^2), x,-0.8,0.8, y,-1.25,1.25),
       contour_levels = 15,
       contour        = base) ;

# (find-maximanode "Functions and Variables for Expressions" "infix")
# (find-maximanode "Function and Variable Index")
# (find-maximacvsnode "Function and Variable Index" "contour")






#####
#
# listify
# 2009oct13
#
#####

# «listify»  (to ".listify")
# (find-maximagpdraww3m "vectors/index.html")
# (find-maximagpdrawgrep "grep -nrH -e listify *")
# (find-maximacvsnode "Functions and Variables for Sets" "Function: listify")
# (find-maximacvsnode "Functions and Variables for Lists" "Function: makelist")
# (find-maximacvsnode "Functions and Variables for Lists" "Function: create_list")

* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
load(draw);
*
*;; A vector field is plotted as a set of vectors.
*;; /* vector origins are {(x,y)| x,y=1,...,10}  */
coord   : setify(makelist(k, k, 1, 10));
points2d: listify(cartesian_product(coord, coord));
*
*;; /* compute vectors at the given points  */
vf2d(x,y):= vector([x,y], 2*[sin(x), cos(y)]);
vf2d(2*%pi, %pi);
vect2: makelist(vf2d(k[1],k[2]), k, points2d);
*
*;; /* draw the vector field */
apply(draw2d,
      append([head_length=0.1, color=blue],
             vect2));

* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
makelist(concat(x, i), i, 1, 6);
makelist(x=y, y, [a, b, c]);
mymakelist(a, b, n) := makelist(a + (b-a)*(i/n), i, 0, n);
mymakelist(b, a, 4);
list_product(L1, L2) := listify(cartesian_product(setify(L1), setify(L2)));
list_product(mymakelist(2, 3, 3), mymakelist(4, 5, 4));



coord   : setify(makelist(k, k, 1, 10));
points2d: listify(cartesian_product(coord, coord));



makelist;



* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
listify ({a, b, c, d});
*;; [a, b, c, d]
listify (F ({a, b, c, d}));
*;; F({a, b, c, d})




#####
#
# Drawing a torus with vectors showing a flux
# 2009oct06
#
#####

# «torus-with-flux»  (to ".torus-with-flux")
# (find-maximacvsnode "Functions and Variables for draw" "option: head_length")
# (find-maximacvsnode "Functions and Variables for draw" "option: head_type")
# (find-maximacvsnode "Functions and Variables for draw" "option: head_angle")
# (find-maximacvsnode "Functions and Variables for draw" "option: unit_vectors")
# (find-maximacvsnode "Functions and Variables for draw" "object: vector")
# http://www.telefonica.net/web2/biomates/maxima/gpdraw/index.html
# http://www.telefonica.net/web2/biomates/maxima/gpdraw/vectors/index.html

* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
load(draw);
xfor(u, v) := cos(u) * (2 + cos(v));
yfor(u, v) := sin(u) * (2 + cos(v));
zfor(u, v) :=               sin(v);
psurface1 : parametric_surface(xfor(u,v), yfor(u,v), zfor(u,v), u,0,u1, v,0,v1);
foo(u1, v1) := draw3d(enhanced3d = u + v, psurface1);
f(uv1) := foo(uv1, uv1);
f(1);
f(1.5);
f(2);
f(2.5);
f(3);
f(3.5);
f(4);
f(4.5);
f(5);
f(5.5);
f(6);

# (find-maximacvsnode "Functions and Variables for Differentiation")
* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
load(draw);




#####
#
# lambda
# 2009oct19
#
#####

# «lambda»  (to ".lambda")
# (find-maximacvsnode "Functions and Variables for Function Definition" "Function: lambda")
# (find-maximacvsnode "Functions and Variables for Function Definition" "`[<L>]'")

* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
f : lambda ([aa, bb, [cc]], aa * cc + bb);
f;
f (foo, %i, 17, 29, 256);
g : lambda ([[aa]], apply ("+", aa));
g (17, 29, x, y, z, %e);



# (find-maximacvsnode "Functions and Variables for draw" "object: parametric_surface")

* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
load(draw);
x_for(u, v) := cos(u) * (2 + cos(v));
y_for(u, v) := sin(u) * (2 + cos(v));
z_for(u, v) :=               sin(v);
*
xyz_for(u, v) := [x_for(u, v), y_for(u, v), z_for(u, v)];
xyz_for_uv(uv) := apply(xyz_for, uv);
xyz_for(0, 0);
xyz_for(0.1, 0.1);
xyz_for_uv([0.1, 0.1]);
uv : [0.1, 0.1];
apply(parametric_surface, append(xyz_for_uv(uv), [u,0,u1, v,0,v1]));
*
psurface1(u1, v1) := parametric_surface(x_for(u,v), y_for(u,v), z_for(u,v), u,0,u1, v,0,v1);
foo(u1, v1) := draw3d(enhanced3d = u + v, psurface1(u1, v1));
f(uv1) := foo(uv1, uv1);
f(2.5);
f(3);
*
Surface : [enhanced3d = u + v, psurface1(3, 3)];
Vector_options : [head_length = 0.05, head_angle = 10];
Vectors : [vector([0,0,0],[0,0,.1])];
apply(draw3d, append(Surface, Vector_options, Vectors));

(enhanced3d = u + v, psurface1(3, 3), vector([0,0,0],[0,0,.1]));


vec := 

           vector([5.35,2.45],[-1.53,3.25]),
           vector([-1,7.5],[3,0]),




       explicit(f(x)+2, x, -2, 7));

       points([[2, f(2)], [2, f(2)+2]]),
       head_length = 0.5,
       head_angle  = 15,
       vector([1,0],[2,3])
       );



# (find-maximanode "Functions and Variables for Help" "example (append);")
# (find-maximacvsnode "Functions and Variables for Help" "example (append);")

# (find-maximacvsnode "Functions and Variables for draw" "Graphic object: vector")
# (find-maximacvsnode "Functions and Variables for draw" "Scene constructor: gr3d")





# (find-maximacvsfile "")
# (find-maximacvsfile "maxima/interfaces/xmaxima/xmaxima")
# (find-maximacvsfile "src/binary-gcl/")

# (find-maximacvsgrep "grep -nirH -e gnuplot_pipes *")







# (find-fline "~/usrc/maxima-cvs/maxima/")
# (find-fline "~/usrc/maxima-cvs/maxima/share/draw/")
# (find-fline "~/usrc/maxima-cvs/maxima/share/draw/draw.lisp")
# (find-fline "~/usrc/maxima-cvs/maxima/share/draw/draw.lisp" "implicit3d")

* (eepitch-maximacvs)
* (eepitch-kill)
* (eepitch-maximacvs)
load("draw");

# (find-maximanode "Functions and Variables for Input and Output" "Function: load")
# (find-maximanode "Functions and Variables for Input and Output" "Function: file_search")
# (find-maximanode "Functions and Variables for Input and Output" "file_search_maxima: append")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
:lisp (load "/home/edrx/usrc/maxima-cvs/maxima/share/draw/draw.lisp")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
file_search_lisp;
file_search_lisp: append ([
  "/home/edrx/usrc/maxima-cvs/maxima/share/draw/###.lisp",
  file_search_lisp]);
load(draw);


* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
mkdir ~/.maxima/
cd    ~/.maxima/
rm -v draw.lisp implicit3d.lisp picture.lisp wbd.lisp worldmap.mac
cp -sv ~/usrc/maxima-cvs/maxima/share/draw/*.{lisp,mac} .

# (find-fline "~/usrc/maxima-cvs/maxima/share/draw/")
# (find-fline "~/.maxima/")
~/usrc/maxima-cvs/maxima/share/draw/


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(draw);
draw3d(surface_hide = true,
       enhanced3d   = true,
       colorbox     = false,
    /* terminal     = png, */
       explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3));




#####
#
# seq
# 2010jan06
#
#####

# «seq»  (to ".seq")
# «n^2+n+41»  (to ".n^2+n+41")
# (find-fline "/usr/share/maxima/5.17.1/share/matrix/eigeni.mac")
# (find-maximanode "Functions and Variables for Lists" "Function: makelist")
# (find-maximanode "Functions and Variables for Program Flow" "Function: map")
# (find-maximanode "Functions and Variables for Input and Output" "Function: display")
# (find-maximanode "Functions and Variables for Program Flow" "Special operator: do")
# (find-maximanode "Functions and Variables for Program Flow" "for <variable> in <list>")
# (find-man "1 seq")
# (find-sh0 "seq 2 5")

*;; Problem: when is f(n) := n^2 + n + 41 a composite number?
*;; Trick 1: if there is a 0 in fmods(m) then some "f(n)"s are divisible by m.
*;; Trick 2: look at:
*;;   makelist(factor(f(n)), n, seq(0, 41));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(n)      := n^2 + n + 41;
fm(n, m)  := mod(f(n), m);
seq(a, b) := makelist(i, i, a, b);
seq(2, 5);
*;; --> [2, 3, 4, 5]
*
fmods(m)  := makelist(fm(n, m), n, seq(0, m-1));
[fm(0, 11), fm(1, 11), fm(2, 11), fm(3, 11), fm(4, 11), fm(5, 11)]; 
display(fmods(11));
primes : [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41];
for m in primes do display(fmods(m))$
factor(f(40));
factor(f(41));
makelist(factor(f(n)), n, seq(0, 41));

for m in seq(1, 40) do display(m, factor(f(m)))$




#####
#
# expand and ev
# 2010feb18
#
#####

# «expand-and-ev»  (to ".expand-and-ev")
# (find-maximanode "Functions and Variables for Simplification" ": expand")
# (find-maximanode "Functions and Variables for Command Line" "Function: ev")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(x) := ((((x-1)*x+1)*x-1)*x+1);
g(x) := ((((x-1)*x+1)*x-1)*x+1)*(x+1);
f(10);
g(10);
g(x);
ev(g(x), expand);




#####
#
# 2010.1, Cálculo 2, prova 1
# 2010may05
#
#####

# «2010.1-C2-P1»  (to ".2010.1-C2-P1")
# (find-maximanode "Functions and Variables for Equations")
# (find-maximanode "Functions and Variables for Equations" "Function: solve")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
F1(x) :=   x + 1;
F2(x) := x^3 - x;
F3(x) :=   1 - x;
F (x) := if x < -1 then F1(x) else if -1 <= x and x <= 1 then F2(x) else F3(x);
load(draw);
draw2d(explicit(F(x), x, -3, 3));
f(x) := diff(F(x), x);
draw2d(explicit(f(x), x, -3, -1.1));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f1(x) := 1;
f2(x) := 3*(x-2)^2 - 1;
f3(x) := -1;
ev(f2(x));
ev(f2(x), expand);
integrate(f2(x), x);
integrate(f2(x), x, 1, 3);
f2(2);

pack13(f1, f2, f3, x) := if x < 1 then f1(x) else if 1 <= x and x <= 3 then f2(x) else f3(x);
f(x) := pack13(f1(x), f2(x), f3(x), x);
load(draw);
draw2d(explicit(f(x), x, -3, 4), xaxis = true);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(x) := sqrt(1-x^2);
f(1);
integrate(f(x), x);
tex(integrate(f(x), x));


# Broken:
#
# f (x) := if x < 1 then f1(x) else if 1 <= x and x <= 3 then f2(x) else f3(x);
# draw2d(explicit(f(x), x, -3, 4), xaxis = true);
#
# F(x)  := integrate (f(x), x);
# draw2d(explicit(F(x), x, -3, 4));
#
# (find-maximanode "Functions and Variables for Integration")


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
e1 : (x/5)^2 + (y/4)^2 = 1;
e2 : x = 0;
e3 : y > 0;
S : solve(e1, y);
S : solve([e1], y);
E : second(S);
first(E);
second(E);
c(x) := ''%;
c(0);
integrate(c(x), x, -5, 5);
grind(E);
string(E);
tex(E);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
atan(0);
ev(atan(1));
ev(atan(1), numer);
ev(atan(4/5));
ev(atan(4/5), numer);
atan(1/2);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
cos(atan(3/4));
sin(atan(3/4));
ev(atan(0), numer);
ev(atan(3/4), numer);
ev(4*atan(1), numer);


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
e1 : (x/5)^2 + (y/4)^2 = 1;
e2 : x = 0;
e3 : y > 0;
S : solve(e1, y);
S : solve([e1], y);
E : second(S);
op(E);
args(E);
solve([e1, e2], y);
solve([e1, e3], y);
[e1, e3];
A : ev(e1, x=0);

# (find-maximanode "Introduction to Command Line")
# (find-maximanode "Introduction to Command Line" "quote-quote")
# (find-maximanode "Functions and Variables for Input and Output" "Function: grind")
# (find-maximanode "Functions and Variables for Input and Output" "Option variable: linel")
# (find-maximanode "Functions and Variables for Input and Output" "Function: string")




#####
#
# 2010.1-C2: trabalho sobre área de superfícies de revolução
# 2010jul01
#
#####

# «2010.1-C2-trab-area»  (to ".2010.1-C2-trab-area")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
*;; x0 : 2;
*;; x1 : 6;
*;; y0 : 2;
*;; y1 : 5;
Dx : x1 - x0;
Dy : y1 - y0;
h : sqrt(Dx^2 + Dy^2);
Dr : h;
L0 : 2 * %pi * y0;
L1 : 2 * %pi * y1;
DL : L1 - L0;
th : 2 * %pi * Dy / Dr;
r0 : L0 / th;
r1 : L1 / th;
r1 - r0 = Dr;
A0 : (th / 2) * r0^2;
A1 : (th / 2) * r1^2;
A : A1 - A0;
*
*
y05 : (y0 + y1) / 2;
r05 : (r0 + r1) / 2;
L05 : (L0 + L1) / 2;
Arect : L05 * Dr;
Arect = A;
tex(Arect = A);
*
A;
radcan(A);
radcan(Arect);

*;; (find-node "(maxima)Functions and Variables for Simplification" "example (radcan)")
*;; (find-node "(maxima)Functions and Variables for Expressions" "demo(\"disol\")")
example (radcan);
demo (disol);
;
;


%*
% (eedn4a-bounded)
% (find-sh0 "cd ~/LATEX/ && dvips  -D 300 -P pk -o tmp.ps tmp.dvi")
% (find-sh0 "cd ~/LATEX/ && dvired -D 300 -P pk -o tmp.ps tmp.dvi")
% (find-pspage "~/LATEX/tmp.ps")

\def\Dx{\DD x}
\def\Dy{\DD y}
\def\Dr{\DD r}
\def\DL{\DD L}

\par {\footnotesize (2010jul01)}
\bsk
\par A derivação da área do tronco de cone que a gente
\par fez em sala partia destas equações básicas:
\par (obs: $A_0$ é a área do pacman interno, $A_1$ a do externo)
\par $L_0 = r_0 = 2y_0$
\par $L_1 = r_1 = 2y_1$
\par $h = \Dr = \sqrt{\Dx^2 + \Dy^2}$
\par $A_0 = r_0^2/2$
\par $A_1 = r_0^2/2$
\par $A = A_1 - A_0$
\msk
\par Daí:
\par $\DL =  \Dr = 2\Dy$
\msk
\par Agora dá pra calcular a área a partir de $x_0$, $x_1$, $y_0$, $y_1$:
\par $\Dr := \sqrt{\Dx^2 + \Dy^2}$
\par $   := 2\Dy/\Dr$
\par $r_0 := 2y_0/ = y_0\Dr/\Dy$
\par $r_1 := 2y_1/ = y_1\Dr/\Dy$
\par $A_0 := r_0^2 = (2\Dy/\Dr)(y_0\Dr/\Dy)^2/2 = y_0^2\Dr/\Dy$
\par $A_1 := r_1^2 = (2\Dy/\Dr)(y_1\Dr/\Dy)^2/2 = y_1^2\Dr/\Dy$
\par $A := A_1 - A_0 = \Dr(y_1^2-y_0^2)/\Dy = \Dr(y_1 + y_0)$
\bsk
\par Olha que vergonha: só hoje eu notei que $(y_1^2-y_0^2)/\Dy = y_1 + y_0$...
\par Vários alunos usaram a fórmula para $A$ que aparece na maioria dos livros,
$$A = 2 \frac{y_0+y_1}{2} \sqrt{\Dx^2 + \Dy^2},$$
\par sem deduzí-la, e eu tive um trabalhão pra verificar que ela dava
\par o mesmo resultado que a minha... 8-(

%*



* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
E4(x) := exp(4*x);
diff(E4, x);

E4 : %e^(4*x);
EH : %e^(x/2);
f10 : 2/7 * E4 - 2/7 * EH;
diff(f10, x); 

(+ -24 73)





#####
#
# Inverse transformations
# 2011dec09
#
#####

# «inverse-transformations»  (to ".inverse-transformations")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("vect");
demo("vect");
;
;
;
;
;
;
;
;
;
;
;

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("vect");
Op : [0, 1];
vp : [1/2, 1/2];
wp : [-1, 1];
 Os : [-1, -1/2];
 vs : [1, -1/2];
 ws : [1, 1/2];
xy : [x, y];
p(v) := Op + v[1]*vp + v[2]*wp;
s(v) := Os + v[1]*vs + v[2]*ws;
p(xy);
s(xy);
p(s(xy));
expand(p(s(xy)));
expand(s(p(xy)));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
circ1(x, y) := x^2 + y^2 - R1;
circ2(x, y) := (x-a)^2 + y^2 - R2;
expand(circ1(x, y)/2 + circ2(x, y)/2);





Muitas pessoas tentaram resolver o problema 5 da P1 encontrando
algebricamente os dois pontos de interseção entre dois círculos, e
para isto elas usaram um método que não funcionava. Neste problema
vamos entender onde é que ele dava errado.

Sejam f(x,y) = x^2 + y^2 - 2^2,
      g(x,y) = (x-4)^2 + y^2 - 3^2,
      h(x,y) = f(x,y)/2 + g(x,y)/2,
      C = {(x,y)ÝR^2 | f(x,y)=0},
      C' = {(x,y)ÝR^2 | g(x,y)=0},
      C'' = {(x,y)ÝR^2 | h(x,y)=0},

a) Encontre 4 pontos pertencentes a C e 4 pontos pertencentes a C'.
   Além disso represente graficamente C e C'.

b) O conjunto C'' é um círculo centrado no ponto (2,0). Descubra o seu
   raio e encontre 4 pontos de C''.

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
circ(x0, y0, R, x, y) := (x-x0)^2 + (y-y0)^2 - R^2;
f(x, y) := circ(0, 0, 2, x, y);
g(x, y) := circ(4, 0, 3, x, y);
h(x, y) := f(x,y)/2 + g(x,y)/2;
H(x, y, a) := circ(2, 0, a, x, y);
expand(h(x,y));
expand(H(x,y, a));
expand(H(x,y, sqrt(5/2)));
ev(sqrt(5/2), numer);










# (find-maximanode "Functions and Variables for Simplification" ": expand")
# (find-maximanode "Functions and Variables for Command Line" "Function: ev")



xyp : Op + x

ev(2 * [2, 3]);



# (find-maximanode "Functions and Variables for Lists" "Function: get")
# (find-maximanode "Arithmetic operators")


# (find-maximanode "Functions and Variables for graphs")
# (find-maximanode "Functions and Variables for implicit_plot")
# (find-maximanode "Introduction to plotdf")
# (find-maximanode "Functions and Variables for plotdf")

# From the wxmaxima tips:
# Maxima uses ':' to set values ('a : 3;') and ':=' to define functions ('f(x) := x^2;').

# (find-fline "/usr/share/wxMaxima/tips.txt")
# (find-fline "/usr/share/wxMaxima/wxmathml.lisp")
# (find-maximanode "Functions and Variables for Input and Output" "tex (<expr>)")

# http://www.csulb.edu/~woollett/
# http://www.csulb.edu/~woollett/mbe7code.txt

http://www.math.utexas.edu/pipermail/maxima/2008/010442.html
http://members3.jcom.home.ne.jp/imaxima/Site/Welcome.html
http://members3.jcom.home.ne.jp/imaxima/Site/Tutorial_of_Imaxima.html
http://members3.jcom.home.ne.jp/imaxima/Site/Easy_Install_on_Windows_XP___Vista.html



* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(x) := 4*x^4 - 7*x^2 + 4*x + 6;
f(0);
load(draw);
draw2d(explicit(f(x), x, -3, 3), xaxis = true, yaxis = true);
draw2d(explicit(f(x), x, -1.5, 1.5), xaxis = true, yaxis = true);
draw2d(explicit(f(x), x, -1.5, 1.5), xaxis = true, yaxis = true, yrange = [-10,20]);
draw2d(explicit(f(x), x, -1.2, -0.8), xaxis = true, yaxis = true);
draw2d(explicit(f(x), x, -1.1, -1), xaxis = true, yaxis = true);
draw2d(explicit(f(x), x, -1.06, -1.05), xaxis = true, yaxis = true);

f(-1);
diff(f(x), x); 
Df(x) := 16*x^3 - 14*x + 4;
diff(Df(x), x); 
DDf(x) := 48*x^2 - 14;
aa : sqrt(7/24);
DDf(aa);
DDf(-aa);
f(-aa);
f(aa);
draw2d(explicit(Df(x), x, -3, 3), xaxis = true, yaxis = true);
solve(Df(x)=0, x);









#  Local Variables:
#  coding:               raw-text-unix
#  ee-delimiter-hash:    "\n#*\n"
#  ee-delimiter-percent: "\n%*\n"
#  ee-anchor-format:     "«%s»"
#  modes: (fundamental-mode emacs-lisp-mode lua-mode c-mode)
#  End: