Warning: this is an htmlized version!
The original is here, 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.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# 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/>.
#
#######





# «.mailing-lists»		(to "mailing-lists")
# «.uporto»			(to "uporto")
# «.stackoverflow»		(to "stackoverflow")
# «.gmane»			(to "gmane")
# «.hyperpolyglot»		(to "hyperpolyglot")
# «.maxima-debs»		(to "maxima-debs")
# «.web-docs»			(to "web-docs")
# «.build-html-index»		(to "build-html-index")
# «.tag-table»			(to "tag-table")
#
# «.2-lisp»			(to "2-lisp")
# «.animations»			(to "animations")
# «.annotations»		(to "annotations")
# «.append»			(to "append")
# «.apply»			(to "apply")
#  «.myapply»			(to "myapply")
# «.assume»			(to "assume")
# «.atom»			(to "atom")
# «.autoload»			(to "autoload")
#   «.setup_autoload»		(to "setup_autoload")
# «.block»			(to "block")
#   «.local»			(to "local")
# «.buildq»			(to "buildq")
#   «.splice»			(to "splice")
#   «.currying»			(to "currying")
# «.buildq-lambda»		(to "buildq-lambda")
# «.catch»			(to "catch")
# «.cons»			(to "cons")
# «.create_list»		(to "create_list")
# «.declare»			(to "declare")
# «.define»			(to "define")
# «.define_variable»		(to "define_variable")
# «.defmfun»			(to "defmfun")
# «.demo»			(to "demo")
# «.describe»			(to "describe")
# «.diff»			(to "diff")
# «.direction-fields»		(to "direction-fields")
# «.dispform»			(to "dispform")
# «.distribute_over»		(to "distribute_over")
# «.divide»			(to "divide")
# «.divisors»			(to "divisors")
# «.divisors-2»			(to "divisors-2")
# «.dosimp-and-doeval»		(to "dosimp-and-doeval")
# «.equal»			(to "equal")
# «.erf»			(to "erf")
# «.errcatch»			(to "errcatch")
# «.ev»				(to "ev")
# «.ev-derivative-quirk»	(to "ev-derivative-quirk")
# «.ev-eval»			(to "ev-eval")
# «.ev-integrate»		(to "ev-integrate")
#   «.read-simp-eval-output»	(to "read-simp-eval-output")
# «.eval»			(to "eval")
# «.example»			(to "example")
# «.flatten»			(to "flatten")
# «.float-and-numer»		(to "float-and-numer")
#   «.float»			(to "float")
#   «.numer»			(to "numer")
#   «.numer-and-float»		(to "numer-and-float")
# «.for»			(to "for")
# «.format»			(to "format")
# «.fundef»			(to "fundef")
# «.funmake»			(to "funmake")
#  «.funcall»			(to "funcall")
# «.getenv»			(to "getenv")
# «.grind»			(to "grind")
# «.if»				(to "if")
#  «.is»			(to "is")
# «.inflag»			(to "inflag")
# «.init-file»			(to "init-file")
#   «.no-init»			(to "no-init")
# «.kill»			(to "kill")
#   «.variables»		(to "variables")
# «.lambda»			(to "lambda")
# «.linel»			(to "linel")
# «.linsolve»			(to "linsolve")
# «.lisp-debugger»		(to "lisp-debugger")
# «.load»			(to "load")
# «.load-path»			(to "load-path")
# «.load_pathname»		(to "load_pathname")
#   «.file_search_maxima»	(to "file_search_maxima")
# «.macros»			(to "macros")
# «.macroexpand»		(to "macroexpand")
# «.makelist»			(to "makelist")
# «.map»			(to "map")
#  «.maplist»			(to "maplist")
# «.mapconcat»			(to "mapconcat")
#  «.intercalate»		(to "intercalate")
# «.matrix»			(to "matrix")
#   «.dot»			(to "dot")
# «.matrix_size»		(to "matrix_size")
# «.nouns-and-verbs»		(to "nouns-and-verbs")
#   «.verbify-bug»		(to "verbify-bug")
#   «.special-nouns»		(to "special-nouns")
#   «.noundisp»			(to "noundisp")
# «.op-and-args»		(to "op-and-args")
# «.operators»			(to "operators")
# «.operator-subst»		(to "operator-subst")
# «.opsubst»			(to "opsubst")
# «.opt-args»			(to "opt-args")
# «.part»			(to "part")
# «.piecewise»			(to "piecewise")
# «.printf»			(to "printf")
# «.properties»			(to "properties")
# «.quad_qagi»			(to "quad_qagi")
# «.runge-kutta»		(to "runge-kutta")
# «.simp»			(to "simp")
# «.solve»			(to "solve")
# «.string»			(to "string")
# «.stringdisp»			(to "stringdisp")
# «.stringp»			(to "stringp")
# «.strings»			(to "strings")
# «.subst»			(to "subst")
# «.subst-lambda»		(to "subst-lambda")
# «.subvarp»			(to "subvarp")
# «.symbolp»			(to "symbolp")
# «.symbols»			(to "symbols")
# «.to_lisp»			(to "to_lisp")
# «.translated»			(to "translated")
# «.varargs»			(to "varargs")
#
# «.low-level-1»		(to "low-level-1")
# «.low-level-nouns»		(to "low-level-nouns")
# «.low-level-verbs»		(to "low-level-verbs")
# «.low-level-makelist»		(to "low-level-makelist")

# «.seqn»			(to "seqn")
# «.seq»			(to "seq")
# «.seq-infix»			(to "seq-infix")
#   «.n^2+n+41»			(to "n^2+n+41")
# «.dispfun»			(to "dispfun")
# «.inner-product»		(to "inner-product")
# «.eigen»			(to "eigen")
# «.eigenvalues»		(to "eigenvalues")
# «.defrule»			(to "defrule")
# «.quote»			(to "quote")
# «.quote-quote»		(to "quote-quote")
# «.depends»			(to "depends")
# «.depends-quadratic»		(to "depends-quadratic")
# «.depends-email»		(to "depends-email")
# «.depends-email-code»		(to "depends-email-code")
# «.depends-email-lambda»	(to "depends-email-lambda")
# «.reader»			(to "reader")
# «.nroots»			(to "nroots")
# «.arrays»			(to "arrays")
# «.defstruct»			(to "defstruct")
# «.compile_file»		(to "compile_file")
# «.translate»			(to "translate")
# «.debugmode»			(to "debugmode")
# «.ratpow»			(to "ratpow")
# «.ratsubst»			(to "ratsubst")
# «.ordering»			(to "ordering")
# «.limit»			(to "limit")
# «.limit-f-cont»		(to "limit-f-cont")
# «.at»				(to "at")
# «.atvalue»			(to "atvalue")

# «.part-and-inpart»		(to "part-and-inpart")
# «.substpart»			(to "substpart")

# «.display2d»			(to "display2d")
# «.display2d_unicode»		(to "display2d_unicode")

# «.MpgP17»			(to "MpgP17")
# «.MpgP18»			(to "MpgP18")
#
# «.rootscontract»		(to "rootscontract")
# «.logcontract»		(to "logcontract")
# «.log»			(to "log")
# «.changevar»			(to "changevar")
# «.changevar2»			(to "changevar2")
# «.changevar2-trig-subst»	(to "changevar2-trig-subst")
# «.changevar-basic»		(to "changevar-basic")
# «.changevar-trig-email»	(to "changevar-trig-email")
# «.changevar-trig»		(to "changevar-trig")
# «.changevar-trig-2»		(to "changevar-trig-2")
# «.changevar-trig-3»		(to "changevar-trig-3")
# «.changevar-email»		(to "changevar-email")
# «.changevar-by-hand»		(to "changevar-by-hand")
# «.changevar-quirk»		(to "changevar-quirk")
# «.changevar-figure»		(to "changevar-figure")
# «.3-changevars»		(to "3-changevars")
# «.subst-2023-2»		(to "subst-2023-2")
# «.subst-trig-questions»	(to "subst-trig-questions")
# «.antichangevar»		(to "antichangevar")
#
# «.find-maximaindex»		(to "find-maximaindex")
# «.:lisp»			(to ":lisp")
# «.foo-and-foo»		(to "foo-and-foo")
# «.foo-and-foo-2»		(to "foo-and-foo-2")
# «.mac-nofix»			(to "mac-nofix")
# «.postfix-m»			(to "postfix-m")
# «.subscripted»		(to "subscripted")
# «.emacsconf2020»		(to "emacsconf2020")
# «.maxima-mode»		(to "maxima-mode")
# «.eepitch-maxima»		(to "eepitch-maxima")
# «.maxima-latex-insert-form»	(to "maxima-latex-insert-form")
# «.prompt»			(to "prompt")
# «.empty-PS2-problem»		(to "empty-PS2-problem")
# «.maxima-src»			(to "maxima-src")
# «.maxima-deb-src»		(to "maxima-deb-src")
# «.producing-eps»		(to "producing-eps")
# «.eepitch-region»		(to "eepitch-region")
# «.draw»			(to "draw")
# «.draw-gr2d»			(to "draw-gr2d")
# «.draw2d»			(to "draw2d")
# «.draw2d-implicit»		(to "draw2d-implicit")
# «.draw3d-implicit»		(to "draw3d-implicit")
# «.draw2d-parametric-bug»	(to "draw2d-parametric-bug")
#   «.parametric-bug»		(to "parametric-bug")
#   «.parametric-fix»		(to "parametric-fix")
# «.draw2d-debug»		(to "draw2d-debug")
# «.draw2d-pdf»			(to "draw2d-pdf")
# «.casting-spels»		(to "casting-spels")
# «.infolists»			(to "infolists")
# «.DDef»			(to "DDef")
# «.vectortolist»		(to "vectortolist")
# «.ode2»			(to "ode2")
# «.separable»			(to "separable")
# «.separable-2»		(to "separable-2")
#   «.2022-2-C2-P2-edovs»	(to "2022-2-C2-P2-edovs")
#   «.2023-1-C2-P2-edovs»	(to "2023-1-C2-P2-edovs")
#   «.2023-1-C2-P2-edolccs»	(to "2023-1-C2-P2-edolccs")
# «.2022-2-C2-P2-edolccs»	(to "2022-2-C2-P2-edolccs")
# «.DtoDx»			(to "DtoDx")
# «.command-line»		(to "command-line")
# «.luatree»			(to "luatree")
# «.luatree-explanation»	(to "luatree-explanation")
# «.luatree-rd»			(to "luatree-rd")
# «.luatree-2023»		(to "luatree-2023")
# «.mtree»			(to "mtree")
#
# «.syntax»			(to "syntax")
# «.parentheses»		(to "parentheses")
# «.MV2-tree»			(to "MV2-tree")
# «.sly»			(to "sly")
# «.swank»			(to "swank")
# «.lisp-describe-tex»		(to "lisp-describe-tex")
# «.defmspec»			(to "defmspec")
# «.describe-mfexpr»		(to "describe-mfexpr")
# «.fapply»			(to "fapply")
# «.sas»			(to "sas")
# «.E-and-Einv»			(to "E-and-Einv")
# «.myexptrick-email»		(to "myexptrick-email")
# «.trigexpand»			(to "trigexpand")
# «.trig-ids»			(to "trig-ids")
# «.int-pow-sin-cos»		(to "int-pow-sin-cos")
# «.books»			(to "books")
#   «.minimal-maxima»		(to "minimal-maxima")
#   «.gurro-book»		(to "gurro-book")
#   «.maxima-workbook»		(to "maxima-workbook")
#   «.diffgeo-of-surfaces»	(to "diffgeo-of-surfaces")
#   «.diffeqs-maxima»		(to "diffeqs-maxima")
#   «.advfree»			(to "advfree")
# «.maxima-cvs»			(to "maxima-cvs")
# «.maxima-git»			(to "maxima-git")
# «.maxima-git-5.47.0»		(to "maxima-git-5.47.0")
# «.installation-directories»	(to "installation-directories")
# «.installation-dirs-2»	(to "installation-dirs-2")
# «.checkinstall»		(to "checkinstall")
# «.hollow-points»		(to "hollow-points")
# «.draw-apply»			(to "draw-apply")
# «.riemann»			(to "riemann")
# «.maxima-gpdraw»		(to "maxima-gpdraw")
# «.listify»			(to "listify")
# «.torus-with-flux»		(to "torus-with-flux")
# «.parametric_surface»		(to "parametric_surface")
# «.filter»			(to "filter")
# «.makelist-evals-2nd-arg»	(to "makelist-evals-2nd-arg")
# «.align_eqs»			(to "align_eqs")
# «.factor»			(to "factor")
# «.factor-complex»		(to "factor-complex")
#   «.complex-roots»		(to "complex-roots")
# «.factorial»			(to "factorial")
# «.factorlist»			(to "factorlist")
# «.sum»			(to "sum")
# «.throw-and-catch»		(to "throw-and-catch")
# «.div-by-0»			(to "div-by-0")
# «.noninteractive»		(to "noninteractive")
# «.numerozinhos»		(to "numerozinhos")
# «.matrixify»			(to "matrixify")
# «.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")
# «.bortolossi-5.5»		(to "bortolossi-5.5")
# «.cabos-na-diagonal»		(to "cabos-na-diagonal")
# «.rubi»			(to "rubi")
#
# «.tex»			(to "tex")
#   «.texput»			(to "texput")
#   «.texput-includegraphics»	(to "texput-includegraphics")
#   «.texput-frac»		(to "texput-frac")
#   «.texput-matrix»		(to "texput-matrix")
#   «.texput-Eq5»		(to "texput-Eq5")
#   «.display2d-Eq5»		(to "display2d-Eq5")
#   «.alt-display»		(to "alt-display")
#   «.barematrix»		(to "barematrix")
#   «.includegraphics»		(to "includegraphics")
#   «.imaxima»			(to "imaxima")
#   «.emaxima»			(to "emaxima")
#   «.emaxima-conv»		(to "emaxima-conv")
#   «.savemaximasession-0»	(to "savemaximasession-0")
#   «.savemaximasession-1»	(to "savemaximasession-1")
#   «.emaxima.lisp»		(to "emaxima.lisp")
#   «.emaxima-bug-2024jul20»	(to "emaxima-bug-2024jul20")
#   «.Maxima2.lua»		(to "Maxima2.lua")
#   «.latex-output»		(to "latex-output")

# «.2021-2-C3-diag-nums»	(to "2021-2-C3-diag-nums")
# «.eev-demo»			(to "eev-demo")
# «.draw3d-points»		(to "draw3d-points")
# «.online-manual»		(to "online-manual")
# «.linearize»			(to "linearize")
# «.input-string-parser-output»	(to "input-string-parser-output")
# «.parse-string»		(to "parse-string")
# «.stringproc»			(to "stringproc")
# «.displr-email»		(to "displr-email")
# «.trace-parser»		(to "trace-parser")
# «.lisp-trace»			(to "lisp-trace")
# «.lisp-trace-meval»		(to "lisp-trace-meval")
# «.lambda-simp»		(to "lambda-simp")

# «.symbol-plist»		(to "symbol-plist")
# «.demos»			(to "demos")
# «.fourier»			(to "fourier")
# «.fourier-square-wave»	(to "fourier-square-wave")
# «.taylor»			(to "taylor")
# «.taylor-2»			(to "taylor-2")
# «.taylor-3»			(to "taylor-3")
# «.taylor-3-anim»		(to "taylor-3-anim")
# «.del»			(to "del")
# «.dely-div-delx»		(to "dely-div-delx")
# «.impdiff»			(to "impdiff")
# «.implicit-diff»		(to "implicit-diff")
# «.pn1-folium»			(to "pn1-folium")
# «.pn1-email»			(to "pn1-email")
# «.gradef»			(to "gradef")
# «.gradef-var»			(to "gradef-var")
# «.gradef-remove»		(to "gradef-remove")
# «.email-subst-2022jan17»	(to "email-subst-2022jan17")
# «.plot-wb»			(to "plot-wb")
# «.plot2d»			(to "plot2d")
# «.plot2d-parametric»		(to "plot2d-parametric")
# «.plot3d-parametric»		(to "plot3d-parametric")
# «.plot3d-plotsurface»		(to "plot3d-plotsurface")
# «.plot2d-xmaxima»		(to "plot2d-xmaxima")
# «.plot2d-style-lines»		(to "plot2d-style-lines")
# «.plot2d-stair»		(to "plot2d-stair")
# «.plotdf»			(to "plotdf")
# «.partial-fractions»		(to "partial-fractions")
# «.two-conics»			(to "two-conics")
# «.mnewton»			(to "mnewton")
# «.find_root»			(to "find_root")
# «.quad_qag»			(to "quad_qag")
# «.TFC2-fails»			(to "TFC2-fails")
# «.numerozinhos»		(to "numerozinhos")
# «.dmiranda»			(to "dmiranda")
# «.2022-1-C2-P2»		(to "2022-1-C2-P2")
# «.2022-2-C3-P1»		(to "2022-2-C3-P1")
# «.2023-2-C2-P1»		(to "2023-2-C2-P1")
# «.2023-2-C2-P2»		(to "2023-2-C2-P2")
# «.2023-2-C2-VR»		(to "2023-2-C2-VR")
# «.2023-2-C2-VS»		(to "2023-2-C2-VS")
# «.2023-2-C2-laurent2»		(to "2023-2-C2-laurent2")
# «.2023-2-edos-lineares»	(to "2023-2-edos-lineares")
# «.2023-2-gradefs»		(to "2023-2-gradefs")
# «.2023-2-DDs»			(to "2023-2-DDs")
# «.2023-2-EDOLCCs»		(to "2023-2-EDOLCCs")
# «.2023-2-C3-P1»		(to "2023-2-C3-P1")
# «.2023-2-raio-conv»		(to "2023-2-raio-conv")
# «.plotting-contours»		(to "plotting-contours")
# «.plotting-contours-2»	(to "plotting-contours-2")
# «.terminal-tikz»		(to "terminal-tikz")
# «.2022-2-C3-P2-Q4»		(to "2022-2-C3-P2-Q4")
# «.2022-2-C3-VR»		(to "2022-2-C3-VR")
# «.myangle»			(to "myangle")
# «.early-references-on-und»	(to "early-references-on-und")
# «.cm-maxima»			(to "cm-maxima")
# «.step_by_step.mac»		(to "step_by_step.mac")
# «.simplifying»		(to "simplifying")
# «.twenty-and-thirty»		(to "twenty-and-thirty")
# «.mfuncall»			(to "mfuncall")
# «.apropos»			(to "apropos")
# «.plot-src»			(to "plot-src")
# «.draw_gnuplot.dem»		(to "draw_gnuplot.dem")
# «.maxima-packages»		(to "maxima-packages")
# «.lexical_symbols.mac»	(to "lexical_symbols.mac")
# «.lexical-symbols-branch»	(to "lexical-symbols-branch")
# «.gaertner-tutorial»		(to "gaertner-tutorial")
# «.gaertner-dynamic»		(to "gaertner-dynamic")
# «.EDOLCCs»			(to "EDOLCCs")
# «.by-cases»			(to "by-cases")
# «.relational»			(to "relational")
# «.binsearch»			(to "binsearch")
# «.doc-info-figures»		(to "doc-info-figures")
# «.columnvector»		(to "columnvector")
# «.mycolumnvector»		(to "mycolumnvector")
# «.myrowvector»		(to "myrowvector")
# «.basis»			(to "basis")
# «.crossproduct»		(to "crossproduct")
# «.coeff»			(to "coeff")
# «.ratcoef»			(to "ratcoef")
# «.polytoabcdef»		(to "polytoabcdef")
# «.sistemas-de-coordenadas»	(to "sistemas-de-coordenadas")
# «.coord-systems-2»		(to "coord-systems-2")
# «.coord-systems-3»		(to "coord-systems-3")
#   «.coefmatrix»		(to "coefmatrix")
#   «.augcoefmatrix»		(to "augcoefmatrix")
# «.LI_split»			(to "LI_split")
# «.linsolve_ify»		(to "linsolve_ify")
# «.LI_Axb»			(to "LI_Axb")
# «.format.mac»			(to "format.mac")
# «.ODEs-by-differentials»	(to "ODEs-by-differentials")
# «.semicirculo»		(to "semicirculo")
# «.gruntz-and-tlimit»		(to "gruntz-and-tlimit")
# «.2023-1-C4-P1»		(to "2023-1-C4-P1")
# «.2023-1-C4-P2»		(to "2023-1-C4-P2")
# «.inversas»			(to "inversas")
# «.maxima-by-example»		(to "maxima-by-example")
# «.maxima-by-example-dl»	(to "maxima-by-example-dl")
# «.maxima-by-example-ccds»	(to "maxima-by-example-ccds")
# «.maxima-by-example-eev»	(to "maxima-by-example-eev")
# «.qdraw»			(to "qdraw")
# «.qdraw-pts»			(to "qdraw-pts")
# «.qdraw-to-pdf»		(to "qdraw-to-pdf")
#   «.terminal-pdf»		(to "terminal-pdf")
# «.qdraw-poly»			(to "qdraw-poly")
# «.parabola-boxes»		(to "parabola-boxes")
# «.parabolas-2024.1»		(to "parabolas-2024.1")
# «.myqdraw-flatten»		(to "myqdraw-flatten")
# «.qdraw-taylor»		(to "qdraw-taylor")
# «.qdraw-imp»			(to "qdraw-imp")
# «.qdraw-orbita»		(to "qdraw-orbita")
# «.qdraw-lissajous»		(to "qdraw-lissajous")
#    «.C3-lissajous»		(to "C3-lissajous")
# «.qdraw-linearize»		(to "qdraw-linearize")
# «.qdraw-proportional»		(to "qdraw-proportional")
# «.qdraw-colors»		(to "qdraw-colors")
# «.qdraw-ex-and-ex1»		(to "qdraw-ex-and-ex1")
# «.qdraw-3Daxes»		(to "qdraw-3Daxes")
# «.qdraw-homogeneous»		(to "qdraw-homogeneous")
# «.qdraw-mis»			(to "qdraw-mis")
# «.qdraw-folium»		(to "qdraw-folium")
# «.qdraw-4-inverses»		(to "qdraw-4-inverses")
# «.qdraw-eigenvectors»		(to "qdraw-eigenvectors")
# «.qdraw1»			(to "qdraw1")
# «.qdraw-contour»		(to "qdraw-contour")
# «.qdraw-bezier1»		(to "qdraw-bezier1")
# «.qdraw-label»		(to "qdraw-label")
# «.laurent»			(to "laurent")
# «.mpg-p17»			(to "mpg-p17")
# «.maw-emails»			(to "maw-emails")
# «.maw»			(to "maw")
# «.mysubst»			(to "mysubst")
# «.total-derivative»		(to "total-derivative")
# «.tellsimpafter»		(to "tellsimpafter")
# «.intermediate-vars»		(to "intermediate-vars")
# «.improper-integral»		(to "improper-integral")
# «.gf»				(to "gf")
# «.chaosgame»			(to "chaosgame")
# «.orbits»			(to "orbits")
# «.staircase»			(to "staircase")
# «.radcan»			(to "radcan")
# «.radcan-homogeneous»		(to "radcan-homogeneous")
# «.graphs»			(to "graphs")
# «.package_graph»		(to "package_graph")
# «.finite_model_theory»	(to "finite_model_theory")
# «.maxima-bezier»		(to "maxima-bezier")
# «.simplify_sum»		(to "simplify_sum")
# «.strang-p1»			(to "strang-p1")
# «.strang-p3»			(to "strang-p3")
# «.pontos-mais-faceis-1»	(to "pontos-mais-faceis-1")
# «.log-constants-anim»		(to "log-constants-anim")
# «.freeof»			(to "freeof")
# «.listofvars»			(to "listofvars")
# «.stewart-pt-p374»		(to "stewart-pt-p374")
# «.leithold-pt-p302»		(to "leithold-pt-p302")
# «.miranda-p191»		(to "miranda-p191")
# «.miranda-p196»		(to "miranda-p196")
# «.integral-calculator»	(to "integral-calculator")
# «.mixima»			(to "mixima")
# «.joel-moses»			(to "joel-moses")
# «.cabs»			(to "cabs")
# «.scalarmatrixp»		(to "scalarmatrixp")
# «.2024.1-dois-metodos»	(to "2024.1-dois-metodos")
# «.aroundx0y0»			(to "aroundx0y0")
# «.aroundx0»			(to "aroundx0")
# «.aroundx0-tools»		(to "aroundx0-tools")
# «.mycolorlerp1»		(to "mycolorlerp1")
# «.2024.1-taylor-1»		(to "2024.1-taylor-1")
# «.2024.1-taylor-2»		(to "2024.1-taylor-2")
# «.2024.1-intervals»		(to "2024.1-intervals")
# «.2024.1-C2-PR1-1»		(to "2024.1-C2-PR1-1")
# «.2024.1-C2-PR1-2»		(to "2024.1-C2-PR1-2")
# «.2024.1-completing-squares»	(to "2024.1-completing-squares")
# «.2024.1-intro-complex»	(to "2024.1-intro-complex")
# «.2024.1-polyx»		(to "2024.1-polyx")
# «.2024-1-C2-P1»		(to "2024-1-C2-P1")
# «.2024-1-C2-P1-rev»		(to "2024-1-C2-P1-rev")
# «.2024-1-C2-P2»		(to "2024-1-C2-P2")
# «.2024-1-C2-VS»		(to "2024-1-C2-VS")
# «.2024.1-stewart-p856-ex10»	(to "2024.1-stewart-p856-ex10")
# «.2024.1-depends»		(to "2024.1-depends")
# «.2024.1-gradefs»		(to "2024.1-gradefs")
# «.2024.1-difs»		(to "2024.1-difs")
# «.2024.1-undet-coefs»		(to "2024.1-undet-coefs")
# «.2024.1-exact»		(to "2024.1-exact")
# «.2024-1-C3-P1»		(to "2024-1-C3-P1")
# «.2024-1-C3-P1-Q3»		(to "2024-1-C3-P1-Q3")
# «.2024.1-C3-PR1»		(to "2024.1-C3-PR1")
# «.2024.1-C3-P2»		(to "2024.1-C3-P2")
# «.2024.1-C3-VRP1»		(to "2024.1-C3-VRP1")
# «.2024.1-C3-VS»		(to "2024.1-C3-VS")
# «.2024.2-C2-teste-niv»	(to "2024.2-C2-teste-niv")
# «.2024.2-C2-MVI3»		(to "2024.2-C2-MVI3")
# «.2024.2-C2-fracs-parcs»	(to "2024.2-C2-fracs-parcs")
# «.2024.2-C2-intro-complex»	(to "2024.2-C2-intro-complex")
# «.2024.2-C2-P1»		(to "2024.2-C2-P1")
# «.2024.2-C3-intro»		(to "2024.2-C3-intro")
# «.2024.2-C3-traj-9»		(to "2024.2-C3-traj-9")
# «.2024.2-C3-piramide»		(to "2024.2-C3-piramide")
# «.2024.2-C3-piramides-1-2»	(to "2024.2-C3-piramides-1-2")
# «.2024.2-C3-2022.2-P1»	(to "2024.2-C3-2022.2-P1")
# «.2024.2-C3-eigenvectors»	(to "2024.2-C3-eigenvectors")
# «.2024.2-C3-P1-Q1»		(to "2024.2-C3-P1-Q1")
# «.2024.2-C3-P1-Q1-latex»	(to "2024.2-C3-P1-Q1-latex")
# «.2024.2-C3-P1-Q2»		(to "2024.2-C3-P1-Q2")
# «.2024.2-C3-P1-Q2-latex»	(to "2024.2-C3-P1-Q2-latex")
# «.parse_string-unicode»	(to "parse_string-unicode")
# «.qm-maxima»			(to "qm-maxima")
# «.unlambda»			(to "unlambda")
# «.lisptree-demo1»		(to "lisptree-demo1")
# «.ppshort.lisp»		(to "ppshort.lisp")
# «.mktable»			(to "mktable")
# «.wxmaxima»			(to "wxmaxima")
# «.spreadsheet»		(to "spreadsheet")
# «.pythagorean-triples»	(to "pythagorean-triples")
# «.edrx-maxima.tgz»		(to "edrx-maxima.tgz")
# «.maxima-interface»		(to "maxima-interface")



# 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





#####
#
# mailing-lists
# 2021dec11
#
#####

# «mailing-lists»  (to ".mailing-lists")
# https://maxima.sourceforge.io/maximalist.html

# maxima-discuss@lists.sourceforge.net
# https://sourceforge.net/p/maxima/mailman/maxima-discuss/
# https://sourceforge.net/p/maxima/mailman/maxima-discuss/?viewmonth=202112
# https://sourceforge.net/p/maxima/mailman/maxima-discuss/?viewmonth=202201
# https://sourceforge.net/p/maxima/mailman/maxima-discuss/?viewmonth=202207
# https://sourceforge.net/p/maxima/mailman/maxima-discuss/?viewmonth=202207&viewday=2&style=threaded
# https://sourceforge.net/p/maxima/mailman/maxima-discuss/?viewmonth=202207&style=threaded
# https://sourceforge.net/p/maxima/mailman/maxima-discuss/?viewmonth=202207&viewday=1
# https://sourceforge.net/p/maxima/mailman/maxima-discuss/?viewmonth=202207&viewday=1
# https://sourceforge.net/p/maxima/mailman/message/37675653/

# 2009jul12:
# http://maxima.sourceforge.net/maximalist.html
# http://maxima.sourceforge.net/compalg.html

# (find-maximamsg)




#####
#
# uporto
# 2024nov29
#
#####

# «uporto»  (to ".uporto")
# (find-maximamsg "58846602 202411 28" "RDodier: uporto")
# (find-maximamsg "58846694 202411 28" "ElObs: mailing_list_2000-2016")
# (find-maximamsg "58846735 202411 28" "JVillate: uporto")
# (find-maximamsg "58846901 202411 29" "ElObs: old-mailing-list-archives")
# (find-esgrep "grep --color=auto -nH --null -e pipermail *.e")

# https://github.com/Observatorio-de-Matematica/Maxima-References/tree/main/mailing_list_2000-2016
# https://github.com/Observatorio-de-Matematica/Maxima-References
# (find-git-links "https://github.com/Observatorio-de-Matematica/Maxima-References" "maximarefs")
# (code-c-d "maximarefs" "~/usrc/Maxima-References/")
# (find-maximarefsfile "")



#####
#
# stackoverflow
# 2023feb22
#
#####

# «stackoverflow»  (to ".stackoverflow")
# https://stackoverflow.com/questions/tagged/maxima




#####
#
# gmane
# 2023jul08
#
#####

# «gmane»  (to ".gmane")
# https://mail.google.com/mail/u/0/#inbox/FMfcgzGtvscWDFBXtHjrbdZmvjJDklzm
# (find-maximamsg "37867861 202307 08" "ThorstenB: gmane.io")




#####
#
# hyperpolyglot
# 2023oct28
#
#####

# «hyperpolyglot»  (to ".hyperpolyglot")
# https://hyperpolyglot.org/computer-algebra




#####
#
# maxima-debs
# 2008jun09 / 2021nov21
#
#####

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

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
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-udfile "maxima-doc/html/")
# (code-pdf-page "maximabook" "/usr/share/doc/maxima-doc/maximabook-19-Sept-2004.pdf.gz")
# (code-pdf-text "maximabook" "/usr/share/doc/maxima-doc/maximabook-19-Sept-2004.pdf.gz")
# (find-maximabookpage)
# (find-maximabooktext)

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

# (find-maximasharefile "fractals/fractals.mac")

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



#####
#
# web-docs
# 2022aug07
#
#####

# «web-docs»  (to ".web-docs")
# (to "maxima-git-5.47.0")
# (find-maximanode "funmake")
# https://maxima.sourceforge.io/documentation.html
# https://maxima.sourceforge.io/docs/manual/maxima_toc.html
# https://maxima.sourceforge.io/docs/manual/maxima_423.html Appendix A Function and Variable Index
# https://maxima.sourceforge.io/docs/manual/maxima_170.html#index-funmake
# (find-maximagitsh "find * | sort")
# (find-maximagitfile "doc/info/maxima-index.lisp")
# (find-maximagitfile "doc/info/maxima-index-html.lisp")
# (find-maximagitfile "doc/info/maxima-index-html.lisp" "%and")
# (find-maximagitfile "doc/info/maxima-index-html.lisp" "mode_declare")
# https://maxima.sourceforge.io/docs/manual/maxima_170.html#index-funmake
# https://maxima.sourceforge.io/docs/manual/maxima_170.html#mode_005fdeclare
# https://maxima.sourceforge.io/docs/manual/maxima_381.html#_0025and

# (find-maximanode "funmake")
# (find-maximanode "funmake" "does not attempt to distinguish")
# (find-maximagitgrep "grep --color=auto -nRH --null -e 'does not attempt to distinguish' *")
# (find-maximagitfile "doc/info/Function.texi" "does not attempt to distinguish")





#####
#
# build-html-index
# 2022aug08
#
#####

# «build-html-index»  (to ".build-html-index")
# (find-maximagitfile "doc/info/build-html-index.lisp")
# (find-maximamsg "37690863 202310 06" "Edrx: /usr/local/share/info/maxima-index-html.lisp")
# (find-maximamsg "37690886 202208 07" "RToy: doc/info/build-html-index.lisp")
# https://mail.google.com/mail/u/0/#inbox/QgrcJHsHqfTGBczPsMPxJVNfDQqtMdlbgWv
# (find-fline "/usr/local/share/info/maxima-index-html.lisp")
# (find-angg "LUA/Lisp4.lua")
# (find-blogme3 "maxima-index-html.lua")



#####
#
# tag-table
# 2022aug06
#
#####

# «tag-table»  (to ".tag-table")
# (find-es "texinfo" "tag-table")
# (find-angg "blogme3/maxima.lua")
# (find-fline "/usr/local/share/info/" "maxima")
# (find-fline "/usr/local/share/info/maxima-index-html.lisp")
# (find-fline "/usr/local/share/info/maxima-index.lisp")
# (find-fline "/usr/local/share/info/maxima.info" "Tag Table:")
# (find-fline "/usr/local/share/info/maxima.info" "Ref: funmake")
# (find-maximanode "funmake")
# (find-fline "~/LOGS/2022aug06.clschool")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cp -v /usr/local/share/info/maxima-index-html.lisp \
      /tmp/index-big.lisp
cat > /tmp/index-mini.lisp <<'%%%'
  (in-package :cl-info)
  (let ((html-index
         '(("a1" "a2" "a3")
           ("b1" "b2" "b3")))))
%%%

* (eepitch-sbcl)
* (eepitch-kill)
* (eepitch-sbcl)
(defvar fnamein)
(defvar fnameout)
(defvar biglist)
(defvar biglist2)
(defvar biglist3)
(setq fnamein "/tmp/index-mini.lisp")
(setq fnamein "/tmp/index-big.lisp")
(setq fnameout "/tmp/index-out.lisp")
(setq biglist (with-open-file (in fnamein) (read in) (read in)))
(setq biglist2 (caadr biglist))
(setq biglist3 (cadadr biglist2))
biglist3

(with-open-file (s fnameout :direction :output :if-exists :supersede)
  (dolist (a biglist3)
    (let ((*print-right-margin* nil))
      (format s "~S~%" a))))

;; (find-fline "/tmp/" "index-out.lisp")
;; (find-fline "/tmp/index-out.lisp")

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
bigstr = ee_readfile "/tmp/index-out.lisp"
for a,b,c in bigstr:gmatch('%("(.-)"%s+"(.-)"%s+"(.-)"%)') do
  print(a,b.."#"..c)
end




#####
#
# Notes on low-level Maxima: "untitled #1"
# 2024oct13
#
#####

# «low-level-1»  (to ".low-level-1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
format([args]) :=
  apply(?format, append([false], args));

[a:'b, b:'c, c:'d];          /* [b,c,d] */
['a, a, ''a, ''''a];         /* [a,b,c,d] */
f1(o) ::= format("~a", o);   /*   just lispify */
f2(o)  := format("~a", o);   /* ev and lispify */

f1('a);                      /* ((MQUOTE SIMP) $A) */
f1 (a);                      /* $A */
f2('a);                      /* $A */
f2 (a);                      /* $B */

f1(2+3);                     /* 5 */
f1(lambda([], 2+3));         /* ((LAMBDA SIMP) ((MLIST)) ((MPLUS) 2 3)) */




#####
#
# Notes on low-level Maxima: nouns and verbs
# 2024oct24
#
#####

# «low-level-nouns»  (to ".low-level-nouns")
# «low-level-verbs»  (to ".low-level-verbs")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* Choose one: */
display2d : false;
display2d : true;

format([args]) := apply(?format, append([false], args));
low(o)         := format("~s",o);    /* low-level representation */
__diffx2 : '( diff(x^2,x));
_qdiffx2 : '('diff(x^2,x));
__diff   : op(__diffx2);             /* diff       */
_qdiff   : op(_qdiffx2);             /* derivative */
__fx     : '( f(x));
_qfx     : '('f(x));
__f      : op(__fx);                 /* f */
_qf      : op(_qfx);                 /* f */
low(__diff);                         /* $DIFF       */
low(_qdiff);                         /* %DERIVATIVE */
low(__f);                            /* $F */
low(_qf);                            /* %F */
[__diff, string(__diff)];            /* [diff,       diff] */
[_qdiff, string(_qdiff)];            /* [derivative, diff] */

verbp(o)        := symbolp(o) and (o = verbify(o));
nounp(o)        := symbolp(o) and (o = nounify(o));
specialnounp(o) := nounp(o) and (string(o)#concat("",o));

specialnounp(_qdiff);
specialnounp(_qf);

linel     : 100;
line_top  : args(
 line(o)  := [o, low(o), verbp(o), nounp(o), low(verbify(o)), low(nounify(o))]
)[2];
lines(os) := apply('matrix, append([line_top], makelist(line(o),o,os)));
lines([__f, _qf, __diff, _qdiff]);











#####
#
# Notes on low-level Maxima: makelist is a special form
# 2024oct13
#
#####

# «low-level-makelist»  (to ".low-level-makelist")
# (find-maximanode "makelist")
# (to "makelist")
# (find-maximamsg "58827939 202410 13" "Edrx: How do I translate...?")
# (find-maximamsg "58827948 202410 13" "Stavros:")
# (find-maximamsg "58827955 202410 13" "Edrx:")
# (find-maximamsg "58827979 202410 13" "RDodier: ***")
# (find-maximamsg "58827988 202410 13" "Stavros:")
# (find-maximamsg "58828007 202410 13" "Edrx:")
# (find-maximamsg "58828279 202410 14" "Stavros:")
# (find-maximamsg "58828283 202410 14" "BWillis:")
# (find-maximamsg "58828394 202410 15" "Stavros:")
# (find-maximamsg "58828517 202410 15" "RFateman:")
# (find-maximamsg "58828616 202410 15" "Stavros:")
# (find-maximamsg "58828773 202410 16" "Andrey:")
# (find-maximamsg "58829039 202410 16" "RDodier:")
# (find-maximamsg "58830517 202410 20" "Stavros: subscripted variables (which are mapatoms)")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
[a:b, b:c, c:d];                   /* [b,c,d] */
['a, a, ''a, ''''a];               /* [a,b,c,d */
makelist([a,b,c],     a, 42,43);   /* [[42,c,d], [43,c,d]] */
makelist([a,b,c],   ''a, 42,43);   /* [[b,42,d], [b,43,d]] */
makelist([a,b,c], ''''a, 42,43);   /* [[b,c,42], [b,c,43]] */

ev     ('[a,b,c],     a=42);        /* [42,c,d] */
ev     ('[a,b,c],   ''a=42);        /* [b,42,d] */
ev     ('[a,b,c], ''''a=42);        /* [b,c,42] */

makelist([a,b,c],    'a, 42,43);   /* [[42,c,d], [43,c,d]] */
makelist([a,b,c],   x+y, 42,43);   /* [[b,c,d], [b,c,d]] */

ev('[a,b,c],    'a=42);
ev('[a,b,c],   x+y=42);

sublis([x+y=42], '[a,b,c]);   /* err     */
subst ([x+y=42], '[a,b,c]);   /* [a,b,c] */
subst ( '[a=42], '[a,b,c]);
subst ('['a=42], '[a,b,c]);


 





#####
#
# Maxima behaves as a 2-lisp: each symbol has a ":"-cell and a ":="-cell
# 2022oct07
#
#####

# «2-lisp»  (to ".2-lisp")
# (to "depends-email")
# (find-maximanode ":")
# (find-maximanode ":=")
# (find-maximanode "values")
# (find-maximanode "functions")
# (find-maximanode "kill")
# (find-maximanode "dispfun")
# (find-maximanode "fundef")
# (find-maximanode "apply")
# (find-maximamsg "37874281 202307 22" "RFateman: f[x]:=x+1")
# (find-elisp-intro "6. Defining functions")
# https://stackoverflow.com/questions/4578574/what-is-the-difference-between-lisp-1-and-lisp-2
# https://news.ycombinator.com/item?id=17536432 I don't really get why you'd ever want a Lisp-2

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a_      :  42;
a_(x,y) := sqrt(x+y);
a_;
a_(1,3);
values;
functions;
dispfun(a_);
fundef(a_);


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f    :  lambda([x], 2*x);  /* sets the value    cell */
f(x) := 3*x;               /* sets the function cell */

f;                    /* uses the value    cell: lambda([x], 2*x) */
f(10);                /* uses the function cell: 30 */
apply( f, [10]);      /* uses the value    cell: 20 */
apply('f, [10]);      /* uses the function cell: 30 */
ev('f);               /* uses the value    cell: lambda([x], 2*x) */
apply('fundef, ['f]); /* uses the function cell: f(x) := 3 x */

diffxv(g) := diff(ev   (g)(x),  x);  /* uses the value    cell */
diffxf(g) := diff(apply(g,[x]), x);  /* uses the function cell */
diffxv('f);                          /* uses the value    cell: 2 */
diffxf('f);                          /* uses the function cell: 3 */

s    : 'f;
ev    ('f)(10);                       /* uses the value    cell: 20 */
apply ('f,[10]);                      /* uses the function cell: 30 */
ev    ( s)(10);                       /* uses the value    cell: 20 */
apply ( s,[10]);                      /* uses the function cell: 30 */
concat('f,'p);                        /* uses the name     cell: sp */
concat( s,'p);                        /* uses the name     cell: sp */

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f    :  lambda([y], 2*y);  /* sets the value    cell */
g    :  lambda([y], 3*y);  /* sets the value    cell */
h    :  lambda([y], 4*y);  /* sets the value    cell */
f(y) := 5*y;               /* sets the function cell */
g(y) := 6*y;               /* sets the function cell */
h(y) := 7*y;               /* sets the function cell */

foo(f,g) := block([f0,f1,ex0,ex1],
    f0  : f,
    f1  : concat(f, 'p),
    ex0 : apply(g,[x]),
    ex1 : diff(ex0, x),
    [f0, f1, ex0, ex1],
    buildq([f0,f1,ex0,ex1],
      [f0 = lambda([x],ex0),
       f1 = lambda([x],ex1)
      ])
    );
foo('g,'h);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f[x]   := x+1;   /* general case: f[3] will return 4 */
f[1/2] :  34;    /* exception:  f[1/2] will return 34 */
f[10];
f[1/2];




#####
#
# animations
# 2024oct22
#
#####

# «animations»  (to ".animations")
# (find-es "qdraw" "animations")

# (to "draw-gr2d")
# (to "maxima" "maxima-cvs")
# (to "plotting-contours-2")
# (find-maximanode "Visualization with VTK")
# http://www.youtube.com/watch?v=kmgVadumhaI Mathematical Animation Using WX Maxima





#####
#
# Annotations, like SIMP, FACTORED, and TRUNC
# 2024aug17
#
#####

# «annotations»  (to ".annotations")
# (find-maximamsg "58807287 202408 17" "Edrx: truncness, annotations")
# (find-angg "MAXIMA/showexpression1.mac")
# (find-maximanode "taylorp")
# (find-maximanode "remove")
# (find-maximanode "remove" "transfun")
# (find-maximanode "compfile")
# (find-maxima-links "taylorp")
# (find-maximagitgrep "grep --color=auto -niRH --null -e taylorp *")
# (find-maximagitfile "src/simp.lisp" "(defmfun $taylorp (x)")

Hi all,

sorry for the delay - we're at the end of the semester here, with lots
of tests to prepare and to mark... and this will be a partial answer -
I haven't tried all of your suggestions yet. Anyway...

My questions about the internal representation of the objects returned
by "factor", "trunc" and "taylor" were not because I need to do
something "practical" with these objects in the near future - I was
asking them just because my mental model of Maxima objects is still
very incomplete, and when I ask these questions here I usually get
answers that help me a lot.

The documentation for "trunc", at

  (find-maximanode "trunc")
  https://maxima.sourceforge.io/docs/manual/maxima_141.html#trunc

says:

  Annotates the internal representation of the general expression
  <expr> so that it is displayed as if its sums were truncated Taylor
  series. <expr> is not otherwise modified.

The snippet below shows some ways of exploring these annotations - I'm
guessing that "annotations" is the correct term:

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a1 : a*b;
a2 : factor(100);
b1 : 23 + 45*x;
b2 : trunc(b1);             /* has a ... */
b3 : taylor(b1, x, 0, 1);   /* has a ... and a /T/ */
ratp(b1);                   /* false */
ratp(b2);                   /* false */
ratp(b3);                   /* true */
to_lisp();
  #$a*b$  ; ((MTIMES SIMP) $A $B)
  #$a1$   ; ((MTIMES SIMP) $A $B)
  #$a2$   ; ((MTIMES SIMP FACTORED) ((MEXPT SIMP) 2 2) ((MEXPT SIMP) 5 2))
  #$b1$   ; ((MPLUS SIMP) 23 ((MTIMES SIMP) 45 $X))
  #$b2$   ; ((MPLUS SIMP TRUNC) 23 ((MTIMES SIMP) 45 $X))
  #$b3$   ; ((MRAT SIMP ... TRUNC) PS ...)
  (car   #$b2$)   ; (MPLUS SIMP TRUNC)
  (cdar  #$b2$)   ; (SIMP TRUNC)
  (cddar #$b2$)   ; (TRUNC)
  (to-maxima)

There is a simple way to detect "taylorness" from Maxima - we can use
"ratp" - but I couldn't find a simple way to detect "truncness", or
"factoredness"... my guess is that if, and when, I decide that some of
these annotations are important in my programs that represent Maxima
objects as trees, then I will have write some Lisp to interpret the
"cdar"s or the "cddar"s of these objects to see if they have any
annotations that are worth showing... and "worth showing" is something
that obviously depends on the context, and in many cases just adding a
way to indicate that "this object has non-trivial annotations" would
be enough.

Anyway, these annotations look very important, but the only places in
the manual in which I remember seeing them mentioned clearly are here,

  (info "(maxima)Introduction to Simplification")
  https://maxima.sourceforge.io/docs/manual/maxima_45.html

that points to this paper, in which they are called "flags",

  https://people.eecs.berkeley.edu/~fateman/papers/intro5.txt
  https://maxima.sourceforge.io/misc/Fateman-Salz_Simplifier_Paper.pdf

and here:

  (find-maximanode "Introduction to Lists")
  https://maxima.sourceforge.io/docs/manual/maxima_20.html

Are there standard functions to inspect them _from Maxima_? Any
pointers, comments, recommendations?

  Thanks in advance, and, again, sorry for not having digested all the
  material in your previous answers _yet_... =/

    Eduardo Ochs
    http://anggtwu.net/eev-maxima.html




#####
#
# append
# 2024sep01
#
#####

# «append»  (to ".append")
# (find-maximanode "append")
# (find-maximanode "apply")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
append();
append([1,2,3]);
append([1,2,3], [4,5], [7,8,9]);
append(f(1,2,3), f(4,5), f(7,8,9));
append(f(1,2,3), f(4,5), g(7,8,9));  /* err */




#####
#
# `myapply' is like the `apply' of Emacs Lisp 
# 2023jul20
#
#####

# «apply»    (to ".apply")
# «myapply»  (to ".myapply")
# (find-maxima-links "apply")
# (find-maximanode "apply")
# (find-maximanode "firstn")
# (find-maximanode "last")
# (find-efunctiondescr 'apply)
# (find-efunctiondescr 'butlast)
# (find-efunction      'butlast)
# (find-angg "MAXIMA/myqdraw1.mac" "myapply")
# (find-angg "MAXIMA/myqdraw2.mac" "myapply")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
butlast     (L)  := firstn(L, length(L)-1);
flattenlast([L]) := append(butlast(L), flatten([last(L)]));
myapply  (f,[L]) := apply(f, flattenlast(L));

flattenlast(2,3,4,5);
flattenlast(2,3,4,[5,[6,7]]);
myapply('foo, 2,3,4,[5,[6,7]]);

        "+"  (1, 2, 3, 4, 5);
  apply("+", [1, 2, 3, 4, 5]);   /* 15 */
  apply("+",  1, 2, 3, [4,5]);   /* err */
myapply("+",  1, 2, 3, [4,5]);   /* 15 */



#####
#
# assume
# 2022jul02
#
#####

# «assume»  (to ".assume")
# (to "inversas")
# (to "noninteractive")
# (find-maximanode "Functions and Variables for Integration" "neg;")
# (find-maximanode "assume")
# (find-maximanode "facts")
# (find-maximanode "forget")
# (find-maximanode "declare")
# (find-maximanode "asksign")
# (to "changevar")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
o  : y = x^2;
a1 : 0 <= x;
a2 : x <= 0;
            [a1, assume(a1), facts(x)];
o2 : -sqrt(o);
[forget(a1), assume(a2), facts(x)];
o3 : sqrt(o);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
o : y = ((x+1)^2 - 3)^4;
a1 : (x+1)^2 - 3 >= 0;
a2 : x+1 >= 0;
assume(a1);
assume(a2);
          o^(1/4);
          o^(1/4)+3;
     sqrt(o^(1/4)+3);
     sqrt(o^(1/4)+3)-1;
o2 : sqrt(o^(1/4)+3)-1;

assume(not equal(k,0));
assume(notequal(k,0));
facts(k);




#####
#
# atom
# 2024oct22
#
#####

# «atom»  (to ".atom")
# (find-maximanode "atom")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
atom(x+y);    /* false */
atom(x);      /* true  */
atom(x[1]);   /* false */
atom(f(x));   /* false */
atom("foo");  /* true  */
atom(?foo);   /* true  */




#####
#
# autoload and setup_autoload
# 2024oct04
#
#####

# «autoload»        (to ".autoload")
# «setup_autoload»  (to ".setup_autoload")
# (find-maximanode "setup_autoload")
# (find-maximanode "Introduction for Runtime Environment" "setup_autoload")
# (find-maximagitgrep "grep --color=auto -niRH --null -e setup_autoload *")
# (find-maximagitgrep "grep --color=auto -niRH --null -e setup_autoload share/")
# (find-es "emacs" "autoload")
# (to "printf")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
to_lisp();
  (describe     '$printf)
  (symbol-plist '$printf)    ;;-> (AUTOLOAD "stringproc")
  (to-maxima)
 



#####
#
# block and local
# 2023jul20
#
#####

# «block»  (to ".block")
# «local»  (to ".local")
# (find-maxima-links "block")
# (find-maximanode "block")
# (find-maximanode ":=")
# (find-maximanode ":=" "local(f)")
# (find-maximanode "local")
# (to "2024.1-completing-squares")
# (to "2024.1-completing-squares" "block and local")
# (find-maximamsg "34163829 201506 01" "BWillis: block and local")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
block([e], e:%pi, e*2);                  e;
block([e:%pi],    e*2);                  e;
block([a:10,b:100],            [a,b]);   [a,b];
block([a:10,b:10*a],           [a,b]);   [a,b]; /* b:10*a uses the outer a */
block([a:10,b],    b:10*a,     [a,b]);   [a,b];
block([a,b], a:10, b:10*a,     [a,b]);   [a,b];
block([f],          f(x):=10*x, f(2));   f(2);  /* bad */
block([g],local(g), g(x):=10*x, g(2));   g(2);  /* ok */
block(    local(h), h(x):=10*x, h(2));   h(2);  /* ok */

# Can I define local functions in blocks like this?
#   block([a, b(x,y):=x*y, c], foo)
# No, but we can use "local"...

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
? block

larry(x) := block([a],           a[1] : x)$
buddy(x) := block([a], local(a), a[1] : x)$
a[2] : 2015;
buddy(0);
a[1];
a[2];
a[1];
a[2];
buddy(x) := block([a], local(a), a[1] : x)$
translate(buddy);
a[2] : 2015;
buddy(0);

? translate




#####
#
# currying / buildq
# 2022nov21
#
#####

# «buildq»    (to ".buildq")
# «splice»    (to ".splice")
# «currying»  (to ".currying")
# (to "lexical_symbols.mac")
# (find-maximamsg "37738228 202211 21" "Edrx: question")
# (find-maximamsg "37738229 202211 21" "Stavros: use buildq")
# (find-maximanode "buildq")
# (find-maximagitfile "src/buildq.lisp")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
      buildq([a,b:[2,22]], [a,b,3]);
      buildq([a,b:[2,22]], [a,splice(b),3]);
a:4;  buildq([a,b:[2,22]], [a,splice(b),3]);

Hi list,

what is right & recommended way to write curried functions in Maxima?
For example, in a first moment I though that this

  F : lambda([a], lambda([b], 10*a+b));
  F(2)(3);

would yield 23, but the result was 10*a+3...

Or: is there a simple way to do backquoting in Maxima? What are your
favorite ways to rewrite this - that is lisp-ish pseudocode -

  F : lambda([a], `lambda([b], 10*,a+b));

into real Maxima code?

  Thanks in advance!
    Eduardo Ochs
    http://angg.twu.net/eev-maxima.html


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
F : lambda([a], buildq([a], lambda([b], 10*a+b)));
F(2);
F(2)(3);




#####
#
# buildq-lambda
# 2024oct23
#
#####

# «buildq-lambda»  (to ".buildq-lambda")
# (find-maximanode "lambda")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
inlambda1(o) ::= block([simp:false], buildq([o], lambda([], o)));
inlambda2(o) ::=                     buildq([o], lambda([], o));
inlambda3(o)  := block([simp:false], buildq([o], lambda([], o)));
inlambda4(o)  :=                     buildq([o], lambda([], o));

inlambda1(2+3);                                /* lambda([], 2+3) */
inlambda2(2+3);                                /* lambda([], 5)   */
inlambda3(2+3);                                /* lambda([], 5)   */
inlambda4(2+3);                                /* lambda([], 5)   */

inlambda1(   2+3);                             /* lambda([], 2+3) */
inlambda1(''(2+3));                            /* lambda([], 5)   */

o : inlambda1(2+3);                            /* lambda([], 2+3) */
block([simp:false], traverse(o, op));          /* lambda          */
block([simp:false], traverse(o, args));        /*       [[], 5]   */
block([simp:false], traverse(o, args,2));      /*            5    */
block([simp:false], traverse(o, args,2,op));   /*             +   */
block([simp:false], traverse(o, args,2,args)); /*           [2,3] */
block([simp:false],      args(o));             /*       [[], 5]   */
block([simp:false],      args(o)[2]);          /*            5    */
block([simp:false],   op(args(o)[2]));         /*             +   */
block([simp:false], args(args(o)[2]));         /*           [2,3] */



#####
#
# catch
# 2024oct31
#
#####

# «catch»  (to ".catch")
# (find-maximanode "catch")
# (find-maximagitgrep "grep --color=auto -nH --null -e fundef $(cat .files.lisp)")
# (find-maximagitfile "src/generr.lisp")
# (find-maximagitfile "src/merror.lisp" "(defun merror ")
# (find-maximagitfile "src/mlisp.lisp" "(defmspec $fundef")
# (find-maximagitfile "src/mlisp.lisp" "(defun consfundef ")
# (find-maximagitfile "src/suprv1.lisp" "(defmacro errcatch ")
# (find-maximagitfile "src/trans1.lisp" "(def%tr $fundef $alias)")
# (find-maximanode "Functions and Variables for Debugging")
# (find-maximanode "errcatch")
# (to "fundef")
# (to "lisp-debugger")
# (to "errcatch")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
lambda ([x], if x < 0 then throw(x) else f(x))$
g(l) := catch (map (''%, l))$
g ([1, 2,  3, 7]);   /* [f(1), f(2), f(3), f(7)] */
g ([1, 2, -3, 7]);   /* -3 */

catch(fundef(h), 42);





#####
#
# cons
# 2024oct15
#
#####

# «cons»  (to ".cons")
# (find-maximanode "cons")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
cons(a, [b,c,d]);    /*  [a, b, c, d] */
cons(a,f(b,c,d));    /* f(a, b, c, d) */
cons(a,b^c);         /* err */

cons(a,-a), inflag:true;
cons(a,-a), inflag:false;





#####
#
# create_list
# 2024jul20
#
#####

# «create_list»  (to ".create_list")
# (find-maximanode "create_list")
# (to "makelist")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
seq(a, b)   := makelist(i, i,a,b)$
create_list(10*a+b, a,[1,2,3], b,[4,5,6]);   /* [14,15,16, 24,25,26, 34,35,36] */
create_list(10*a+b, a,[1,2,3], b,seq(1,a));  /* [11,       21,22,    31,32,33] */




#####
#
# declare
# 2022oct06
#
#####

# «declare»  (to ".declare")
# (find-maximanode "declare")
# (find-maximanode "declare" "nonarray")
# (find-maximagitfile "")
# (find-maximagitsh "find * | sort")
# (find-maximagitsh "find * | sort | grep mac")
# (find-maximagitgrep "grep --color=auto -nRH --null -e declare share")

# (find-maximamsg "37743974 202212 05" "MTalon: declare(integrate,linear);")



#####
#
# define
# 2024oct04
#
#####

# «define»  (to ".define")
# (find-maximanode "define")



#####
#
# define_variable
# 2024oct04
#
#####

# «define_variable»  (to ".define_variable")
# (find-maximanode "define_variable")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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;





#####
#
# defmfun
# 2022aug01
#
#####

# «defmfun»  (to ".defmfun")
# https://jtra.cz/stuff/lisp/sclr/concatenate.html

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
to_lisp();
  (defmfun $foo (str) (concatenate 'string "::" str))
  (to-maxima)
**
foo("bar");




#####
#
# demo
# 2024oct15
#
#####

# «demo»  (to ".demo")
# (find-maximanode "demo")
# (find-maxima-links "demo")
# (find-maximagitfile "src/macsys.lisp" "(defmfun $demo (filename)")




#####
#
# ?, ??, and describe
# 2023oct20
#
#####

# «describe»  (to ".describe")
# (find-maximanode "describe")
# (find-maxima-links "describe")
# (find-maximagitfile "src/macdes.lisp" "(defmspec $describe ")
# (find-maximagitfile "src/trans1.lisp" "(def%tr $describe ")
# (find-maximagitfile "src/cl-info.lisp")
# (find-maximagitfile "src/cl-info.lisp" "(defun info-exact ")
# (find-maximagitfile "src/cl-info.lisp" "(defun info-inexact ")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
:lisp (describe '$describe)
:lisp (symbol-plist '$describe)
:lisp (describe 'cl-info::info-exact)
:lisp (describe 'cl-info::info-inexact)




#####
#
# diff
# 2024aug15
#
#####

# «diff»  (to ".diff")
# (find-maximanode "diff")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
 diff(x^4*y^5, x);
 diff(x^4*y^5, x,2);
 diff(x^4*y^5, x,2, y,1);
'diff(x^4*y^5, x,2, y,1);



#####
#
# direction-fields
# 2022jul09
#
#####

# «direction-fields»  (to ".direction-fields")
# (to "plotdf")
# (find-maximanode "Functions and Variables for drawdf")
# (find-maximanode "drawdf")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("drawdf")$
drawdf(exp(-x)+y)$        /* default vars: x,y */
drawdf(exp(-t)+y, [t,y])$ /* default range: [-10,10] */
drawdf([y,-9*sin(x)-y/5], [x,1,5], [y,-2,2])$
drawdf(2*cos(t)-1+y, [t,y], [t,-5,10], [y,-4,9],
       [trajectory_at,0,0])$
drawdf(2*cos(t)-1+y, [t,-5,10], [y,-4,9],
       solns_at([0,0.1],[0,-0.1]),
       color=blue, soln_at(0,0))$
drawdf(2*cos(t)-1+y, [t,-5,10], [y,-4,9],
       field_degree=2, field_grid=[20,15],
       solns_at([0,0.1],[0,-0.1]),
       color=blue, soln_at(0,0))$
drawdf(2*cos(t)-1+y, [t,-5,10], [y,-4,9],
       soln_arrows=true,
       solns_at([0,0.1],[0,-0.1],[0,0]))$
drawdf([x*(1-x-y), y*(3/4-y-x/2)], [x,0,1.1], [y,0,1],
       field_degree=2, duration=40,
       soln_arrows=true, point_at(1/2,1/2),
       solns_at([0.1,0.2], [0.2,0.1], [1,0.8], [0.8,1],
                [0.1,0.1], [0.6,0.05], [0.05,0.4],
                [1,0.01], [0.01,0.75]))$

drawdf([x*(1-x-y), y*(3/4-y-x/2)], [x,0,1.1], [y,0,1],
       field_degree='solns, duration=40,
       soln_arrows=true, point_at(1/2,1/2),
       solns_at([0.1,0.2], [0.2,0.1], [1,0.8],
                [0.8,1], [0.1,0.1], [0.6,0.05],
                [0.05,0.4], [1,0.01], [0.01,0.75]))$

drawdf([y,-9*sin(x)-y/5], tstep=0.05,
       soln_arrows=true, point_size=0.5,
       points_at([0,0], [2*%pi,0], [-2*%pi,0]),
       field_degree='solns,
       saddles_at([%pi,0], [-%pi,0]))$

drawdf([y,-9*sin(x)-y/5], tstep=0.05,
       show_field=false, soln_arrows=true,
       point_size=0.5,
       points_at([0,0], [2*%pi,0], [-2*%pi,0]),
       saddles_at([3*%pi,0], [-3*%pi,0],
                  [%pi,0], [-%pi,0]))$

drawdf(x^2+y^2, [x,-2,2], [y,-2,2], field_color=gray,
       key="soln 1", color=black, soln_at(0,0),
       key="soln 2", color=red, soln_at(0,1),
       key="isocline", color=green, line_width=2,

colors : ['red,'blue,'purple,'orange,'green]$
drawdf([x-x*y/2, (x*y - 3*y)/4],
       [x,2.5,3.5], [y,1.5,2.5],
       field_color = gray,
       makelist([ key   = concat("soln",k),
                  color = colors[k],
                  soln_at(3, 2 + k/20) ],
                k,1,5))$



#####
#
# dispform
# 2024apr07
#
#####

# «dispform»  (to ".dispform")
# (find-maximanode "dispform")
# (to "format")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
o : - x;
format("~S~%", o);
o : dispform (- x);
format("~S~%", o);

o : sqrt (x);
format("~S~%", o);
o : dispform (sqrt (x));
format("~S~%", o);

expr : sin (sqrt (x));
freeof (sqrt, expr);
freeof (sqrt, dispform (expr));
freeof (sqrt, dispform (expr, all));




#####
#
# distribute_over
# 2024jul28
#
#####

# «distribute_over»  (to ".distribute_over")
# (find-maximanode "distribute_over")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
sin([x,1,1.0]);
properties(sin);



#####
#
# division of polinomials (with remainder)
# 2023nov06
#
#####

# «divide»  (to ".divide")
# (find-maximanode "divide")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
p1 : x^4 + 1;
p2 : x - 1;
[q,r] : divide(p1, p2, x);
matrix([p1, p2],[r, q]);

P([coefs]) := sum(reverse(coefs)[k+1]*x^k, k,0,length(coefs)-1)$
P(2,3,4);
p2 : P(1,1,1);
q0 : P(1,1,1,1,1);
r0 : P(2,3);
p1 : expand(p2*q0+r0);

[q,r] : divide(p1, p2, x);
matrix([p1, p2],[r, q]);




#####
#
# divisors
# 2024jul30
#
#####

# «divisors»  (to ".divisors")
# (find-maximanode "divisors")
# (find-maximanode "setify")
# (find-maximanode "listify")
# (find-maximanode "divide")
# (find-maximanode "factor")
# 2iT1: (c2m241edolccsp 8 "raizes-chutar-testar")
#       (c2m241edolccsa   "raizes-chutar-testar")
# http://anggtwu.net/LATEX/2024-1-C2-edolccs.pdf#page=8

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
poly0 : (x-2)*(x+5);
poly1 : expand(poly0);
b : ratcoef(poly1, x, 1);    /* coeficiente do x^1 */
c : ratcoef(poly1, x, 0);    /* coeficiente do x^0 */
                divisors(c);
divs0 : listify(divisors(c));
                reverse(divs0);
               -reverse(divs0);
divs1 : append(-reverse(divs0), divs0);
line(d1) := block([d2:c/d1], [d1,d2,d1*d2,d1+d2])$
line(2);
lines0 : makelist(line(d1), d1, divs1)$
lines1 : append([["d1", "d2", "d1*d2", "d1+d2"]], lines0)$
apply('matrix, lines1);



#####
#
# divisors-2
# 2024nov09
#
#####

# «divisors-2»  (to ".divisors-2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
c : 20;
divisor_(d,n) := if d=0 then [] elseif n/d=round(n/d) then [d] else []$
divisors_ (n) := apply('append, makelist(divisor_(d,n), d, -abs(n),abs(n)));
divisor_(10,20);
divisor_ (9,20);
divisors_  (20);

line_(d1,d2) := [d1, d2, d1+d2, d1*d2]$
table_(n) := block([d1s, topline, otherlines],
  d1s : reverse(divisors_(n)),
  topline : rhs(fundef(line_)),
  otherlines : makelist(line_(d1,n/d1), d1, d1s),
  apply('matrix, append([topline], otherlines)))$

table_(10);
table_(28);
table_(-28);





#####
#
# dosimp-and-doeval
# 2022jan14
#
#####

# «dosimp-and-doeval»  (to ".dosimp-and-doeval")
# (to "simp")
# (find-maximamsg "37417447 202201 14" "Stavros: dosimp and doeval")
# (find-maximanode "simp")
# (find-maximanode "block")
# (find-maximanode "expand")
# (find-maximanode "?")

** dosimp(ex)        - simplifies ex without evaluating it
** doeval(ex)        - evaluates ex without simplifying it
** fullyeval(ex)     - evaluates and simplifies
** parse_string(str) - converts "x+x" to x+x
** tolispstr(ex)     - converts x+x to "((MPLUS) $X $X)"
** fromlispstr(ex)   - "((MPLUS) $X $X)" to x+x

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
simp:false$
dosimp(ex)   := block([simp:true],  expand(ex,0,0))$
doeval(ex)   := block([simp:false], ?meval(ex))$
fulleval(ex) := block([simp:true],  ?meval(ex))$
load(stringproc)$
to_lisp();
  (defun $tolispstr   ($ex)  (format nil "~s" $ex))
  (defun $fromlispstr ($str) (read-from-string $str))
  (to-maxima)
**
q: parse_string("x+x");
dosimp(q);
doeval(q);
tolispstr(parse_string("x+x"));
tolispstr(x + x);
fromlispstr(tolispstr(x + 2));
**
q:  '('integrate(f(x), x, a, b) = F(b) - F(a));
       subst([a=42, b=99, f(x)=3*x^2, F=lambda([x],x^3)], q)$
doeval(subst([a=42, b=99, f(x)=3*x^2, F=lambda([x],x^3)], q));
**
simp:true;
ex1 : 'integrate(exp(2*x), x);
ex2 :  integrate(exp(2*x), x);





#####
#
# equal
# 2022jul09
#
#####

# «equal»  (to ".equal")
# (find-maximanode "equal")
# (find-maximanode "=")
# (find-maximanode "=" "is (a = b);")
# (find-maximanode "symbolp")
# (find-maximanode "stringp")
# (find-maximanode "prederror")
# (find-maximamsg "39730760 202309 30" "Edrx: is(equal(op(f(x,y)), 'del)) -> unknown")
# (find-maximamsg "39730814 202309 30" "BWillis: prederror")
# (to "is")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
is(equal(a, b));
is(a=b);

is(equal(op(del(w)), 'del));
is(equal(op(f(x,y)), 'del));
is      (op(del(w)) ='del);
is      (op(f(x,y)) ='del);
if is(equal(op(del(w)), 'del)) then "yes" else "no";
if is(equal(op(f(x,y)), 'del)) then "yes" else "no";
if is      (op(del(w) = 'del)) then "yes" else "no";
if is      (op(f(x,y) = 'del)) then "yes" else "no";

ex : '(a:=b);
ex : f(a);
op(ex);
symbolp(op(ex));
stringp(op(ex));

is('f = "f");
is(op(f(a)) = "f");
is(op(f(a)) = 'f);
is(op('(a:=b)) = ":=");

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
block([prederror : false], is(equal((x+1)^2, x^2+2*x+1)));
block([prederror : true],  is(equal(op(f(x,y)), 'del)));
block([prederror : false], is(equal(op(f(x,y)), 'del)));
block([prederror : true],  is(op(f(x,y))= 'del));
block([prederror : false], is(op(f(x,y))= 'del));



# (find-maximamsg "37675653 202207  1" "Stavros: structural equality")
# Let's look at a simpler example. Consider:
# 
#   f(x):= block([n],if n=0 then 1 else x);
# 
# In Maxima, if a variable *n* is not assigned a value, it evaluates to
# itself (the symbol *n*). The "=" operation checks for structural
# equality, not mathematical equality. The symbol *n* is not equal to
# the number *0*, so the predicate is false, and thus your function
# returns *x*. So you should use *equal*:
# 
#   f(x):= block([n],if equal(n,0) then 1 else x);
# 
# Until *n* is defined, the test *equal(n,0) *is undefined, so an unevaluated
# conditional is returned.




#####
#
# erf
# 2024nov27
#
#####

# «erf»  (to ".erf")
# (find-maximanode "erf")
# (to "quad_qagi")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-myqdraw "myqdraw3.mac")
diff(erf(x), x);
load_myqdraw();
[xmin,ymin, xmax,ymax] : [-4,-4, 4,4];
myqdraw(xyrange(),
        myex1(erf(x), lc(blue)),
        myex1(diff(erf(x),  x), lc(red)),
        myex1(diff(erf(2*x),x), lc(orange)),
        myex1(diff(erf(x-1),x), lc(forest_green))
       );





#####
#
# errcatch
# 2024oct31
#
#####

# «errcatch»  (to ".errcatch")
# (find-maxima-links "errcatch")
# (find-maximanode "errcatch")
# (find-maximanode "errormsg")
# (find-maximanode "false")
# (find-maximagitgrep "grep --color=auto -niH --null -e errcatch $(cat .files.mac)")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(x) := x;
fundef(f);
fundef(g);
errcatch(fundef(f));
errcatch(fundef(g));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
myerrcatch(code, default) ::=
  buildq ([code, default],
    block([errormsg:false, result],
      result : errcatch(code),
      if   length(result)=0
      then default
      else result[1]));

myerrcatch0(rslt, default) := if length(rslt)=0 then default else rslt[1];
myerrcatch (code, default) ::=
  buildq  ([code, default],
    block([errormsg:false, result],
      myerrcatch0(errcatch(code), default)));

f(x) := x;
myerrcatch(fundef(f), false);
myerrcatch(fundef(g), false);





#####
#
# ev
# 2022jul16
#
#####

# «ev»  (to ".ev")
# (find-books "__comp/__comp.el" "maxima-workbook" "11 Evaluation")
# (find-maximawbpage (+ 20 76) "11 Evaluation")
# (find-maximanode "ev")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
z : a00 + a10*Dx + a20*Dx^2
  + (a01 + a11*Dx + a21



#####
#
# ev-derivative-quirk
# 2024aug24
#
#####

# «ev-derivative-quirk»  (to ".ev-derivative-quirk")
# (to "2024-1-C2-P2")
# (find-maximanode "ev")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
e1 : 'diff(y,x) - 2*y/x = 3*x;
e1 : 'diff(y,x) = 4*y;
e2 : ode2(e1,y,x);
e3 : subst(e2, e1);
e4 : ev(e3,            'derivative);  /* ok    */
e4 : ev(subst(e2, e1), 'derivative);  /* wrong */

e2;
e1;
subst(e2,e1);

        print(subst(print(e2), print(e1)));
e4 : ev(print(subst(print(e2), print(e1))), 'derivative);
depends(y,x);
e4 : ev(print(subst(print(e2), print(e1))), 'derivative);



#####
#
# ev-eval
# 2024jul11
#
#####

# «ev-eval»  (to ".ev-eval")
# (find-maximanode "ev")
# (find-maximanode "ev" "noeval")
# (find-maximanode "ev" "For each instance of 'eval'")
# (find-maximanode "ev" "Special symbol: eval")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
[a:b,b:c,c:d,d:e];
a;
ev(a);
ev(ev(a));
ev(ev(ev(a)));
ev(ev(ev(ev(a))));

''a;
''(''a);

a, noeval;
ev(a),eval;
a,eval,eval;




#####
#
# ev(foo,integrate) and read-simp-eval-output
# 2022jun23
#
#####

# «ev-integrate»           (to ".ev-integrate")
# «read-simp-eval-output»  (to ".read-simp-eval-output")
# (find-maximanode "Introduction to Simplification")
# (find-maximanode "Functions and Variables for Rules and Patterns")
# (find-maximanode "simp")
# (find-maximanode "ev")
# (find-maximanode "ev" "evaluation of noun forms")
# (find-maximanode "ev" "evaluation of noun forms" "integrate")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
ex1 : 'integrate(x, x);
ex2 :  integrate(x, x);
      ex1;
    ''ex1;
ev (''ex1);
ev (''ex1, integrate);
ev (  ex1);
ev (  ex1, integrate);
? integrate;



#####
#
# eval
# 2024oct22
#
#####

# «eval»  (to ".eval")
# (find-maximanode "eval_string")
# (find-maximanode "eval_string_lisp")
# (find-maximanode "parse_string")
# (to "parse-string")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f1(a) := [11,a];
f2(a) := [22,a];
g(n)  := concat("f",n);
h(n)  := parse_string(g(n));
g(1)(33);              /* [11,33] */
map(g(1), [33,44]);    /* err */
map(h(1), [33,44]);    /* [[11,33], [11,44]]




#####
#
# example
# 2022jan10
#
#####

# «example»  (to ".example")
# (find-maximanode "Functions and Variables for Help" "Function: example")
# (find-sh "locate manual.demo")
# (find-maximagitfile "demo/manual.demo")
# (find-maximagitfile "")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
??example
example(dispfun);
example();
manual_demo;
example(declare);





#####
#
# flatten
# 2024sep01
#
#####

# «flatten»  (to ".flatten")
# (find-maximanode "flatten")
# (to "myapply")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
flatten (2,3,4);                       /* err */
flatten([2,3,4, [5, [[6,7],[8,9]]]]);

myflatten([args]) := flatten([[args]]);

  flatten([2,3,4,[5,[[6,7],[8,9]]]]);
myflatten( 2,3,4,[5,[[6,7],[8,9]]] );




#####
#
# float-and-numer
# 2022apr25
#
#####

# «float-and-numer»  (to ".float-and-numer")
# «float»  (to ".float")
# «numer»  (to ".numer")
# (to "eigenvalues")
# (find-maximanode "float")
# (find-maximanode "numer")
# (find-maximanode "fpprec")
# (find-maximanode "fpprintprec")
# (find-maximabookpage (+ 1 34) "Numerical Output - FLOAT and NUMER")
# (find-maximabooktext (+ 1 34) "Numerical Output - FLOAT and NUMER")
# (find-maximamsg "37781666 202302 22" "RToy: foo,numer, ev(foo,numer), float(foo)")
# (find-maximamsg "37781642 202302 22" "BWillis: block([numer : true], foo)")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a:9/4;
exp(a);
ev(exp(a),FLOAT);
ev(exp(a*x),FLOAT);
numerval(b, 25);
a*b;
ev(a*b,FLOAT);
ev(a*b,NUMER);
float(a);
float(b);
float(a*b);
c : sqrt(2);
float(c);
fpprintprec : 4;
float(c);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a : sqrt(2);
a : float(a);
fpprintprec : 2;
a;
a*100;




#####
#
# numer-and-float
# 2022nov20
#
#####

# «numer-and-float»  (to ".numer-and-float")
# (to "2022-2-C3-P1")
# (find-maximamsg "37736745 202211 18" "Edrx: first half of plotting contour levels?")
# (find-maximamsg "37737021 202211 18" "Stavros: ratprint / float")
# (find-maximanode "numer")
# (find-maximanode "float")
# (find-maximanode "keepfloat")
# (find-maximanode "ratprint")
# (find-maximanode "Functions and Variables for Polynomials" "'solve' ignores 'keepfloat'")
# (find-maximanode "replaced x by y")

* Solve is designed to give exact solutions, so you will get solutions in
radicals, not floating-point numbers (even with float inputs and
*keepfloat:true*)
* You can silence the "rat replaced" messages by setting *ratprint:false*,
but those warnings are telling you that Maxima is calculating with
rationals rather than floats. e.g., *solve(x^2=.14,x) *gives the exact
solution *sqrt(7)/(5*sqrt(2)) *rather than 0.374
* At the very least, you should convert everything to numbers before any
further calculations (including *min*).
* It is almost always a bad idea to use *ev* in code. I think you can
replace *ev(...,numer)* with *float(...)*




#####
#
# for
# 2022dec11
#
#####

# «for»  (to ".for")
# (find-maximanode "for")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
for i: 2 thru  5        do display(i);
for a:-3 thru 26 step 7 do display(a)$

s:0;
for i: 1 while i <= 10 do s: s+i;
s;

     Note that the condition 'while i <= 10' is equivalent to 'unless i
     > 10' and also 'thru 10'.

          (%i1) series: 1$
          (%i2) term: exp (sin (x))$
          (%i3) for p: 1 unless p > 7 do
                    (term: diff (term, x)/p,
                     series: series + subst (x=0, term)*x^p)$
          (%i4) series;
                            7    6     5    4    2
                           x    x     x    x    x
          (%o4)            -- - --- - -- - -- + -- + x + 1
                           90   240   15   8    2

     which gives 8 terms of the Taylor series for 'e^sin(x)'.

          (%i1) poly: 0$
          (%i2) for i: 1 thru 5 do
                    for j: i step -1 thru 1 do
                        poly: poly + i*x^j$
          (%i3) poly;
                            5      4       3       2
          (%o3)          5 x  + 9 x  + 12 x  + 14 x  + 15 x
          (%i4) guess: -3.0$
          (%i5) for i: 1 thru 10 do
                    (guess: subst (guess, x, 0.5*(x + 10/x)),
                     if abs (guess^2 - 10) < 0.00005 then return (guess));
          (%o5)                  - 3.162280701754386

     This example computes the negative square root of 10 using the
     Newton- Raphson iteration a maximum of 10 times.  Had the
     convergence criterion not been met the value returned would have
     been 'done'.

     Instead of always adding a quantity to the control-variable one may
     sometimes wish to change it in some other way for each iteration.
     In this case one may use 'next <expression>' instead of 'step
     <increment>'.  This will cause the control-variable to be set to
     the result of evaluating <expression> each time through the loop.

          (%i6) for count: 2 next 3*count thru 20 do display (count)$
                                      count = 2

                                      count = 6

                                     count = 18

     As an alternative to 'for <variable>: <value> ...do...' the syntax
     'for <variable> from <value> ...do...' may be used.  This permits
     the 'from <value>' to be placed after the 'step' or 'next' value or
     after the termination condition.  If 'from <value>' is omitted then
     1 is used as the initial value.

     Sometimes one may be interested in performing an iteration where
     the control-variable is never actually used.  It is thus
     permissible to give only the termination conditions omitting the
     initialization and updating information as in the following example
     to compute the square-root of 5 using a poor initial guess.

x: 1000$
thru 20 do x: 0.5*(x + 5.0/x)$
x;
sqrt(5), numer;

newton (f, x):= ([y, df, dfx], df: diff (f ('x), 'x),
    do (y: ev(df), x: x - f(x)/y,
        if abs (f (x)) < 5e-6 then return (x)))$
sqr (x) := x^2 - 5.0$
newton (sqr, 1000);

     (Note that 'return', when executed, causes the current value of 'x'
     to be returned as the value of the 'do'.  The 'block' is exited and
     this value of the 'do' is returned as the value of the 'block'
     because the 'do' is the last statement in the block.)

     One other form of the 'do' is available in Maxima.  The syntax is:

          for <variable> in <list> <end_tests> do <body>

     The elements of <list> are any expressions which will successively
     be assigned to the 'variable' on each iteration of the <body>.  The
     optional termination tests <end_tests> can be used to terminate
     execution of the 'do'; otherwise it will terminate when the <list>
     is exhausted or when a 'return' is executed in the <body>.  (In
     fact, 'list' may be any non-atomic expression, and successive parts
     are taken.)

for f in [log, rho, atan] do ldisp(f(1))$




#####
#
# format
# 2024apr06
#
#####

# «format»  (to ".format")
# (find-angg    ".maxima/maxima-init.mac" "format")
# (find-fline "~/.maxima/maxima-init.mac" "format([args]) :=")
# (find-es "lisp" "format")
# (find-es "lisp" "format-recipes")
# (find-es "lisp" "format-recipes" "12,'0d")
# (find-maximanode "?")
# (find-maximanode "Lisp and Maxima")
# (find-maximanode "Lisp and Maxima" "?foo")
# (find-maximanode "dispform")
# (find-maximanode "dispform" "?format")
# (to "printf")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
format([args]) := apply(?format, append([false], args));
topdfstem(n)   := format("/tmp/pdfs/a_~3,'0d", n);
topdfstem(1);
topdfstem(20);




#####
#
# fundef
# 2024oct31
#
#####

# «fundef»  (to ".fundef")
# (find-maximanode "fundef")
# (find-maxima-links "fundef")
# (find-maximagitgrep "grep --color=auto -niH --null -e fundef $(cat .files.mac)")
# (find-maximagitgrep "grep --color=auto -niH --null -e fundef $(cat .files.lisp)")
# (find-maximagitfile "src/mlisp.lisp" "(defmspec $fundef (x)")
# (to "catch")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(x) := x;
g(x) ::= y;
fundef(f);
fundef(g);
fundef(h);
errcatch(fundef(f));
errcatch(fundef(g));
errcatch(fundef(h));
errormsg:false;
errcatch(fundef(h));
errormsg:true;
errcatch(fundef(h));


to_lisp();
  (apropos "fundef")
  (defun $myfundef (x) (ignore-errors ($fundef x)))
  (to-maxima)

myfundef(f);
myfundef(g);
myfundef(h);





#####
#
# funmake, and translating the "funcall" from elisp
# 2024sep01
#
#####

# «funmake»    (to ".funmake")
#   «funcall»  (to ".funcall")
# (find-maximanode "funmake")
# (find-efunctiondescr 'funcall)
# (find-efunctiondescr 'apply)
# (apply   '+ 1 2 '(3 4))
# (funcall '+ 1 2   3 4)

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
funmake("+", [1, 2, 3, 4, 5]);   /* 15 */
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]);



#####
#
# getenv
# 2023nov08
#
#####

# «getenv»  (to ".getenv")
# (find-angg ".maxima/maxima-init.mac" "HOME")
# (find-maximanode "Environment operations")
# (find-maximanode "getenv")
# (find-sh "locate operatingsystem")
# (find-maximagitfile "share/contrib/operatingsystem/")
# (find-maximagitfile "share/contrib/operatingsystem/operatingsystem.mac")
# (find-maximagitfile "share/contrib/operatingsystem/operatingsystem.lisp")




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

# «grind»  (to ".grind")
# (find-maximanode "grind")

* (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);




#####
#
# if and is
# 2023sep26
#
#####

# «if»  (to ".if")
# «is»  (to ".is")
# (find-fline "~/luatree/luatree.mac" "if")
# (find-maximanode "if")
# (find-maximanode "if" "prederror")
# (find-maximanode "prederror")
# (find-maximanode "is")
# (find-maximanode "maybe")
# (find-maximanode "Relational operators" "map (is, %)")
# (to "equal")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a : '(f(x,y) := 10*x+y);
a : '(b = 42);
           op(a);
      equal(op(a), ":=");
   is(equal(op(a), ":="));
if is(equal(op(a), ":=")) then "yes" else "no";

if 2<3 then "yes";
if 2>3 then "yes";

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-anchor "~/lisptree/lisptree.mac")
load           ("~/lisptree/lisptree.mac");
lisptreeq(if 1 then 2);
lisptreeq(if 1 then 2 else      false);
lisptreeq(if 1 then 2 else          4);
lisptreeq(if 1 then 2 elseif 3 then 4);
lisptreeq(if 1 then 2 elseif 3 then 4 else false);
lisptreeq(if 1 then 2 elseif 3 then 4 else 6);



#####
#
# inflag
# 2024oct28
#
#####

# «inflag»  (to ".inflag")
# (find-maxima-links "inflag")
# (find-maximanode "inflag")
# (find-maximamsg "58834679 202410 28" "BWillis: lisptree / inflag")
# (find-maximamsg "58834704 202410 28" "Edrx: I forgot to test it with inflag")
# (find-clhsdoci "let")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-anchor "~/lisptree/lisptree.mac")
load           ("~/lisptree/lisptree.mac");
block([inflag:true],  lisptree(a/b));
block([inflag:false], lisptree(a/b));
block([inflag:true],  format0(a/b));
block([inflag:false], format0(a/b));
o : a/b;
to_lisp();
  #$o$

  (defun newsimplify (o)
    (if (and (consp o) (consp (car o)))
        `(,(caar o) ,@(map 'list #'newsimplify (cdr o)))
        o))
  (defun $new2dtree_ (o)
    (lisptree::toplain-lines (lisptree::lispytree (newsimplify o))))
  (defun $new2dtree (o)
    (format nil "~%~a" ($new2dtree_ o)))

  ($new2dtree_ #$o$)
  ($new2dtree  #$o$)
  (to-maxima)

new2dtree(o);


Hi Barton,

you are right - the conversion from "Maxima objects" to "Maxima trees"
is done in Maxima, by the functions in lisptree.mac whose names that
start with "lisptree0". Try:

  load("/tmp/lisptree/lisptree.mac");
  block([inflag:true],  lisptree(a/b));
  block([inflag:false], lisptree(a/b));
  block([inflag:true],  lisptree0(a/b));  /* [*,a,[^,b,-1]] */
  block([inflag:false], lisptree0(a/b));  /* [/,a,b] */

The function `lisptree0_apatom' calls `args', and if I remember
correctly it is `args' that chooses between the representations a/b
and a*b^-1 depending on the value of `inflag'... anyway, I just saw
that it would be useful to have functions that generate trees like
this one

  MTIMES__.
  |       |
  $A      MEXPT__.
          |      |
          $B     -1

from Maxima objects like a/b, i.e., 

  ((MTIMES SIMP) $A ((MEXPT SIMP) $B -1))

Here is a prototype. Run this in a REPL:

  load("/tmp/lisptree/lisptree.mac");
  block([inflag:true],  lisptree(a/b));
  block([inflag:false], lisptree(a/b));
  block([inflag:true],  format0(a/b));
  block([inflag:false], format0(a/b));
  o : a/b;
  to_lisp();
    #$o$
  
    (defun newsimplify (o)
      (if (and (consp o) (consp (car o)))
          `(,(caar o) ,@(map 'list #'newsimplify (cdr o)))
          o))
    (defun $new2dtree_ (o)
      (lisptree::toplain-lines (lisptree::lispytree (newsimplify o))))
    (defun $new2dtree (o)
      (format nil "~%~a" ($new2dtree_ o)))
  
    ($new2dtree_ #$o$)
    ($new2dtree  #$o$)
    (to-maxima)
  
  new2dtree(o);

Here the output of its last line is this 2D tree:

  MTIMES__.
  |       |
  $A      MEXPT__.
          |      |
          $B     -1

Cheers, thanks for testing, more in other messages, etc,
  Eduardo

https://sourceforge.net/p/maxima/mailman/message/58834704/
https://sourceforge.net/p/maxima/mailman/message/58834679/






#####
#
# init-file
# 2021dec24
#
#####

# «init-file»  (to ".init-file")
# (find-maximagitgrep "grep --color=auto -nRH --null -e maxima-init *")
# (find-maximanode "Introduction for Runtime Environment")
# (find-maximanode "Introduction for Runtime Environment" "maxima-init.mac")
# (find-maximanode "Functions and Variables for Runtime Environment" "maxima_userdir")
# (find-man "1 maxima")
# (find-man "1 maxima" "MAXIMA_USERDIR")
# (find-man "1 maxima" "maximarc")
# (find-man "1 maxima" "maxima-init.lisp")
# (find-fline "~/.maxima/")
# (find-angg ".maxima/maxima-init.mac")
# (find-angg ".maxima/maxima-init.lisp")




#####
#
# The options --no-init and --userdir=/tmp
# 2024aug07
#
#####

# «no-init»  (to ".no-init")
# (find-angg ".emacs" "oldmaxima")
# (find-angg ".maxima/maxima-init.mac" "load_qdraw")
# (find-maximanode "file_search_maxima")

* (eepitch-maxima0)
* (eepitch-kill)
* (eepitch-maxima0)
load("qdraw");
file_search_maxima;
addpath(p) := (file_search_maxima : append([p], file_search_maxima))$
try(p)     := (addpath(p), load("qdraw"))$
try("~/snarf/https/home.csulb.edu/~woollett/*.mac");          /* ok */

load("~/.maxima/maxima-init.mac");
load("qdraw");

try("/home/edrx/snarf/https/home.csulb.edu/~woollett");
try("/home/edrx/snarf/https/home.csulb.edu/~woollett/");
try("~/snarf/https/home.csulb.edu/~woollett/###.{mac,lisp}");
try("/home/edrx/snarf/https/home.csulb.edu/~woollett/###.{mac,lisp}");
try("~/snarf/https/home.csulb.edu/~woollett/*.mac");          /* ok */
try("/home/edrx/snarf/https/home.csulb.edu/~woollett/*.mac"); /* ok */
try("~/snarf/https/home.csulb.edu/~woollett/*.{mac,lisp}");

* (eepitch-oldmaxima0)
* (eepitch-kill)
* (eepitch-oldmaxima0)
load("qdraw");
file_search_maxima;
addpath(p) := (file_search_maxima : append([p], file_search_maxima))$
try(p)     := (addpath(p), load("qdraw"))$
try("~/snarf/https/home.csulb.edu/~woollett/*.mac");          /* ok */

try("/home/edrx/snarf/https/home.csulb.edu/~woollett");
try("/home/edrx/snarf/https/home.csulb.edu/~woollett/");
try("~/snarf/https/home.csulb.edu/~woollett/###.{mac,lisp}");           /* ok on old */
try("/home/edrx/snarf/https/home.csulb.edu/~woollett/###.{mac,lisp}");  /* ok on old */
try("~/snarf/https/home.csulb.edu/~woollett/*.mac");          /* ok */
try("/home/edrx/snarf/https/home.csulb.edu/~woollett/*.mac"); /* ok */
try("~/snarf/https/home.csulb.edu/~woollett/*.{mac,lisp}");          /* ok on old */


# (find-sh "maxima --help")
# (find-sh "maxima --help" "--directories")
# (find-sh "maxima --help" "--no-init")
# (find-sh "/usr/bin/maxima --help" "--no-init")
# (find-sh "/usr/bin/maxima --help" "--userdir=<directory>")

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

# (find-maximanode "load")
# (find-oldmaximanode "load")
# (find-maximanode "filename_merge")

# (find-node "(/usr/share/info/maxima)")

file_search_maxima;
file_search_lisp;
file_search_demo;
file_search_usage;
file_search_tests;

* (find-3EE '(eepitch-maxima) '(eepitch-maxima0))
* (find-3ee '(eepitch-maxima) '(eepitch-maxima0))
* (eepitch-maxima)
seq(2,5);
* (eepitch-maxima0)
seq(2,5);

* (find-3EE '(eepitch-oldmaxima) '(eepitch-oldmaxima0))
* (find-3ee '(eepitch-oldmaxima) '(eepitch-oldmaxima0))
* (eepitch-oldmaxima)
seq(2,5);
* (eepitch-oldmaxima0)
seq(2,5);




#####
#
# variables
# 2021dec18
#
#####

# «kill»       (to ".kill")
# «variables»  (to ".variables")
# (find-maximanode "kill")
# (find-maxima-links "kill")
# (find-maximagitgrep "grep --color=auto -niH --null -e kill src/*.lisp")
# (find-maximagitfile "src/db.lisp" "(defun kill ")
# (find-maximagitfile "src/trans1.lisp" "(def%tr $kill ")
# (find-maximagitfile "src/suprv1.lisp" "(defmspec $kill ")

<edrx> hi! how can I undefine a function?
<edrx> if I do "diff(f(x), x)" without defining f maxima treats f
       as an abstract function... how do I revert f to that state
       after doing "f(x) := sin(x)"?
<merryprog> edrx you can doo kill(f);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
diff(f(x), x);
f(x) := sin(x);
diff(f(x), x);
kill(f);
diff(f(x), x);




#####
#
# lambda and ''
# 2022may07
#
#####

# «lambda»  (to ".lambda")
# (to "quote-quote)
# (find-maximaindex-links "' '' buildq lambda")
# (find-maximanode "lambda")
# (find-maximanode "quote-quote")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
y : x^2;
f : lambda([x], y);
f : lambda([x], ''y);
f(10);
y : x^3;
f(10);
f : lambda([x], ''y);
f(10);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
[a:b, b:c, c:d, d:e];
a;
b;
c;
d;
makelist([a,b,c,d],       a, 2,3);
makelist([a,b,c,d],     ''a, 2,3);
makelist([a,b,c,d],   ''''a, 2,3);
makelist([a,b,c,d], ''''''a, 2,3);



#####
#
# linel: screen width, in columns
# 2024apr15
#
#####

# «linel»  (to ".linel")
# (find-maximanode "linel")

     'linel' is the assumed width (in characters) of the console display
     for the purpose of displaying expressions.  'linel' may be assigned
     any value by the user, although very small or very large values may
     be impractical.  Text printed by built-in Maxima functions, such as
     error messages and the output of 'describe', is not affected by
     'linel'.




#####
#
# linsolve
# 2022dec07
#
#####

# «linsolve»  (to ".linsolve")
# (find-maximanode "linsolve")
# (find-books "__analysis/__analysis.el" "hefferon")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
linsolve ([3*x + 4*y = 7, 2*x + a*y = 13], [x, y]);
linsolve ([3*x + 4*y, 2*x + a*y] = [7,13], [x, y]); /* err */
linsolve ([3*x + 4*y, 2*x + a*y] - [7,13], [x, y]);

eq_1 : u = a1*x + b1*y + c1;
eq_2 : v = a2*x + b2*y + c2;
eqs_12 : [eq_1, eq_2];
eqs_34 : linsolve([eq_1, eq_2], [x,y]);
eqs_34 : linsolve(eqs_12, [x,y]);
eqs_56 : linsolve(eqs_34, [u,v]);

rlhs(eq) := rhs(eq) - lhs(eq);
lrhs(eq) := lhs(eq) - rhs(eq);
flip(eq) := rhs(eq) = lhs(eq);
keqk(k)  := k = k;

eq_1 : u =   x + 2*y;
eq_2 : v = 3*x + 4*y;
eq_3 : eq_1 + keqk(-2*y);
eq_4 : flip(eq_3);
eq_5 : subst(eq_4, eq_2);
eq_6 : expand(eq_5);
eq_7 : eq_6 + keqk(2*y-v);
eq_8 : eq_7 / 2;
[eq_4, eq_8];
linsolve([eq_1, eq_2], [x,y]);

apply('matrix, map("[", eqs_56));

colv([entries]) := apply('matrix, map("[", entries));
colv(2, 3);
colv(eqs_56);
apply('colv, eqs_56);




#####
#
# lisp-debugger
# 2024oct31
#
#####

# «lisp-debugger»  (to ".lisp-debugger")
# https://mail.google.com/mail/u/0/#search/lisp-debugger
# (find-maximamsg "37611853 202202 16" "MTalon: About the debugger")
# (find-maximamsg "58827442 202410 11" "RToy: |-g| option ... lisp debugger")

# (find-maximanode "Command-line options" "-g, --enable-lisp-debugger")
# (find-maximagitfile "src/init-cl.lisp" "--enable-lisp-debugger")
# (find-maxima-links "enable-lisp-debugger")
# (find-maxima-links "debugger-hook")
# (find-maximagitgrep "grep --color=auto -nH --null -e debugger-hook $(cat .files.lisp)")
# (to "catch")






#####
#
# load and load-path
# 2023jul19
#
#####

# «load»                (to ".load")
# «load-path»           (to ".load-path")
# «load_pathname»       (to ".load_pathname")
# «file_search_maxima»  (to ".file_search_maxima")
# (find-maximanode "Files")
# (find-maximanode "load_pathname")
# (find-maximanode "load")
# (find-maximanode "file_search")
# (find-maximanode "file_search_maxima")
# (find-maximanode "file_search_lisp")
# (find-maximanode "file_search_demo")
# (find-maximanode "file_search_usage")
# (find-maximanode "file_search_tests")
# (find-maximamsg "37874366 202307 23" "RToy: The current search paths are now:")
# (find-angg "luatree/luatree.mac")
# (find-angg ".maxima/maxima-init.mac" "HOME")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
file_search_maxima;
file_search_lisp;
file_search_demo;
file_search_usage;
file_search_tests;
:lisp (describe '$load)

** (find-angg "MAXIMA/mkmatrix1.mac")
load                ("mkmatrix1.mac");
load       ("~/MAXIMA/mkmatrix1.mac");

file_search_maxima : append(["~/MAXIMA/*.mac"], file_search_maxima);
file_search_maxima;
load                ("mkmatrix1");
load                ("mkmatrix1.mac");
? load
? file_search

# (find-es "lisp" "sharpsign-P")
# (hyperspec-lookup-reader-macro "#P")
# (find-clhsdoc "Body/02_dhn" "Sharpsign P")

<edrx> anyone knows how do I do something equivalent to
       (add-to-list 'load-path
       "/usr/share/emacs/site-lisp/maxima/") in Common Lisp (SBCL)?
<pjb> (push #P"/usr/share/emacs/site-lisp/maxima/"
      asdf:*central-registry*)
<pjb> or (push #P"/usr/share/emacs/site-lisp/maxima/"
      quicklisp-client:*local-project-directories*)




#####
#
# macros
# 2023jul08
#
#####

# «macros»  (to ".macros")
# (to "op-and-args")
# (find-maximanode "Macros")
# (find-maximanode "::=")



#####
#
# macroexpand
# 2024jul12
#
#####

# «macroexpand»  (to ".macroexpand")
# (find-maximanode "macroexpand")
# (find-maximanode "macroexpand1")
# (find-maximanode "macros")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
g (x) ::= x / 99;
h (x) ::= buildq ([x], g (x - a));
a: 1234;
macroexpand1 (h (y));
macroexpand  (h (y));
h (y);

o0 : '(h(y));
o1 : apply('macroexpand1, [o0]);
o2 : apply('macroexpand1, [o1]);
o2 : apply('macroexpand,  [o0]);  /* same as the previous o2 */
o3 : ev(o2);
o3 : ev(o0);                      /* same as the previous o3 */

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
m1(x) ::= x;
m2(x) ::= m1(x);
macros;
       m2(42);
     '(m2(42));
o0 : '(m2(42));
o1 : apply('macroexpand,  [o0]);
o1 : apply('macroexpand1, [o0]);

macroexpand1(m2(42));



#####
#
# makelist
# 2022jul22
#
#####

# «makelist»  (to ".makelist")
# «seqn»      (to ".seqn")
# (find-maximanode "makelist")
# (find-angg "LUA/lua50init.lua" "map" "seqn =")
# (to "create_list")
# (to "low-level-makelist")

? makelist

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
makelist (concat (x,i), i, 6);   /* [x1, x2, x3, x4, x5, x6] */
makelist (x=y, y, [a, b, c]);    /* [x = a, x = b, x = c] */
makelist (x^2, x, 3, 2*%pi, 2);  /* [9, 25] */
makelist (random(6), 4);         /* [2, 0, 2, 5] */
flatten (makelist (makelist (i^2, 3), i, 4)); /* [1, 1, 1, 4, 4, 4, 9, 9, 9, 16, 16, 16] */
flatten (makelist (makelist (i^2, i, 3), 4)); /* [1, 4, 9, 1, 4, 9, 1, 4, 9, 1, 4, 9] */

[a,b,n] : [10,20,5];
makelist(a + (b-a)*k/n, k, 0, n);
seqn(a,b,n) := makelist(a + (b-a)*k/n, k, 0, n);
seqn(10, 20, 5);
seqn(10, 20, 2);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(a) := a+x;
makelist(f(i),i,1,5);  /* good */
makelist(f(x),x,1,5);  /* bad  */






#####
#
# map and maplist
# 2023jul19
#
#####

# «map»      (to ".map")
# «maplist»  (to ".maplist")
# (find-maxima-links "maplist")
# (find-maximanode "map")
# (find-maximanode "maplist")
# (find-maximanode "maperror")
# (find-maximanode "outermap")
# (find-maximanode "listarith")
# (find-maximamsg "48131547 202310 23" "Edrx: makelist(apply(f, [a]), a, as)")
# (find-maximamsg "48448811 202310 24" "MTalon: what is the problem with the simpler")
# (find-maximamsg "48496619 202310 24" "Edrx: map sometimes recurses on trees, not on lists")
# (find-maximamsg "48496623 202310 24" "BWillis: listarith")
# (find-maximamsg "48496643 202310 24" "RFateman")
# (find-maximamsg "48496673 202310 24" "Edrx: ouch")
# (find-maximamsg "48496694 202310 24" "Stavros: (nice examples)")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
map    (lambda([x,y], 10*x+y), [1, 2, 3], [4, 5, 6]);
maplist(lambda([x,y], 10*x+y), [1, 2, 3], [4, 5, 6]);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f : lambda([x], x+10);
g : lambda([ab], 10*ab[1]+ab[2]);
f([3,4]);
map(f, [[1,2],[3,4],[5,6]]);  /* [[11, 12], [13, 14], [15, 16]] */
map(g, [[1,2],[3,4],[5,6]]);  /* [12, 34, 56] */
map(f, [[1,2],[3,4],5]);      /* [[11, 12], [13, 14], 15] */
map(g, [[1,2],[3,4],5]);      /* error */
listarith : false;
map(f, [[1,2],[3,4],[5,6]]);  /* [[1,2]+10, [3,4]+10, [5,6]+10] */
map(g, [[1,2],[3,4],[5,6]]);  /* [12, 34, 56] */
map(f, [[1,2],[3,4],5]);      /* [[1,2]+10, [3,4]+10, 15] */
map(g, [[1,2],[3,4],5]);      /* error */


map sometimes recurses on trees, not on lists:

It tries to do the right thing and it usually does, but there are some
cases in which its dtrt-iness is not what I expected... so I thought
that it would be nice to also have some functions with a simpler
logic.





#####
#
# Implementing a mapconcat in Maxima
# 2023oct19
#
#####

# «mapconcat»    (to ".mapconcat")
# «intercalate»  (to ".intercalate")
# (find-angg    ".maxima/maxima-init.mac" "mapconcat")
# (find-fline "~/.maxima/maxima-init.mac" "mapconcat(f,a,sep)")
# (find-es "lean" "intercalate")
# (find-maximanode "makelist")
# (find-maximanode "map")
# (find-elnode "Mapping Functions" "mapconcat")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
intercalate(sep, strs) :=
  block([strs2, rest],
         strs2: makelist(concat(sep,strs[i]), i,2,length(strs)),
         rest:  apply('concat, strs2),
         concat(strs[1], rest))$
mapconcat(f,a,sep) := intercalate(sep, map(f,a))$

intercalate(",", ["a", "b", "c"]);
intercalate(",", []);                /* err */
mapconcat(tex1, [x/y, z*w], " & ");



** Old version:
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
concat_with_sep(a, sep) := concat(a[1],
  apply('concat, makelist(concat(sep,a[i]), i, 2,length(a))))$
mapconcat(f,a,sep) := concat_with_sep(makelist(f(x),x,a), sep);

a : [10, 20, 30, 40];
concat_with_sep(a, "_");
b : [x/y, z*w];
makelist(tex1(x), x, b);
mapconcat('tex1, b, " & ");




#####
#
# matrix
# 2023may07
#
#####

# «matrix»  (to ".matrix")
# «dot»     (to ".dot")
# (find-maximanode "matrix")
# (find-maximanode "dot")
# (find-maximanode "dot0nscsimp")
# (find-maximanode "dot0simp")
# (find-maximanode "dot1simp")
# (find-maximanode "dotassoc")
# (find-maximanode "dotconstrules")
# (find-maximanode "dotdistrib")
# (find-maximanode "dotexptsimp")
# (find-maximanode "dotident")
# (find-maximanode "dotscrules")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
? .

A : matrix ([a, b], [c, d]);
?print(A)$
v : matrix ([x], [y]);
[A, v, A.v];
v.A;         /* err */

A : matrix ([0, 1], [0, 0]);
B : matrix ([0, 0], [1, 0]);
[A, B, A.B, B.A];

A : matrix ([a, b]);
B : matrix ([c], [d]);
[A, B, A.B, B.A];

L : matrix ([a, 0], [b, c]);
U : matrix ([d, e], [0, f]);
[L, U, L.U, U.L];

A : matrix ([a, b], [c, d]);
B : matrix ([x, y], [z, w]);
[A, B, A.B, A*B];

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-anchor "~/lisptree/lisptree.mac")
load           ("~/lisptree/lisptree.mac");
o : matrix([2,3],[4,5]);
format0(o);
to_lisp();
  (symbol-plist '$matrix)
  (to-maxima)




#####
#
# matrix_size
# 2023may28
#
#####

# «matrix_size»   (to ".matrix_size")
# «vectortolist»  (to ".vectortolist")
# (find-es "maxima" "linsolve")
# (find-maximanode "matrix_size")
# (find-maximanode "lu_factor")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
matrix_height(v) := matrix_size(v)[1];
matrix_width (v) := matrix_size(v)[2];
vectortolist (v) := makelist(v[i][1], i, 1, matrix_height(v));
A    : matrix([2, 1, -5], [-3, 4, 1], [4, 13, -23]);
determinant(A);
xyz  : [x, y, z];
v    : [1, -2, 1];
eqs1 : A . xyz = v;
eqs2 : A . xyz - v;
eqs3 : vectortolist(eqs2);
linsolve (eqs3, [x, y, z]);

matrix_size(eqs2);
matrix_size(eqs2)[1];
matrix_size(A);
matrix_size(eqs2);
op(eqs2);
eqs2[1];
eqs2[1][1];
args(eqs2);
linsolve (A . xyz - v, [x, y, z]);




#####
#
# nouns-and-verbs
# 2023dec04
#
#####

# «nouns-and-verbs»  (to ".nouns-and-verbs")
# (find-maximanode "Nouns and Verbs")
# (find-maximanode "Nouns and Verbs" "noundisp")
# (find-maximanode "verbify")
# (find-maximanode "nounify")
# (find-maximanode "nouns")
# (find-maximanode "noun")
# (find-maximamsg "37747201 202212 11" "Edrx: Why is op('diff(f, x)) equal to 'derivative?")
# (find-maximamsg "37747216 202212 11" "RFateman: ?print(diff(f(x),x))")
# (find-maximamsg "37747238 202212 11" "Edrx: funmake('diff, [f, x])")
# (find-maximamsg "37747282 202212 11" "Stavros: op( '( diff(f(x),x) ) ) is the verb form")
# (to "changevar")
# (to "depends-email")
# (find-angg "MAXIMA/showexpression1.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
foo (x) := x^2;
foo (42);
'foo (42);
'foo (42), nouns;
declare (bar, noun);
bar (x) := x/17;
bar (52);
bar (52), nouns;
integrate (1/x, x, 1, 42);
'integrate (1/x, x, 1, 42);
ev (%, nouns);

nounify('diff);
verbify('derivative);

noundisp : true;
bar (52);
bar (52), nouns;

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
verbify('diff);          /* diff       */
verbify('derivative);    /* diff       */
nounify('diff);          /* derivative */
nounify('derivative);    /* derivative */




#####
#
# verbify-bug
# 2024oct29
#
#####

# «verbify-bug»  (to ".verbify-bug")
# (find-maximamsg "58835424 202410 29" "Edrx: The result of verbify(nounify(foo)) changes!")
# (find-maximamsg "58835438 202410 29" "Stavros: it adds verb/noun properties both ways")
# https://sourceforge.net/p/maxima/bugs/4397/

Hi list,

I was trying to fix a bug in how LispTree handles nouns and verbs and
I think that I found a bug in verbify... try this, and look at what
happens when we run low(f5(foo)) again after running low(f5(?foo)):

  format([args]) := apply(?format, append([false], args));
  low(o) := format("~s",o);
  v(o) := verbify(o);
  n(o) := nounify(o);
  f5(o) := [n(v(o)), v(o), o, n(o), v(n(o))];
  low(f5(foo));   /* ((MLIST SIMP) %FOO $FOO $FOO %FOO $FOO) */
  low(f5(?foo));  /* ((MLIST SIMP) %FOO  FOO  FOO %FOO  FOO) */
  low(f5(foo));   /* ((MLIST SIMP) %FOO $FOO $FOO %FOO  FOO) */

The result of verbify(nounify(foo)) changes!

  Cheers =/,
    Eduardo Ochs
    http://anggtwu.net/eev-maxima.html
    http://anggtwu.net/lisptree.html





#####
#
# special nouns and specialnounp
# 2024oct28
#
#####

# «special-nouns»  (to ".special-nouns")
# (find-lisptree "lisptree.mac" "atoms-test")
# (find-maxima-links "verbify")
# (find-maxima-links "nounify")
# (to "mktable")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
maxima --no-init
/usr/bin/maxima --userdir=/tmp
format([args]) := apply(?format, append([false], args));
low(o) := format("~s",o);
v(o) := verbify(o);
n(o) := nounify(o);
f5(o) := [n(v(o)), v(o), o, n(o), v(n(o))];
low(f5(foo));   /* ((MLIST SIMP) %FOO $FOO $FOO %FOO $FOO) */
low(f5(?foo));  /* ((MLIST SIMP) %FOO  FOO  FOO %FOO  FOO) */
low(f5(foo));   /* ((MLIST SIMP) %FOO $FOO $FOO %FOO  FOO) */




properties(foo);
properties(?foo);
properties(verbify('foo));
properties(nounify('foo));



** (find-anchor "~/lisptree/lisptree.mac")
load           ("~/lisptree/lisptree.mac");
_qfoo      : op('foo(42));
_qdiff     : op('diff(y,x));
mysymbols  : [?foo, foo, _qfoo, diff, _qdiff];
lsymbol(n) := parse_string(concat("lisptree0_symbol", n));
lsyline(n) := map(lsymbol(n),mysymbols);
lsylines   :  matrix(lsyline(0), lsyline(1), lsyline(3), lsyline(4));

linel : 110;
l(o) := format0(o);
v(o) := verbify(o);
n(o) := nounify(o);

v("bar");



propline(o) := [low(o), verbp(o), nounp(o), specialnounp(o)];
propline(o) := [l(n(v(o))), l(v(o)), l(o), l(n(o)), l(v(n(o)))];
propline(o) := [l(o), string(o), concat("",o)];
topline     : rhs(fundef(propline));
otherlines  : map('propline, mysymbols);
proplines   : apply('matrix, append([topline],otherlines));


f5(o) := [n(v(o)), v(o), o, n(o), v(n(o))];
l(f5(foo));
l(f5(?foo));
l(f5(_qfoo));

l(f5(fooo));




#####
#
# noundisp
# 2024oct23
#
#####

# «noundisp»  (to ".noundisp")
# (find-maximanode "noundisp")
# (find-maximanode "quote")
# (find-maximanode "quote" "'bfloat(%pi)")
# (find-maximagitfile "src/displa.lisp" "(defmvar $noundisp ")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(o) :=  diff(o,x);
g(o) := 'diff(o,x);
f(x^2);
g(x^2);
                  'bfloat(x);   /*  bfloat(x) */
noundisp:true$    'bfloat(x);   /* 'bfloat(x) */
noundisp:false$   'bfloat(x);   /*  bfloat(x) */

                  'f(x^2);      /*  f(x^2) */
noundisp:true$    'f(x^2);      /* 'f(x^2) */
noundisp:false$   'f(x^2);      /*  f(x^2) */




#####
#
# op-and-args
# 2022jul09
#
#####

# «op-and-args»  (to ".op-and-args")
# (find-angg ".maxima/maxima-init.mac" "traverse")
# (find-angg "MAXIMA/traverse.mac")
# (find-es "sympy" "func-and-args")
# (find-maximanode "Introduction to Lists")
# (find-maximanode "Operators for Equations" "right-hand and left-hand sides")
# (find-maximanode "Introduction to operators")
# (find-maximanode "Arithmetic operators")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a : b = c;
a;
lhs(a);
op(a);
args(a);
args(a)[1];
args(a)[2];
       integrate(x, x);
foo : 'integrate(x, x);
op(foo);
args(foo);
? lhs

# Question: foo(a, 2, 4, 1, 3) -> bar(bar(bar(bar(a, 2), 4), 1), 3)?
# (find-maximamsg "37678799 202207 09" "Edrx")
# (find-maximamsg "37678795 202207 09" "Barton: lreduce")
# (find-maximamsg "37678764 202207 09" "MTalon: foo(a, b, c, d, e)::=")
# (find-maximamsg "37678799 202207 09" "Edrx: I need a little more help *")
# (find-maximamsg "37678838 202207 09" "Stavros: you need =")
# (find-maximamsg "37678839 202207 09" "Edrx: perfect! ...transcript:")
# (find-maximamsg "37678963 202207 10" "Stavros: quote literal constants")
# (find-maximamsg "37679359 202207 11" "MTalon: swank ***")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
foo1 : lambda([a, b], 10*a + b);
xreduce(foo1, [2, 3, 4, 5]);
xreduce(foo1, [2, 3, 4, 5], 9);
foo(a, [b]) := xreduce(foo1, b, a);
foo(9, 2, 3, 4, 5);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
foo1 : lambda([o, action],
  if     action = 'op   then op(o)
  elseif action = 'args then args(o)
  else   args(o)[action]);
foo(a, [b]) := xreduce(foo1, b, a);
ex1 : a+b*c;
foo(ex1);
foo(ex1, op);
foo(ex1, args);
foo(ex1, 1);
foo(ex1, 1, op);
foo(ex1, 1, args);
foo(ex1, 1, 1);
foo(ex1, 1, 2);
foo(ex1, 2);




#####
#
# operators
# 2022aug18
#
#####

# «operators»  (to ".operators")
# (to "texput")
# (find-maximanode "Introduction to operators")
# (find-maximanode "Introduction to operators" "Operator   lbp     rbp")
#      ^        140     139
#      -        100     134
# (find-maximawbpage (+ 20 71) "10.1     Defining and using operators")
# (find-maximawbtext (+ 20 71) "10.1     Defining and using operators")
# (find-maximanode "infix")
# (find-maximanode "matchfix")
# (find-maximanode "nary")
# (find-maximanode "nofix")
# (find-maximanode "postfix")
# (find-maximanode "prefix")
# (find-maximanode "dispfun")
# (find-maximanode "sconcat")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)

:lisp (get '$+ 'lbp)
:lisp (get '$+ 'rbp)
infix ("##", 101, 101);
"##"(a, b) := sconcat("(", a, "##", b, ")");
1 + a ## b + 2;
infix ("##", 99, 99);
1 + a ## b + 2;

infix ("##", 100, 99);
"##"(a, b) := sconcat("(", a, "##", b, ")")$
foo ## bar ## baz;
infix ("##", 100, 101);
foo ## bar ## baz;

infix ("##", 100, 99, expr, expr, expr);
if x ## y then 1 else 0;
infix ("##", 100, 99, expr, expr, clause);
if x ## y then 1 else 0;

matchfix ("@@", "~");
@@ a, b, c ~;
matchfix (">>", "<<");
>> a, b, c <<;
matchfix ("foo", "oof");
foo a, b, c oof;
>> w + foo x, y oof + z << / @@ p, q ~;

matchfix ("!-", "-!");
!- x, y -! := x/y - y/x;
define (!-x, y-!, x/y - y/x);
define ("!-" (x, y), x/y - y/x);
dispfun ("!-");
!-3, 5-!;
"!-" (3, 5);




#####
#
# Implementing (a+b)[a:=42] as (a+b)_s_[a=42]
# 2024aug30
#
#####

# «operator-subst»  (to ".operator-subst")
# (find-angg "MAXIMA/mysubst2.mac")
# (c2m242introp 6 "manga")
# (c2m242introa   "manga")
# (patp 10 "substituicao")
# (pata    "substituicao")
# (c2m241exsubstp 3 "funcoes")
# (c2m241exsubsta   "funcoes")
# (find-maximanode "subst")
# (find-maximanode "psubst")
# (find-maximanode "sublis")
# (find-maximanode "sublis" "atom")
# (to "mysubst")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
Aipim : sqrt(a^2+b^2) = a+b;
S1 : [a=3];
S2 : [b=4];
S3 : [a=3,b=4];
          Aipim;
subst(S1, Aipim);
subst(S2, Aipim);
subst(S3, Aipim);

"_s_"(expr,su) := subst(su, expr)$
infix("_s_",99,101)$

Aipim;
Aipim _s_ S1;
Aipim _s_ S1 _s_ S2;

5=7;
is(5=7);

LSUBST (eqs) := map('LBSUBST1,eqs)$
LSUBST1(eq)  := if is(op(eq) = ":=") then
  block([fxy,f,xy,r],
    fxy:lhs(eq), f:op(fxy), xy:args(fxy), r:rhs(eq),
    buildq([fxy,f,xy,r], f=lambda(xy,r)))
  else eq$




#####
#
# opsubst
# 2024oct30
#
#####

# «opsubst»  (to ".opsubst")
# (find-maximanode "Functions and Variables for opsubst")
# (find-maximanode "Functions and Variables for Expressions" "opsubst")
# (find-maxima-links "opsubst")
# (find-maximagitfile "share/contrib/opsubst.lisp")
# (to "setup_autoload")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load ("opsubst")$
opsubst(f,g,g(g(x)));
opsubst(f,g,g(g));
opsubst(f,g[x],g[x](z));
opsubst(g[x],f, f(z));
opsubst(tan, sin, sin(sin));
opsubst([f=g,g=h],f(x));
opsubst("+","-",a-b);
opsubst("f","-",-a);
opsubst("^^","/",a/b);
opsubst("[","*", -a*b);
opsubst(a+b,f, f(x));
opsubst(g[5],f, f(x));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
opsubst([f=g,g=h],f(x));
setup_autoload("opsubst", opsubst);
opsubst([f=g,g=h],f(x));

fundef('opsubst);





#####
#
# Implementing optional arguments with if is(length(args)=...)
# 2024aug28
#
#####

# «opt-args»  (to ".opt-args")
# (find-angg ".maxima/maxima-init.mac" "seq")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* seq(a,b)     := makelist(i, i,a,b); */
seqby1(a,b)     := makelist(i, i,a,b);
seqby (a,b,stp) := makelist(i, i,a,b,stp);
seqn  (a,b,n)   := makelist(a + (b-a)*k/n, k,0,n);
seq   ([args])  := if is(length(args)=2)
                   then apply('seqby1,args)
                   else apply('seqby, args)$
seq(2,4);
seq(2,4,1/3);




#####
#
# part
# 2024nov07
#
#####

# «part»  (to ".part")
# (find-maximanode "part")
# (find-angg ".maxima/maxima-init.mac" "traverse")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
part(z+2*y+a, 2);
part(z+2*y+a, [1,3]);
part(z+2*y+a, 2,1);




#####
#
# piecewise
# 2024nov27
#
#####

# «piecewise»  (to ".piecewise")
# (find-maximamsg "58846487 202411 27" "Edrx: Integrating piecewise defined functions")
# (find-maximamsg "58846534 202411 28" "Edrx: quad_qagi error")
# (find-maximamsg "58846603 202411 28" "JVillate: Laplace transforms")
# (find-maximamsg "58846678 202411 28" "Edrx: I was expecting h(x)=0 for x<=0")
# (find-maximamsg "58846686 202411 28" "BWillis: calculations by hand")
# (find-maximamsg "58846689 202411 28" "TDean: pwilt not found")
# (find-maximamsg "58846725 202411 28" "AZorine: There was a PW package")
# (find-maximamsg "58846736 202411 28" "JVillate: it is a bug in pwilt")
# (find-maximamsg "58846741 202411 28" "JVillate: Maxima does not define hstep")
# (find-maximamsg "58846795 202411 28" "RFateman: Integrating, Plotting")
# (find-maximamsg "58846802 202411 28" "RDodier: quad_qagi needs to be postponed")
# (find-maximamsg "58846805 202411 28" "ElObs: mext/tree/master/packages/pw")
# (find-maximamsg "58846868 202411 28" "BWillis: load(abs_integrate)")

# (find-maximanode "hstep")
# (find-maximanode "unit_step")
# (to "quad_qagi")
# (to "quad_qag")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-myqdraw "myqdraw3.mac")
load_myqdraw();
[xmin,ymin, xmax,ymax] : [-4,-4, 4,4];

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)


Hi list,

I tried to replace the `integrate' of my last question with a variant
that calls `quad_qagi':

  integrate_qagi(f,x,a,b) := quad_qagi(f,x,a,b)[1]$
  
  f(x) := if     x<0 then 0
          elseif x<1 then 1
          else            0;
  g(x) := if     x<0 then 0
          elseif x<1 then x
          else            0;
  h(x) := integrate_qagi(f(t)*g(x-t), t, minf, inf);
  
  draw2d(xrange=[-4,4],
         yrange=[-4,4],
         proportional_axes=xy,
         explicit('h(w),w,-4,4));

Now calculating h(x) at specific points works:

  h(0.0042906454260024365);
  h(0.5);
  h(0.1);
  h(-1);
  h(-2);
  h(-3);

but the draw2d above fails with this error...

  quad_qagi: Numerical evaluation of (if t < 0 then 0 elseif t < 1 then 1 else 0)
   (if w - t < 0 then 0 elseif w - t < 1 then w - t else 0) at 
  0.0042906454260024365 is not a float or is not defined

Is that a bug?
Thanks in advance!
  Eduardo Ochs







integrate_qag (f,x,a,b) := quad_qag (f,x,a,b, 2)[1]$


quad_qagi: Numerical evaluation of (if t < 0 then 0 elseif t < 1 then 1 else 0)
 (if w - t < 0 then 0 elseif w - t < 1 then w - t else 0) at 
0.0042906454260024365 is not a float or is not defined




draw2d(xrange=[-4,4],
       yrange=[-4,4],
       proportional_axes=xy,
       explicit(w^2,w,-4,4));



Hi list,

what is the recommended way to integrate piecewise defined
functions? I tried this,

  f(x) := if     x<0 then 0
          elseif x<1 then 1
          else            0;
  g(x) := if     x<0 then 0
          elseif x<1 then x
          else            0;
  h(x) := integrate(f(t)*g(x-t), t, -2, +2);

and I couldn't find a way to make Maxima calculate this
integral...

        integrate(f(x), x, -2, 4);
  float(integrate(f(x), x, -2, 4));

The convolution left Maxima even more confused, obviously...
Thanks in advance!
  Eduardo Ochs





#####
#
# printf
# 2024apr07
#
#####

# «printf»  (to ".printf")
# (find-maximanode "printf")
# (find-maxima-links "printf")
# (find-maximanode "Introduction to String Processing")
# (find-maximagitsh "find * | sort")
# (find-maximagitfile "share/stringproc/")
# (find-maximagitfile "share/stringproc/stringproc.mac")
# (find-maximagitfile "share/stringproc/printf.lisp")
# (to "format")
# (to "autoload")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
printf(false, "foo bar");
printf(false, "foo bar");
printf(false, "~a", "foo bar");
printf(false, "~m", "foo bar");
printf(false, "~s", "foo bar");
printf(false, "~s", 123);



#####
#
# properties
# 2024oct04
#
#####

# «properties»  (to ".properties")
# (find-maximanode "Functions and Variables for Properties")
# (find-maximanode "qput")
# (find-maximanode "put")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
properties(sin);
properties(%pi);
properties(foo);
properties(?foo);
properties("foo");



#####
#
# quad_qagi
# 2024nov27
#
#####

# «quad_qagi»  (to ".quad_qagi")
# (find-maximanode "quad_qag")
# (find-maximanode "quad_qags")
# (find-maximanode "quad_qagi")
# (to "piecewise")
# (to "erf")
# (to "quad_qag")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
quad_qagi (x^2*exp(-4*x), x, 0, inf, 'epsrel=1d-8);
quad_qagi (x^2*exp(-4*x), x, 0, inf, 'epsrel=1d-8)[1];
quad_qagi (x^2*exp(-4*x), x, 0, inf)[1];
quad_qagi (x^2*exp(-4*x), x, 0, inf);
integrate (x^2*exp(-4*x), x, 0, inf);



f(x) := if     x<0 then 0
        elseif x<1 then 1
        else            0;
g(x) := if     x<0 then 0
        elseif x<1 then x
        else            0;
                       integrate(f(x), x, minf, inf);
                  args(integrate(f(x), x, minf, inf));
apply('quad_qagi, args(integrate(f(x), x, minf, inf)));
apply('quad_qagi, args(integrate(f(x), x, minf, inf)))[1];
quad_qagi(f(x), x, minf, inf);

integrate_qagi([args]) := apply('quad_qagi, args)[1]$
integrate     (f(x), x, minf, inf);
integrate_qagi(f(x), x, minf, inf);


** (find-myqdraw "myqdraw3.mac")
load_myqdraw();
[xmin,ymin, xmax,ymax] : [-4,-4, 4,4];
myqdraw(xyrange(), myex1(erf(x)));






#####
#
# runge-kutta
# 2023dec03
#
#####

# «runge-kutta»  (to ".runge-kutta")
# (find-maximamsg "58347826 202312 03" "JVillate")
# (find-maximamsg "58347743 202312 03" "KarenKharatian")
# (find-maximanode "rk")
# (find-maximanode "point_type")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
[sigma, rho, beta]: [10, 28, 8/3]$
eq: [sigma*(y-x), x*(rho-z)-y, x*y-beta*z]$
sol: rk(eq, [x, y, z], [1, 0, 0], [t, 0, 50, 1/100])$
len: length(sol)$
x: makelist(sol[k][2], k, len)$
y: makelist(sol[k][3], k, len)$
z: makelist(sol[k][4], k, len)$
draw3d(points_joined=true, point_type=-1, points(x, y, z), proportional_axes=xyz)$

sol;




#####
#
# simp
# 2022jul02
#
#####

# «simp»  (to ".simp")
# (to "dosimp-and-doeval")
# (find-maximanode "Introduction to Simplification")
# (find-maximanode "Introduction to Simplification" "1965")
# (find-maximanode "Functions and Variables for Simplification")
# (find-maximanode "simplification-pkg")
# (find-maximanode "ev")
# (find-maximanode "evfun")

# (find-maximanode "additive")
# (find-maximanode "antisymmetric")
# (find-maximanode "combine")
# (find-maximanode "commutative")
# (find-maximanode "demoivre")
# (find-maximanode "demoivre")
# (find-maximanode "distrib")
# (find-maximanode "distribute_over")
# (find-maximanode "domain")
# (find-maximanode "evenfun")
# (find-maximanode "oddfun")
# (find-maximanode "expand")
# (find-maximanode "expandwrt")
# (find-maximanode "expandwrt_denom")
# (find-maximanode "expandwrt_factored")
# (find-maximanode "expon")
# (find-maximanode "exponentialize")
# (find-maximanode "expop")
# (find-maximanode "lassociative")
# (find-maximanode "linear")
# (find-maximanode "maxnegex")
# (find-maximanode "maxposex")
# (find-maximanode "multiplicative")
# (find-maximanode "multthru")
# (find-maximanode "nary")
# (find-maximanode "negdistrib")
# (find-maximanode "opproperties")
# (find-maximanode "define_opproperty")
# (find-maximanode "outative")
# (find-maximanode "radcan")
# (find-maximanode "radexpand")
# (find-maximanode "rassociative")
# (find-maximanode "scsimp")
# (find-maximanode "simp")
# (find-maximanode "symmetric")
# (find-maximanode "xthru")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
ex0 : s * sqrt(1 - s^2);



#####
#
# solve
# 2022jan11
#
#####

# «solve»  (to ".solve")
# (find-maximaindex-links "solve")
# (find-maximaindex "solve" :RET)
# (find-maximanode "solve")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
solve (asin (cos (3*x))*(f(x) - 1), x);
ev (solve (5^f(x) = 125, f(x)), solveradcan);
[4*x^2 - y^2 = 12, x*y - x = 2];
solve (%, [x, y]);
solve (1 + a*x + x^3, x);
solve (x^3 - 1);
solve (x^6 - 1);
ev (x^6 - 1, %[1]);
expand (%);
x^2 - 1;
solve (%, x);
ev (%th(2), %[1]);
solve([x+y=1,2*x+2*y=2],[x,y]);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
? solve
**
f    :  x^-2;
f(x) := x^-2;
F    :  integrate(f, x);
F(x) := -1/x;
F(1) - F(-1);
**
solve(f-4, x);
solve(f-4, x)[1];
solve(f-4, x)[2];
solve(f+4, x);
solve(F-4, x);
solve(F+4, x);
solve(u^3=v^5, u);
solve(u=4, u);
** Doesn't work:
solve([u=v, v=4], u);



#####
#
# string
# 2024oct22
#
#####

# «string»  (to ".string")
# (find-maximanode "string")
# (find-maximanode "stringp")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)


#####
#
# stringdisp
# 2024nov03
#
#####

# «stringdisp»  (to ".stringdisp")
# (find-maximanode "stringdisp")
# (find-maximanode "stringdisp" "double quote marks")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
M : matrix([a, "=", b], ["", "=", d]);
stringdisp : true;  M;
stringdisp : false; M;

load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp")$
:lisp (setf (get '$display2d 'assign) nil)
display2d:'emaxima$
stringdisp : true;  M;
stringdisp : false; M;

load("~/MAXIMA/barematrix1.mac")$
stringdisp : true;  M;
stringdisp : false; M;

load("~/myqdraw/myqdraw-tex.lisp")$
ig(name) := includegraphics("height=1cm", name)$
M1 : matrix([a, "=", b], ["", "=", d]);
M2 : matrix([ig(a), "=", ig(b)], ["", "=", ig(d)]);






#####
#
# stringp
# 2024oct23
#
#####

# «stringp»  (to ".stringp")
# (find-maximanode "stringp")
# (find-maxima-links "stringp")
# (find-maximagitfile "share/stringproc/")
# (find-maximagitfile "share/stringproc/stringproc.lisp" "(defun $stringp ")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
?stringp("2");
?stringp(2);
:lisp (describe '$stringp)
stringp("2");
stringp(2);
:lisp (describe '$stringp)

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* define: warning: redefining the built-in function stringp */
stringp(o) := ?stringp(o);
?stringp("2");
?stringp(2);
stringp("2");
stringp(2);




#####
#
# strings
# 2022jul28
#
#####

# «strings»  (to ".strings")
# (find-maximanode "Introduction to Strings")
# (find-maximanode "Functions and Variables for Strings")
# (find-maximanode "atom")
# (find-maximanode "numberp")
# (find-maximanode "map")
# (find-maximanode "concat")
# (find-maximanode "string")
# (find-maximanode "stringp")
# (find-maximanode "printf")
# (find-maximanode "format")
# (find-maximanode "stringdisp")
# (find-maximanode "stringdisp" "double quote marks")




#####
#
# subst
# 2023apr14
#
#####

# «subst»  (to ".subst")
# (find-maximanode "subst")
# (find-maximanode "sublis")
# (find-maximanode "sublis_apply_lambda")
# (find-maximanode "psubst")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
subst (a, x+y, x + (x+y)^2 + y);
subst (-%i, %i, a + b*%i);
subst ([a=b, b=c], a+b);
sublis([a=b, b=c], a+b);
subst(["+"="-"],a+b-c);
g1:y(t)=a*x(t)+b*diff(x(t),t);
subst('diff(x(t),t)=1,g1);
at(g1,'diff(x(t),t)=1);

psubst([a^2=b,b=a], sin(a^2)+sin(b));   /* sin(b)  + sin(a) */
subst ([a^2=b,b=a], sin(a^2)+sin(b));   /* 2 sin(a) */
sublis([a=b,b=c,c=a], sin(a)+cos(b)+tan(c));

example (subst);



#####
#
# subst-lambda
# 2024nov08
#
#####

# «subst-lambda»  (to ".subst-lambda")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-anchor "~/lisptree/lisptree.mac")
load           ("~/lisptree/lisptree.mac");

             o:lambda([],(a+b)/c);
            o2:subst([a=2,b=3,c=4],o);
simp:false; o3:subst([a=2,b=3,c=4],o); simp:true;
lisptreeq(''o);
lisptreeq(''o2);
lisptreeq(''o3);

o;
o2;
o3;




#####
#
# subvarp
# 2024oct17
#
#####

# «subvarp»  (to ".subvarp")
# (to "mtree")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
o : a(b)(c);
traverse(o);
traverse(o, args);
traverse(o, op, op);





#####
#
# symbolp
# 2024oct22
#
#####

# «symbolp»  (to ".symbolp")
# (find-maximanode "symbolp")
# (to "atom")



#####
#
# symbols
# 2021dec10
#
#####

# «symbols»  (to ".symbols")
# (find-maximanode "Identifiers")
# (find-maximanode "symbolp")
# (find-maximanode "stringp")
# (find-es "sympy" "tut-symbols")
# (find-maximagitfile "share/stringproc/stringproc.lisp")
# (find-maximagitfile "share/stringproc/stringproc.lisp" "(defun $stringp (obj) (stringp obj))")
# (to "foo-and-foo")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
%an_ordinary_identifier42;
embedded\ spaces\ in\ an\ identifier;
symbolp (%);
[foo+bar, foo\+bar];
[1729, \1729];
[symbolp (foo\+bar), symbolp (\1729)];
[is (foo\+bar = foo+bar), is (\1729 = 1729)];
baz\~quux;
declare ("~", alphabetic);
baz~quux;
[is (foo = FOO), is (FOO = Foo), is (Foo = foo)];
:lisp (defvar *my-lisp-variable* '$foo)
?\*my\-lisp\-variable\*;

o : ?format;
string(o);
string('o);
symbolp(o);
symbolp(x);
symbolp("x");
stringp(x);
stringp("x");

** (find-maxima-links "stringp")
properties(stringp);
:lisp (describe '$stringp)
:lisp (symbol-plist '$stringp)
:lisp (get '$stringp 'lineinfo)




#####
#
# to_lisp
# 2021dec24
#
#####

# «to_lisp»  (to ".to_lisp")
# (to "part-and-inpart")
# (find-maximanode "Lisp and Maxima")
# (find-maximanode "Lisp and Maxima" "to_lisp")
# (find-maximanode "Lisp and Maxima" "mfuncall")
# (find-maximanode "Lisp and Maxima" "`#$<expr>$'")
# (find-maximanode "Function")
# (find-maximanode "Macros" "'splice (<x>)'")

* (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 #$foo$
:lisp (mfuncall '$foo 'a 'b)
:lisp (number-sequence 0 7)

# (find-node "(sbcl)Top")
# (find-node "(ansicl)Top")
# (find-node "(ansicl)Backquote")
# (find-es "lisp" "dpans2texi")
# (find-elnode "Building Lists" "Function: number-sequence")




#####
#
# translated
# 2024aug17
#
#####

# «translated»  (to ".translated")
# (to "translate")
# (find-maximamsg "58807303 202408 17" "Edrx: TRANSLATED -> T")
# (find-maximamsg "58807309 202408 17" "Stavros: unlike a genuine translated function")
# (find-maximamsg "58807327 202408 18" "RToy: Add the TRANLATED property")

Thanks!!!
A quick question...
The source of taylorp in simp.lisp is very clear:

  (defmfun $taylorp (x)
    (and (not (atom x))
         (eq (caar x) 'mrat)
         (member 'trunc (cdar x)) t))

but

  :lisp (describe '$taylorp)

says "Symbol-plist: ... TRANSLATED -> T ...".

What does the "translated" mean in this case? I took a quick look at
all the occurences of "translate" in the info manual and I got the
impression that translated functions come from Maxima functions, but I
grepped the sources and I didn't find a possible Maxima source for
this $taylorp...

  Cheers, TIA, etc,
    Eduardo




#####
#
# varargs
# 2023sep19
#
#####

# «varargs»  (to ".varargs")
# (find-maximanode ":=")
# (find-maximanode ":=" "When the last or only function argument")
# (find-maximanode "::=")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
foo(a,b,[c]) ::= [a,b,c];
bar(a,b,[c]) :=  [a,b,c];
foo(2,3,4,5);
bar(2,3,4,5);
lambda([a,b,[c]], [a,b,c]) (2,3,4,5);






#####
#
# MpgP17
# 2024oct04
#
#####

# «MpgP17»  (to ".MpgP17")
# (mpgp 17 "intersecoes-de-retas")
# (mpga    "intersecoes-de-retas")
# http://anggtwu.net/LATEX/material-para-GA.pdf#page=17
# (to "maplist")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
vv([args]) := transpose(matrix(args));
vv(2,3,4);
maplist('vv, [1,2,3], [10,20,30], [100,200,300]);
maplist("=", [1,2,3], [10,20,30]);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
P(t) := [3,3] + t*[2,-1];
Q(u) := [4,1] + u*[-1,1];
eq1  : P(t)=Q(u);
eq2  : makelist(P(t)[i]=Q(u)[i], i,1,2);
eq3  : maplist("=", P(t), Q(u));
     solve(eq1, [t,u]);
     solve(eq2, [t,u]);
tu : solve(eq3, [t,u]);
subst(tu, [P(t),Q(u)]);




#####
#
# MpgP18: sistemas de coordenadas
# 2024aug31
#
#####

# «MpgP18»  (to ".MpgP18")
# (mpgp 18 "sistemas-de-coordenadas")
# (mpga    "sistemas-de-coordenadas")
# http://anggtwu.net/LATEX/material-para-GA.pdf#page=18
# (to "qdraw-pts")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/zpts1.mac")
** (find-angg "MAXIMA/myqdraw1.mac")
load       ("~/MAXIMA/myqdraw1.mac");
** (find-angg "MAXIMA/mycolorlerp1.lisp")
load       ("~/MAXIMA/mycolorlerp1.lisp");
Sigma(a,b) := O + a*uu + b*vv;
[O,uu,vv]  : [[2,3],[2,1],[0,-1]];
[O,uu,vv]  : [[1,2],[1,1],[2,0]];
Sigma      : [O,uu,vv];
[O,uu,vv]  : Sigma;
moveqin(veqw) := maplist("=", lhs(veqw), rhs(veqw));
eqs           : [x,y] = Sigma(a,b);
eqs2          : moveqin(eqs);
defsforxy     : solve(eqs2, [x,y]);
defsforab     : solve(eqs2, [a,b]);
define(x(a,b), subst(defsforxy, x));
define(y(a,b), subst(defsforxy, y));
define(a(x,y), subst(defsforab, a));
define(b(x,y), subst(defsforab, b));

[xmin,xmax,ymin,ymax] : [-2,6,-2,6];
myimp1(expr,[opts]) := myapply('imp1, expr,x,xmin,xmax,y,ymin,ymax, opts);
mylevel(expr,label,color,[opts]) := myimp1(expr, lk(label), lc(color), [mylevel_opts(), opts]);
mylevel_opts() := [lw(2), line_type=short_long_dashes];
mylevel_opts() := [lw(2)];

xryr()   := [xr(xmin,xmax), yr(ymin,ymax), more(proportional_axes=xy)];
Ouuvv()  := [pts   (O,     ps(2), pc(blue)),
             vector(O, uu, hl(0.1), lw(2), lc(purple),      lk("uu")),
             vector(O, vv, hl(0.1), lw(2), lw(3), lc(blue), lk("vu"))
            ];
gridab() := [mylevel(a(x,y)=1,  "a=1",  orange),
             mylevel(a(x,y)=0,  "a=0",  orange),
             mylevel(a(x,y)=-1, "a=-1", orange),
             mylevel(b(x,y)=1,  "b=1",  yellow),
             mylevel(b(x,y)=0,  "b=0",  yellow),
             mylevel(b(x,y)=-1, "b=-1", yellow),
             mylevel(a(x,y)^2+b(x,y)^2=1, "z=1", brown)
            ];
myqdraw(xryr(), gridab(), Ouuvv());




#####
#
# rootscontract
# 2024aug20
#
#####

# «rootscontract»  (to ".rootscontract")
# (find-maximanode "rootscontract")
# (find-maximanode "rootsconmode")
# (to "changevar-trig-email")
# (to "changevar-trig")
# (find-maximawbpage (+ 19 117) "rootscontract (expr)")
# (find-maximawbtext (+ 19 117) "rootscontract (expr)")
# (find-books "__comp/__comp.el" "maxima-workbook" "116" "rootscontract (expr)")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
rootsconmode: false$
rootscontract (x^(1/2)*y^(3/2));
rootscontract (x^(1/2)*y^(1/4));
rootsconmode: true$
rootscontract (x^(1/2)*y^(1/4));
rootscontract (x^(1/2)*y^(1/3));
rootsconmode: all$
rootscontract (x^(1/2)*y^(1/4));
rootscontract (x^(1/2)*y^(1/3));
rootsconmode: false$
rootscontract (sqrt(sqrt(x) + sqrt(1 + x))
              *sqrt(sqrt(1 + x) - sqrt(x)));
rootsconmode: true$
rootscontract (sqrt(5 + sqrt(5)) - 5^(1/4)*sqrt(1 + sqrt(5)));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
F : 'integrate(sqrt(4-9*x^2), x);
changevar(F, u=3*x, u, x);
rootsconmode: all$
changevar(F, u=3*x, u, x);
rootsconmode: true$
changevar(F, u=3*x, u, x);
rootsconmode: false$
changevar(F, u=3*x, u, x);




#####
#
# logcontract
# 2024aug21
#
#####

# «logcontract»  (to ".logcontract")
# (find-maximanode "logcontract")
# (find-maximanode "logexpand")
# (find-maximanode "evfun")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
2*(a*log(x) + 2*a*log(y))$
logcontract(%);

log(n^2), logexpand=true;
log(10*x), logexpand=all;
log(a/(n + 1)), logexpand=super;
my_product : product (X(i), i, 1, n);
log(my_product), logexpand=all;
log(my_product), logexpand=super;
logexpand : false $
log(n^2);
log(10*x);
log(a/(n + 1));
log('product (X(i), i, 1, n));




#####
#
# log
# 2024aug24
#
#####

# «log»  (to ".log")
# (find-maximanode "log")
# (find-maximanode "evflag")
# (find-maximanode "evflag" "logexpand")
# (to "2024-1-C2-P2" "Questão 4")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
e1 : exp(-2/3*log(x));
radcan(e1);




#####
#
# changevar
# 2022jun22
#
#####

# «changevar»  (to ".changevar")
# (find-maximanode "changevar")
# (find-maximanode "'")
# (find-maximanode "quote")
# (find-maximanode "quote-quote")
# (find-maximanode "display2d")
# (find-maximanode "ev")
# (find-maximanode "ev" "nouns")
# (find-maxima-links "changevar")
# (find-maximagitgrep "grep --color=auto -nH --null -e changevar $(cat .files.lisp)")
# (find-maximagitfile "src/outmis.lisp" "(defmfun $changevar")
# (find-maximagitfile "src/outmis.lisp" "(defun changevar")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
ex0 : 'integrate((3*cos(2 + sqrt(3*x+4))) / (2*sqrt(3*x+4)), x, a, b);
ex0 : 'integrate((3*cos(2 + sqrt(3*x+4))) / (2*sqrt(3*x+4)), x);
ex2 : changevar(ex0, u=3*x, u, x);
ex3 : changevar(ex2, v=u+4, v, u);
assume(w>0);
ex4 : changevar(ex3, w=sqrt(v), w, v);
ex5 : changevar(ex4, y=2+w, y, w);
ex5 ;
ex6 : ev(ex5, integrate);
ex6 : ev(ex5, nouns);
ex7  : subst([y=2+w],     ex6);
ex8  : subst([w=sqrt(v)], ex7);
ex9  : subst([v=u+4],     ex8);
ex10 : subst([u=3*x],    ex9);
ex1;
ex10 - ex1;

ex0 : 'integrate((3*cos(2 + sqrt(3*x+4))) / (2*sqrt(3*x+4)), x, a, b);
ex0 : 'integrate((3*cos(2 + sqrt(3*x+4))) / (2*sqrt(3*x+4)), x);
assume(0 < a);
assume(0 < b);
ev(ex0, integrate);

display2d : false;




#####
#
# A variant of changevar that takes only 2 arguments
# 2024apr19
#
#####

# «changevar2»  (to ".changevar2")
# (find-maximanode "ev" "nouns")
# (to "listofvars")
# (to "changevar-trig")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
freevar      (expr)     := listofvars(expr)[1];
changevar2   (expr, cv) := changevar(expr, cv, freevar(lhs(cv)), freevar(rhs(cv)));
changevarback(expr, cv) := subst(cv, expr);

/* A standard example: */
int0 : 'integrate(cos(x^3)*3*x^2, x);
cv01 : u=x^3;
int1 : changevar (int0, cv01, u, x);
int1 : changevar2(int0, cv01);
F1   : ev(int1, nouns);
F0   : changevarback(F1, cv01);




#####
#
# Hacking changevar2 to make it work with trig substs
# 2024apr19
#
#####

# «changevar2-trig-subst»  (to ".changevar2-trig-subst")
# (to "changevar2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
freevar      (expr)     := listofvars(expr)[1];
changevar2   (expr, cv) := changevar(expr, cv, freevar(lhs(cv)), freevar(rhs(cv)));
changevarback(expr, cv) := subst(cv, expr);

int0 : 'integrate(1/sqrt(1-s^2), s);   /* bad */
int0 : 'integrate(s*sqrt(1-s^2), s);   /* works */
cv01 : sin(th)=s;
cv10 : [cos(th)=sqrt(1-s^2), sin(th)=s, th=asin(s)];
int1 : changevar2(int0, cv01);

  /* fix int1 */
       assume(cos(th) >= 0);
int1 : map(rootscontract, int1);
int1 : map(trigsimp,      int1);

F1   : ev(int1, nouns);
F2   : changevarback(F1, cv10);




#####
#
# A basic example of using changevar (with u=x^2)
# 2023oct10
#
#####

# «changevar-basic»  (to ".changevar-basic")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
ex0 : 'integrate(cos(x^2)*2*x, x);
ex1 : changevar(ex0, u=x^2, u, x);
ex2 : ev(ex1, 'integrate);
ex3 : subst([u=x^2], ex2);



#####
#
# changevar-trig-email
# 2023oct12
#
#####

# «changevar-trig-email»  (to ".changevar-trig-email")
# (find-maximamsg "37675741 202207 02" "Edrx: sqrt(1-sin(t)^2) -> sqrt(1-sin(t))*sqrt(sin(t)+1)")
# (find-maximamsg "37675749 202207 02" "MTalon: rootscontract")
# (to "rootscontract")

Hi list,

if I execute this

  display2d : false;
  ex0 : 'integrate(s*sqrt(1-s^2), s);
  ex1 : changevar(ex0, s=sin(t), t, s);

what I get is:

  (%i1) display2d : false;
  (%o1) false
  (%i2) ex0 : 'integrate(s*sqrt(1-s^2), s);
  (%o2) 'integrate(s*sqrt(1-s^2),s)
  (%i3) ex1 : changevar(ex0, s=sin(t), t, s);
  (%o3) 'integrate(cos(t)*sqrt(1-sin(t))*sin(t)*sqrt(sin(t)+1),t)

but I am trying to prepare material for a course on basic integration
techniques, so the style of simplification that I need is different...
this factorization is "bad":

   sqrt(1-sin(t)^2)
   ->  sqrt(1-sin(t))*sqrt(sin(t)+1)

Questions:

  1) how do I tell Maxima to not factor that sqrt?
  2) how do I tell Maxima to do this instead?

     sqrt(1-sin(t)^2)
     ->  cos(t)

Thanks in advance!
  Eduardo Ochs
  http://angg.twu.net/eev-maxima.html



#####
#
# changevar-trig
# 2022jul02
#
#####

# «changevar-trig»  (to ".changevar-trig")
# (find-maximanode "rootscontract")
# (find-maximanode "map")
# (to "rootscontract")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
ex0 : 'integrate(s*sqrt(1-s^2), s);
ex1 : changevar(ex0, s=sin(t), t, s);
rootsconmode : all;
ex2 : map(rootscontract, ex1);
ex3 : map(trigsimp, ex2);
      assume(cos(t) > 0);
      ev(ex3);
ex4 : changevar(ex3, u=cos(t), u, t);
      assume(u > 0);
ex5 : ev(ex4);
ex6 : ev(ex5, integrate);
ex7 : subst([u=cos(t)], ex6);
ex8 : subst([cos(t)=c], ex7);
ex9 : subst([c=sqrt(1-s^2)], ex8);
**
ev(ex0, integrate);
display2d : false;

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
ex0 : 'integrate(x*sqrt(4-9*x^2), x);
ex0 : 'integrate(x*sqrt(1-9*x^2), x);
ex1 : changevar(ex0, u=3*x, u, x);




#####
#
# changevar-trig: integrate(s*sqrt(1-s^2), s)
# 2023oct10
#
#####

# «changevar-trig-2»  (to ".changevar-trig-2")
# (find-es "maxima" "2023-2-C2-P1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
assume(c>0);
ex0   : 'integrate(s*sqrt(1-s^2), s);
ex1   : changevar(ex0, s=sin(th), th, s);
  ex1 : map(rootscontract, ex1);
  ex1 : subst([sqrt(1-sin(th)^2)=cos(th)], ex1);
ex2   : changevar(ex1, c=cos(th), c, th);
ex3   : ev(ex2, 'integrate);
ex4   : subst([c=cos(th)], ex3);
ex5   : subst([th=asin(s)], ex4);
ex0 = ex5;
diff(ex5, s);

align_eqs([ex0, ex1, ex2, ex3, ex4, ex5]);



#####
#
# changevar-trig-3
# 2023dec19
#
#####

# «changevar-trig-3»  (to ".changevar-trig-3")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
assume(c>0);
I_s    : 'integrate(s*sqrt(1-s^2), s);
I_th   : changevar(I_s, s=sin(th), th, s);
  I_th : map(rootscontract, I_th);
  I_th : subst([sqrt(1-sin(th)^2)=cos(th)], I_th);
I_c    : changevar(I_th, c=cos(th), c, th);
F_c    : ev(I_c, 'integrate);
F_th   : subst([c=cos(th)], F_c);
I_s    : subst([th=asin(s)], F_th);
I_s = I_s;
diff(I_s, s);

align_eqs([I_s, I_th, I_c, F_c, F_th, I_s]);

I_c    : 'integrate(c/(1-c^2), c);




#####
#
# changevar-email
# 2022jun23
#
#####

# «changevar-email»  (to ".changevar-email")
# (find-maximamsg "37672073 202206 24" "Edrx: unquote integrate(cos(y),y)")
# (find-maximamsg "37672076 202206 24" "Stavros: ev(...,integrate) or ev(...,nouns)")
# (find-maximamsg "37672078 202206 24" "Edrx: thanks!")

Hi list,

I'm trying to write code that will solve some basic problems of
integration by change of variables "step by step"... my first example
starts with:

  ex0 : 'integrate((3*cos(2 + sqrt(3*x+4))) / (2*sqrt(3*x+4)), x);
  ex1 :  integrate((3*cos(2 + sqrt(3*x+4))) / (2*sqrt(3*x+4)), x);
  ex2 : changevar(ex0, u=3*x, u, x);
  ex3 : changevar(ex2, v=u+4, v, u);
  assume(w>0);
  ex4 : changevar(ex3, w=sqrt(v), w, v);
  ex5 : changevar(ex4, y=2+w, y, w);
  display2d : false;
  ex5 ;

but how do I make Maxima integrate ex5? Its value is:

  'integrate(cos(y),y)

I know how to use the quote to make Maxima _avoid solving_ an integral
- see ex0 and ex1 above - but how do I maka Maxima solve the integral
in ex5? I made several attempts using ev, simp:true, and quote-quote,
but none of them worked...

  Thanks in advance!
    Eduardo Ochs
    http://angg.twu.net/eev-maxima.html




#####
#
# changevar-by-hand
# 2024aug25
#
#####

# «changevar-by-hand»  (to ".changevar-by-hand")
# (find-angg "MAXIMA/changevarbyhand1.mac")



#####
#
# E-mail: a question on/about how changevar expands roots
# 2024aug25
#
#####

# «changevar-quirk»  (to ".changevar-quirk")
# (find-maximagitgrep "grep --color=auto -niRH --null -e changevar *")
# (find-maximagitgrep "grep --color=auto -niRH --null -e changevar src/*.lisp")
# (find-maximagitgrep "grep --color=auto -niRH --null -e ratfac src/*.lisp")
# (find-maximagitfile "src/outmis.lisp" "(defmfun $changevar")
# (find-maximagitfile "src/outmis.lisp" "(defun changevar")
# (find-maximagitfile "src/outmis.lisp" "(defun changevar" "ovar = tfun(nvar)")
# (find-maximamsg "58809951 202408 25" "Edrx: A question...")
# (find-maximamsg "58810074 202408 26" "BWillis: radcan")
# (find-maximamsg "58810106 202408 26" "RToy: ratsimp")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)

A question about how changevar expands roots

Hi list,

sometimes changevar "expanded roots" in a way that was not what I
wanted but I was able to fix its results using just rootscontract,
like here:

  [trans,nvar,ovar] : [x=sin(theta), theta, x];
  obody : sqrt(1-x^2);
  oexpr : 'integrate(obody, ovar);
  nexpr : changevar(oexpr,trans,nvar,ovar);
  nexpr : rootscontract(nexpr);

but here is a case in which changevar decides to pull some "%i"s out
of the roots, and rootscontract contracts the roots but leaves the
"%i"s outside:

  [trans,nvar,ovar] : [x=2*u, u, x];
  obody : sqrt(4-x^2)^3;
  oexpr : 'integrate(obody, ovar);
  nexpr : changevar(oexpr,trans,nvar,ovar);
  nexpr : rootscontract(nexpr);

  display2d : false;
  nexpr;            /* 'integrate(sqrt(u^2-1)*(16*%i-16*%i*u^2),u) */
  display2d : true;

Here is a way to do that change of variables by hand that gives the
result that I was trying to get - if I didn't commit any errors, of
course...

  [trans,nvar,ovar] : [x=2*u, u, x];
  obody : sqrt(4-x^2)^3;
  oexpr : 'integrate(obody, ovar);
  ovar_eq_tfun_nvar : solve(trans, ovar)[1];
  deriv : diff(rhs(solve(trans, nvar)[1]), ovar);
  nbody : subst(ovar_eq_tfun_nvar, obody/deriv);
  nexpr_by_hand : 'integrate(nbody, nvar);
  nexpr_maxima  : changevar(oexpr, trans, nvar, ovar);
  nexpr_maxima  : rootscontract(nexpr_maxima);

I thought that I would be able to find the flags that control how
changevar expands roots by reading its source in src/outmis.lisp and
trying to understand what it does... but that didn't work - I'm not
even sure where in the (defun changevar ...) it calls the thing that
expands roots.

  Any suggestions, pointers, or whatever else?
  Thanks in advance!
    Eduardo Ochs
    http://anggtwu.net/eev-maxima.html




#####
#
# changevar-figure
# 2022jul08
#
#####

# «changevar-figure»  (to ".changevar-figure")
# (c2m221atisp 12 "substituicao-figura")
# (c2m221atisa    "substituicao-figura")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
ex0 : 'integrate(sin(u), u);
ex1 : changevar(ex0, u=x^3, x, u);
ex2 : 3*x^2 * sin(x^3);
plot2d (ex2, [x, -4, 4]);
plot2d (ex2, [x, 0.5, 2]);

solve([u=x^3, x=2], u);
solve([u=x+4, x=2], u);




#####
#
# 3-changevars
# 2023oct10
#
#####

# «3-changevars»  (to ".3-changevars")
# (find-angg "MAXIMA/3-changevars1.mac")




#####
#
# subst-2023-2: idéias para um slide sobre RC[f(x):=bla]
# 2023aug27
#
#####

# «subst-2023-2»  (to ".subst-2023-2")
# See: (to "texput-frac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* RP: regra do produto
 * RE: regra errada
*/
RP : 'diff(x^n,x) = n*x^(n-1);
subst([n=4], RP);
RE : 'diff(x^n,x) = x^(n-1)+10*n;
subst([n=42], RE);

RC : 'diff(f(g(x)),x) = fp(g(x))*gp(x);
ex1g  : lambda([x],42*x);
ex1gp : lambda([x],42);
ex1f  : lambda([x],sin(x));
ex1fp : lambda([x],cos(x));
subst([g=ex1g,gp=ex1gp], RC);
subst([f=ex1f,fp=ex1fp], RC);
subst([f=ex1f], RC);    /* errado! */




* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("/home/edrx/bigsrc/maxima/interfaces/emacs/emaxima/emaxima.lisp")$
display2d:'emaxima$
a/b;
'diff(y,x);
texput("/", lambda([r],
    block([n,d],
          n:num(r),
          d:denom(r),
          printf(false,"\\frac{~a}{~a}",tex1(n),tex1(d)))))$
a/b;
'diff(y,x);

texput, \frac, and diff
Hi list,

In this message

  https://sourceforge.net/p/maxima/mailman/message/37875807/

Leo Butler showed a texput that makes tex1 use \frac instead of \over.
But I just noticed that when I use "display2d:'emaxima$" his texput
makes d/dx be displayed as 1/x... and I don't know how to debug that.
Help, please?

Here is the code:

  load("/home/edrx/bigsrc/maxima/interfaces/emacs/emaxima/emaxima.lisp")$
  display2d:'emaxima$
  a/b;
  'diff(y,x);
  texput("/", lambda([r],
      block([n,d],
            n:num(r),
            d:denom(r),
            printf(false,"\\frac{~a}{~a}",tex1(n),tex1(d)))))$
  a/b;
  'diff(y,x);

When I run it in a REPL I get this:

  (%i1) load("/home/edrx/bigsrc/maxima/interfaces/emacs/emaxima/emaxima.lisp")$
  
  (%i2) display2d:'emaxima$
  
  (%i3) a/b;
  (%o3) {{a}\over{b}}
  (%i4) 'diff(y,x);
  (%o4) {{d}\over{d\,x}}\,y
  (%i5) texput("/", lambda([r],
      block([n,d],
            n:num(r),
            d:denom(r),
            printf(false,"\\frac{~a}{~a}",tex1(n),tex1(d)))))$
  
  (%i6) a/b;
  (%o6) \frac{a}{b}
  (%i7) 'diff(y,x);
  (%o7) \frac{1}{x}\,y
  (%i8)

Thanks in advance!
  Eduardo Ochs


texput(fp, "f'")$
texput(gp, "g'")$
linenum:0;


# (find-sh "locate emaxima.lisp")





#####
#
# Choosing good test questions on trigonometric substitution
# 2022nov29
#
#####

# «subst-trig-questions»  (to ".subst-trig-questions")
# (find-es "maxima" "2023-2-C2-P1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
ff(a,b,c) := x^a * sqrt(1 - c*x^2)^b;
f (a,b)   := x^a * sqrt(1 -   x^2)^b;
FF(a,b,c) := integrate(ff(a,b,c), x);
F (a,b)   := integrate(f (a,b),   x);
Q (a,b)   := ('integrate(f(a,b),x) = integrate(f(a,b),x));
F(1,1);
F(1,3);
F(1,5);

F(2,1);
f(2,1);

F(2,3);   /* has an arcsin */
F(2,5);

F(3,1);
F(3,3);
F(3,5);

ff(3,1,1);
FF(3,1,1);
ff(3,1,4);
FF(3,1,4);

F(4,1);
F(4,3);
F(4,5);

Q(3,3);
Q(0,-1);
Q(-2,1);



#####
#
# antichangevar
# 2022dec13
#
#####

# «antichangevar»  (to ".antichangevar")
# (c2m222p1p 5 "questao-1-gab")
# (c2m222p1a   "questao-1-gab")
# (find-maximanode "changevar")
# (find-maximanode "subst")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
anticv(bodyu, ux, x) := subst(ux, bodyu) * diff(rhs(ux), x);
fu : sin(u);
fx : anticv(fu, u=x^2, x);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
fx  : x^3 * sqrt(1-4*x^2);
fu  : subst([x=u/2],     fx) * diff(u/2,     u);
fth : subst([u=sin(th)], fu) * diff(sin(th), th);
fth : subst([sqrt(1-sin(th)^2)=cos(th)], fth);
fc  : subst([cos(th)=c], fth) / diff(cos(th), th);
fc  : subst([sin(th)^2=1-c^2], fc);
fc  : expand(fc);




#####
#
# find-maximaindex
# 2022apr26
#
#####

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

;; (ee-maximaindex-rest ())
;; (ee-maximaindex-rest '("foo" "bar"))
;; (ee-maximaindex-rest '(:RET "bar"))




#####
#
# :lisp
# 2022nov18
#
#####

# «:lisp»  (to ".:lisp")
# (find-maximanode "Lisp and Maxima")
# (find-maximanode "Lisp and Maxima" "(%i1) :lisp (foo $x $y)")
# (find-maximanode "Lisp and Maxima" "to_lisp")
# (find-maximanode "Lisp and Maxima" "#$<expr>$")
# (find-maximanode "Lisp and Maxima" "?foo")
# (find-angg ".maxima/maxima-init.lisp")
# (find-maxima-links "[")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
:lisp (list $x $y)
:lisp (foo  $x $y)
:lisp (msetq $foo1 #$[x, y]$)
foo2 : [x, y];
[foo1, foo2];
:lisp #$[x, y, z]$
:lisp (list $x $y)
:lisp (displa '((MLIST SIMP) $X $Y $Z))

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
:lisp (mfuncall '$foo 'a 'b)
foo(x,y) := x*y$
:lisp (mfuncall '$foo 'a 'b)

:lisp (describe     '$[)
:lisp (symbol-plist '$[)
:lisp (describe '$list)

list(2,3);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
:lisp (defun foo (x) (* 10 x))
:lisp (foo 2)
?foo(2);
load("~/luatree/luatree.mac");
bar : lambda([x], ?foo(x));
bar(2);
luatree(bar);
traverse(bar);
traverse(bar, op);
traverse(bar, args);
traverse(bar, args, 2);
traverse(bar, args, 2, op);
o : traverse(bar, args, 2, op);
stringp(o);
symbolp(o);
:lisp $o
:lisp $bar




#####
#
# How do I distinguish "foo" from "?foo"?
# 2024sep23
#
#####

# «foo-and-foo»  (to ".foo-and-foo")
# (to "symbols")
# (to "mycolorlerp1")
# (find-angg "MAXIMA/mycolorlerp1.lisp")
# (find-maximamsg "58820057 202409 23" "Edrx: How do I distinguish foo from ?foo")
# (find-maximamsg "58820176 202409 23" "Edrx: For more context")
# (find-maximamsg "58820179 202409 23" "BWillis: $my_color_lerp")
# How do I distinguish foo from ?foo, i.e., $FOO from FOO, in Maxima?

Hi list,

is there an easy way to distinguish the symbol "foo" from the symbol
"?foo" in Maxima? The question is bad, but look at the code below...

"foo" in Maxima is "$FOO" in Lisp, and
"?foo" in Maxima is "FOO" in Lisp -

...but in Maxima the are displayed in the same way.

  Thanks in advance!
    Eduardo Ochs

Here is the code:

--snip--snip--
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
traverse_1 : lambda([o, action],
  if     is(action = 'op)   then op(o)
  elseif is(action = 'args) then args(o)
  else   args(o)[action])$
traverse(o, [actions]) := xreduce('traverse_1, actions, o)$

:lisp (defun foo (x) (* 10 x))
:lisp (foo 2)                    ; 20
?foo(2);                        /* 20 */
 foo(2);                        /* foo(2) */

bar0 : lambda([x],  foo(x));
bar  : lambda([x], ?foo(x));
bar(2);                         /* 20 */
traverse(bar);                  /* lambda([x], foo(x)) */
traverse(bar, op);              /* lambda              */
traverse(bar, args);            /*       [[x], foo(x)] */
traverse(bar, args, 2);         /*             foo(x)  */
traverse(bar, args, 2, op);     /*             foo     */

o : traverse(bar, args, 2, op); /* foo */
foo;                            /* foo */

:lisp $o                        ; FOO
:lisp $bar0                     ; ((LAMBDA SIMP) ((MLIST) $X) (($FOO) $X))
:lisp $bar                      ; ((LAMBDA SIMP) ((MLIST) $X) ((FOO) $X))
--snip--snip--



#####
#
# foo-and-foo-2
# 2024sep23
#
#####

# «foo-and-foo-2»  (to ".foo-and-foo-2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
:lisp (defun foo (x) (* 10 x))
:lisp (foo 2)
x : ?foo;
?print(x);
?print(foo);
?print('foo);



?foo(2);                        /* 20 */
 foo(2);                        /* foo(2) */
?print(?foo)
?print( foo)






#####
#
# The nofix("...") trick in my package for Taylors and MacLaurins
# 2023dec06
#
#####

# «mac-nofix»  (to ".mac-nofix")
# (find-angg "MAXIMA/mac1.mac")
# (find-maximanode "taylor")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("~/MAXIMA/mac1.mac");
        mac(1,2,3);
        mac(1,2,3,...);
        mac(1,2,3,...) * mac(0,1,0,...);
mac_ify(mac(1,2,3,...) * mac(0,1,0,...));
        mac1 : mac(1,2,-3,4,5,...);
        mac2 : mac(a,b,c,d,e,...);
        mac3 : 1/mac1;
        mac1 * mac3;
mac_ify(mac1 * mac3);




#####
#
# postfix-m
# 2024aug28
#
#####

# «postfix-m»  (to ".postfix-m")
# (to "operators")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
m(o) := o*m_;
postfix("m");
10 m;




#####
#
# subscripted
# 2022aug28
#
#####

# «subscripted»  (to ".subscripted")
# (find-es "maxima" "mtree")
# (find-maximawbpage (+ 19 21) "When the lhs is a subscripted")
# (find-maximawbtext (+ 19 21) "When the lhs is a subscripted")
# (find-maximanode "Functions and Variables for Lists")
# (find-maximanode "array")
# (find-maximanode "arrayinfo")
# (find-maximanode "subvar")
# (find-maximanode "arraymake")
# (find-maximanode "op")
# (find-maximanode "op" "F [x, y]")
# (find-maximanode "ordergreatp" "subscripted expressions")
# (find-maximanode "subnumsimp")
# (find-maximanode ":" "not subscripted")
# (find-maximanode "ev" "subscripted")
# (find-maximanode "declare" "nonarray")
# (find-maximanode "nonarray")
# (find-maximanode "assume_pos_pred")
# (find-maximanode "coeff" "subscripted")
# (find-maximanode "diff" "subscripted")
# (find-maximanode "gradef")
# (find-maximanode "ishow")
# (find-maximanode "Functions and Variables for itensor")
# (find-maximanode "tellsimpafter")
# (find-maximanode "flatten")
# (find-maximanode "makeset")
# (find-maximanode "dispfun")
# (find-maximanode "functions")
# (find-maximanode "functions" "Memoizing functions")
# (find-maximanode "fundef")
# (find-maximanode "funmake")
# (find-maximanode "remfunction")
# (find-maximanode "mapatom")
# (find-maximanode "setcheck")
# (find-maximanode "opsubst")
# (find-maximanode "Functions and Variables for opsubst")

# (find-maximanode "nonarray")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a:'b$ b:'c$ c:'d$
a[x];
declare(a, nonarray);
a[x];
a[1];
a[1] : 23;
a[1];
a[2][3];
a[2][3] : 45;

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a[1,2];
a[1,2] : 34;
a[1,2];
arrayinfo(a);
c(coefx, coefy) := a[coefx, coefy] * x^coefx * y^coefy;
z : c(0,0) + c(0,1) + c(0,2) + c(1,0) + c(1,1) + c(2,0); 
a[2,0] : 0;
z;
ev(z);



#####
#
# Fermin's talk about Maxima at the EmacsConf2020
# 2021dec11
#
#####

# «emacsconf2020»  (to ".emacsconf2020")
# https://gitlab.com/sasanidas/maxima
# https://emacsconf.org/2020/talks/33/
# https://mirror.csclub.uwaterloo.ca/emacsconf/2020/smaller/emacsconf-2020--33-maxima-a-computer-algebra-system-in-emacs--fermin--vp9-q56-video-original-audio.webm

# (code-c-d "maxima" "~/usrc/maxima/")
# (find-maximafile "")
# (find-maximafile "maxima.el")
# (find-maximafile "maxima.el" "maxima-symbol-doc")

(code-video "maximavideo" "$S/https/mirror.csclub.uwaterloo.ca/emacsconf/2020/smaller/emacsconf-2020--33-maxima-a-computer-algebra-system-in-emacs--fermin--vp9-q56-video-original-audio.webm")
;; (find-maximavideo)
;; (find-maximavideo "0:00")
;; (find-maximavideo "2:20" "org-mode support")
;; (find-maximavideo "2:35" "eqns: an array of three equations")
;; (find-maximavideo "2:45" "solutions:")
;; (find-maximavideo "3:05" "first of all you have to send this")
;; (find-maximavideo "3:39" "maxima-help-at-point")
;; (find-maximavideo "4:10" "information about the symbol: maxima-symbol-doc")
;; (find-maximavideo "4:29" "a more complicate example")
;; (find-maximavideo "5:02" "maxima-latex-insert-form")
;; (find-maximavideo "5:25" "load(\"draw\")")
;; (find-maximavideo "5:50" "draw2d(implicit())")
;; (find-maximavideo "7:19" "the original package")

;; (find-maximavideo "11:15" "maxima-send-block")
;; (find-maximavideo "12:10" "CI/CD")
;; (find-maximavideo "12:45" "company")
;; (find-maximavideo "12:49" "org mode and latex")
;; (find-maximavideo "12:58" "polymode")
;; (find-maximavideo "13:02" "maxima can understand lisp code")
;; (find-maximavideo "13:27" "send with C-c C-r")
;; (find-maximavideo "13:45" ":lisp")
;; (find-maximavideo "13:50" "integration with slime mode")
;; (find-maximavideo "14:07" "features right now")
;; (find-maximavideo "14:26" "minibuffer minor mode")



#####
#
# maxima-mode
# 2021dec11
#
#####

# «maxima-mode»  (to ".maxima-mode")
# (find-angg ".emacs" "maxima-mode")
# (find-epackage-links 'maxima "maxima" t)
# (find-epackage       'maxima)
# (code-c-d "maxima" "~/.emacs.d/elpa/maxima-20210526.1525/")
# (find-maximafile "")
# (find-maximafile "maxima-autoloads.el" "maxima-start")
# (find-maximafile "maxima.el")
# (find-efunctiondescr 'maxima-mode)
# (find-efunction      'maxima-send-line)
# (find-efunction      'maxima-start)
# (find-efunction      'maxima-init-inferiors)

# 2022dec07:
# Font locking is much better in upstream Maxima's maxima.el
# https://gitlab.com/sasanidas/maxima/-/issues/40

Hi Fermin,
compare the two screenshots below:

http://angg.twu.net/IMAGES/maxima-mode-melpa-2022.png
http://angg.twu.net/IMAGES/maxima-mode-git-2022.png

The one that says "melpa" is what I get from the Maxima mode from
MELPA; it is quite bad. The one that says "git" is what I get using
the maxima.el from an upstream Maxima git-pull'ed and compiled a few
days ago, and it is much better.

Do you get something similar? If not, should I try to check which
other packages are interfering in on your maxima mode and
maxima-font-lock? They do not affect the maxima mode from upstream...




#####
#
# eepitch-maxima (obsolete)
# 2021dec11
#
#####

# «eepitch-maxima»  (to ".eepitch-maxima")
# (find-efunctiondescr 'maxima-init-inferiors)
# (find-efunction      'maxima-init-inferiors)
# (find-efunctiondescr 'maxima-string)
# (find-efunction      'maxima-string)
# (eek "M-h M-k  C-c C-c  ;; maxima-send-line")
# (find-efunctiondescr 'maxima-send-line)
# (find-efunction      'maxima-send-line)
# (find-efunctiondescr 'maxima-send-region)
# (find-efunction      'maxima-send-region)
# (find-efunctiondescr 'maxima-region)
# (find-efunction      'maxima-region)


;; See: (find-eepitch-intro \"3.3. `eepitch-preprocess-line'\")
;; (setq eepitch-preprocess-regexp \"^\")
;; (setq eepitch-preprocess-regexp \"^;; ?\")

;; eepitch-maxima uses comint.
;; eepitch-fmaxima uses Fermin's maxima-mode.

(defun find-fmaximaprocess (&rest rest)
  (require 'maxima)
  (maxima-init-inferiors)
  (find-ebuffer (process-buffer (get-process "maxima")) :end))

(defun eepitch-line-fmaxima (line)
  (maxima-string (ee-no-properties line)))

;; Based on: (find-efunction 'eepitch-vterm)
;;
(defun eepitch-fmaxima ()
  (interactive)
  (prog1 (eepitch `(find-fmaximaprocess))
    (setq eepitch-line 'eepitch-line-fmaxima)))

;; Tests:
;; (find-2a nil '(find-fmaximaprocess))
;; (eepitch-line-fmaxima "1+2;")
;; (eepitch-line-fmaxima "")

 (eepitch-fmaxima)
 (eepitch-kill)
 (eepitch-fmaxima)
1+2;
1+2
;

 (maxima-string "")



#####
#
# maxima-latex-insert-form (for Fermin's mode?)
# 2021dec11
#
#####

# «maxima-latex-insert-form»  (to ".maxima-latex-insert-form")
# (find-efunctiondescr 'maxima-latex-insert-form)
# (find-efunction      'maxima-latex-insert-form)
# (find-orgfile "org.el" "org-preview-latex-image-directory")
# (find-evardescr        'org-preview-latex-image-directory)
# (find-evariable        'org-preview-latex-image-directory)




#####
#
# prompt
# 2023jul13
#
#####

# «prompt»  (to ".prompt")
# (find-maximanode "inchar")
# (find-maximanode "outchar")
# (find-maximanode "linechar")
# (find-maximanode "linenum")
# (find-maxima-links "linenum")
# (find-maximanode "programmode")
# (find-maximanode "labels")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a : 42;
b : 99;
linenum : 0;
inchar;
inchar: "bla";
inchar: "%i";




#####
#
# 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?





#####
#
# maxima-src
# 2021nov21
#
#####

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




#####
#
# 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.44.0/")
# (find-maximasrcsh "find * -type f | sort")
# (find-maximagitsh "find * -type f | sort")
# (find-maximagitfile "")
# (find-maximagitfile "share/calculus/pade2.mac")
# (find-maximagitfile "src/buildq.lisp")
# (find-maximagitfile "src/nparse.lisp")
# (find-maximagitfile "src/nparse.lisp" "recognize '#' comments")
# (find-maximagitfile "src/nparse.lisp" "The Expression Parser")
# (find-maximagitfile "src/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")

* (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-maximanode "Lisp and Maxima")
# (find-maximanode "Lisp and Maxima" "same effect as")
# (find-maximanode "Lisp and Maxima" "same effect as" "foo: [x, y]")
# (find-maximanode "Documentation")
# (find-maximanode "Functions and Variables for Help")
# (find-maximanode "Source Level Debugging")
# (find-maximanode "Function and Variable Index")
# (find-maximanode "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();




#####
#
# 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-maximanode "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 (obsolete)
# 2009sep21
#
#####

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



#####
#
# draw
# 2022apr27
#
#####

# «draw»  (to ".draw")
# «draw-gr2d»  (to ".draw-gr2d")
# (find-maximanode "draw")
# (find-maximanode "gr2d")
# (find-maximanode "key")
# (find-maximanode "grid")
# (find-maximanode "color")
# (find-maximanode "explicit")
# (find-maximanode "Functions and Variables for draw" "Graphic option: grid")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
draw(gr2d(key="sin (x)",
          grid=[2,2],
          explicit(sin(x), x,0,2*%pi)
          ),
     gr2d(key="cos (x)",
          grid=[2,2],
          explicit(cos(x), x,0,2*%pi)
    ));
draw(gr2d(grid=[2,2],
          explicit(sin(x), x,0,2*%pi),
          color="red",
          explicit(cos(x), x,0,2*%pi)
          )
    );

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
scene1: gr2d(title="Ellipse",
             nticks=300,
             parametric(2*cos(t),5*sin(t),t,0,2*%pi));
scene2: gr2d(title="Triangle",
             polygon([4,5,7],[6,4,2]));
draw(scene1, scene2, columns = 2);
**
scene1: gr2d(title="A sinus",
  grid=true,
  explicit(sin(t),t,0,2*%pi));
scene2: gr2d(title="A cosinus",
  grid=true,
  explicit(cos(t),t,0,2*%pi));
draw(scene1, scene2);
**
** The following two draw sentences are equivalent:
draw(gr3d(explicit(x^2+y^2,x,-1,1,y,-1,1)));
draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1));
**
** Creating 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)));
**
** (find-fline "/tmp/zzz.gif")



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

# «draw2d»  (to ".draw2d")
# (find-es "qdraw" "ex")
# (find-status   "gnuplot")
# (find-vldifile "gnuplot.list")
# (find-udfile   "gnuplot/")
# (find-maximanode "draw")
# (find-maximanode "draw2d")
# (find-maximanode "explicit")
# (find-maximanode "Functions and Variables for 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));
draw2d(explicit(x^3, x, -1, -1),
       xaxis       = true,
       xaxis_color = blue,
       yaxis       = true,
       yaxis_width = 2,
       yaxis_type  = solid,
       yaxis_color = "#f3b507");



#####
#
# Implicit functions
# 2010mar15 / 2024nov10
#
#####

# «draw2d-implicit»  (to ".draw2d-implicit")
# «draw3d-implicit»  (to ".draw3d-implicit")
# (find-maximanode "implicit")
# (find-es "qdraw" "imp")
# (find-maximagpdraww3m "implic/index.html")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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" );

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
draw3d(
  color=blue,
  implicit((x^2+y^2+z^2-1)*(x^2+(y-1.5)^2+z^2-0.5)=0.015,
           x,-1,1,y,-1.2,2.3,z,-1,1),
  surface_hide=true);




#####
#
# draw2d(parametric(...)) fails on a function defined by cases
# 2024oct09
#
#####

# «draw2d-parametric-bug»  (to ".draw2d-parametric-bug")
# «parametric-bug»  (to ".parametric-bug")
# (find-maximamsg "58826831 202410 09" "Edrx: draw2d parametric fails...")
# (find-maximamsg "58826871 202410 09" "RDodier: listofvars(foo(x)[1])")
# (find-maximamsg "58826903 202410 10" "Edrx: /* redefine as */")
# (find-maximamsg "58827040 202410 10" "JVillate: plot2d 1")
# (find-maximamsg "58827041 202410 10" "JVillate: plot2d 2")
# (find-es "qdraw" "para-bug")

Hi all,

Try this:

  P(t) := [cos(t),sin(t)];
  draw2d(explicit(P(t)[1], t,0,10),
         explicit(P(t)[2], t,0,10));
  draw2d(parametric(P(t)[1], P(t)[2], t,0,10));

  P(t) := if t <= 6 then [t,4] else [6,10-t];
  draw2d(explicit(P(t)[1], t,0,10),
         explicit(P(t)[2], t,0,10));
  draw2d(parametric(P(t)[1], P(t)[2], t,0,10));

The first three "draw2d"s work perfectly, but the last one
yields this error:

  draw2d (parametric): non defined variable

I got the same error with the two versions of Maxima
that I have here, that are:

  Maxima branch_5_47_base_1348_g39c0ffa27 https://maxima.sourceforge.io
  using Lisp SBCL 2.1.1.debian

  Maxima 5.44.0 http://maxima.sourceforge.net
  using Lisp GNU Common Lisp (GCL) GCL 2.6.12

Is that documented? Is there a known workaround?

  Thanks in advance,
    Eduardo Ochs
    http://anggtwu.net/eev-maxima.html


#####
#
# parametric-fix
# 2024oct17
#
#####

# «parametric-fix»  (to ".parametric-fix")
# (find-maximamsg "58826903 202410 10" "Edrx: /* redefine as */")
# (to "by-cases")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
P(t) :=  if t <= 6 then [t,4] else [6,10-t];   /* redefine as: */
P(t) := [if t <= 6 then  t    else  6,         /* x */
         if t <= 6 then    4  else    10-t];   /* y */

draw2d(xrange=[-1,8], yrange=[-1,8],
       parametric(P(t)[1],P(t)[2], t,0,10));




#####
#
# draw2d-debug
# 2024oct11
#
#####

# «draw2d-debug»  (to ".draw2d-debug")
# (find-maximanode "Command-line options" "-g, --enable-lisp-debugger")
# (find-maximamsg "58827432 202410 11" "Edrx: draw2d(parametric(...)) and Slime/Sly")
# (find-maximamsg "58827442 202410 11" "RToy: ")
# (find-try-sly-intro "8. Inspect Maxima with Sly")
# (find-elocus-links "C-M-h" 'global-map 2 "mark-defun")
# (find-elocus-links "C-c C-c" 'sly-editing-mode-map 2 "sly-compile-defun")


One thing is to start maxima with the |-g| option. There was also 
another variable that caused the lisp debugger to invoked on errors, but 
I can’t remember what it is; I rarely use it.

What I end up doing is doing |debugmode(true)| and run the command 
again. When I enter debug mode, I press Ctrl-C and get dropped into the 
debugger.

But you don’t need to do this to test out code. Just use Sly (Slime) to 
compile the new code and run it. Or just stick a |(break)| in the code 
just after or before the call to |listofvars|. Or if your |trace| 
function supports a |:break| option like cmucl and sbcl, use that to 
cause a break when |listofvars| is traced.

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
maxima -g
  debugmode(true);
  P(t) := if t <= 6 then [t,4] else [6,10-t];
  draw2d(parametric(P(t)[1], P(t)[2], t,0,10));






#####
#
# draw2d-pdf
# 2023nov19
#
#####

# «draw2d-pdf»  (to ".draw2d-pdf")
# (find-es "qdraw" "terminal-pdf")
# (find-myqdraw "myqdraw3.mac" "myterminalpdf")





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

# «casting-spels»  (to ".casting-spels")
# https://riotorto.users.sourceforge.net/Maxima/casting/index.htm 2023sep26
#  http://riotorto.users.sourceforge.net/Maxima/casting/index.htm 2022jan15
# 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;





#####
#
# infolists
# 2023jul08
#
#####

# «infolists»  (to ".infolists")
# (find-maximanode "infolists")



#####
#
# DDef: define in the default way
# 2023sep25
#
#####

# «DDef»  (to ".DDef")
# (find-angg ".maxima/maxima-init.mac" "DDef")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
DDef1(fxy) := buildq([f:op(fxy),xy:args(fxy)], define(f(splice(xy)),f));
DDef([fxys]) ::= map('DDef1,fxys);

P  : [cos(k*t), sin(k*t)];
Pt : diff(P, t);

macroexpand(DDef( P(t),   Pt(t)   ));
macroexpand(DDef( P(k,t), Pt(k,t) ));

DDef ( P(t), Pt(t) );
P(a);
Pt(a);

DDef ( P(k,t), Pt(k,t) );
P(2,a);
Pt(2,a);





#####
#
# dispfun
# 2009oct06 / 2022jan10
#
#####

# «dispfun»  (to ".dispfun")
# (find-maximaindex-links "apply define define_variable demoivre dispfun fundef funmake")
# (find-maximanode "apply")
# (find-maximanode "define")
# (find-maximanode "define_variable")
# (find-maximanode "demoivre")
# (find-maximanode "dispfun")
# (find-maximanode "fundef")
# (find-maximanode "funmake")
# (find-maximanode "Functions and Variables for Function Definition")
# (find-maximagitfile "")
# (find-maximagitgrep "grep --color=auto -niRH --null -e dispfun *")
# (find-maximagitgrep "grep --color=auto -niRH --null -e dispfun * | grep -ai '(def'")
# (find-maximagitfile "src/mlisp.lisp" "(defmspec $dispfun ")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
? fundef
? dispfun

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
L : [1, 5, -10.2, 4, 3];
apply (min, L);
*
F (x) := x / 1729;
fname : F;
dispfun (F);
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));
*
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);



#####
#
# inner-product
# 2023jul03
#
#####

# «inner-product»  (to ".inner-product")
# «eigen»  (to ".eigen")
# (find-maximagitfile "share/matrix/" "eigen")
# (find-maximagitfile "share/matrix/eigen.dem")
# (find-maximagitfile "share/matrix/eigen.mac" "columnvector(x):=")
# (find-maximanode "vectors")
# (find-maximagitfile "share/vector/vect.mac")
# (find-maximagitfile "share/vector/vect.mac" "\\gradprod(uu,pv) :=")
# (find-maximagitfile "share/vector/vect.dem")
# (find-maximagitfile "share/vector/" "vect.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
demo  ("eigen");
batch ("eigen");



#####
#
# eigenvalues and eigenvectors
# 2023nov04
#
#####

# «eigenvalues»  (to ".eigenvalues")
# (find-maximanode "eigenvalues")
# (find-maximanode "eigenvectors")
# (find-maximanode "eivals")
# (find-maximanode "eivects")
# (find-maximagitfile "share/matrix/eigen.dem" "eigenvalues(matrix1);")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
M1: matrix([1, 2],
           [2, 5]);
M1: matrix([0, 1, 0, 0],
           [0, 0, 0, 0],
           [0, 0, 2, 0],
           [0, 0, 0, 2]);
[vals, vecss]: eigenvectors (M1);
val  (i) := vals[1][i]$
mult (i) := vals[2][i]$
vecs (i) := vecss[i]$
vecst(i) := map('transpose, vecss[i]);
vmvs (i) := [val(i), mult(i), vecs (i)]$
vmvst(i) := [val(i), mult(i), vecst(i)]$

vmvs(1);
vmvs(2);
vecs(2);
vecst(2);
vmvst(1);
vmvst(2);
float(vmvst(1));
float(vmvst(2));
fpprintprec : 4;
float(vmvst(1));
float(vmvst(2));

                vecst(2)[1];
       M1     . vecst(2)[1];
       val(2) * vecst(2)[1];
expand(M1     . vecst(2)[1]);
expand(val(2) * vecst(2)[1]);





#####
#
# ode2
# 2023jul18
#
#####

# «ode2»  (to ".ode2")
# (find-maximanode "ode2")
# (find-maximanode "ic1")
# (find-maximanode "ic2")
# (find-maximanode "eliminate")

# (find-mbe03page 1)
# (find-mbe03text 1)
# (find-mbe-links 3 3 "3.2.2    Exact Solution with ode2 and ic1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
de : 'diff(u,t)- u - exp(-t);
gsoln : ode2(de,u,t);
psoln : ic1(gsoln,t = 2, u = -0.1);
psoln : ic1(gsoln,t = 2, u = -0.1),ratprint:false;
rhs(psoln),t=2,ratsimp;
de,psoln,diff,ratsimp;
us : rhs(psoln);
plot2d(us,[t,0,7],
          [style,[lines,5]],[ylabel," "],
          [xlabel,"t0 = 2, u0 = -0.1, du/dt = exp(-t) + u"])$


# (find-mbe-links 3 9 "3.3.2   Exact Solution with ode2, ic2, and eliminate")
# (find-mbe03page   9 "3.3.2   Exact Solution with ode2, ic2, and eliminate")
# (find-mbe03text   9 "3.3.2   Exact Solution with ode2, ic2, and eliminate")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
de : 'diff(u,t,2) - 4*u;
gsoln : ode2(de,u,t);
de,gsoln,diff,ratsimp;
psoln : ic2(gsoln,t=2,u=1,'diff(u,t) = 0);
us : rhs(psoln);
us, t=2, ratsimp;
plot2d(us,[t,0,4],[y,0,10],
          [style,[lines,5]],[ylabel," "], 
          [xlabel," U versus t, U''(t) = 4 U(t), U(2) = 1, U'(2) = 0 "])$




#####
#
# separable
# 2022feb03
#
#####

# «separable»  (to ".separable")
# (to "2023-1-C2-P2-edovs")
# (find-maximanode "ode2")
# (find-maximanode "ode2" "separable")
# (find-maximanode "ode2" "ic1(soln1,x = %pi,y = 0)")
# (find-maximanode "solve")
# (find-maximanode "ic1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
x^2*'diff(y,x) + 3*y*x = sin(x)/x;
ode2(%,y,x);
ic1(%o2,x=%pi,y=0);
'diff(y,x,2) + y*'diff(y,x)^3 = 0;
ode2(%,y,x);
ratsimp(ic2(%o5,x=0,y=0,'diff(y,x)=2));
bc2(%o5,x=0,y=1,x=1,y=3);
*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
myeq    : ('diff(y,x) = -     1/y);
myeq    : ('diff(y,x) = -     x/y);
myeq    : ('diff(y,x) = - 2 * x/y);
myeq    : ('diff(y,x) =     - y/x);
mysolg  : ode2 (myeq, y, x);
mysolgs : solve(mysolg, y);
mysolg1 : solve(mysolg, y)[1];
mysolg2 : solve(mysolg, y)[2];
x0      : 4;
y0      : 3;
x0      : 4;
y0      : 6;
mysolp1 : ic1(mysolg, x=x0, y=y0);
myc1    :           subst([x=x0, y=y0], mysolg);
myc1    :     solve(subst([x=x0, y=y0], mysolg), %c);
myc1    :     solve(subst([x=x0, y=y0], mysolg), %c)[1];
myc1    : rhs(solve(subst([x=x0, y=y0], mysolg), %c)[1]);
*
myeq    : ('diff(y,x) = - x/(4*y));
mysolg  : ode2 (myeq, y, x);
mysol1  : ic1(mysolg, x=6, y=4);
mysol2  : solve(mysol1, y);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
dydx    :  'diff(y,x);
myeq    : ('diff(y,x) = - 4*x/y);
mysolg  : ode2 (myeq, y, x);
mysol1  : ic1(mysolg, x=4, y=6);
mysol1  : ic1(mysolg, x=2, y=3);
mysol2  : solve(mysol1, y);
x0      : 2;
y0      : 3;
mysol3  : subst([x=x0],       mysol2);
mysol3  : subst([x=x0, y=y0], mysol2);
my_y    : mysol2[2];
my_y    : rhs(mysol2[2]);
my_y_x  : diff(my_y, x);
subst([],                    myeq);
subst([dydx=my_y_x],         myeq);
subst([dydx=my_y_x, y=my_y], myeq);



#####
#
# separable-2
# 2022dec06
#
#####

# «separable-2»  (to ".separable-2")
# «2022-2-C2-P2-edovs»  (to ".2022-2-C2-P2-edovs")
# (c2m222p2p 2 "edovs")
# (c2m222p2a   "edovs")
# (c2m222p2p 2 "links-edovs")
# (c2m222p2a   "links-edovs")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)

/* Dados do problema */
define(G(x), x^4 + 5);
define(H(y), y^2 + 3);

x_1  : 3;
y_1  : 4;

define(g(x), diff(G(x),x));
define(h(y), diff(H(y),y));
edo    : dydx = g(x) / h(y);

eq_a   : x = H(y);
         solve(eq_a, y);
eq_b   : solve(eq_a, y)[2];  /* adjust */
define(Hinv(x), rhs(eq_b));

test_v : y = Hinv(H(y));
assume(y >= 0);
test_v : y = Hinv(H(y));

eq_c   : y = Hinv(G(x) + C3);
define(f  (x), rhs(eq_c));
define(f_x(x), diff(f(x), x));
test_gen : subst([y=f(x), dydx=f_x(x)], edo);

eq_d  : subst([x=x_1, y=y_1], eq_c);
        solve(eq_d, C3);
eq_e  : solve(eq_d, C3)[1];  /* adjust */
C3_1  : rhs(eq_e);
eq_f1 : subst([C3=C3_1], eq_c);
define(f_1(x), rhs(eq_f1));
test_xy1 : f_1(x_1) = y_1;

** (find-maximanode "ode2")
** (find-maximanode "ic1")
**
edo2 : subst([dydx='diff(y,x)], edo);
eq_g : ode2 (edo2, y, x);
       solve(eq_g, y);
eq_h : solve(eq_g, y)[2];
eq_i : subst([x=x_1, y=y_1], eq_h);
       solve(eq_i, %c);
eq_j : solve(eq_i, %c)[1];
eq_k : subst(eq_j, eq_h);
eq_l : subst([x=x_1, y=y_1], eq_k);

ic1(solve(eq_g, y)[2], x=x_1, y=y_1);
ic1(eq_h,              x=x_1, y=y_1);




#####
#
# 2023-1-C2-P2: uma questão sobre uma EDO com variáveis separáveis
# 2023jul07/2024aug18
#
#####

# «2023-1-C2-P2-edovs»  (to ".2023-1-C2-P2-edovs")
# http://anggtwu.net/LATEX/2023-1-C2-P2.pdf#page=2 Questão 1
# http://anggtwu.net/LATEX/2023-1-C2-P2.pdf#page=7 Questão 1: gabarito
# 2gT134: (c2m231p2p 2 "questao-1")
#         (c2m231p2a   "questao-1")
# 2gT139: (c2m231p2p 7 "questao-1-gab")
#         (c2m231p2a   "questao-1-gab")
# (to "separable")


** Solução, versão 2024aug18:
**
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
e1 : y*dy = -1/2 * dx;
e2 : e1/dx;
e3 : subst(dy='diff(y,x)*dx, e2);  /* EDO num formato que o Maxima entende */
sol_imp : ode2(e3, y, x);          /* solução implícita */
sols    : solve(sol_imp, y);
sol_pos : sols[2];                 /* solução positiva: y =   sqrt(...) */
sol_neg : sols[1];                 /* solução negative: y = - sqrt(...) */

e4 : subst(sol_pos, e3);           /* teste da sol_pos */
e5 : ev(e4, 'derivative);          /* continuação */

e6 : subst(sol_neg, e3);           /* teste da sol_neg */
e7 : ev(e6, 'derivative);          /* continuação */

/* Item b:
 * encontre uma solução que passa pelo ponto (3,2) e teste-a.
*/
sol_pos;
sol_b0 : subst([x=3,y=2], sol_pos);
sol_b1 : solve(sol_b0, %c);
sol_b  : subst(sol_b1, sol_pos);
test_b : subst([x=3,y=2], sol_b);

/* Item b:
 * encontre uma solução que passa pelo ponto (4,-3) e teste-a.
*/
sol_neg;
sol_c0 : subst([x=4,y=-3], sol_neg);
sol_c1 : solve(sol_c0, %c);
sol_c  : subst(sol_c1, sol_neg);
test_c : subst([x=4,y=-3], sol_c);



** Solução antiga (2023):
**
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
define(G(x), -x);
define(H(y), y^2);
define(g(x), diff(G(x),x));
define(h(y), diff(H(y),y));
myode   :  dydx = g(x) / h(y);

sdydx   :  [dydx='diff(y,x)     ];
sddx(f) := [dydx= diff(f,x), y=f];
                subst(sdydx, myode);
sols    :  ode2(subst(sdydx, myode), y, x);
                  solve(sols, y);
              rhs(solve(sols, y)[1]);
              rhs(solve(sols, y)[2]);
define(f1(x), rhs(solve(sols, y)[2]));
define(f2(x), rhs(solve(sols, y)[1]));

getsolxy(xy, sol) := block(
  [solxy, eqc],
  solxy : subst(xy, sol),
  eqc   : solve(solxy, %c),
  subst(eqc, sol));
eq3 : getsolxy([x=3, y= 2], y=f1(x));
eq4 : getsolxy([x=4, y=-3], y=f2(x));
define(f3(x), rhs(eq3));
define(f4(x), rhs(eq4));

      sddx(f3(x));
                   myode;
subst(sddx(f1(x)), myode);
subst(sddx(f2(x)), myode);
subst(sddx(f3(x)), myode);
subst(sddx(f4(x)), myode);
f3(3) =  2;
f4(4) = -3;




#####
#
# 2023-1-C2-P2-edolccs
# 2023jul07
#
#####

# «2023-1-C2-P2-edolccs»  (to ".2023-1-C2-P2-edolccs")
# (c2m231p2p 3 "questao-2")
# (c2m231p2a   "questao-2")
# (c2m231p2p 7 "questao-2-gab")
# (c2m231p2a   "questao-2-gab")
# (find-maximanode "ode2")
# (find-maximanode "scanmap")
# (find-maximanode "factor")
# (find-maximanode "gfactor")
# (find-maximamsg "37867816 202307 08" "Stavros: scanmap('factor,f2)")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* y'' + y' - 20y = 0
   f1(x) = e^{-5x}
   f2(x) = e^{4x}
*/
factor(D^2 + D - 20);
edo     :  y_xx + y_x - 20*y = 0;
edo2    :  subst([y_xx='diff(y,x,2), y_x='diff(y,x)     ], edo);
edo2(f) := subst([y_xx= diff(f,x,2), y_x= diff(f,x), y=f], edo);
sol     :          ode2(edo2,y,x);
define(f(x),   rhs(ode2(edo2,y,x)));
define(f1(x),  subst([%k1=0, %k2=1], f(x)));
define(f2(x),  subst([%k1=1, %k2=0], f(x)));
define(f_x(x), diff(f(x), x));
k1k2    : linsolve([f(0)=4, f_x(0)=5], [%k1, %k2]);
define(g(x),   subst(k1k2, f(x)));
define(g_x(x), diff(g(x), x));
/* Tests: */
[g(0)=4, g_x(0)=5];
       edo2(g(x));
expand(edo2(g(x)));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
edo       :  y_xx + 4*y_x + 29*y = 0;
edo2      :  subst([y_xx='diff(y,x,2), y_x='diff(y,x)     ], edo);
edo2(f)   := subst([y_xx= diff(f,x,2), y_x= diff(f,x), y=f], edo);
sol       :       ode2(edo2,y,x);
define(f0(x), rhs(ode2(edo2,y,x)));
define(f3(x), subst([%k1=0, %k2=1], f0(x)));
define(f4(x), subst([%k1=1, %k2=0], f0(x)));
mysymp(a) := scanmap('factor,expand(exponentialize(a)));
define(f1(x), mysymp(f3(x) + %i*f4(x)));
define(f2(x), mysymp(f3(x) - %i*f4(x)));
    f1(x);
    f2(x);
log(f1(1));
log(f2(1));
    f3(x);
    f4(x);

gfactor(D^2 + 4*D + 29);





#####
#
# 2022-2-C2-P2-edolccs
# 2022dec07
#
#####

# «2022-2-C2-P2-edolccs»  (to ".2022-2-C2-P2-edolccs")
# (c2m222p2p 3 "edolccs")
# (c2m222p2a   "edolccs")
# (find-maximanode "diff")
# (find-maximanode "del")
# (find-maximanode "ode2")
# (find-maximanode "ic2")
# (find-maximanode "linsolve")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
edo  : y_xx + y_x - 20*y = 0;
edo2 : subst([y_x='diff(y,x), y_xx='diff(y,x,2)], edo);
f    : rhs(ode2(edo2, y, x));
f_x  : diff(f, x);
fs0  : subst([x=0], [f,f_x]);
subst([%k1=4,%k2=3], fs0);

f1   : subst([%k1=1,%k2=0], f);
f2   : subst([%k1=0,%k2=1], f);
g    : 4*f1 + 3*f2;
g_x  : diff(g, x);
gs0  : subst([x=0], [g,g_x]);

linsolve(fs0-[7,1], [%k1, %k2]);




#####
#
# DtoDx
# 2022dec11
#
#####

# «DtoDx»  (to ".DtoDx")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
eq_1 : (D-2)*(D+3)*f = 0;
eq_2 : expand(eq_1);
eq_3 : subst([f=exp(4*x)], eq_2);

Dx                      :  lambda([ex,n], diff(ex,'x,n));
Dxq                     :  lambda([ex,n],'diff(ex,'x,n));
substDn(ex, newD, n)    := newD(ratcoef(ex, 'D, n), n);
substDs(ex, newD, maxn) := sum(substDn(ex, newD, n), n, 0, maxn);
DtoDxs (ex, maxn)       := substDs(ex, Dx,  maxn);
DtoDxqs(ex, maxn)       := substDs(ex, Dxq, maxn);

DtoDxs (lhs(eq_1), 2);
DtoDxqs(lhs(eq_1), 2);




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

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






#####
#
# luatree
# 2022jul29
#
#####

# «luatree»  (to ".luatree")
# (find-maximanode "Files")
# (find-maximanode "Functions and Variables for File Input and Output")
# (find-maximanode "printfile")
# (find-maximanode "stringout")
# (find-maximanode "texput")
# (find-angg "luatree/luatree.mac")
# (find-maximamsg "37689770 202208 04" "Basic question on paths (for luatree.{mac, lisp, lua})")
# (find-maximamsg "37689986 202208 05" "Problem solved!")
# (find-maximamsg "37690207 202208 05" "RDodier")
# (find-maximamsg "37690392 202208 06" "The first version of my luatree.lua just read stdin")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "luatree/luatree.mac")
load       ("~/luatree/luatree.mac");
luatreedir;
MV2 : 'integrate(fp(g(x))*gp(x), x, a, b) = 'integrate(fp(u), u, g(a), g(b));
luatree  (MV2);
luatree1d(luatree1d);
luatree  (luatree1d);
          luatree1d;
luatree  (luatree);
          luatree;

:lisp #$MV2$




#####
#
# My post to the mailing list explaining luatree
# 2022aug06
#
#####

# «luatree-explanation»  (to ".luatree-explanation")
# (find-maximamsg "37689770 202208 04" "Edrx: Basic question on paths")
# (find-maximamsg "37689986 202208 05" "Edrx: Problem solved!")
# (find-maximamsg "37690207 202208 05" "RDodier")
# (find-maximamsg "37690392 202208 06" "Edrx: I think that I found a way")
# (find-maximamsg "37690570 202208 06" "RDodier: lua_table_from(e) :=")
# (find-angg "luatree/luatree.mac")
# (find-angg "luatree/luatree.lisp")
# (find-angg "luatree/luatree.lua")

Hi Robert!

I think that I found a way to answer your question that makes the main
idea look portable to other languages. Let me try.

I usually program using REPLs from Emacs, with this:

  http://angg.twu.net/eepitch.html

My favorite programming language is Lua and my init file for Lua has
lots of functions and classes that I use often in throwaway programs.
If I just start a Lua REPL and type this in it,

  foo = {[0]="+", {[0]="*", "2", "3"}, {[0]="/", "4", "5"}, 6}
  print(SynTree.from(foo))

the first line sets foo to an associative table that I interpret as a
tree as:

  2*3 + 4/5 + 6

and the second line converts it to an object of the class SynTree in a
certain way and prints it using the __tostring method of the SynTree
class. What we see in the REPL buffer is this:

  Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
  > foo = {[0]="+", {[0]="*", "2", "3"}, {[0]="/", "4", "5"}, 6}
  > print(SynTree.from(foo))
  +_____._____.
  |     |     |
  *__.  /__.  6
  |  |  |  |
  2  3  4  5
  > 

The first version of my luatree.lua just read stdin, interpreted it as
a Lua expression, and ran something like this:

  print(SynTree.from(expressionreadfromstdin))

Then at some point I rewrote luatree.lua to make it self-contained,
i.e., independent of my init file, and it became this:

  http://angg.twu.net/luatree/luatree.lua.html

Note that at the end of luatree.lua there is a multi-line comment
containing this test,

  echo '{[0]="[", {[0]="/", "x", "y"}, "33"}' \
    | ./luatree.lua

that outputs this when I run it:

  [_____.
  |     |
  /__.  33
  |  |
  x  y

The function luatree1d in

  http://angg.twu.net/luatree/luatree.mac.html

receives a Maxima object and returns a string that is a
one-dimensional representation of a tree in Lua syntax - like the

  '{[0]="[", {[0]="/", "x", "y"}, "33"}'

in the "echo" above - and the function luatree, that is defined in
luatree.mac as:

  luatree : lambda([o], print(luatree_lua(luatree1d(o))), "");

calls luatree_lua to convert the 1D representation of a tree into a 2D
representation... and luatree_lua is defined in 

  http://angg.twu.net/luatree/luatree.lisp.html

as:

  (require :asdf)
  
  (defun luatree-lua (bigstr)
    (with-input-from-string
     (s bigstr)
     (reduce (lambda (a b) (format nil "~a~%~a" a b))
             (uiop:run-program
              (concatenate 'string #$luatreedir$ "luatree.lua")
              :input s :output :lines))))
  
  (defmfun $luatree_lua (str) (luatree-lua str))

This is my first Common Lisp program ever, and I had to ask for help
on IRC channels a lot to find this way to use uiop:run-program to pipe
a string through luatree.lua.

The class SynTree in luatree.lua builds the 2D representation of a
"syntax tree" by manipulation ascii rectangles that are objects of the
class Rect. Here is a demo that creates two Rect objects in a very
low-level way and then "concatenates" them:

  Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
  > r1 = Rect({"a", "bb", "ccc"}) 
  > r2 = Rect({"dd", "e"}) 
  > print(r1..r2)
  a  dd
  bb e
  ccc
  > 

Lua sees both r1 and r2 as tables, and the usual concatenation
operator - the ".." - doesn't know how to handle concatenation of
tables, so it calls the function __concat in the metatable of r1. I
don't know how to do something like that in Common Lisp, but I plan to
learn how to do that when I grow up. Help welcome! =P

About GraphViz: I'm interested! Please explain! =)
  Cheers,
    Eduardo




#####
#
# Robert Dodier's version of luatree
# 2022aug07
#
#####

# «luatree-rd»  (to ".luatree-rd")
# (find-maximamsg "37690570 202208 06" "RDodier: lua_table_from(e) :=")
# (find-angg     "luatree/luatree.mac")
# (find-anchor "~/luatree/luatree.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load ("~/luatree/luatree.mac");
luatree_rd (lambda([], 2*3 + 4/5 + 6));
luatree_rd (lambda([], x^y));
luatree_rd (lambda([], x[y]));   /* bad */

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load ("~/luatree/luatree.mac");
expr1 : lambda([], a*b + c/d + e);
expr2 : subst([a=x+y], expr1), simp:false;
expr3 : subst([a=2+3], expr1), simp:false;
luatree_rd(expr1);
luatree_rd(expr2);
luatree_rd(expr3);






#####
#
# luatree-2023
# 2023apr14
#
#####

# «luatree-2023»  (to ".luatree-2023")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "luatree/luatree.mac")
load       ("~/luatree/luatree.mac");
luatree(a+b);

'integrate(x^2, x);
'integrate(x^2, x, a, b);
 integrate(x^2, x);
 integrate(x^2, x, a, b);

luatree('integrate(x^2, x));
luatree('integrate(x^2, x, a, b));




#####
#
# mtree
# 2024jul12
#
#####

# «mtree»  (to ".mtree")
# (find-maximamsg "58794446 202407 12" "Edrx: a(b), a[b], op, args")
# (find-maximamsg "58794474 202407 12" "BWillis: subvarp")
# (find-maximamsg "58795759 202407 15" "Stavros: show_expression")
# (find-maximamsg "58805154 202408 12" "Edrx: trunc and taylor")
# (find-angg "MAXIMA/showexpression1.mac")
# (find-maximanode "subvarp")
# (find-maximanode "inflag")
# (find-angg "luatree/luatree2.mac")
# (find-angg "luatree/luatree2.mac" "tests")
# (find-angg ".maxima/maxima-init.mac")
# (to "subvarp")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
mtree(o) :=
  if atom(o) then concat("", o)
  elseif subvarp(o)  then append(["[_]", mtree(op(o))], map(mtree, args(o)))
  elseif atom(op(o)) then append([       mtree(op(o))], map(mtree, args(o)))
  else                    append(["ap",  mtree(op(o))], map(mtree, args(o)));

mtreetoluatree1d(m) :=
  if atom(m)
  then concat("\"", m, "\"")
  else concat("{[0]=", mapconcat(mtreetoluatree1d, m, ", "), "}");

luatree1d(o) := mtreetoluatree1d(mtree(o));

luatree1d(a(b,c));
mtree(a(b,c));

mtree(a[1][2](b,c));
luatree1d(a[1][2](b,c));




stringp("abx");

mtree(2);
mtree(a);
mtree(a[1]);
mtree(a[1][2]);
mtree(a(b,c));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
mtree1      : lambda([o], concat("", o));
mtreeop     : lambda([o], mtree1d(o));
mtreearg    : lambda([o], mtree1d(o));
mtreeargs   : lambda([L], map(mtreearg, L));
mtreeopargs : lambda([o], append([mtreeop(op(o))], mtreeargs(args(o))));
mtreeopargs : lambda([o], if atom(op(o))
                          then append(      [mtreeop(op(o))], mtreeargs(args(o)))
                          else append(["ap", mtreeop(op(o))], mtreeargs(args(o)));
mtree1d     : lambda([o], if atom(o) then mtree1(o) else mtreeopargs(o));

mtree1d(b(c,d));
mtree1d(b[1](c,d));
mtree1d(b[1]);
mtree1d(b(1));
mtree1d(f(2));
mtree1d(a*b);


a(b), a[b], op, args

Hi list,

"op" and "args" don't distinguish between a(b) and a[b]:

  (%i1) [o:a(b),op(o),args(o)];
  (%o1)                           [a(b), a, [b]]
  (%i2) [o:a[b],op(o),args(o)];
  (%o2)                            [a , a, [b]]
                                     b
  (%i3) 

what do I need to use to distinguish them?

Why I'm asking: there are several kinds of expressions that this
program - <http://anggtwu.net/eev-maxima.html#luatree> - doesn't
handle well... I'm trying to fix it.

  Thanks in advance!
    Eduardo =)







(%i1) o:a(b);    [op(o),args(o)];
(%o1)                                a(b)
(%o2)                              [a, [b]]
(%i3) o:a[b];    [op(o),args(o)];
(%o3)                                 a
                                       b
(%o4)                              [a, [b]]
(%i5) 

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
[o:a(b),op(o),args(o)];
[o:a[b],op(o),args(o)];

b(1);
b[1];

op(b[1]);
args(b[1]);
atom(b[1]);
atom(b);

mtree1d('(a*'b));
mtree1d(lambda([], a*'b));
mtree1d(lambda([], a*''b));
mtree1d(lambda([], a*`b));




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

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




#####
#
# part-and-inpart
# 2022jul10
#
#####

# «part-and-inpart»  (to ".part-and-inpart")
# (find-angg "MAXIMA/traverse.mac")
# (find-maximamsg "37678963 202207 10" "Stavros: quote, part, inpart")
# (find-maximamsg "37679111 202207 11" "Edrx: I wasn't even aware")
# (find-maximamsg "37679201 202207 11" "MTalon: structure ... internal form ***")
# (find-maximamsg "37679414 202207 11" "Stavros: shows most of the differences ***")
# (to "to_lisp")
# (find-maximanode "part")
# (find-maximanode "inpart")
# (find-maximanode "allbut")
# (find-maximanode "display_format_internal")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
ex1 : a+b*c;
part(ex1);
part(ex1, 0);
part(ex1, 1);
part(ex1, 2);
part(ex1, 1, 0);
part(ex1, 1, 1);
part(ex1, 1, 2);
ex1 : 1/a;
inpart(ex1, 0);
inpart(ex1, 1);
inpart(ex1, 2);
ex1 : a*b/c;
inpart(ex1, 0);
inpart(ex1, 1);
inpart(ex1, 2);
inpart(ex1, 3);
inpart(ex1, 3, 0);
:lisp #$ex1$




I don't know what exactly your goal is with *foo1* (maybe just a test), but
a few observations:

   - You should always quote literal constants, e.g., *action='op*, even
   though *op *evaluates to *op *if it's not bound to some value.
   Otherwise, if there happens to be a variable called *op* in your
   environment, you will get surprising results.
   - I hope you're aware that *op* and *args* work on the *external* form
   of an expression, which is designed for human consumption. The internal
   form is more uniform and generally better for automatic manipulation. You
   can get the internal form by binding *inflag* or by using the
*inpart* function:
   *op(1/a)=part(1/a,0)="/" *but *inpart(1/a,0)="^" *(*1/a = a^-1)*.
   - A useful argument for *part* is *allbut*, which is perversely
   documented under *allbut*, but not under *part*: *inpart(a*b/c,allbut(2))
   => a/c* (because *a*b/c* is internally *a*b*c^-1)*.
   - Unfortunately, there is not an *in* version of *args*. Maybe we should
   define *(in)part(...,allbut(0))* to be equivalent to *args(...)*.




#####
#
# substpart
# 2022aug06
#
#####

# «substpart»  (to ".substpart")
# (find-maximamsg "37690226 202208 05" "Stavros: substpart('t,y,2)")



#####
#
# swank / sly
# 2022aug19
#
#####

# «sly»    (to ".sly")
# «swank»  (to ".swank")
# (find-angg ".maxima/startsly.lisp")
# (find-maximamsg "37679359 202207 11" "MTalon: swank ***")
# https://def.fe.up.pt/pipermail/maxima-discuss/2012/042643.html
# (find-es "lisp" "quicklisp")
# (to "op-and-args")
# (find-try-sly-links)

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("startsly");
:lisp (describe '$changevar)

:lisp 

# (find-maximamsg "37679359 202207 11" "MTalon: swank ***")

* (sly-connect "localhost" 56789)
** (sly-edit-definition "dim-$matrix")





#####
#
# lisp-describe-tex
# 2023jul15
#
#####

# «lisp-describe-tex»  (to ".lisp-describe-tex")
# (find-maximamsg "37871261 202307 15" "Edrx: :lisp (describe '$tex)")
# (find-maximamsg "37871279 202307 15" "JPellegrini: defmspec")
# (find-maximamsg "37871290 202307 15" "RFateman: tex('integrate(f,x)= ratsimp(integrate(f,x)))")
# (find-maximamsg "37871320 202307 16" "RDodier: DEFMSPEC")

Hi list,

I just realized that I don't know how to go to the source of the "tex"
function... I did this,

  f  : x^3 * sqrt(1 - 4*x^2);
  F1 : 'integrate(f, x);
  F2 : changevar(F1, u=2*x, u, x);
  F3 : ev(F2, 'integrate);
  F4 : expand(F3);
  F5 : subst([u=2*x], F4);
  s  : sqrt(1-4*x^2);
  F6 : expand(F5/s)*s;
  tex(F6, false);

  :lisp (describe '$changevar)
  :lisp (describe '$tex)

and the ":lisp (describe '$changevar)" gave me lots of information:

  MAXIMA::$CHANGEVAR
    [symbol]
  
  $CHANGEVAR names a compiled function:
    Lambda-list: (&REST #:REST-ARG-1)
    Derived type: FUNCTION
    Source file: /home/edrx/bigsrc/maxima/src/outmis.lisp
  
  $CHANGEVAR has a compiler-macro:
    Documentation:
      Compiler-macro to convert calls to $CHANGEVAR to CHANGEVAR-IMPL
    Source file: /home/edrx/bigsrc/maxima/src/outmis.lisp
  
  Symbol-plist:
    SUBC -> NIL
    KIND -> (C)
    IMPL-NAME -> CHANGEVAR-IMPL
    TRANSLATED -> T
    ARG-LIST -> (EXPR TRANS NVAR OVAR)

when I'm connected to Sly I can type `M-.' on the "MAXIMA::$CHANGEVAR"
to go to the definition of changevar, and when I'm not using Sly I can
use the "/home/edrx/bigsrc/maxima/src/outmis.lisp" to go to the file
in which changevar is defined - so all good there. But the output of
":lisp (describe '$tex)" was just this:

  MAXIMA::$TEX
    [symbol]
  
  Symbol-plist:
    MFEXPR* -> #<FUNCTION (LAMBDA (L) :IN "/ho..

Is "tex" a different kind of function? Where can I read more about
that? What is the right way to inspect it?

  Thanks in advance!
    Eduardo Ochs
    http://angg.twu.net/eev-maxima.html




#####
#
# defmspec
# 2023jul15
#
#####

# «defmspec»  (to ".defmspec")
# (find-maximamsg "37871279 202307 15" "JPellegrini: defmspec")
# (find-maximamsg "37871320 202307 16" "RDodier: DEFMSPEC")
# (find-maximamsg "37871361 202307 16" "Edrx: found 153")
# (find-maximagitgrep "grep --color=auto -niRH --null -e defmspec *")
# (find-maximagitgrep "grep --color=auto -niH --null -e defmspec $(find * | grep 'lisp$')")
# (find-maximagitfile "src/mactex.lisp")
# (find-maximagitfile "src/mactex.lisp" "(defmspec $tex(l)")

* (eepitch-sly)
* (eepitch-kill)
* (eepitch-sly)
(apropos 'describe-function-source)
(symbol-function 'describe)
(sb-impl::describe-function-source 'describe nil)
(sb-impl::describe-function-source (symbol-function 'describe) nil)

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
tex(x^2, false);
to_lisp()$
  (describe '$changevar)
  (describe '$tex)
  (symbol-plist '$tex)
  (get '$tex 'mfexpr*)
  (describe (get '$tex 'mfexpr*))
  (to-maxima)

Hi Jeronimo and Robert,

I grepped the sources and (I think that I) found 153 Maxima functions
that are defined using defmspec... it would be good to have a nice way
to jump to their sources, but I confess that I would be happy with a
non-nice way, too. I just found that if I run this,

  to_lisp()$
    (describe '$changevar)
    (describe '$tex)
    (symbol-plist '$tex)
    (get '$tex 'mfexpr*)
    (to-maxima)

the output of the "(get '$tex 'mfexpr*)" is:

  #<FUNCTION (LAMBDA (L) :IN "/home/edrx/bigsrc/maxima/src/mactex.lisp") {52FB567B}>

how do I extract the "/home/edrx/bigsrc/maxima/src/mactex.lisp" from
that?

  Thanks in advance =P,
    Eduardo Ochs




#####
#
# describe-mfexpr
# 2023jul16
#
#####

# «describe-mfexpr»  (to ".describe-mfexpr")
# «fapply»  (to ".fapply")
# (find-maximamsg "37871477 202307 16" "RToy: (describe (get '$tex 'mfexpr*))")
# (find-maximamsg "37871481 202307 16" "Edrx: (defun describe-mfexpr ")
# (find-maximamsg "37871601 202307 17" "BWillis: (do-symbols (s (find-package")
# (find-maximamsg "37871681 202307 17" "DBillinghurst: fapply")
# (find-maximagitfile "src/mopers.lisp")

Hi Raymond! Hey, thanks!
SBCL. I got this a few minutes before your answer:

  to_lisp()$
    (defun describe-mfexpr (symbol)
      (sb-impl::describe-function-source
        (get symbol 'mfexpr*) nil))
    (describe-mfexpr '$tex)
    (to-maxima)

But your suggestions are much better:

  (describe (get '$tex 'mfexpr*))
  (inspect  (get '$tex 'mfexpr*))

  (defun describe-mfexpr (symbol) (describe (get symbol 'mfexpr*)))
  (describe-mfexpr '$tex)

Cheers! =)
  Eduardo


Hi Barton!
That's super neat!!! =)
But I don't have fapply here... can you send your definition?
Here's a version that works, but in which the fapply was
(re)constructed by guesswork:

  to_lisp()$
  
    (defun fapply (op lst) `((,op simp) ,@lst))
  
    (defun $defmspec_list ()
      (let ((lst nil))
        (do-symbols (s (find-package "MAXIMA"))
          (when (get s 'mfexpr*)
            (push s lst)))
        (fapply 'mlist lst)))
  
    (to-maxima)
  
  defmspec_list();
  sort(defmspec_list());

Cheers, thanks, etc =),
  Eduardo




#####
#
# sas
# 2023jul16
#
#####

# «sas»  (to ".sas")
# (find-maximamsg "37871360 202307 16" "Edrx: Here is a _VERY_ bare prototype")
# (find-maximamsg "37871501 202307 16" "RDodier: printf")
# (find-maximamsg "37871523 202307 16" "Edrx: Fantastic, thanks! / step-by-step")

# (find-maximanode "tex1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f  : x^3 * sqrt(1 - 4*x^2);
F1 : 'integrate(f, x);
F2 : changevar(F1, u=2*x, u, x);
F3 : rootscontract(F2);
F4 : ev(F3, 'integrate);
F5 : expand(F4);
F6 : subst([u=2*x], F5);
s  : sqrt(1-4*x^2);
F7 : expand(F6/s)*s;

nl : "
"$
tex0(ex) := block([s,len],
  s : tex(ex,false),
  len : slength(s),
  substring(s,3,len-2))$
sa2(name,ex)   := sconcat(nl, "\\sa{", name, "}{", tex0(ex), "}")$
sa2(name,ex)   := printf(false, "~%\\sa{~a}{~a}", name, tex1(ex))$
sa1(nameex)    := apply('sa2, nameex)$
sas([nameexs]) := apply('sconcat, map('sa1, nameexs))$

sas(["F1", F1],
    ["F3", F3],
    ["F7", F7]);



% Usage:
%   \sa{42}{foo bar}
%   \ga{42}
% is roughly equivalent to this,
%   \def\myarg42{foo bar}
%   \myarg42
% but with the "4" and the "2" being treated as letters. 
\def\sa#1#2{\expandafter\def\csname myarg#1\endcsname{#2}}
\def\ga#1{\csname myarg#1\endcsname}

\sa{F1}{\int {x^3\,\sqrt{1-4\,x^2}}{\;dx}}
\sa{F3}{{{\int {u^3\,\sqrt{1-u^2}}{\;du}}\over{16}}}
\sa{F7}{\sqrt{1-4\,x^2}\,\left({{x^4}\over{5}}-{{x^2}\over{60}}-{{1}\over{
 120}}\right)}

$$\begin{array}{l}
  \ga{F1} \\
  = \ga{F3} \\
  = \ga{F7} \\
  \end{array}
$$





#####
#
# parentheses
# 2022jul09
#
#####

# «parentheses»  (to ".parentheses")
# (find-maximanode "op")
# (find-maximanode "arg")
# (find-maximanode "declare_index_properties")
# (find-maximanode "Functions and Variables for Display")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
simp : false;
a : b + c * d^e;
op(a);
args(a);
args(a)[1];




#####
#
# Change of variable in the definite integral, as a tree
# 2022jul12
#
#####

# «MV2-tree»  (to ".MV2-tree")
# (c2m221ftp 5 "MVs" "[MV2]")
# (to "op-and-args")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
foo1 : lambda([o, action],
  if     action = 'op   then op(o)
  elseif action = 'args then args(o)
  else   args(o)[action]);
foo(a, [b]) := xreduce(foo1, b, a);
simp : true;
simp : false;
MV2 : 'integrate(fp(g(x))*gp(x), x, a, b) = 'integrate(fp(u), u, g(a), g(b));
:lisp #$MV2$
simp : true;
foo(MV2, op);
foo(MV2, 1);
foo(MV2, 1, op);
foo(MV2, 1, args);
foo(MV2, 1, 1);
foo(MV2, 1, 1, op);
foo(MV2, 1, 1, args);
foo(MV2, 1, 1, 1);
foo(MV2, 1, 1, 1, op);
foo(MV2, 1, 1, 1, 1);

* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
-- (find-angg "LUA/Rect.lua" "SynTree-tests" "SynTree.from(s0)")
-- (find-angg "LUA/SynTreeV1.lua")
eq  = function (a, b)   return {[0]="=", a, b} end
mul = function (a, b)   return {[0]="*", a, b} end
app = function (f, arg) return {[0]=f, arg} end
f   = function (arg) return app("f ", arg) end
fp  = function (arg) return app("fp", arg) end
g   = function (arg) return app("g",  arg) end
gp  = function (arg) return app("gp", arg) end
int = function (f, x, a, b) return {[0]="int", f, x, a, b} end
x,u,a,b = "x","u","a","b"
intl = int(mul(fp(g(x)),gp(x)),x,a,b)
intr = int(fp(u),u,g(a),g(b))
MV2  = eq(intl,intr)
= SynTree.from(intl)
= SynTree.from(MV2)






#####
#
# Obtaining trigonometric identities with E and E^-1
# 2021dec17
#
#####

# «E-and-Einv»  (to ".E-and-Einv")
# Superseded by: (to "laurent")
#                (to "trig-ids")
# (find-angg "MAXIMA/myexptrick.mac")
# (find-xpdfpage "~/LATEX/2018-2-C2-P1.pdf")
# (find-xpdfpage "~/LATEX/2019-2-C2-P1.pdf")
# (find-LATEX "2018-2-C2-P1.tex" "gab-1")
# (find-LATEX "2018-2-C2-P1.tex" "gabarito-maxima")
# (find-LATEX "2019-2-C2-P1.tex" "gabarito")
# (find-LATEX "2019-2-C2-P1.tex" "gabarito-maxima")
# (c2m192p1p 4 "gabarito-maxima")
# (c2m192p1a   "gabarito-maxima")
# (find-es "ipython" "2018.2-C2-VS")
# (find-es "ipython" "2018.2-C2-VS" "E,Einv =")
# (find-maximanode "Introduction to Simplification" "demoivre:true")
# (find-maximanode "Functions and Variables for Simplification" "Function: exponentialize")
# (find-maximagitfile "doc/share/brchre.txt" "define rules of their own")
# (find-maximagitfile "")
# (find-maximagitsh "find * | sort | grep mac")
# (find-maximagitsh "find * | sort | grep mac | grep calculus")
# (find-maximagitgrep "grep --color=auto -nirH --null -e exponentialize *")
# (find-maximagitgrep "grep --color=auto -nirH --null -e demoivre *")
# (find-maximagitgrep "grep --color=auto -nirH --null -e 'defmfun $coeff' *")
# (find-maximagitgrep "grep --color=auto -nirH --null -e 'defmfun $ratcoef' *")
# (find-maximagitfile "src/csimp.lisp" "defmfun $demoivre")
# (find-maximagitfile "src/nrat4.lisp" "defmfun $ratcoef")
# (find-maximanode "Functions and Variables for Polynomials" "Function: coeff")
# (find-maximanode "Functions and Variables for Polynomials" "Function: ratcoef")

# (find-angg "MAXIMA/myexptrick.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("~/MAXIMA/myexptrick.mac");

f : sin(x)^4 * cos(x)^2;
g : expand(exponentialize(f));
ratcoeff(g, exp(%i*x), 0);
ratcoeff(g, exp(%i*x), 6);

h : subst(exp(%i*x)=z, g);
h : subst(x=-%i*log(z), g);

h : myexptrick(f);
ff(t) := subst([x=t], f);
hh(t) := subst([x=t], h);
plot2d ([ff(x), hh(x)], [x, 0, 2*%pi]);

coeff(g, x, 0);


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f : sin(x)^4 * cos(x)^2;
g : expand(exponentialize(f));
h : expand(demoivre(g));

myexptrick(f) := expand(demoivre(expand(exponentialize(f))));
myexptrick(sin(x)^4 * cos(x)^2);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
exp(2);
exp(%i * %pi);
E(k) := exp(k * t * %pi * %i);
C(k) := (E(k) + E(-k)) / 2;
C(1);
subst(1,   t, C(1));
subst(1/4, t, C(1));

f : cos(2*x);
f : cos(2*x) * sin(3*x);
exponentialize(f);
g : expand(exponentialize(f));
demoivre(g);

coeff(g, exp( 5 * %i * x));
coeff(g, exp(-5 * %i * x));

remfun1(fun,exp):=scanmap(lambda([q],delfun1(fun,q)),exp)$


# (find-maximagitsh "find * | sort | grep mac | grep calculus")
# (find-maximanode "Introduction to Expressions")
# (find-maximanode "Introduction to Expressions" "for i from")
# (find-maximanode "Functions and Variables for Function Definition" "Function: block")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
myexptrickcos(k, coefplus) := coefplus * cos(k * x) / 2$
myexptricksin(k, coefplus) := coefplus * sin(k * x) / (2 * %i)$
myexptricksel(k, coefplus, coefminus) :=
  if coefplus = coefminus
  then myexptrickcos(k, coefplus)
  else myexptricksin(k, coefplus)$
myexptrickcoeff(f, k) := coeff(f, exp(k * %i * x));
myexptrickself (f, k) :=
  myexptricksel(k, myexptrickcoeff(f, k),
                   myexptrickcoeff(f, -k))$

for k from 5 thru 7 do (print(k, k*10))$
for k from 0 thru 20 do (print(myexptrickself(g, k)))$
g;
myexptrickself(g, 5);

(total:0, for k from 0 thru 20 do (total: total + k), total);
(total:0, for k from 0 thru 20 do (print(myexptrickself(g, k))), total);
(total:0, for k from 0 thru 20 do (total: total + myexptrickself(g, k)), total);

myexptrick(cos(2*x));

f : cos(2*x) * sin(3*x);
g : expand(exponentialize(f));
myexptricksel(5, 10, 10);
myexptricksel(5, 10, -10);
myexptrickself(g, 5);
myexptrick(g);
myexptricksel(4, -5, -5);
myexptricksel(4, -5,  5);

sum (myexptrickself(g, k), k, 0, 10);








#####
#
# My e-mail about myexptrick to the Maxima mailing list
# 2022jan03
#
#####

# «myexptrick-email»  (to ".myexptrick-email")
# (find-maximamsg "37411162 202201 04" "Edrx: then I discovered")
# Subj: Extracting the constant from a sum of exponentials 
# then I discovered that I can replace it by this one-line program...

Thanks, Michael and Richard!

Just as a curiosity - and for the sake of completeness, and because
it's fun - let me explain why I needed this. I teach Calculus 2, and
all the books that I know say that to integrate polynomials of
"sin(k*x)"s and "cos(k*x)"s you have to apply some standard
trigonometric identities as many times as needed, and hope that at
some point you get something that you know how to integrate. I don't
like that method, so I teach an alternative... I was trying to write a
program that performs the alternative method that I like, and I was
able to write something - ugly, but it was my first program in Maxima!
- that gave the right results except for the "constant" part... and
then I discovered that I can replace it by this one-line program:

  myexptrick(f) := expand(demoivre(expand(exponentialize(f))));

So, in

  f : sin(x)^4 * cos(x)^2;
  g : expand(exponentialize(f));
  ratcoeff(g, exp(%i*x), 0);
  v : subst([x=-%i*log(z)], g);
  vt : taylor(v, z, 0, 10);
  coeff(vt, z, 0);

  myexptrick(f) := expand(demoivre(expand(exponentialize(f))));
  h : myexptrick(f);
  plot2d([f, h], [x, 0, 2*%pi]);

the line with "ratcoeff" implements Michael's suggestion, and the
lines with "v" and "vt" implement Richard's suggestion. The lines with
"myexptrick" convert the function f to the normal form that I was
looking for, and the "plot2d" is a good way to give to students some
evidence that at least in this case "myexptrick" returns an output
that is equivalent to its input...

  Cheers and thanks again =),
    Eduardo Ochs
    http://angg.twu.net/#eev
    http://angg.twu.net/eev-maxima.html




#####
#
# trigexpand
# 2022jan10
#
#####

# «trigexpand»  (to ".trigexpand")
# (find-maximamsg "37415086 202201 10" "R Toy: trigexpand")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
? trigexpand



#####
#
# trig-ids
# 2022jan03
#
#####

# «trig-ids»  (to ".trig-ids")
# Supersedes: (to "E-and-Einv")
# See: (c2m192p1p 4 "gabarito-maxima")
#      (c2m192p1a   "gabarito-maxima")
# (find-books "__analysis/__analysis.el" "hernandez")
# (find-hernandezpage (+ 10  47) "6 Integrais de Funções Trigonométricas")
# (find-maximanode "expand")
# (find-maximanode "demoivre")
# (find-maximanode "exponentialize")
# (find-maximanode "subst")
# (find-maximanode "%edispflag")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
myexptrick1(f) :=                        exponentialize(f);
myexptrick2(f) :=                 expand(exponentialize(f));
myexptrick3(f) :=        demoivre(expand(exponentialize(f)));
myexptrick(f)  := expand(demoivre(expand(exponentialize(f))));
xtoE(f)        := subst([x=log(E)/%i], f);

** (c2m192p1p 4 "gabarito-maxima")
** (c2m192p1a   "gabarito-maxima")
**
f : sin(5*x)^2 * cos(6*x)^2;
     myexptrick1(f);
     myexptrick2(f);
xtoE(myexptrick2(f));
xtoE(myexptrick2(f));
     myexptrick3(f);
     myexptrick(f);
integrate(myexptrick(f), x);

f : sin(x)^2 + cos(x)^2;
myexptrick(f);
f : sin(x)^2;
myexptrick(f);
f : cos(x)^2;
myexptrick(f);
f : sin(m*x) * cos(n*x);
myexptrick(f);
f : cos(x)^3;
myexptrick(f);

f : cos(x)^3 * sin(x)^2;
     myexptrick1(f);
     myexptrick2(f);
xtoE(myexptrick2(f));
     myexptrick3(f);
     myexptrick(f);

f : sin(x)^3 / 3 - sin(x)^5 / 5;
     myexptrick(f);
diff(myexptrick(f), x);
f : cos(x)^4;
myexptrick(f);
f : sin(x)^6;
myexptrick(f);



#####
#
# int-pow-sin-cos
# 2022sep22
#
#####

# «int-pow-sin-cos»  (to ".int-pow-sin-cos")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(kc,ks) := cos(x)^kc * sin(x)^ks;
F(kc,ks) := integrate(f(kc,ks), x);
F(0,1);
F(0,3);
F(0,5);
F(1,0);
F(1,1);
F(1,2);
F(1,3);
F(1,4);
F(1,5);
F(2,1);
F(2,3);
F(2,5);
F(3,0);
F(3,1);
F(3,2);
F(3,3);
F(3,4);
F(3,5);





#####
#
# books
# 2021dec21
#
#####

# «books»  (to ".books")
# (find-books "__comp/__comp.el" "maximabook")
# (find-books "__comp/__comp.el" "maxima-urroz")



#####
#
# Minimal Maxima, by Robert Dodier
# 2023oct10
#
#####

# «minimal-maxima»  (to ".minimal-maxima")
# (find-books "__comp/__comp.el" "maxima-minimal")
# https://maxima.sourceforge.io/documentation.html
# https://maxima.sourceforge.io/docs/tutorial/en/minimal-maxima.pdf
# (code-pdf-page "minimaxima" "$S/https/maxima.sourceforge.io/docs/tutorial/en/minimal-maxima.pdf")
# (code-pdf-text "minimaxima" "$S/https/maxima.sourceforge.io/docs/tutorial/en/minimal-maxima.pdf")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* (find-minimaximapage 1 "1       What is Maxima?")
 * (find-minimaximatext 1 "1       What is Maxima?")
*/
V: 4/3 * %pi * r^3;
r: 10;
V;
''V;
''V, numer;

/* (find-minimaximapage 2 "2     Expressions")
 * (find-minimaximatext 2 "2     Expressions")
*/
[a, foo, foo_bar, "Hello, world!", 42, 17.29];

[a + b + c, a * b * c, foo = bar, a*b < c*d];

L:  [a, b,  c, %pi,  %e, 1729,  1/(a*d - b*c)];
L2: [a, b, [c, %pi, [%e, 1729], 1/(a*d - b*c)]];
L   [7];
L2  [3];
M:  matrix ([%pi, 17], [29, %e]);
M2: matrix ([[%pi, 17], a*d - b*c], [matrix ([1, a], [b, 7]), %e]);
M  [2][1];
M2 [2][1];

(a: 42) - (b: 17);
[a, b];
block ([a], a: 42, a^2 - 1600) + block ([b], b: 5, %pi^b);
(if a > 1 then %pi else %e) + (if b < 0 then 1/2 else 1/7);

op (p + q);
op (p + q > p*q);
op (sin (p + q));
op (foo (p, q));
op (foo (p, q) := p - q);
args (p + q);
args (p + q > p*q);
args (sin (p + q));
args (foo (p, q));
args (foo (p, q) := p - q);
atom (p);
atom (p + q);
atom (sin (p + q));

op ('(block ([a], a: 42, a^2 - 1600)));
op ('(if p > q then p else q));
op ('(for x in L do print (x)));
args ('(block ([a], a: 42, a^2 - 1600)));
args ('(if p > q then p else q));
args ('(for x in L do print (x)));

block (a: 1, b: 2, e: 5);
[a, b, c, d, e];

  block (x: %pi, y: %e);
  sin (x + y);
  x > y;
  x!;

  foo (p, q) := p - q;
  p: %phi;
  foo (p, q);
  bar (p, q);

  block (a: 1, b: %pi, c: x + y);
  [a, b, c];
  save ("tmp.save", a, b, c);
  f (a) := a^b;
f (7);
kill (a, b, c);
[a, b, c];

  foo (x, y) := y - x;
  block (a: %e, b: 17);
  foo (a, b);
  foo ('a, 'b);
  'foo (a, b);
  '(foo (a, b));

diff (sin (x), x);
foo (x) := diff (sin (x), x);
foo (x) := ''(diff (sin (x), x));

/* (find-minimaximapage 6 "3      Evaluation")
 * (find-minimaximatext 6 "3      Evaluation")
*/
block (xx: yy, yy: zz);
[xx, yy];
foo (x) := ''x;
foo (xx);
bar (x) := ev (x);
bar (xx);

(%i1)   block (a: aa, b: bb, c: cc);
(%i2)   block (aa: 11, bb: 22, cc: 33);
(%i3)   [a, b, c, aa, bb, cc];
(%i4)   apply (kill, [a, b, c]);
(%i5)   [a, b, c, aa, bb, cc];
(%i6)   kill (a, b, c);
(%i7)   [a, b, c, aa, bb, cc];

(%i1) integrate (sin (a*x), x, 0, %pi);
(%i2) foo (x) := integrate (sin (a*x), x, 0, %pi);
(%i3) define (foo (x), integrate (sin (a*x), x, 0, %pi));

/* (find-minimaximapage 10 "4     Simplification")
 * (find-minimaximatext 10 "4     Simplification")
*/
(%i1) '[1 + 1, x + x, x * x, sin (%pi)];
(%i2) simp: false$
(%i3) block ([x: 1], x + x);

(%i1) (a + b)^2;
(%i2) expand (%);
(%i3) a/b + c/b;
(%i4) ratsimp (%);
(%i5) sin (2*x);
(%i6) trigexpand (%);
(%i7) a * exp (b * %i);
(%i8) demoivre (%);

/* (find-minimaximapage 11 "5     apply, map, and lambda")
 * (find-minimaximatext 11 "5     apply, map, and lambda")
*/
(%i1) apply (sin, [x * %pi]);
(%i2) L: [a, b, c, x, y, z];
(%i3) apply ("+", L);

(%i1) map (foo, [x, y, z]);
(%i2) map ("+", [1, 2, 3], [a, b, c]);
(%i3) map (atom, [a, b, c, a + b, a + b + c]);

(%i1) f: lambda ([x, y], (x + y)*(x - y));
(%i2) f (a, b);
(%i3) apply (f, [p, q]);
(%i4) map (f, [1, 2, 3], [a, b, c]);

/* (find-minimaximapage 12 "6      Built-in object types")
 * (find-minimaximatext 12 "6      Built-in object types")
*/

/* (find-minimaximapage 13 "7      How to...")
 * (find-minimaximatext 13 "7      How to...")
*/
(%i1) foo (x) := diff (sin(x)^2, x);
(%i2) foo (u);
(%i3) foo (1);

(%i1) define (foo (x), diff (sin(x)^2, x));
(%i2) foo (u);
(%i3) foo (1);

/* (find-minimaximapage 14 "7.3    Integrate and differentiate")
 * (find-minimaximatext 14 "7.3    Integrate and differentiate")
*/
(%i1) eq_1: a * x + b * y + z = %pi;
(%i2) eq_2: z - 5*y + x = 0;
(%i3) s: solve ([eq_1, eq_2], [x, z]);
(%i4) length (s);
(%i5) [subst (s[1], eq_1), subst (s[1], eq_2)];
(%i6) ratsimp (%);

(%i1) integrate (1/(1 + x), x, 0, 1);
(%i2) integrate (exp(-u) * sin(u), u, 0, inf);
(%i3) assume (a > 0);
(%i4) integrate (1/(1 + x), x, 0, a);
(%i5) integrate (exp(-a*u) * sin(a*u), u, 0, inf);
(%i6) integrate (exp (sin (t)), t, 0, %pi);
(%i7) 'integrate (exp(-u) * sin(u), u, 0, inf);

(%i1) diff (sin (y*x));
(%i2) diff (sin (y*x), x);
(%i3) diff (sin (y*x), y);
(%i4) diff (sin (y*x), x, 2);
(%i5) 'diff (sin (y*x), x, 2);

/* (find-minimaximapage 16 "7.4     Make a plot")
 * (find-minimaximatext 16 "7.4     Make a plot")
*/
(%i1) plot2d (exp(-u) * sin(u), [u, 0, 2*%pi]);
(%i2) plot2d ([exp(-u), exp(-u) * sin(u)], [u, 0, 2*%pi]);
(%i3) xx: makelist (i/2.5, i, 1, 10);
(%i4) yy: map (lambda ([x], exp(-x) * sin(x)), xx);
(%i5) plot2d ([discrete, xx, yy]);
(%i6) plot2d ([discrete, xx, yy], [gnuplot_curve_styles, ["with points"]]);

/* (find-minimaximapage 16 "7.5     Save and load a file")
 * (find-minimaximatext 16 "7.5     Save and load a file")
*/
(%i1) a: foo - bar;
(%i2) b: foo^2 * bar;
(%i3) save ("my.session", a, b);
(%i4) save ("my.session", all);

(%i1) load ("my.session");

(%i5) a;
(%i6) b;

/* (find-minimaximapage 17 "8     Maxima programming")
 * (find-minimaximatext 17 "8     Maxima programming")
*/
(%i1) (x: 42, y: 1729, z: foo*bar);
(%i2) f (x, y) := x*y*z;
(%i3) f (aa, bb);
(%i4) lambda ([x, z], (x - z)/y);
(%i5) apply (%, [uu, vv]);
(%i6) block ([y, z], y: 65536, [x, y, z]);

(%i1)   foo (y) := x - y;
(%i2)   x: 1729;
(%i3)   foo (%pi);
(%i4)   bar (x) := foo (%e);
(%i5)   bar (42);

(%i1) (aa + bb)^2;
(%i2) :lisp $%

(%i1) :lisp (defun $foo (a b) `((mplus) ((mtimes) ,a ,b) $%pi))

(%i1) (p: x + y, q: x - y);
(%i2) foo (p, q);

(%i1) :lisp (defmspec $bar (e) (let ((a (cdr e))) `((mplus) ((mtimes) ,@a)
(%i1) bar (p, q);
(%i2) bar (''p, ''q);
(%i1) blurf (x) := x^2;
(%i2) :lisp (displa (mfuncall '$blurf '((mplus) $grotz $mumble)))




#####
#
# Gilberto Urroz's draft Maxima book
# 2009sep16 / 2021dec17
#
#####

# «gurro-book»  (to ".gurro-book")
# https://maxima.sourceforge.io/documentation.html
# https://maxima.sourceforge.io/misc/maxima-opinions.pdf
# https://maxima.sourceforge.io/docs/maximabook/maximabook-19-Sept-2004.pdf


# https://home.csulb.edu/~woollett/
# https://home.csulb.edu/~woollett/mbe.html
# https://maxima.sourceforge.io/docs/manual/intromax.pdf
# https://maxima.sourceforge.io/docs/tutorial/en/minimal-maxima.pdf

http://servidor.demec.ufpr.br/disciplinas/EngMec_NOTURNO/TM350/SMath/SMathStudio.0_85.Article.Eng.pdf

# (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-workbook
# 2022jul23
#
#####

# «maxima-workbook»  (to ".maxima-workbook")
# (find-books "__comp/__comp.el" "maxima-workbook")
# (find-angg "blogme3/sandwiches-defs.lua" "code-pdf-page-tests")
# http://roland-salz.de/html/maxima.html
# http://roland-salz.de/Maxima_Workbook.pdf
# https://roland-salz.de/Maxima_Workbook.pdf

# (code-pdf-page "maximawb" "$S/http/roland-salz.de/Maxima_Workbook.pdf")
# (code-pdf-text "maximawb" "$S/http/roland-salz.de/Maxima_Workbook.pdf" 19)
# (code-pdf-page "maximawb" "$S/https/roland-salz.de/Maxima_Workbook.pdf")
# (code-pdf-text "maximawb" "$S/https/roland-salz.de/Maxima_Workbook.pdf" 20)
;; (find-maximawbpage 1)
;; (find-maximawbtext)

# (find-escript-upload-links "maxima" "maxima-workbook")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
makeL
makeR
makeR1  e/maxima.e.html
# file:///home/edrx/TH/R/e/maxima.e.html#maxima-workbook




#####
#
# Book - Classical Differential Geometry with Maxima
# 2023apr01
#
#####

# «diffgeo-of-surfaces»  (to ".diffgeo-of-surfaces")
# https://georgeweigt.github.io/Lindner/DiffGeo-of-Surfaces-Maxima.pdf
# https://georgeweigt.github.io/Lindner/
# https://georgeweigt.github.io/
# https://sourceforge.net/p/maxima/mailman/message/37798754/
# https://sourceforge.net/p/maxima/mailman/message/37798791/
# (find-maximamsg "37798754 202304 01" "WLindner: Classical Differential Geometry with Maxima")
# (find-maximamsg "37798791 202304 01" "RDodier: Classical Differential Geometry with Maxima")

https://independent.academia.edu/LindnerDrWolfgang



#####
#
# diffeqs-maxima
# 2023jun23
#
#####

# «diffeqs-maxima»  (to ".diffeqs-maxima")
# (find-books "__comp/__comp.el" "maxima-diffeqs")
# [Maxima-discuss] Introductory Differential Equations with Maxima
# https://mail.google.com/mail/u/0/#inbox/FMfcgzGsnLFHrMPlXVPMxJvpSzgVPZlW
# https://sourceforge.net/p/maxima/mailman/maxima-discuss/thread/3001e919-eed6-6d42-3c1b-cfcac190592a%40gmail.com/#msg37860621
# https://lindnerdrwg.github.io/DifferentialEquationsMaxima.pdf
# https://lindnerdrwg.github.io/
# (find-maximamsg "37860110 202306 20" "WLindner: Introductory Differential Equations with Maxima")
# (find-maximamsg "37860338 202306 20" "RFateman: Introductory DE")



#####
#
# Justin R. Smith: "Adventures with Free Mathematical Software"
# 2023apr08
#
#####

# «advfree»  (to ".advfree")
# (find-books "__comp/__comp.el" "maxima-advfree")
# (find-maximamsg "37801439 202304 08" "JSmith: New book on Maxima Applications (wxMaxima)")
# (find-advfreepage (+ 16 16) "we need if-statements")
# (find-advfreetext (+ 16 16) "we need if-statements")
# http://www.five-dimensions.org/Textbooks/adventures.pdf

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(x) := if (x<-1) then 0
        else if (x<0) then 1
        else if (x<=1) then x^2
        else 0;
plot2d('f(x), [x,-5,5]);




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

# «maxima-cvs»  (to ".maxima-cvs")
# http://maxima.sourceforge.net/download.html

# (find-fline "~/usrc/maxima-cvs/usr/bin/")
(defun eepitch-maximacvs () (interactive)
  (eepitch-comint "maximacvs" "~/usrc/maxima-cvs/usr/bin/maxima"))

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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));




#####
#
# maxima-git
# 2021dec18
#
#####

# «maxima-git»  (to ".maxima-git")
# (find-angg ".emacs" "maxima-git")
# https://maxima.sourceforge.io/download.html
# https://sourceforge.net/p/maxima/code/ci/master/tree/
# git clone https://git.code.sf.net/p/maxima/code maxima-code
# (find-git-links "https://git.code.sf.net/p/maxima/code" "maximagit")
# (find-gitk  "~/bigsrc/maxima/")

* (eepitch-shell3)
* (eepitch-kill)
* (eepitch-shell3)
cd ~/bigsrc/
git clone https://git.code.sf.net/p/maxima/code maxima
cd ~/bigsrc/maxima/
git pull
git checkout lexical-symbols
git checkout 5.47.0
git checkout master
git pull

export PAGER=cat
git branch --list -a
git for-each-ref
git log --oneline --graph --all -20

cd ~/bigsrc/maxima/
git checkout master

cd ~/bigsrc/maxima/
git clean -dfx
git reset --hard
git pull
find * | sort                 > .files
find * | sort | grep '.lisp$' > .files.lisp
find * | sort | grep '.mac$'  > .files.mac
./bootstrap               |& tee ob
./configure --help        |& tee och
./configure --enable-sbcl |& tee oc
./configure --enable-gcl  |& tee oc
make                      |& tee om
sudo make install         |& tee omi

 /usr/bin/install -c -m 644

# (find-status   "maxima")
# (find-vldifile "maxima.list")
# (find-udfile   "maxima/")

apti gcl gcl-doc

# (find-maximagitfile "omi")
# (find-maximagitfile "omi" "/usr/local/share/maxima/branch_5_47_base_1316_g59adc2c4c/")
# (find-maximagitfile "omi" "/usr/local/share/maxima/branch_5_47_base_1348_g39c0ffa27/")
# (find-fline               "/usr/local/share/maxima/branch_5_47_base_1316_g59adc2c4c/")
# (find-fline               "/usr/local/share/maxima/branch_5_47_base_1348_g39c0ffa27/")
# (find-fline "/usr/local/bin/maxima")
# (find-fline "/usr/local/bin/maxima" "MAXIMA_VERSION=")
make check

# (find-fline      "/var/lib/dpkg/status")
# (find-fline "/sda1/var/lib/dpkg/status")

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


make                |& tee om
make                |& tee omh

cd ~/bigsrc/maxima/
git checkout 5.46.0
git checkout master
git checkout lexical-symbols
git clean -dfx
git reset --hard
# (find-maximagitsh "find * | sort")
# (find-maximagitfile "doc/info/maxima-index.lisp")
make                |& tee om
make                |& tee omh

cd ~/bigsrc/maxima/
git checkout master
git clean -dfx
git reset --hard

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-es "git" "very-hard-reset")
# (find-maximagitfile "INSTALL")
# (find-maximagitfile "INSTALL" "IF CONFIGURE SCRIPT IS PRESENT")
# (find-maximagitsh   "./configure --help")
# (find-maximagitfile "oc")
# (find-maximagitfile "och")
# (find-maximagitfile "om")
# (find-maximagitfile "om" "makeinfo")
# (find-maximagitfile "om" "makeinfo --html -c TEXI2HTML=1 --split=chapter")
# (find-maximagitfile "omi")
# (find-maximagitgrep "grep --color=auto -nRH --null -e '--split=chapter' *")
# (find-maximagitgrep "grep --color=auto -nRH --null -e branch_5_45_base *")
# (find-maximagitgrep "grep --color=auto -nRH --null -e verpkglibdir *")
# (find-maximagitgrep "grep --color=auto -nRH --null -e checkinst *")
# (find-maximagitfile "Makefile" "verpkglibdir =")
# (find-maximagitfile "doc/info/Makefile")
# (find-maximagitfile "doc/info/Makefile.am")
# (find-maximagitfile "doc/info/Makefile.in")
# (find-maximagitfile "doc/info/build_html.sh")
# (find-maximagitfile "doc/info/build_html.sh" "--no-node-files so")
# (find-maximagitfile "doc/info/")
# (find-maximagitfile "missing")
# (find-maximagitfile "Makefile")
# file:///home/edrx/bigsrc/maxima/doc/info/maxima_75.html
# (find-gitk "~/bigsrc/maxima/")

* (eepitch-shell3)
* (eepitch-kill)
* (eepitch-shell3)
cd ~/bigsrc/maxima/
git checkout master
git clean -dfx
git reset --hard
git pull
./bootstrap         |& tee ob
./configure --help  |& tee och
./configure         |& tee oc
make                |& tee om
make check          |& tee omc
sudo make install   |& tee omi
make tags           |& tee omt

make html           |& tee omh

sudo make uninstall |& tee omui

# (find-maximagitfile "" "omi")
# (find-fline "/usr/local/share/maxima/")
# (find-fline "/usr/local/share/maxima/branch_5_46_base_555_g6fa201ff5/")
# (find-fline "/usr/local/share/maxima/branch_5_46_base_415_ge406ac453/")
# (find-fline "/usr/local/share/maxima/branch_5_45_base_309_gea23a96f9/")
# (find-fline "/usr/local/share/maxima/branch_5_46_base_250_gbd5ffb328/")




#####
#
# maxima-git-5.47.0 (for maxima-index-html.lisp)
# 2023oct08
#
#####

# «maxima-git-5.47.0»  (to ".maxima-git-5.47.0")
# (to "web-docs")
# (code-c-d "maxima5470" "~/bigsrc/maxima-git-5.47.0/")
# (find-maxima5470file "")
# (find-maxima5470file "doc/info/maxima-index-html.lisp")
# (find-maxima5470file "doc/info/maxima-index-html.lisp" "mode_declare")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rf ~/bigsrc/maxima-git-5.47.0/
mkdir  ~/bigsrc/maxima-git-5.47.0/
cd     ~/bigsrc/maxima-git-5.47.0/
git clone ~/bigsrc/maxima .

git checkout 5.47.0
git clean -dfx
git reset --hard

./bootstrap         |& tee ob
./configure         |& tee oc
make                |& tee om

cp -v doc/info/maxima-index-html.lisp ~/blogme3/







#####
#
# installation-directories
# 2021dec22
#
#####

# «installation-directories»  (to ".installation-directories")
# https://mail.google.com/mail/u/0/#sent/QgrcJHsbdJTJPlSGDHTrjKFDmwBNnpbzBXb
# (find-maximamsg "37405965 202112 21" "Edrx" "directory")

Hi list,

I am on Debian and I am trying to use Maxima from git.
If I run

  cd ~/bigsrc/maxima/
  git reset
  ./bootstrap
  ./configure --help
  ./configure
  make
  make check
  sudo make install

the "make install" installs the directories demo/, doc/, share/, src/,
tests/, and xmaxima/ inside this directory:

  /usr/local/share/maxima/branch_5_45_base_309_gea23a96f9/

How can I make it use this directory

  /usr/local/share/maxima/

or this one

  /usr/local/share/maxima/5.45/

instead of the one with the very long name? I found these lines in
~/bigsrc/maxima/Makefile.in,

  verpkglibdir = $(pkglibdir)/@VERSION@
  verpkglibexecdir = $(libexecdir)/@PACKAGE@/@VERSION@
  verpkgdatadir = $(pkgdatadir)/@VERSION@

and i saw that they becomes these ones in ~/bigsrc/maxima/Makefile:

  verpkglibdir = $(pkglibdir)/branch_5_45_base_309_gea23a96f9
  verpkglibexecdir = $(libexecdir)/maxima/branch_5_45_base_309_gea23a96f9
  verpkgdatadir = $(pkgdatadir)/branch_5_45_base_309_gea23a96f9

but I couldn't find a clean way to change the @VERSION@...

Thanks in advance! =)
  Eduardo Ochs
    http://angg.twu.net/#eev
    http://angg.twu.net/math-b.html




#####
#
# installation-dirs-2
# 2021dec23
#
#####

# «installation-dirs-2»  (to ".installation-dirs-2")

Hi all,

I asked about a way to install Maxima in directories with shorter
names because I thought that it would be natural to have an easy way
to do that...

I usually keep "executable notes" of everything that I do - that's a
long story; the best short version of it that I have that people can
understand in one minute or two is here:

  http://angg.twu.net/LATEX/2019emacsconf.pdf
  http://angg.twu.net/emacsconf2019.html

and for most kinds of "elisp hyperlinks" I have good tricks to hide
long directory names. For example, each of the three sexps below
defines a function `find-maximasharefile' in Emacs in a different way,

  (code-c-d "maximashare" "~/bigsrc/maxima/share/")
  (code-c-d "maximashare" "/usr/local/share/maxima/branch_5_45_base_309_gea23a96f9/share/")
  (code-c-d "maximashare" "/usr/share/maxima/5.44.0/share/")

and after running one of these `code-c-d's I can use sexps like this
to point to a file, and to point to the first occurrence of a certain
string in a file:

  (find-maximasharefile "calculus/fourie.mac")
  (find-maximasharefile "calculus/fourie.mac" "fourcos(f%,x,p):=")

There is one situation in which I still use normal URLs instead of
these sexp hyperlinks, thought - it's when I have to point to docs in
HTML. I use URLs like these ones

  file:///usr/share/doc/maxima-doc/html/maxima_43.html
  file:///home/edrx/bigsrc/maxima/doc/info/maxima_43.html
  file:///usr/local/share/maxima/branch_5_45_base_309_gea23a96f9/doc/html/maxima_43.html
  https://maxima.sourceforge.io/docs/manual/maxima_43.html

to point to the HTML version of a page of the Maxima manual... I
usually just copy these URLs from the browser to my notes, and I never
had good excuses to work on tools to transform these sexps until now -
or, to be more honest: until a few months ago.

Soooo: there isn't an easy way to make Maxima use a shorter version
name, but I can add a step to my build script that will copy the HTMLs
to another directory, so that this would work:

  file:///usr/local/share/maxima-html/maxima_43.html

The program that I use to htmlize my notes knows how to transform
file:/// urls, and in a few hours or days I will teach it that the
URL above has to become this in the htmlized version:

  https://maxima.sourceforge.io/docs/manual/maxima_43.html

My notes about Maxima are here, but they are a huge horrible mess at
the moment:

  http://angg.twu.net/e/maxima.e.html

I started to use Maxima in 2008 but I didn't learn much then, and
after some years I sort of switched to SymPy and forgot that Maxima
existed... I _HATED_ SymPy but I kept trying to use it - until I
rediscovered Maxima some time ago. So now I am trying to migrate the
few programs that I wrote in SymPy in my SymPy phase to Maxima...

Anyway, here is a wishlist-ish bug. If we hover the mouse at the right
of a section title in a page like

  https://docs.sympy.org/latest/modules/polys/reference.html

we see a pilcrow sign with a permalink to that section. Would it be
easy to implement something like that in the HTML docs of Maxima?





#####
#
# checkinstall
# 2021dec23
#
#####

# «checkinstall»  (to ".checkinstall")
# https://en.wikipedia.org/wiki/CheckInstall
# https://wiki.debian.org/CheckInstall
# (find-maximamsg "37406152 202112 23" "I usually don't bother")

FWIW, Eduardo, I usually don't bother installing Maxima and just run
it from its directory. In the rare case that I did need to install a
Maxima built from git, I used checkinstall.





# (find-fline "~/usrc/")
# (find-fline "~/usrc/code/")
# (find-gitk  "~/usrc/code/")

# (code-c-d "maximagit" "~/bigsrc/maxima/")
# (find-maximagitfile "")
# (find-maximagitfile "INSTALL.git")
# (find-maximagitfile "INSTALL")
# (find-maximagitfile "src/")
# (find-maximagitfile "demo/cf.dem")
# (find-maximagitfile "demo/manual.demo")
# (find-maximagitfile "archive/books/")
# (find-maximagitfile "archive/books/schelter/")
# (find-maximagitfile "archive/books/schelter/xplot.bk")
# (find-maximagitfile "archive/info/")
# (find-maximagitfile "archive/info/maxima-primer.tex")
# (find-maximagitfile "share/")
# (find-maximagitfile "share/integration/")
# (find-maximagitfile "share/calculus/")
# (find-maximagitgrep "grep --color=auto -niH --null -e kill src/*.lisp")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)





#####
#
# 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-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-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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")




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

# (find-maximanode "contour_levels")
# (find-maximanode "contour")
# (find-maximagpdraww3m "contours/index.html")
# (find-sh "locate -i maxima | grep -i contour")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
2 + 3;


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-maximanode "Function and Variable Index" "contour")




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

# «listify»  (to ".listify")
# (find-maximagpdraww3m "vectors/index.html")
# (find-maximagpdrawgrep "grep -nrH -e listify *")
# (find-maximanode "listify")
# (find-maximanode "makelist")
# (find-maximanode "create_list")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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-maximanode "Functions and Variables for draw")
# (find-maximanode "head_length")
# (find-maximanode "head_type")
# (find-maximanode "head_angle")
# (find-maximanode "unit_vectors")
# (find-maximanode "vector")
# http://www.telefonica.net/web2/biomates/maxima/gpdraw/index.html
# http://www.telefonica.net/web2/biomates/maxima/gpdraw/vectors/index.html

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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);




#####
#
# parametric_surface
# 2021dec17
#
#####

# «parametric_surface»  (to ".parametric_surface")
# (find-maximanode "Functions and Variables for draw" "object: parametric_surface")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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-maximanode "Functions and Variables for Help" "example (append);")
# (find-maximanode "Functions and Variables for draw" "Graphic object: vector")
# (find-maximanode "Functions and Variables for draw" "Scene constructor: gr3d")
# (find-maximafile "")
# (find-maximafile "maxima/interfaces/xmaxima/xmaxima")
# (find-maximafile "src/binary-gcl/")
# (find-maximagrep "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-maxima)
* (eepitch-kill)
* (eepitch-maxima)
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")
# (find-man "1 seq")
# (find-angg ".maxima/maxima-init.mac" "seq")
# (find-sh0 "seq 2       5")
# (find-sh0 "seq 2.0     5.0")
# (find-sh0 "seq 2   0.5 5")
# (to "n^2+n+41")

# «seq-infix»  (to ".seq-infix")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
seq (a, b) := makelist(i, i, a, b);
".."(a, b) := makelist(i, i, a, b);
infix("..", 51, 51);
2 .. 5;
x+2 .. x+5;





#####
#
# filter
# 2024jul21
#
#####

# «filter»  (to ".filter")
# (find-maximanode "delete")
# (find-maximanode "sublist")
# (find-maximanode "sublist_indices")
# (find-maximanode "unique")




#####
#
# makelist evals 2nd arg and doesn't report some errors
# 2024jul13
#
#####

# «makelist-evals-2nd-arg»  (to ".makelist-evals-2nd-arg")
# https://sourceforge.net/p/maxima/bugs/4333/ makelist evals 2nd arg and doesn't report some errors





#####
#
# align_eqs
# 2023oct10
#
#####

# «align_eqs»  (to ".align_eqs")
# (find-angg ".maxima/maxima-init.mac" "align_eqs")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a : [11, 22, 33, 44, 55, 66];

matrix([11, "=", 22]);
matrix([11, "=", 22],
       ["", "=", 33],
       ["", "=", 44]);
apply('matrix, [[11, "=", 22],
                ["", "=", 33],
                ["", "=", 44]]);
apply('matrix, append([[11, "=", 22]],
                      [["", "=", 33],
                       ["", "=", 44]]));

align_eqs(exprs) :=
  apply('matrix,
        append([[exprs[1], "=", exprs[2]]],
               makelist(["", "=", exprs[i]], i, 3, length(exprs))));
align_eqs(a);




#####
#
# factor
# 2024aug06
#
#####

# «factor»  (to ".factor")
# (find-maximanode "factor")
# (find-maximanode "ifactors")
# (find-maximanode "solve")
# (find-maximanode "noun")
# (find-maximanode "noun" "won't be evaluated" "automatically")
# (to "unlambda")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
factor (2^63 - 1);
factor (-8*y - 4*x + z^2*(2*y + x));
-1 - 2*x - x^2 + y^2 + 2*x*y^2 + x^2*y^2;
block ([dontfactor: [x]], factor (%/36/(1 + 2*y + y^2)));
factor (1 + %e^(3*x));
factor (1 + x^4, a^2 - 2);
factor (-y^2*z^2 - x*z^2 + x^2*y^2 + x^3);
(2 + x)/(3 + x)/(b + x)/(c + x)^2;
ratsimp (%);
partfrac (%, x);
map ('factor, %);
ratsimp ((x^5 - 1)/(x - 1));
subst (a, x, %);
factor (%th(2), %);
factor (1 + x^12);
factor (1 + x^99);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-fline "~/lisptree/lisptree.mac")
load          ("~/lisptree/lisptree.mac");
             factor(12345678);
lisptree    (factor(12345678));
lisptree (''(factor(12345678)));
lisptreeq(''(factor(12345678)));
format0(o);

o  : factor(12345678);
o2 : lambda([], 2 * 3^2 * 47 * 14593);
o3 : lambda([], 2+3);

format0(o);
format0(o2);
format0(o3);

to_lisp();
    (defun $unlambda (olambda)
      (let* ((obody (cddr olambda))
             (oop   (caaar obody))
             (oargs (cdar obody)))
        `((,oop simp factored) ,@oargs)
        ))
    #$o$
    #$o2$
    #$o3$
    ($unlambda #$o2$)
    ($unlambda #$o3$)
  (to-maxima)

unlambda(o2);
unlambda(o3);
format0(unlambda(o3));




#####
#
# Factor a quadratic polynomial with complex roots
# 2024aug19
#
#####

# «factor-complex»  (to ".factor-complex")
# «complex-roots»   (to ".complex-roots")
# (find-maximanode "expand")
# (find-maximanode "solve")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
z  : 3 + 4*%i;
zc : conjugate(z);
p  : expand((x-z)*(x-zc));
factor(p);     /* returns p */
solve (p,x);

L : (D^2 + 4*D + 29);
factor(L);
                    solve(L=0, D);
          map('rhs, solve(L=0, D));
[r1,r2] : map('rhs, solve(L=0, D));
L2      : (D-r1)*(D-r2);
expand(L2);

roots(poly,var) := map('rhs, solve(poly, var));
          roots(L,D);
[r1,r2] : roots(L,D);
L2      : (D-r1)*(D-r2);
expand(L2);
L = L2;



#####
#
# factorial
# 2024nov03
#
#####

# «factorial»  (to ".factorial")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-anchor "~/lisptree/lisptree.mac")
load           ("~/lisptree/lisptree.mac");
o : x!;
format0(o);
to_lisp();
  (symbol-plist 'mfactorial)
  (to-maxima)




#####
#
# factorlist
# 2024aug18
#
#####

# «factorlist»  (to ".factorlist")
# (find-maximamsg "58806648 202408 15" "improved factorlist")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
factorlist(r) := map(lambda([k], if listp(k) then k else [k,1]),
                     psubst([ "^"="[","*"="[" ], factor(r)));
factorlist(24);
v:ratexpand(x^2*(y+z)^3);
factorlist(v);             /* [[x,2],[z+y,3]] */




#####
#
# sum
# 2023sep27
#
#####

# «sum»  (to ".sum")
# (find-maximanode "sum")
# (find-maximanode "simpsum")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
sum (i^2,     i,1,7);
sum (a[i],    i,1,7);
sum (a(i),    i,1,7);
sum (a(i),    i,1,n);
sum (2^i+i^2, i,0,n);
sum (2^i+i^2, i,0,n), simpsum;
sum (1/3^i,   i,1,inf);
sum (1/3^i,   i,1,inf), simpsum;
sum (i^2,     i,1,4) * sum (1/i^2, i,1,inf);
sum (i^2,     i,1,4) * sum (1/i^2, i,1,inf), simpsum;
sum (integrate(x^k, x,0,1), k,1,n);
sum (if k <= 5 then a^k else b^k, k,1,10);




#####
#
# Throw and catch
# 2024aug24
#
#####

# «throw-and-catch»  (to ".throw-and-catch")
# (find-maximanode "throw")
# (find-maximanode "catch")
# (find-maximanode "errcatch")
# (find-maximanode "errormsg")
# (find-maximanode "error")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
errormsg;
sin(a,b);
errormsg: false;
sin(a,b);
f(bool):=block([errormsg:bool],
errormsg:true;
f(false);
errormsg:false;
f(true);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
0/0;
catch(0/0);
[1, catch(0/0), 3];
[1, errcatch(0/0), 3];
[1, error, errcatch(0/0), error, 3];




#####
#
# Handling x/0
# 2024aug24
#
#####

# «div-by-0»  (to ".div-by-0")
# (find-maximanode "0 to a negative exponent")
# https://mail.google.com/mail/u/0/#search/maxima+nan
# (find-maximamsg "34437931 201509 07" "DScherfgen: noninteractive")
# (find-maximamsg "34439765 201509 07" "RFateman:")
# (find-maximamsg "34439771 201509 07" "RFateman:")
# (find-maximamsg "34440949 201509 08" "DScherfgen: ")
# (find-maximamsg "34441486 201509 08" "ADomarkas: ")
# (find-maximamsg "34442523 201509 08" "RDodier:")
# (find-maximamsg "34442539 201509 08" "DScherfgen: ")
# (find-maximamsg "34442667 201509 08" "DScherfgen: ")
# (find-maximamsg "34445805 201509 09" "RDodier: ")
# (find-maximamsg "34447000 201509 10" "DScherfgen: ")
# (find-maximamsg "34450440 201509 11" "DScherfgen: giving rootsof a second argument")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
[a,b,c] : [0/0, 1/0, -2/0];




#####
#
# noninteractive
# 2024aug24
#
#####

# «noninteractive»  (to ".noninteractive")
# (to "div-by-0")
# (to "assume")
# (find-maximanode "asksign")
# (find-sh "locate noninteractive")
# (code-c-d "noninteractive" "~/bigsrc/maxima/share/contrib/noninteractive/")
# (find-maximagitfile "share/contrib/noninteractive/")
# (find-noninteractivefile "")
# (find-noninteractivefile "noninteractive.lisp" "Redefine MERROR to throw something")
# (find-noninteractivefile "noninteractive.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("noninteractive");

throw (x); "THROW NOT WITHIN CATCH SUPPRESSED; THAT'S PROBABLY A BUG"
asksign (x);
asksign (log (x));
asksign (abs (x));
abs (asin (x + %i));
(declare (xx, complex), abs (asin (xx + %i)));   (TRIGGERS STACK OVERFLOW)
realpart (sqrt (25 - x^2 - y^2));
integrate (exp(a*x), x, 0, inf);  (INCORRECT RESULT FOR A=0, NOT OUR PROBLEM)
integrate (x^k, x);
integrate (x^k, x, 1, b);
integrate (x**a/(x + 1), x, 0, inf);
integrate (x**a/(x + 1)**(5/2), x, 0, inf);
integrate (exp(-%i*x) + a * exp(%i*x), x, 0, 2*%pi);
integrate (sqrt (1 - s^2)/(z - s), s, -1, 1);
(xmax(a, b) := (a + b + abs(a - b)) / 2, integrate (xmax (a - x, 0), x, 0, b));
integrate (1 / (a^2 * cos(t)^2 + 1), t, 0, %pi);
integrate (exp(- la*t) * la, t, 0, inf);
integrate (sin(5*x) * exp(- s*x), x, 0, inf);
integrate (1/x, x, a, 4);
integrate (x^k, x, 0, 1);
integrate (1 / sqrt(n + i),i,1,n);
integrate (1 / (1 + a^2 * sin(x)^2), x, 0, 3*%pi);
integrate (integrate (p2^2, x1, -4*%pi / kp, 4*%pi / kp), x2, 5*%pi / kp / 2, 7*%pi / kp / 2);
integrate (1/log(t), t, x, 2*x);
integrate ((6*cos(9*x) + 6*sin(8*x)) * (j - x), x, -%pi, %pi) / %pi; (TRIGGERS "TOO MANY CONTEXTS"; BUG IN MONSTERTRIG)
integrate (cos(n*x) * sin(n*x), x, 0, t);
integrate (1 / (sin(x)^2 + 1), x, 0, z);
integrate (cos(x) - cos(x - c), x, 0, c/2) = %pi - c - integrate (cos (x - c), x, c, %pi / 2 + c);
integrate (cot(x), x, 0, %pi/2);
integrate (r, z, - sqrt (20 - r^2), sqrt (20 - r^2));
integrate ((x^2 + x + 2)/(x^2 + x + c), c);
specint (sqrt(t) * %e^(- p*t - a/t), t);

(f(x) := x - 2 * log ((exp(x) + 1) / 2) + x**2/4,
 exp (- x**2/4) * ratsimp (taylor (exp (f(x)) * (x*kb + mu)**gamma, x, 0, 4)),
 integrate (%%, x, minf, inf));

(aa : 3*kbt^4*x^4/(128*mu^4) - kbt^3*x^3/(16*mu^3) + 3*kbt^2*x^2/(8*mu^2) + 3*kbt*x/(2*mu) + 1,
 integrate (exp(x)/(exp(x) + 1)^2*aa, x, minf, inf));

(tmpp : (x2/2 + x1/2)*sin((%pi * (- x3/2 - (- x3 - x2 - x1 + 1)/2 + x2/2 + x1/2)) / 2),
 integrate (integrate (integrate (tmpp, x3, 0, 1 - x1 - x2), x2, 0, 1 - x1), x1, 0, 1));

limit (a * x, x, inf);
limit (x^a, x, inf);
limit (x^a, x, minf);
declare (a, integer);
limit (x^a, x, minf);
tlimit (s/(1 + s^2) / sinh (s*T), s, inf);
solve (x = log(a + sqrt( a^2 - r^2)), r); (MAKES A MESS; RESULTS INCORRECTLY MERGED INTO CONDITIONAL)
solve (sqrt(x) + sqrt(y) = sqrt(a), y);
solve (y^2 + x^2 + 2*a*e*x + a^2*e^2 = (2*a - sqrt (y^2 + x^2 - 2*a*e*x + a^2*e^2))^2, y);
solve (b^(a*t) = 1, b); (ATTEMPTS DECLARE(A*T, INTEGER) => ERROR, STACK OVERFLOW)
ode2 ('diff(x, t, 2) + a*x = b*sin(c*t), x, t);
ode2 ('diff(x, t, 2) + a*'diff(x, t) + b*x = 0, x, t);
ode2 ('diff(x, t, 2) + a*'diff(x, t) + b*x = d*sin(e*t), x, t);
ode2 ('diff(y, x, 2) + a*y = c* x, y, x);
ode2 ('diff(y, x, 2) + a*'diff(y, x) + b*y = c*x, y, x);

gcd : spmod;
expr : sin(a) / (1 - cos(a)^2*sin(t)^2);
assume (cos(a) > 0, sin(a) > 0);
integrate (expr, t, 0, 2*%pi);

(load (simplify_sum),
 sum (r/k*binom(n, r) * binom(m, k - r)/binom(n + m, k), r, 0, k),
 simplify_sum (intosum (%%))); (TRIGGERS "CONTEXT ALREADY EXISTS"; THROW LEAVES CONTEXT HANGING AROUND)

(load (to_poly_solve), to_poly_solve ([sqrt(x) + sqrt(y) = a , x^2=y] , [x, y]));

(load (Solver), Solver ([x=2, y=3], [x], [y])); (TRIGGERS "ZERO OR NONZERO" QUERY; SOLVER HAS ITS OWN ASKSIGN-LIKE FUNCTION)
(load (Solver), Solver ([x=a, y=b], [x], [y, b])); (TRIGGERS "ZERO OR NONZERO" QUERY; SOLVER HAS ITS OWN ASKSIGN-LIKE FUNCTION)


(to "noninteractive")




#####
#
# numerozinhos
# 2022jul22
#
#####

# «numerozinhos»  (to ".numerozinhos")
# (find-maximanode "matrix")
# (find-maximanode "apply")
# (find-maximanode "function")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
apply(matrix, [[1, 2], [3, 4]]);
makelist(i, i, 2, 5);
makelist(i, i, 5, 2, -1);
numerozinhos :
   lambda([xmin,ymin, xmax,ymax, f],
          apply(matrix,
                makelist(makelist(f(x,y), x, xmin, xmax),
                y, ymax, ymin, -1)));
grind(numerozinhos);
numerozinhos(2,3, 4,5, lambda([x,y], 10*x+y));
numerozinhos(2,3, 4,5, lambda([x,y], (x,y)));
numerozinhos(2,3, 4,5, lambda([x,y], [x,y]));
[Dx,Dy] : [x-x0,y-y0];
[x0,y0] : [4,3];
x0;
ev(Dx);
numerozinhos(x0-2,y0-2, x0+2,y0+2, lambda([x,y], ev([Dx,Dy])));
numerozinhos(x0-2,y0-2, x0+2,y0+2, lambda([x,y], ev(Dx+Dy)));
numerozinhos(x0-2,y0-2, x0+2,y0+2, lambda([x,y], ev(Dx-Dy)));
numerozinhos(x0-2,y0-2, x0+2,y0+2, lambda([x,y], ev((Dx-Dy)*Dy)));
numerozinhos(x0-3,y0-3, x0+3,y0+3, lambda([x,y], ev((Dx-Dy)*Dy)));
F : (Dx-Dy)*Dy;
numerozinhos(x0-3,y0-3, x0+3,y0+3, lambda([x,y], ev(F)));
F - 1;




#####
#
# matrixify
# 2022jul22
#
#####

# «matrixify»  (to ".matrixify")
# (find-angg "MAXIMA/matrixify.mac")
# (find-maximanode "contour_levels")
# (to "qdraw-imp")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/matrixify.mac")
load       ("~/MAXIMA/matrixify.mac");
[Dx,Dy] : [x-x0,y-y0];
[x0,y0] : [5,4];
matrixify(x0-3,y0-3, x0+3,y0+3, [x,y]);
matrixify(x0-3,y0-3, x0+3,y0+3, [Dx,Dy]);
matrixify(x0-3,y0-3, x0+3,y0+3, Dx-Dy);
matrixify(x0-3,y0-3, x0+3,y0+3, Dy);
matrixify(x0-3,y0-3, x0+3,y0+3, Dy*(Dx-Dy));
z : Dy*(Dx-Dy);
z : ev(z);
plot2d([contour, z], [x,x0-3,x0+3], [y,y0-3,y0+3]);
set_plot_option(contour_levels, 15);
plot2d([contour, z], [x,x0-3,x0+3], [y,y0-3,y0+3]);

load_qdraw();
qdraw(imp([z=0, z=1, z=-1, z=-2], x,x0-3,x0+3, y,y0-3,y0+3));

? set_plot_option
set_plot_option();
** (find-books "__comp/__comp.el" "maxima-workbook")
** (find-maximawbpage (+ 19 31) "5 Graphical representation of functions")


sols : solve(z-1, y);
** (find-angg "MAXIMA/traverse.mac")
load       ("~/MAXIMA/traverse.mac");
traverse(sols);
traverse(sols, 1);
traverse(sols, 1, 'op);
traverse(sols, 1, 'args);
traverse(sols, 1, 2);
traverse(sols, 1, 2, 'op);
traverse(sols, 1, 2, 'args);
traverse(sols, 1, 2, 1);
traverse(sols, 1, 2, 1, 1);
traverse(sols, 1, 2, 1, 1, 'args);
traverse(sols, 1, 2, 1, 1, 1);
traverse(sols, 1, 2, 1, 1, 1, 'args);
traverse(sols, 1, 2, 1, 1, 1, 1);
eq1 : traverse(sols, 1, 2, 1, 1, 1, 1);
solve(eq1, x);
**
** (find-maximanode "contour_levels")
** (find-maximanode "contour")
** (find-maximanode "explicit")
draw3d(color = green,
       explicit(z, x,x0-3,x0+3, y,y0-3,y0+3),
       contour_levels = [0,0.2,2],
       contour        = both,
       surface_hide   = true) $
draw3d(color = green,
       explicit(z, x,x0-3,x0+3, y,y0-3,y0+3),
       contour_levels = [0,0.2,2],
       contour        = both) $

** (find-maximanode "solve")
** (find-maximanode "plot3d")
** (find-maximanode "contour")
** (find-maximanode "plot3d" "Two surfaces in the same plot")
plot3d(ev(z), [x,x0-3,x0+3], [y,y0-3,y0+3]);




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

# «expand-and-ev»  (to ".expand-and-ev")
# (find-maximaindex-links "ev expand")
# (find-maximaindex "ev" :RET)
# (find-maximaindex "ev" :RET "expand")
# (find-maximanode "ev")
# (find-maximanode "ev" " <expr>, <arg_1>, ..., <arg_n>")
# (find-maximanode "expand")
# (find-maximaindex "expand" :RET)

* (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);
g(x);
g(x), expand;
g(x), expand=true;
g(x), expand=false;




#####
#
# When is f(n) := n^2 + n + 41 a composite number?
# 2010jan06
#
#####

# «n^2+n+41»  (to ".n^2+n+41")
# (to "seq")
# (find-maximanode "for")
# (find-maximanode "do")
# (find-maximanode "display")
# (find-books "__discrete/__discrete.el" "scheinerman" "n^2 + n + 41")

** 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;
seq(a, b) := makelist(i, i, a, b);
for m in seq(1,42) do display('f(m) = factor(f(m)))$

* (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);

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,42) do display('f(m) = factor(f(m)))$




#####
#
# 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);

* (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 "Functions and Variables for Display" "Option variable: linel")
# (find-maximanode "Functions and Variables for Strings" "Function: string")
# (find-maximanode "Nouns and Verbs" "noundisp")




#####
#
# 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-maximanode "Functions and Variables for Simplification" "example (radcan)")
*;; (find-maximanode "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);



#####
#
# bortolossi-5.5
# 2021dec10
#
#####

# «bortolossi-5.5»  (to ".bortolossi-5.5")
# (find-es "ipython" "bortolossi-5.5")
# (c3m212nfp 20 "exercicio-5")
# (c3m212nfa    "exercicio-5")
# (c3m212nfp 26 "exercicio-5-maxima")
# (c3m212nfa    "exercicio-5-maxima")
# (find-bortolossi5page (+ -162 177)   "[01] ...parciais de primeira ordem")
# (find-maximanode "Functions and Variables for Differentiation" "Function: diff")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)

/* Item a:
*/
f : sqrt(r^2 + s^2);
diff(f, r);
diff(f, s);
[diff(f, r), diff(f, s)];

/* Item b:
*/
f : t/s - s/t;
[diff(f, s), diff(f, t)];

/* Item c:
*/
f : 2*x^4*y^3 - x*y^2 + 3*y + 1;
[diff(f, x), diff(f, y)];


/* Item d:
*/
f :          (t+v) / (t-v)  ;
g :     sqrt((t+v) / (t-v)) ;
h : log(sqrt((t+v) / (t-v)));
[diff(f, t), diff(f, v)];
[diff(g, t), diff(g, v)];
[diff(h, t), diff(h, v)];






#####
#
# Figuras pro video sobre cabos na diagonal
# 2021dec17
#
#####

# «cabos-na-diagonal»  (to ".cabos-na-diagonal")
# (find-anggfile "GNUPLOT/piramide-2.dem" "find-bgprocess")
# (find-LATEXfile "2021-2-C3-diag-nums.gnuplot" "eepitch-shell")

* (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));

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
gnuplot ~/LATEX/2021-2-C3-diag-nums.gnuplot





#####
#
# rubi
# 2021dec19
#
#####

# «rubi»  (to ".rubi")
# https://mail.google.com/mail/u/0/#inbox/FMfcgzGllVpgMbpPSmZbSswQRVLRCVbf
# https://rulebasedintegration.org/
# https://rulebasedintegration.org/testProblems.html
# https://rulebasedintegration.org/TestFiles/MaximaSyntaxFiles/
# https://rulebasedintegration.org/TestFiles/MaximaSyntaxFiles/MaximaSyntaxTestFiles.zip




#####
#
# display2d
# 2022apr26
#
#####

# «display2d»  (to ".display2d")
# (find-maximaindex-links "display2d")
# (find-maximaindex "display2d" :RET)
# (find-maximanode "display2d")
# (find-maximanode "grind")
# (find-maximanode "ldisp")
# (find-maximanode "disp")
# (find-maximanode "with_default_2d_display")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
x/(x^2+1);
display2d:false$
x/(x^2+1);
display2d:true$
x/(x^2+1);



#####
#
# display2d_unicode
# 2023dec30
#
#####

# «display2d_unicode»  (to ".display2d_unicode")
# (find-maximamsg "58718036 202312 30" "RDodier: Unicode pretty printer display merged into master")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
display2d_unicode : true;
'integrate(x^2, x);
'sum(x^2, x, 0, 4);
display2d_unicode : false;
'integrate(x^2, x);
'sum(x^2, x, 0, 4);




#####
#
# tex
# 2022aug19
#
#####

# «tex»  (to ".tex")
# (find-maximanode "Functions and Variables for TeX Output")
# (find-maximanode "tex")
# (find-maximanode "tex1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
integrate (1/(1+x^3), x);
tex (%o1);
tex (integrate (sin(x), x));
tex (%o1, "foo.tex");
S : tex (x * y * z, false);
S;
tex1 (sin(x) + cos(x));



#####
#
# texput
# 2023jul25
#
#####

# «texput»  (to ".texput")
# (to "operators")
# (find-maximanode "texput")
# (find-maximanode "prefix")
# (find-maximanode "infix")
# (find-maximanode "nofix")
# (find-maximanode "nary")
# (find-maximanode "matchfix")
# (find-maxima-links "texput")
# (find-maxima-links "matrix")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
texput (me,"\\mu_e");
tex    (me);
texput (lcm, "\\mathrm{lcm}");
tex    (lcm (a, b));

texfoo (e) := block ([a, b],
         [a,b] : args (e),
         concat("\\left[\\stackrel{",
                tex1(b),
                "}{",
                tex1(a),
                "}\\right]"))$
texput (foo, texfoo);
tex    (foo (2^x, %pi));

prefix ("grad");
texput ("grad", " \\nabla ", prefix);
tex    (grad f);

infix  ("~");
texput ("~", " \\times ", infix);
tex    (a ~ b);

postfix ("##");
texput  ("##", "!!", postfix);
tex     (x ##);

nary   ("@@");
texput ("@@", " \\circ ", nary);
tex    (a @@ b @@ c @@ d);

nofix  ("foo");
texput ("foo", "\\mathsc{foo}", nofix);
tex    (foo);

matchfix ("<<", ">>");
texput   ("<<", [" \\langle ", " \\rangle "], matchfix);
tex      (<<a>>);
tex      (<<a, b>>);
texput   ("<<", [" \\langle ", " \\rangle ", " \\, | \\,"], matchfix);
tex      (<<a>>);
tex      (<<a, b>>);




#####
#
# texput-includegraphics
# 2024jul20
#
#####

# «texput-includegraphics»  (to ".texput-includegraphics")
# (find-angg "MAXIMA/barematrix1.mac"   "includegraphics")
# (find-LATEXgrep "grep --color=auto -nH --null -e includegraphics 2024*.tex")
# (find-angg ".maxima/maxima-init.mac" "format")
# (find-es "tex" "includegraphics")
# (to "format")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
includegraphics_dir : "2024-1-C3/"$
includegraphics_fmt (opts, stem) :=
  format("\\includegraphics[~a]{~a~a.pdf}", opts, includegraphics_dir, stem)$
includegraphics_fmt1(o) := apply('includegraphics_fmt, args(o));
texput('includegraphics, 'includegraphics_fmt1);

     includegraphics_fmt     ("height=2cm", "foo");
     includegraphics_fmt1(bla("height=2cm", "foo"));
     includegraphics         ("height=2cm", "foo");
tex (includegraphics         ("height=2cm", "foo"));
tex1(includegraphics         ("height=2cm", "foo"));




format()




texfoo (e) := block ([a, b],
         [a,b] : args (e),
         concat("\\left[\\stackrel{",
                tex1(b),
                "}{",
                tex1(a),
                "}\\right]"))$
texput (foo, texfoo);
tex    (foo (2^x, %pi));


\includegraphics[height=4cm]{2021-1-C3/20210804_sqrt.pdf}




#####
#
# texput for "/" and "matrix"
# 2023jul25
#
#####

# «texput-frac»    (to ".texput-frac")
# «texput-matrix»  (to ".texput-matrix")
# (find-maximamsg "37875726 202307 25" "Edrx: I know two basic formats")
# (find-maximamsg "37875807 202307 25" "LButler: texput(matrix, ...)")
# (find-maximamsg "37876999 202307 28" "RDodier: TEX, TEXWORD, and TEXSYM")
# (find-maximamsg "37888856 202308 29" "Edrx: texput, \\frac, and diff")
# (find-maximamsg "37889136 202308 29" "LButler: simp:false")
# (find-maxima-links "matrix")
# (find-maxima-links "texput")
# (find-maximagitfile "src/mactex.lisp" "(defun tex-mquotient ")
# (find-maximagitfile "src/mactex.lisp" "(defun tex-matrix ")
# (find-maximagitfile "src/mactex.lisp" "(defmfun $texput ")
# (find-angg "MAXIMA/barematrix1.lisp" "tex-matrix")
# (find-angg "MAXIMA/barematrix1.lisp" "tex-barematrix")
# (find-angg "MAXIMA/barematrix1.lisp" "tex-mquotient")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
A : matrix([10,20],[30,40]);
B : x/y;
:lisp #$A$
:lisp #$B$

properties(matrix);
:lisp (describe '$matrix)
:lisp (symbol-plist '$matrix)
properties("/");
:lisp (describe '$/)
:lisp (symbol-plist '$/)

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
texput("*"," ")$
tex(a*b);
texput("/", lambda([r],
    block([n,d],
          n:num(r),
          d:denom(r),
          printf(false,"\\frac{~a}{~a}",tex1(n),tex1(d)))));
tex(a/b);
tex(a/(b+c/d));
tex(a/(b+c/d+x*y/cos(t)));
texput(matrix, lambda([expr],
    printf(false,
           "\\begin{bmatrix} ~{~{~a~^&~}~^\\\\~} \\end{bmatrix}",
           map(lambda([row],map(lambda([element],tex1(element)),row)),args(expr)))))$
tex(matrix([a,b],[c,d]));
tex(matrix([a,b,c/d],[c,d,a*b],[u,v,sin(t)]));
texput(%i,"\\mathrm{i}");
texput(%e,"\\mathrm{e}");
tex(%i+%e);








#####
#
# Something like texput, but for display2d?
# 2022aug23
#
#####

# «texput-Eq5»     (to ".texput-Eq5")
# «display2d-Eq5»  (to ".display2d-Eq5")
# (find-maximamsg "37697583 202208 24" "Edrx: Something like texput, but for display2d?")
# (find-maximamsg "37698054 202208 24" "LButler: define_alt_display")
# (find-maximamsg "37697660 202208 24" "GKönigsmann: lmxchar")
# (find-maximamsg "37698492 202208 25" "LButler: Apologies, before %i5 you need to also enter")
# (find-maximamsg "37698576 202208 25" "RFateman: dim-$matrix")
# (find-maximanode "Functions and Variables for TeX Output")
# (find-maximanode "texput")
# (find-maximanode "lmxchar")
# (find-maximanode "rmxchar")

Hi list,

I am trying to learn how to define new operators that have "nice"
representations in LaTeX and in display2d. Here is the example on
which I am working. I want

  Eq5(aa, bb, cc, dd, ee)

to be displayed as:

  aa = bb
     = cc
     = dd
     = ee

To configure its LaTeX output I simply adapted the example in the
section about "texput" here,

  (info "(maxima)Functions and Variables for TeX Output")

and I wrote this:

  texEq5(ex) :=
    block([a,b,c,d,e], [a,b,c,d,e] : args (ex),
      concat("\\begin{array}{rcl}",
             tex1(a), "&=&", tex1(b), "\\\\",
                      "&=&", tex1(c), "\\\\",
                      "&=&", tex1(d), "\\\\",
                      "&=&", tex1(e), "\\\\",
             "\\end{array}"));
  texput(Eq5, texEq5);
  tex(Eq5(aa, bb, cc, dd, ee));

Here's the output of the last line above, indented by hand:

  $$\begin{array}{rcl}
      {\it aa} &=& {\it bb} \\
               &=& {\it cc} \\
               &=& {\it dd} \\
               &=& {\it ee} \\
    \end{array}
  $$

This was easy to do, and works great. But I couldn't find much
documentation on how to configure how display2d displays "Eq5"
objects. I was only able to write this prototype for the first step:

  MatrixEq5(ex) :=
    block([a,b,c,d,e], [a,b,c,d,e] : args (ex),
      matrix([a,"=",b],["","=",c],["","=",d],["","=",e]))$

If I run this

  MatrixEq5(Eq5(aa, bb, cc, dd, ee));

the output is:

      [ aa  =  bb ]
      [           ]
      [     =  cc ]
      [           ]
      [     =  dd ]
      [           ]
      [     =  ee ]

So, questions:

  1) How can I get rid of the outer "[]"s?
  2) How can I get rid of the blank lines?
  3) How can I make Eq5 objects be displayed with MatrixEq5?
  4) Where can I find docs and examples about this?

Thanks in advance! =)
  Eduardo Ochs
  http://angg.twu.net/eev-maxima.html



#####
#
# Notes on alt-display (from Leo Butler's answer to my question about Eq5)
# 2022aug27
#
#####

# «alt-display»  (to ".alt-display")
# (find-maximamsg "37698054 202208 24" "LButler: define_alt_display")
# (find-maximamsg "37698492 202208 25" "LButler: Apologies, before %i5 you need to also enter")
# (find-maximanode "Introduction to alt-display")
# (find-maximanode "Introduction to alt-display" "<*alt-display1d*>")
# (find-maximagitfile "share/contrib/alt-display/")
# (find-maximagitfile "share/contrib/alt-display/alt-display.lisp")
# (find-maximagitfile "share/contrib/alt-display/alt-display.mac")
# (find-maximagitfile "share/contrib/alt-display/tex-display.lisp")
# (find-maximagitgrep "grep --color=auto -nRH --null -e twod_display *")
# (find-maximanode "printf")
# (find-maximanode "display")
# (find-maximanode "display2d")
# (find-maximanode "get")
# (find-maximanode "mapatom")
# (find-maximanode "alt_display_output_type")
# (find-maximanode "define_alt_display")
# (find-maximanode "info_display")
# (find-maximanode "set_alt_display")
# (find-maximanode "tex_display")
# (find-maximanode "twod_display")
# (find-maxima-links "displa")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("alt-display.mac")$
? set_alt_display
? define_alt_display
define_alt_display(ochs_display(form),
   block([alt_display1d : false,
          alt_display2d : false,
          x : second(form),
          p],
     if mapatom(x) then displa(form) else
       if (p : get(op(x), display2d_printer)) # false then p(form) else
         twod_display(form)))$
set_alt_display(2, ochs_display);

fundef(displa);
grind(fundef(displa));

ochs_display(a*b);
twod_display(a*b);
grind(fundef(ochs_display));
properties(displa);

macroexpand(ochs_display(a*b));
put(Eq5, printEq5, display2d_printer)$
printEq5(x) := block([a : args(second(x))],
  printf(true, "BANG!~%~a ~{= ~a ~}~%!GNAB", first(a), rest(a)))$
display2d : true$
Eq5(aa,bb);
Eq5(aa,bb,cc,dd,ee);
1/2+x;


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("alt-display.mac")$
? displa
?? displa
fundef(displa);
properties(displa);
:lisp (describe '$displa)
:lisp (symbol-plist '$displa)
:lisp (get '$displa 'lineinfo)
set_alt_display(2, lambda([form], tex(?caddr(form))))$
integrate(exp(-t^2),t,0,inf);



#####
#
# barematrix
# 2023oct20
#
#####

# «barematrix»  (to ".barematrix")
# (find-angg "MAXIMA/barematrix1.mac")




#####
#
# includegraphics
# 2024nov03
#
#####

# «includegraphics»  (to ".includegraphics")
# (find-angg "MAXIMA/barematrix1.mac")
# (find-myqdraw "includegraphics.lisp")




#####
#
# imaxima
# 2021dec22
#
#####

# «imaxima»  (to ".imaxima")
# (find-angg ".emacs" "imaxima")
# (find-maximagitsh "find * | sort | grep -i imaxima")
# (find-node "(imaxima)Top")
# (find-node "(imaxima)Top" "Manual installation")
# (find-maximagitfile "interfaces/emacs/imaxima/")
# (find-maximagitfile "interfaces/emacs/imaxima/README")
# (find-maximagitfile "interfaces/emacs/imaxima/" "imaxima.el")
# (find-maximagitfile "interfaces/emacs/imaxima/" "imaxima.lisp")
# (find-maximagitfile "interfaces/emacs/imaxima/imaxima.el")
# (find-maximaelfile "" "imaxima.el")
# (find-efunction 'imaxima-latex)

(defun find-imaximaprocess (&rest rest)
  (require 'imaxima)
  (imaxima)
  (find-ebuffer
   (if imaxima-use-maxima-mode-flag
       "*maxima*"
     "*imaxima*")))

(defun eepitch-imaxima () (interactive)
  (eepitch '(find-imaximaprocess)))

(defun ee-imaxima-latex-middle-part ()
  (interactive)
  (while (not (eobp))
    (let* ((region-start (copy-marker (point)))
	   (region-end (copy-marker (next-single-property-change (point) 'display nil (point-max))))
	   (text-prop (get-text-property region-start 'display))
	   (latex-prop (get-text-property region-start 'latex)))
      (if latex-prop
	  (progn
	    (delete-region region-start region-end)
	    (goto-char region-start)
	    (insert (concat latex-prop "\n\n")))
	(progn
	  (goto-char region-start)
	  (insert "\n\\begin{verbatim}\n")
	  (goto-char region-end)
	  (insert "\n\\end{verbatim}\n\n"))))))

* (eepitch-imaxima)
* (eepitch-kill)
* (eepitch-imaxima)
1+2;


# (find-fline "~/bigsrc/maxima/interfaces/emacs/imaxima/")

(add-to-list 'load-path "~/bigsrc/maxima/interfaces/emacs/imaxima/")
(require 'imaxima)

# (find-sh "locate imaxima")





#####
#
# emaxima
# 2021dec21
#
#####

# «emaxima»  (to ".emaxima")
# (find-angg "LUA/emaxima.lua")
# (find-maximagitsh "find * | sort | grep -i emaxima")
# (find-maximagitfile "doc/emaxima/")
# (find-maximagitfile "interfaces/emacs/emaxima/")
# (find-maximagitfile "interfaces/emacs/emaxima/emaxima.sty")
# (find-maximagitgrep "grep --color=auto -nH --null -e session interfaces/emacs/emaxima/*")
# (find-fline "~/bigsrc/maxima/doc/emaxima/")

# (find-sh "locate emaxima")
# (find-fline "/usr/share/emacs/site-lisp/maxima/")
# (find-sitelispfile "")
# (find-sitelispgrep "grep --color=auto -nH --null -e session maxima/*")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "~/usrc/emaximaintro/")
rm -Rv ~/usrc/emaximaintro/
mkdir  ~/usrc/emaximaintro/
cd     ~/usrc/emaximaintro/
cp -v ~/bigsrc/maxima/doc/emaxima/EMaximaIntro.tex .
cp -v ~/bigsrc/maxima/interfaces/emacs/emaxima/emaxima.sty .
# cp -iv ~/bigsrc/maxima/interfaces/emacs/emaxima/emaxima.sty ~/LATEX/
pdflatex EMaximaIntro.tex
pdflatex EMaximaIntro.tex
pdflatex EMaximaIntro.tex

# Comment out:
# (find-fline  "~/LATEX/emaxima.sty" "\\usepackage{pdfcolmk}")
# (find-tkdiff "~/LATEX/emaxima.sty" "~/bigsrc/maxima/interfaces/emacs/emaxima/emaxima.sty")

# (code-c-d      "emaximaintro" "~/usrc/emaximaintro/")
# (code-pdf-page "emaximaintro" "~/usrc/emaximaintro/EMaximaIntro.pdf")
# (code-pdf-text "emaximaintro" "~/usrc/emaximaintro/EMaximaIntro.pdf")
# (find-emaximaintrofile "")
# (find-emaximaintrofile "emaxima.sty")
# (find-emaximaintropage)
# (find-emaximaintrotext)
# (find-emaximaintropage 3 "\\usepackage{emaxima}")
# (find-emaximaintrotext 3 "\\usepackage{emaxima}")
# (find-emaximaintropage 10 "\\begin{maximasession}")
# (find-emaximaintrotext 10 "\\begin{maximasession}")

# (find-epackage-links 'maxima "maxima" t)
# (find-epackage       'maxima)
# (code-c-d "maxima" "~/.emacs.d/elpa/maxima-20210526.1525/")
# (find-maximafile "")
# (find-maximagrep "grep --color=auto -nH --null -e maximasession *")



#####
#
# emaxima-conv
# 2021dec28
#
#####

# «emaxima-conv»  (to ".emaxima-conv")
# (find-angg ".emacs" "emaxima-conv")






#####
#
# My question on how to write a "savemaximasession"
# 2021dec21
#
#####

# «savemaximasession-0»  (to ".savemaximasession-0")
# Subj: Saving a \begin{maximasession} ... \end{maximasession} block
# (find-maximamsg "37405293 202112 22" "Edrx: saving a \\begin{maximasession}...")
# (find-maximamsg "37405573 202112 22" "LButler: another low-level way")

People,

what are your favourite ways to convert a part of a log of a Maxima
session to LaTeX? Let me explain what I did and what I need...

I am on Debian and besides having Maxima installed from the Debian
packages I also have a clone of the git repository of Maxima in the
directory ~/bigsrc/maxima/. I was able to compile EMaximaIntro.tex
with:

  rm -Rv /tmp/emaxima/
  mkdir  /tmp/emaxima/
  cd     /tmp/emaxima/
  cp -v ~/bigsrc/maxima/doc/emaxima/EMaximaIntro.tex .
  cp -v ~/bigsrc/maxima/interfaces/emacs/emaxima/emaxima.sty .
  pdflatex EMaximaIntro.tex
  pdflatex EMaximaIntro.tex

I followed the instructions in the pages 3 and 10 of EMaximaIntro.pdf
and created a .tex file whose important parts were:

  \usepackage{emaxima}
  ...
  \begin{maximasession}
  diff(sin(x),x);
  integrate(cos(x),x);
  \maximaoutput*
  \i5. diff(sin(x),x); \\
  \o5. \cos x \\
  \i6. integrate(cos(x),x); \\
  \o6. \sin x \\
  \end{maximasession}

When I LaTeXed it I got exactly the kind of output that I was looking
for.

My question is: how do I generate a maximasession block like the one
above from inside a Maxima session? Can you recommend me a low-level
way to do that? I normally run Maxima inside Emacs using the low-level
way to send lines to its REPL described here -

  http://angg.twu.net/LATEX/2021emacsconf.pdf  <- slides
  http://angg.twu.net/emacsconf2021.html

I do have Fermin MF's maxima.el installed,

  https://gitlab.com/sasanidas/maxima
  https://emacsconf.org/2020/talks/33/

but I don't understand it well yet, and when I tried to integrate it
with my way of doing things I stumbled on some quirks of its function
`maxima-string'... I tried to ask Fermin for help but he was too busy,
so I thought that it was better to wait until 1) he was in holidays,
2) I had done more of my homework... anyway, I _think_ that I can
handle answers like "use Fermin's functions maxima-foo and maxima-bar"
- and answers that yield a command like

  savemaximasession(42, 99, "/tmp/foo");

that I can run in a Maxima REPL to save the cells 42 to 99 to /tmp/foo
as a maximasession block would be ideal...

  Thanks in advance!!!
    Eduardo Ochs
    http://angg.twu.net/#eev
    http://angg.twu.net/math-b.html



#####
#
# savemaximasession-1
# 2021dec22
#
#####

# «savemaximasession-1»  (to ".savemaximasession-1")
# https://mail.google.com/mail/u/0/#sent/KtbxLzGPpHrHZjRTJnHfpfxTcWlKbxMSNB
# (find-maximamsg "37405293 202112 22" "Edrx 1: Saving a \begin{maximasession} ...")
# (find-maximamsg "37405510 202112 22" "LButler 2")
# (find-maximamsg "37405573 202112 22" "LButler 3")
# (find-maximamsg "37405584 202112 22" "Edrx 4")
# (find-maximamsg "37405793 202112 22" "LButler 5")

Thanks!!!

A question on your first solution... I am using this to make sure
that an imaxima process is running and to switch to its buffer:

  (defun find-imaximaprocess (&rest rest)
    (require 'imaxima)
    (imaxima)
    (find-ebuffer            ;; this is similar to switch-to-buffer
     (if imaxima-use-maxima-mode-flag
         "*maxima*"
       "*imaxima*")))

I took the

  (if imaxima-use-maxima-mode-flag "*maxima*" "*imaxima*")

from the (cl-defun imaxima () ...). Is there a better way to find
the name of the imaxima buffer?

Btw, eev now supports imaxima (yay!), but it may be better to
rewrite the code above a bit... here are some details, for the
sake of completeness:

  http://angg.twu.net/eev-intros/find-eepitch-intro.html#2.3
  (find-eepitch-intro "2.3. `eepitch'")

About your second solution: it was exactly what I needed! I was
able to convert its output by hand to the format that emaxima.sty
expects in just a minute. =) =) =)

  Cheers,
    Eduardo Ochs
    http://angg.twu.net/#eev


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("emaxima.lisp");
load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp");
display2d:'emaxima;
integrate(x^2,x);
diff(sin(x),x);
diff(cos(x),x);

# (find-maximanode "Functions and Variables for TeX Output")



#####
#
# emaxima.lisp
# 2023jul23
#
#####

# «emaxima.lisp»  (to ".emaxima.lisp")
# (find-maximagitfile "interfaces/emacs/emaxima/emaxima.lisp")
# (find-maximagitfile "interfaces/emacs/emaxima/emaxima.lisp" "(if (eq $display2d '$emaxima)")

% (setq eepitch-preprocess-regexp "^")
% (setq eepitch-preprocess-regexp "^%T ")
%
%T * (eepitch-maxima)
%T * (eepitch-kill)
%T * (eepitch-maxima)
%T load("emaxima.lisp");
%T load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp")$
%T display2d:'emaxima$




#####
#
# emaxima-bug-2024jul20
# 2024jul20
#
#####

# «emaxima-bug-2024jul20»  (to ".emaxima-bug-2024jul20")
# (find-es "emacs" "maxima-font-lock-bug")
# (find-maximamsg "58797458 202407 21" "Edrx: display2d:'emaxima; fails")
# (find-maximamsg "58797475 202407 21" "RDodier: :lisp (setf (get '$display2d 'assign) nil)")
# (find-efunction 'find-Maxima2-links)

Hi all,

I updated Maxima to the latest version in
<https://git.code.sf.net/p/maxima/code> a few hours ago - after
several months - and in the current version emaxima.lisp doesn't
work...

Here are some details. I'm on Debian 11 ("oldstable"), and these
commands

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
  /usr/bin/maxima
    load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp");
    display2d:'emaxima;
    x*y;
    quit();
  
  /usr/local/bin/maxima
    load("/usr/local/share/emacs/site-lisp/emaxima.lisp");
    display2d:'emaxima;
    x*y;
    quit();

compare a version of Maxima in which "display2d:'emaxima;" works with
a version in which it doesn't work. Here's what I get when I execute
them:

  /home/edrx(edrx:sc)# /usr/bin/maxima
  
  Maxima 5.44.0 http://maxima.sourceforge.net
  using Lisp GNU Common Lisp (GCL) GCL 2.6.12
  Distributed under the GNU Public License. See the file COPYING.
  Dedicated to the memory of William Schelter.
  The function bug_report() provides bug reporting information.
  (%i1)   load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp");
  (%o1)           /usr/share/emacs/site-lisp/maxima/emaxima.lisp
  (%i2)   display2d:'emaxima;
  (%o2) \mathrm{emaxima}
  (%i3)   x*y;
  (%o3) x\,y
  (%i4)   quit();
  /home/edrx(edrx:sc)# 
  /home/edrx(edrx:sc)# /usr/local/bin/maxima
  Loading /home/edrx/.maxima/maxima-init.lisp
  Loading /home/edrx/.maxima/maxima-init.mac
  Maxima branch_5_47_base_1316_g59adc2c4c https://maxima.sourceforge.io
  using Lisp SBCL 2.1.1.debian
  Distributed under the GNU Public License. See the file COPYING.
  Dedicated to the memory of William Schelter.
  The function bug_report() provides bug reporting information.
  (%i1)   load("/usr/local/share/emacs/site-lisp/emaxima.lisp");
  (%o1)            /usr/local/share/emacs/site-lisp/emaxima.lisp
  (%i2)   display2d:'emaxima;
  
  assignment: cannot assign emaxima to `display2d': must be one of: false, true.
   -- an error. To debug this try: debugmode(true);
  (%i3)   x*y;
  (%o3)                                 x y
  (%i4)   quit();
  /home/edrx(edrx:sc)# 

Am I the only one getting that?

  Cheers, and thanks in advance,
    Eduardo Ochs
    http://anggtwu.net/eev-maxima.html





#####
#
# Maxima2.lua - an alternative to emaxima.sty
# 2023sep30
#
#####

# «Maxima2.lua»  (to ".Maxima2.lua")
# (find-angg "LUA/Maxima2.lua")
# (find-TH "eev-maxima" "embedding-in-LaTeX")






#####
#
# latex-output
# 2022jul04
#
#####

# «latex-output»  (to ".latex-output")
# (find-maximanode "tex")
# (find-maximanode "texput")
# (find-maximanode "texput" "texput (\"grad\", \" \\\\nabla \", prefix);")
# (find-LATEXgrep "grep --color=auto -nH --null -e emaxima *.tex")
# (find-LATEXgrep "grep --color=auto -nH --null display2d:.emaxima *.tex")
# (find-LATEXgrep "grep --color=auto -nH --null -e eepitch-maxima *.tex")
# (find-efunction 'emaxima-block)





#####
#
# 2021-2-C3-diag-nums
# 2021dec22
#
#####

# «2021-2-C3-diag-nums»  (to ".2021-2-C3-diag-nums")
# «eev-demo»  (to ".eev-demo")
# (c3m212dnp 5 "exercicio-2-maxima")
# (c3m212dna   "exercicio-2-maxima")
# (find-maximanode "plot2d")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
max(2, 4);
min(2, 4);
q(t)   := max(0, t-2);
r(t)   := min(q(t), 2);
S(x,y) := max(r(x), r(y));
plot2d (r(t), [t, 0, 6]);
plot3d (S(x,y), [x, 0, 6], [y, 0, 6]);
       





#####
#
# draw3d-points
# 2024feb27
#
#####

# «draw3d-points»  (to ".draw3d-points")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
seqn(a,b,n)       := makelist(a + (b-a)*k/n, k, 0, n);
mydraw3d([lists]) := apply('draw3d, apply('append, lists))$
mytranspose(m)    := args(transpose(apply('matrix, m)));
mypoints(pts)     := apply('points, mytranspose(pts));

mypoints([[2,3,4],[5,6,7]]);

f0(th) := [cos(th), sin(th), 0];
f1(th) := [cos(th), sin(th), cos(th)^2];

mydraw3d([points_joined=true,
          point_type=-1,
          mypoints(makelist(f0(th), th, seqn(0, 2*%pi, 100))),
          mypoints(makelist(f1(th), th, seqn(0, 2*%pi, 100)))
         ],
         makelist(mypoints([f0(th), f1(th)]), th, seqn(0, 2*%pi, 100))
        );




#####
#
# online-manual
# 2021dec22
#
#####

# «online-manual»  (to ".online-manual")
# (find-es "texinfo" "makeinfo-html")
# (find-maximanode "Introduction to Polynomials")
# https://maxima.sourceforge.io/docs/manual/maxima_75.html
# (find-maximagitfile "doc/info/")





#####
#
# linearize
# 2022may08
#
#####

# «linearize»  (to ".linearize")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
y    : x^(1/2);
f    : lambda([x], ''y);
x0   : 4;
y0   : f(x0);
y_x  : diff(y, x);
ff   : lambda([x], ''y_x);
Dx   : x - x0;
L    : lambda([x], ''(f(x0) + ff(x0) * Dx));
fL   : lambda([x], [f(x), ev(L(x),numer)]);
fL(4);
fL(4.02);
fL(3.95);
** (find-es "maxima" "draw")
draw(gr2d(explicit(f(x),  x,0,6),
          color="red",
          explicit(L(x),  x,0,6)
          )
    );




#####
#
# depends
# 2021dec28
#
#####

# «depends»  (to ".depends")
# (find-maximabookpage (+ 1 50) "depends")
# (find-maximaindex-links "depends")
# (find-maximanode "Functions and Variables for Differentiation" "Function: depends")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
? depends

depends ([f, g], x);
depends ([r, s], [u, v, w]);
depends (u, t);
dependencies;
diff (r.s, u);
diff (r.s, t);
remove (r, dependency);
diff (r.s, t);




#####
#
# depends-quadratic
# 2022jan12
#
#####

# «depends-quadratic»  (to ".depends-quadratic")
# (c3m212qp 3 "equacao-da-superficie")
# (c3m212qa   "equacao-da-superficie")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
z : a + b*Dx + c*Dy + d*Dx^2 + e*Dx*Dy + f*Dy^2;
zz : psubst ([Dx=x1-x0, Dy=y1-y0], z);
zz : psubst ([x0=4, y0=3], zz);





#####
#
# The text of my e-mail to the mailing list about dependent variables
# 2022jan11
#
#####

# «depends-email»  (to ".depends-email")
# (find-maximamsg "37415334 202201 11" "Edrx: f:x^2 versus g(x):=x^2")
# (find-maximamsg "37415338 202201 11" "DBillinghurst")
# (find-maximamsg "37415350 202201 11" "Edrx: ta-da")
# (find-maximamsg "37415545 202201 11" "Stavros: noun/verb")
# (find-maximamsg "37415545 202201 11" "Stavros: If *f* has *not* been defined as a routine")
# (find-maximamsg "37415708 202201 11" "RFateman")
# Subj: "f:x^2" versus "g(x):=x^2", and a question on dependent variables
# (to "2-lisp")

Hi list,

I am trying - first - to understand the difference between these ways
of defining functions,

  f    :   x^2;
  g(x) :=  x^3;
  h(x) ::= x^4;

both from a user's points of view and from a common lisper's point of
view, and - second - I'm looking for some references on how people
decided to implement things in this way... let me explain.

First: what are your favorite ways to show how the innards of Maxima
see the "f", the "g(x)", and the "h(x)" above? I executed this,

  f    :   x^2;
  g(x) :=  x^3;
  h(x) ::= x^4;
  f;
  g;
  g(x);
  g(y);
  dispfun(g);
  dispfun(h);

  :lisp #$[f]$
  :lisp #$[F]$
  :lisp #$[g]$
  :lisp #$[g(x)]$
  :lisp         #$[g(y+z)]$
  :lisp (displa #$[g(y+z)]$)
  :lisp         '((MLIST SIMP) ((MEXPT SIMP) ((MPLUS SIMP) $Y $Z) 3))
  :lisp (displa '((MLIST SIMP) ((MEXPT SIMP) ((MPLUS SIMP) $Y $Z) 3)))

  :lisp                $functions
  :lisp           (cdr $functions)
  :lisp (dispfun1 (cdr $functions) t nil)
  :lisp                $macros
  :lisp           (cdr $macros)
  :lisp (dispfun1 (cdr $macros) t nil)

I haven't progressed much beyond this point yet... for example, I
still don't know where f is stored, and I am trying to understand the
"(defmspec $dispfun ...)" and the "(defun dispfun1 ...)" in
src/mlisp.lisp, but my attempts to run parts of their code in "(let
(...) ...)" inside the Lisp REPL, i.e., inside a "to_lisp();" /
"(to-maxima)" block in the Maxima REPL, are not working - and I don't
even know why first line below works but the second one doesn't:

  dispfun(g);
  :lisp #$[dispfun(g)]#

So I'm a beginner asking questions that may look too advanced...
sorry! By the way, my favorite style for explaining these inner
details _in Emacs Lisp_ is with tutorials like this one,

  http://angg.twu.net/eev-intros/find-elisp-intro.html#6

in which I expect people to execute lots of sexps in different orders,
and understand their results.



Now the second question. This one is more open-ended, and any pointer
to references and/or to keywords to search for are more than welcome.

I teach Calculus 2 and 3 in a small university in Brazil - or, more
precisely, in a small countryside campus that is part of a big
university whose main campus is 300 Km away - and I started an
experiment a few semesters ago. Instead of teaching the students only
the modern notational conventions, in which in

  g(x) := x^3;

the name "x" is always totally irrelevant and can be replaced by any
other name, I am trying to teach them both the "old" convention and
the "new" one, and I trying to show how to translate between the two,
even though I don't know all the rules of the translation...

The "old" convention can be seen for example here,

  Silvanus P. Thompson - "Calculus Made Easy" (1914) - p.14:
  https://www.gutenberg.org/files/33283/33283-pdf.pdf#page=25

and the "new" convention is the one that says that variables and
functions must have different names, all arguments should be explicit,
there is no such thing as a "dependent variable", and so on.

I call the "old" convention "physicists' notation" and the "new" one
the "mathematicians' notation", always between quotes, and I always
explain to the students that my attempts to formalize the translation
are totally improvised, and that I've asked my friends who work in
EDPs or in Mathematical Physics where I can find formalizations of the
translation and they simply don't know...

So: Maxima has some support for dependent variables - see "? depends"
- and I _guess_ that as Maxima is quite old some of its old papers may
contain discussions on how people were trying to implement both the
"mathematicians' notation" and the "physicists' notation" on Computer
Algebra Systems, and how they reached the implementation that Maxima
still uses today... I took a look here,

  http://ftp.math.utah.edu/pub/tex/bib/macsyma.html

but that list is huge, it has very few links to online versions, and
most of them are broken, and none of the titles mention dependent
variables explicitly...

  Thanks in advance!!!
    Eduardo Ochs
    http://angg.twu.net/eev-maxima.html


P.S.: for the sake of completeness, my material on the "physicists'
notation" is here -
http://angg.twu.net/LATEX/2021-2-C3-notacao-de-fisicos.pdf - but it is
messy and in Portuguese...




#####
#
# Code for my e-mail on depend variables
# 2022jan10
#
#####

# «depends-email-code»  (to ".depends-email-code")
# (find-maximagitgrep "grep --color=auto -niRH --null -e biblio *")
# (find-maximagitgrep "grep --color=auto -niRH --null -e bibarchive *")
# (find-maximagitfile "")
# (find-maximanode "Functions and Variables for Expressions")
# (find-maximanode "Nouns and Verbs")
# (find-maximanode "Lisp and Maxima")
# (find-maximanode "Functions and Variables for Command Line" "System variable: infolists")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f    :   x^2;
g(x) :=  x^3;
h(x) ::= x^4;
f;
g;
g(x);
g(y);
dispfun(g);
dispfun(h);
**
:lisp #$[f]$
:lisp #$[F]$
:lisp #$[g]$
:lisp #$[g(x)]$
:lisp         #$[g(y+z)]$
:lisp (displa #$[g(y+z)]$)
:lisp         '((MLIST SIMP) ((MEXPT SIMP) ((MPLUS SIMP) $Y $Z) 3))
:lisp (displa '((MLIST SIMP) ((MEXPT SIMP) ((MPLUS SIMP) $Y $Z) 3)))
**
                      functions;
:lisp                $functions
:lisp           (cdr $functions)
:lisp (dispfun1 (cdr $functions) t nil)
                      macros;
:lisp                $macros
:lisp           (cdr $macros)
:lisp (dispfun1 (cdr $macros) t nil)
**
** The ":lisp" below yields an error:
**
dispfun(g);
:lisp #$[dispfun(g)]#
**
values;
labels;


# Based on a suggestion by David Billinghurst:

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
display2d:false$
f : x^2$
g(x) := x^3$
h(x) ::= x^4$
values;
functions;
macros;
fundef(g);
fundef(h);
**
infolists;




#####
#
# depends-email-lambda
# 2022jan11
#
#####

# «depends-email-lambda»  (to ".depends-email-lambda")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
x       : 3;
y       : 4;
f       :  x^2+y^2;
f1(x)   := x^2+y^2;
f1(z);
  y : 0;
  f1(z);
  y : 4;
  f;
f2(x,y) := x^2+y^2;
f2(w,z);
f3      : lambda([x], x^2+y^2);
f3(z);
f(q)    := q+f;
f(z);
** /*  yes Maxima is like a "2-lisp".  A name can be used for a function and a value */
:lisp $f
:lisp (symbol-plist '$f)

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f :  x^2;
f(x) := x^3;
g : lambda([x], x^4);

g    : lambda([x], x^2+y^2);
:lisp $f
:lisp (symbol-plist '$f)




#####
#
# quote
# 2022jan12
#
#####

# «quote»  (to ".quote")
# (find-maximanode "quote")
# (find-maximanode "quote" "prevents evaluation")
# (find-maximanode "quote" "does not prevent simplification")
# (find-maximanode "Functions and Variables for Help" "'describe' quotes its argument")
# (find-maximanode "Functions and Variables for Simplification" "Option variable: simp")
# (find-maximanode "Introduction to Simplification")
# (find-maximanode "Lisp and Maxima" "`#$<expr>$'")
# https://people.eecs.berkeley.edu/~fateman/papers/intro5.txt

# (code-c-d "fatemanp" "$S/https/people.eecs.berkeley.edu/~fateman/papers/")
# (find-fatemanpfile "")
# (find-fatemanpfile "intro5.txt")
# (find-fatemanpfile "intro5.txt" "MACSYMA Syntax and Internal Representation")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a;
?a;
"a";
`a;
:lisp #$x+y$
:lisp #$x-y$

diff(f(x), x);
diff(f(g(x)), x);




#####
#
# quote-quote
# 2024oct22
#
#####

# «quote-quote»  (to ".quote-quote")
# (find-maximanode "quote-quote")
# (find-maximanode "kill")
# (find-maximanode "kill" "quote-quote")
# (to "low-level-makelist")
# (to "lambda")




#####
#
# input-string-parser-output
# 2022jan13
#
#####

# «input-string-parser-output»  (to ".input-string-parser-output")
# (code-c-d "fatemanp" "$S/https/people.eecs.berkeley.edu/~fateman/papers/")
# (find-fatemanpfile "intro5.txt" "Input String" "Parser Output")
# (find-maximagitfile "src/nparse.lisp")
# (find-maximagitgrep "grep --color=auto -nH --null -e defun src/nparse.lisp")
# (find-maximagitgrep "grep --color=auto -niH --null -e reader src/*.lisp")
#
# Thread: A question about parsing: ":lisp #$expr$" is not low-level enough
# (find-maximamsg "37416623 202201 13" "Edrx: :lisp #$expr$ is not low-level enough")
# (find-maximamsg "37416631 202201 13" "RDodier")
# (find-maximamsg "37416632 202201 13" "RFateman")
# (find-maximamsg "37416641 202201 13" "Edrx")
# (find-maximamsg "37416792 202201 13" "MTalon")
# (find-maximamsg "37416824 202201 13" "Stavros: that is evaluated is immediately simplified")
# (find-maximamsg "37416824 202201 13" "Stavros: within *lambda* expressions")
# (find-maximamsg "37417262 202201 14" "Edrx")
# (find-maximamsg "37417447 202201 14" "Stavros")
# (find-maximamsg "37417646 202201 14" "RFateman")
# (find-maximamsg "37417663 202201 14" "BWillis")
# (find-maximamsg "37417692 202201 14" "PKlosowski")
# (find-maximamsg "37417720 202201 15" "RFateman")
# (find-maximamsg "37418008 202201 15" "RToy")
# (find-maximamsg "37418382 202201 16" "JVillate")
# (find-maximamsg "37419130 202201 17" "Edrx")
# (find-maximamsg "37419177 202201 17" "RFateman")


Hi Richard and Stavros,

I made some progress on the questions that I asked here,

  https://sourceforge.net/p/maxima/mailman/message/37415334/
  https://sourceforge.net/p/maxima/mailman/message/37415708/

but I need to ask more questions, and I felt that it was better to
create a new thread.

I am reading about expressions, simplification, evaluation, and the
internal representation mainly in these places:

  (info "(maxima)Expressions")
  (info "(maxima)Evaluation")
  (info "(maxima)Simplification")
  (info "(maxima)Lisp and Maxima")
  https://people.eecs.berkeley.edu/~fateman/papers/intro5.txt

The first two sentences of

  (info "(maxima)Introduction to Simplification")

are:

  Maxima performs a cycle of actions in response to each new
  user-typed command. This consists of four steps: reading or
  "parsing" the input, evaluation, simplification and output.

I am still in a stage in which the rules for evaluation and
simplification feel overwhelming, so I'm trying to understand parsing,
evaluation, simplification, and output separately...

The second part of

  https://people.eecs.berkeley.edu/~fateman/papers/intro5.txt

has a table with "Input String"s in the left column and "Parser
Output"s in the right column. The most obvious - and naïve - way to
transform that table into a series of executable examples/tests is to
wrap each "Input String" in a ":lisp #$___$"; I found that if I run a
"simp:false;" before the tests then all these tests yield essentially
the same results as in the paper (obs: I had to fix some typos - or
scanos - in the .txt... Richard, do you want a list of the
typos/scanos?):

  simp:false;
  :lisp #$a$
  :lisp #$?a$
  :lisp #$"a"$
  :lisp #$x+y$
  :lisp #$x-y$
  :lisp #$x*y$
  :lisp #$a(x)$
  :lisp #$a[1,2]$
  :lisp #$a[1,2](x)$
  :lisp #$sin(x)$
  :lisp #$x/y$
  :lisp #$x.y$
  :lisp #$x^2$
  :lisp #$x^^2$
  :lisp #$[a,b,c]$
  :lisp #$if a then b$
  :lisp #$if a then b else c$
  :lisp #$'diff(y,x)$
  :lisp #$'integrate(a,b,c,d)$
  :lisp #$not a$
  :lisp #$a or b$
  :lisp #$a and b$
  :lisp #$a=b$
  :lisp #$a>b$
  :lisp #$a>=b$
  :lisp #$a<b$
  :lisp #$a<=b$
  :lisp #$a#b$

but these entries give outputs that are very wrong:

  :lisp #$'a$
  :lisp #$(a,b,c)$
  :lisp #$for i:a thru b step c unless q do f(i)$
  :lisp #$for i:a next n unless q do f(i)$
  :lisp #$for i in L do f(i)$
  :lisp #$diff(y,x)$
  :lisp #$diff(y,x,2,z,1)$
  :lisp #$integrate(a,b,c,d)$
  :lisp #$block([l1,l2], s1,s2)$
  :lisp #$block(s1,s2)$
  :lisp #$a:b$
  :lisp #$a::b$
  :lisp #$a(x):f$

it seems that there is some kind of evaluation that is still going on.
How can I run just the parser? I guess that it would be something like
this,

  to_lisp();
    (mread-raw "a<b")

but using another function, as mread-raw expects a stream...

  Thanks in advance =),
    Eduardo Ochs
    http://angg.twu.net/eev-maxima.html
    http://angg.twu.net/e/maxima.e.html#input-string-parser-output





#####
#
# parse-string - Robert Dodier's answer to the question above
# 2022jan13
#
#####

# «parse-string»  (to ".parse-string")
# (find-maximanode "stringproc-pkg")
# (find-maximanode "String Processing" "Function: parse_string")
# (find-maximagitsh "find * | grep stringproc")
# (find-maximagitfile "share/stringproc/")
# (find-maximagitfile "share/stringproc/eval_string.lisp" "(defun $parse_string ")
# (find-maximagitfile "share/stringproc/eval_string.lisp" "(defun parse-string ")
# (find-maximagitfile "")
# (find-maximamsg "37416631 202201 13" "RDodier")
# (to "eval")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(stringproc);
:lisp ($parse_string "'a")
:lisp ($parse_string "(a,b,c)")
:lisp ($parse_string "for i:a thru b step c unless q do f(i)")
:lisp ($parse_string "for i:a next n unless q do f(i)")
:lisp ($parse_string "for i in L do f(i)")
:lisp ($parse_string "diff(y,x)")
:lisp ($parse_string "diff(y,x,2,z,1)")
:lisp ($parse_string "integrate(a,b,c,d)")
:lisp ($parse_string "block([l1,l2], s1,s2)")
:lisp ($parse_string "block(s1,s2)")
:lisp ($parse_string "a:b")
:lisp ($parse_string "a::b")
:lisp ($parse_string "a(x):f")




#####
#
# stringproc
# 2023jul15
#
#####

# «stringproc»  (to ".stringproc")
# (find-maximanode "stringproc-pkg")
# (find-sh "locate maxima | grep stringproc")
# (find-maximagitfile "share/stringproc/")
# (find-maximagitfile "share/stringproc/printf.lisp")
# (find-maximagitfile "share/stringproc/stringproc.mac")




#####
#
# displr-email
# 2022jan14
#
#####

# «displr-email»  (to ".displr-email")
# (find-maximamsg "37417262 202201 14" "Edrx: My use case is very atypical")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
simp:false;
q: lambda([foo], x+x);
q2: subst ([x=a+b], q);
to_lisp();
  $q
  (caddr $q)
  (displa (caddr $q))
  (defun $displrl (lambdaexpr) (displa (caddr lambdaexpr)))
  ($displrl $q)
  (to-maxima)
q2;
displrl(q2)$
q3: lambda([foo], integrate(a,b,c,d));
q3: lambda([foo], integrate(a,b));
displrl(q3)$
? integrate
integrate(a,b,c,d);
'integrate(a,b,c,d);
q3: lambda([foo], 'integrate(a,b,c,d));
q3: subst([a=x+y], q3);
displrl(q3)$


doeval(q2);

q: lambda([foo], ('integrate(f(x), x, a, b) = F(b) - F(a)));
  displr(q)$
  displr(subst([a=42, b=99], q))$
  displr(subst([a=42, b=99, f(x)=3*x^2, F(x)=x^3], q))$
  displr(subst([a=42, b=99, f(x)=3*x^2, F=lambda([x],x^3)], q))$



* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
simp:false;
q: lambda([foo], 'integrate (x+x, x, a, b));
to_lisp();
  $q
  (caddr $q)
  (displa (caddr $q))
  (defun $displrl (lambdaexpr) (displa (caddr lambdaexpr)))
  ($displrl $q)
  (to-maxima)
displrl(q)$
displrl(subst([x=y+y], q))$



Nifty!!!!!!! =) =) =)

My use case is very atypical. In my classes I have many students who
have very little practice with using variables - really! It's sad &
scary - and when these students have to take a formula and perform a
substitution on it to obtain a particular case they usually make a big
mess... for example, they often substitute only certain occurrences of
the variables, and leave the other ones unsubsituted. And when they
have to perform substitutions on theorems, propositions, or proofs the
mess is even bigger...

So: I'm trying to teach them that substitution and simplification _can
be treated_ as separate operations, and when we keep them as separate
steps our calculations become much easier to debug... We're doing that
on paper, and I told them that I believe that all decent programs for
Computer Algebra should be able to perform substitution in a purely
syntactical way, without simplification, _if we call the right
low-level functions in them_. With your trick I'm almost there... try
this:

  simp:false;
  to_lisp();
    (defun $displr (lambdaexpr) (displa (caddr lambdaexpr)))
    (to-maxima)
  q: lambda([foo], ('integrate(f(x), x, a, b) = F(b) - F(a)));
  displr(q)$
  displr(subst([a=42, b=99], q))$
  displr(subst([a=42, b=99, f(x)=3*x^2, F(x)=x^3], q))$
  displr(subst([a=42, b=99, f(x)=3*x^2, F=lambda([x],x^3)], q))$

In the last two lines I'm trying to replace all occurrences of F(expr)
by expr^3, but I haven't found the right trick yet...

  Cheers and probably thanks in advance =),

  Eduardo Ochs
    http://angg.twu.net/eev-maxima.html











#####
#
# trace-parser
# 2022jan13
#
#####

# «trace-parser»  (to ".trace-parser")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
:lisp (trace parser)
(a,b,c);




#####
#
# lisp-trace
# 2023jul17
#
#####

# «lisp-trace»  (to ".lisp-trace")
# (find-maximamsg "37872177 202307 17" "RFateman: :lisp (trace")
# (find-es "lisp" "trace")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
v: rat((x+y+5)^2);
:lisp (trace newvar pplus ptimes pexpt)
v: rat((x+y+5)^2);
?print(v);




#####
#
# lisp-trace-meval
# 2024jul20
#
#####

# «lisp-trace-meval»  (to ".lisp-trace-meval")
# (find-maximamsg "58796109 202407 16" "Stavros: :lisp (trace meval)")
# (find-es "lisp" "trace")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
:lisp   (trace meval)
makelist(x^2, x, 3, 5);
:lisp (untrace meval)




#####
#
# reader
# 2022jan13
#
#####

# «reader»  (to ".reader")
# (find-maximagitgrep "grep --color=auto -niH --null -e reader src/*.lisp")
# (find-maximagitgrep "grep --color=auto -niH --null -e '#\\$' src/*.lisp")
# (find-maximagitgrep "grep --color=auto -niH --null -e set-dispatch-macro-character src/*.lisp")
# (find-maximagitfile "src/commac.lisp" "(defvar *sharp-read-buffer*")
# (find-maximagitfile "src/intl.lisp")
# (find-es "lisp" "sharpsign-quote")
# (find-es "lisp" "sharpsign-minus")

Fantastic! Thanks!!! =)

By the way, where is the code that tells the Lisp reader how to handle
expressions starting with "#$"? This page

  (info "(maxima)Lisp and Maxima")

mentions "The '#$' Lisp macro" but it doesn't give a function name or
the name of a Lisp file, and I grepped a bit and couldn't find it...

  Cheers =),
    E.



# From Michel Talon, 2022jan13:
# (find-maximamsg "37416792 202201 13" "MTalon")

Such stuff from the lisp side is treated by  set-dispatch-macro-character.

For this specific case i think this is the code in commac.lisp starting with

defvar *sharp-read-buffer*  and ending with
(set-dispatch-macro-character #\# #\$ #'x$-cl-macro-read)

Note that  other parsing functions for maxima are rather in intl.lisp.




#####
#
# lambda-simp
# 2022jan13
#
#####

# «lambda-simp»  (to ".lambda-simp")
# (find-maximamsg "37416824 202201 13" "Stavros: to prevent evaluation")

Simplification does not happen as a separate step after evaluation of
the whole expression. Every subexpression that is evaluated is
immediately simplified. Maxima couldn't possibly work otherwise.

Obviously we need to be review our documentation more carefully to
keep such howlers out!

Using :lisp #$ ... $ seems pretty roundabout. To turn off
simplification, set simp:false. To prevent evaluation, use '( ... ).
To show the internal form of something, use ?print(...).

Here's a neat trick: within lambda expressions (as well as named
function definitions), neither simplification nor evaluation is
performed, so q: lambda([simp], ?print(2+2)) might help you see how
things work; look at q, and call q(false) and q(true) .


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
simp:false;
q: lambda([simp], ?print(2+2));
q;
q(false)$
q(true)$
q: lambda([simp], ?print(x+x));
q: lambda([simp], ?print(x/x));
q2: subst ([x=a/b], q);
q2: subst ([x=a+b], q);
print(q)$
print(q2)$
q2(true);
q2(false);
print(q);
to_lisp();
  $q
  (cdr $q)
  (cddr $q)
  (displa (cddr $q))
  `(a b ,(+ 1 2))
  (to-maxima)
:lisp #$[x, y, z]$
:lisp (displa '((MLIST SIMP) $X $Y $Z))




#####
#
# nroots
# 2024jul26
#
#####

# «nroots»  (to ".nroots")
# https://en.wikipedia.org/wiki/Sturm%27s_theorem
# (find-maximanode "nroots")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
nroots((x-5)*(x-7)*(x^2+42),minf, inf);
nroots((x-5)*(x-7)*(x^2+42),6, 8);





#####
#
# arrays
# 2024aug04
#
#####

# «arrays»  (to ".arrays")
# (find-maximanode "Arrays")
# (find-maximanode "array")
# (find-maximanode "arrayinfo")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
array (aa, 2, 3);
aa [2, 3] : %pi;
aa [1, 2] : %e;
arrayinfo (aa);
listarray (aa);
bb [FOO] : (a + b)^2;
bb [BAR] : (c - d)^3;
arrayinfo (bb);
listarray (bb);
cc [x, y] := y / x;
cc [u, v];
cc [4, z];
arrayinfo (cc);
listarray (cc);
for i:0 thru 10 do a[i]:i^2$
indices:map(first,rest(rest(arrayinfo(a))));
array(A,fixnum,length(indices)-1)$
fillarray(A,map(lambda([x],a[x]),indices))$
listarray(A);
dd [x] (y) := y ^ x;
dd [a + b];
dd [v - u];
arrayinfo (dd);
listarray (dd);






#####
#
# symbol-plist
# 2022jan11
#
#####

# «symbol-plist»  (to ".symbol-plist")
# (find-maximagitfile "src/mlisp.lisp" "(defmspec $dispfun ")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
to_lisp();
  (describe '$dispfun)
  (describe '$dispfun)
  (describe 'dispfun1)
  (symbol-plist '$dispfun)
  (describe 'getf)
  (describe 'get)
  (get '$dispfun 'mfexpr*)

<Catie> GETF would be like (getf (symbol-plist '$dispfun)
        '$mfexpr).  GETF is for plists, GET is for symbols


  (getf '$dispfun 'mfexpr*)
  (getf 'mfexpr* '$dispfun)
(describe 'getf)



#####
#
# demos
# 2022jan01
#
#####

# «demos»  (to ".demos")
# (find-maximagitsh "find * -type f | sort")
# (find-maximagitsh "find * -type f | sort | grep 'dem$'")
# (find-maximagitfile "share/calculus/fourie.dem")




#####
#
# fourier
# 2022jan01
#
#####

# «fourier»  (to ".fourier")
# (find-maximaindex-links "absint fourexpand fourint foursimp foursin funp remfun")
# (find-maximagitfile "share/calculus/fourie.dem")
# (find-maximagitfile "")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load('fourie)$
funp(sin,sin(a)*cos(x)+sin(b));
funp(sin,sin(a)*cos(x)+sin(b),x);
remfun(abs,abs(a)+sin(abs(b)+c)*abs(d)/e);
remfun(abs,abs(a*abs(x)+abs(b))+abs(c)+abs(x*abs(d)),x);
f(f(f(a)+b)*c)*f(d)^f(e);
remfun(f,''%);
absint(abs(a)*abs(x),x,both);
absint(abs(cos(x)),x);
** absint(abs(a)*exp(-abs(b)*abs(x)),x,minf,inf);
absint(sin(x),x,-%pi,%pi);
absint(abs(sin(x)),x,-%pi,%pi);
fourier(abs(x),x,1);
foursimp(%);
fourexpand(%,x,1,inf);
fourexpand(%th(2),x,1,5);
totalfourier(x,x,%pi);
foursin(1,x,%pi);
foursimp(%);
fourint(exp(-abs(x)),x);




#####
#
# fourie.mac fails for simple square wave
# 2024aug19
#
#####

# «fourier-square-wave»  (to ".fourier-square-wave")
# (find-maximamsg "58748861 202403 14" "EMajzoub: fourie.mac fails for simple square wave")
# (find-maximamsg "58749337 202403 15" "")
# (find-maximamsg "58749351 202403 15" "")
# (find-maximamsg "58749358 202403 15" "")
# (find-maximamsg "58749389 202403 15" "")
# (find-maximamsg "58749434 202403 15" "")
# (find-maximamsg "58749762 202403 17" "EMajzoub: fourie.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(abs_integrate);
load(fourie);
f(x) := 2*unit_step(x) -1 ;
foursimp(fourier(f(x),x,1));




#####
#
# taylor
# 2022jan01
#
#####

# «taylor»  (to ".taylor")
# (to "ratpow")
# (find-maximanode "taylor")
# (find-maximanode "trunc")
# (find-maximagitgrep "grep --color=auto -nRH --null -e 'truncated Taylor or Laurent' *")
# (find-maximagitgrep "grep --color=auto -niRH --null -e taylor *")
# (find-maximagitgrep "grep --color=auto -niRH --null -e taylor bin/src/*")
# (find-maximagitgrep "grep --color=auto -niRH --null -e taylor demo*")
# (find-maximagitgrep "grep --color=auto -niRH --null -e taylor share/calc*")
# (find-maximagitgrep "grep --color=auto -niRH --null -e taylor share/builtins-list.txt")
# (find-maximagitgrep "grep --color=auto -niRH --null -e taylor src/*")
# (find-maximagitgrep "grep --color=auto -niRH --null -e taylor tests/*")
# (find-maximagitfile "doc/info/Series.texi" "truncated Taylor or Laurent series")
# (find-maximagitfile "archive/info/maxima.fns" "\\entry {\\code {TAYLOR}}{184}")
# (find-maximagitfile "doc/share/brchre.txt" "has an excellent Taylor series")
# (find-maximagitfile "doc/share/brchre.txt" "A truncated series")
# (find-maximagitfile "om" "processing (SUBC $TAYLOR ...)")
# (find-maximagitfile "src/hayat.lisp")
# (find-maximagitfile "src/mhayat.lisp")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** ? taylor
** ?? taylor
:lisp (describe '$taylor)

taylor (sqrt (sin(x) + a*x + 1), x, 0, 3);
%^2;
taylor (sqrt (x + 1), x, 0, 5);
%^2;
product ((1 + x^i)^2.5, i, 1, inf)/(1 + x^2);
ev (taylor(%, x,  0, 3), keepfloat);
taylor (1/log (x + 1), x, 0, 3);
taylor (cos(x) - sec(x), x, 0, 5);
taylor ((cos(x) - sec(x))^3, x, 0, 5);
taylor (1/(cos(x) - sec(x))^3, x, 0, 5);
taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6);
taylor ((x + 1)^n, x, 0, 4);
taylor (sin (y + x), x, 0, 3, y, 0, 3);
taylor (sin (y + x), [x, y], 0, 3);
taylor (1/sin (y + x), x, 0, 3, y, 0, 3);
taylor (1/sin (y + x), [x, y], 0, 3);

taylor (exp(2*x), x, 0, 3);
taylor (exp(2*x), x, 0, 4);
taylor (exp(2*x), x, 0, 5);
ta : taylor (exp(2*x), x, 0, 3);
ta;
:lisp #$ta$
coeff(ta, x, 3);
sta : subst(x=1/2, ta);
ev(sta, NUMER);
ev(sta, FLOAT);



ta : taylor (exp(2*x), x, 0, 3);
:lisp #$ta$

((MRAT SIMP
       (((MEXPT) $%E $X) $X)
       (%e^x491 X492)
       (($X ((3 . 1)) 0 NIL X492 . 2))
       TRUNC)
 PS
 (X492 . 2)
 ((3 . 1))
 ((0 . 1) 1 . 1)
 ((1 . 1) 2 . 1)
 ((2 . 1) 2 . 1)
 ((3 . 1) 4 . 3))




#####
#
# More notes on Taylor series
# 2022apr26
#
#####

# «taylor-2»  (to ".taylor-2")
# (find-maximaindex-links "coeff lambda makelist subst sum taylor trunc")
# (find-maximaindex-links "coeff")
# (find-maximanode "Functions and Variables for Numbers" " map ")
# (find-maximaindex "coeff")
# (find-maximaindex "coeff" :RET)
# (find-maximanode "coeff")
# (find-maximanode "lambda")
# (find-maximanode "makelist")
# (find-maximanode "subst")
# (find-maximanode "sum")
# (find-maximanode "taylor")
# (find-maximanode "taytorat")
# (find-maximanode "trunc")


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
maxk         : 5;
ta_series    : taylor(exp(10*x), x, 0, 4);
ta_series    : taylor(exp(10*x), x, 0, maxk);
ta_poly      : subst(x=x, ta_series);
ta_coeff     : lambda([k], coeff(ta_series, x, k));
ta_coeff     : lambda([k], coeff(ta_poly,   x, k));
ta_coeff(2);
ta_coeff(3);
ta_coeffs    : makelist(ta_coeff(k), k, 0, maxk);
ta_coeffs    : [1, 10, 50, 300/3, 1250/3, 2500/3];
ta_coeffs    : makelist(ta_coeff(k), k, 0, maxk);
ta_monomial  : lambda([k], ta_coeffs[k+1] * x^k);
ta_monomials : makelist(ta_monomial(k), k, 0, maxk);

ta_at        : lambda([x0], subst(x=x0, ta_poly));
ta_at        : lambda([x0], subst(x=x0, ta_series));
ta_at(0.01);
exp(10*0.01);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f   : exp(x);
f   : log(x+1);
fn  : lambda([maxk],            taylor(f, x, 0, maxk) );
fn  : lambda([maxk], subst(x=x, taylor(f, x, 0, maxk)));
display2d : false;
f0  : fn(0);
f1  : fn(1);
f2  : fn(2);
f3  : fn(3);
f4  : fn(4);
minx : -3;
maxx :  1;
draw(gr2d(grid=[2,2],
          color="black",   explicit(f,  x,minx, maxx),
          color="red",     explicit(f0, x,minx, maxx),
          color="orange",  explicit(f1, x,minx, maxx),
          color="green",   explicit(f2, x,minx, maxx),
          color="blue",    explicit(f3, x,minx, maxx),
          color="violet",  explicit(f4, x,minx, maxx)
          )
    );



#####
#
# taylor-3
# 2024dec12
#
#####

# «taylor-3»  (to ".taylor-3")

* (find-sh0 "rm -v /tmp/taylor*")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-myqdraw "myqdraw3.mac")
load_myqdraw();
[xmin,ymin,xmax,ymax] : [-2,-2,2,2];
f  : x^3;

drawing(x0) := (
  f0 : taylor(f, x,x0,0),
  f1 : taylor(f, x,x0,1),
  f2 : taylor(f, x,x0,2),
  [xyrange(),
   cut(all),
   myex1(f,  lc(blue), lw(5)),
   myex1(f0, lc(red)),
   myex1(f1, lc(orange)),
   myex1(f2, lc(forest_green))
  ])$

* (eepitch-maxima)
** (find-mkanim1-links "/tmp/" "" "taylor_x3" "" "")
[topdf_a,topdf_b,topdf_c,topdf_n] : ["/tmp/", "", "taylor_x3", 0];
myqdrawp_to_screen ();
myqdrawp_to_new_pdf();    "Skip this line to draw to the screen"$

[xmin,ymin,xmax,ymax] : [-2,-2,2,2];
f : x^3;
for x0 in seqn(-1.2, 1.2, 24) do
  print(myqdrawp(drawing(x0)));

** (find-mkanim1-links "/tmp/" "" "taylor_sin" "" "")
**
* (eepitch-maxima)
[topdf_a,topdf_b,topdf_c,topdf_n] : ["/tmp/", "", "taylor_sin", 0];
myqdrawp_to_screen ();
myqdrawp_to_new_pdf();    "Skip this line to draw to the screen"$

[xmin,xmax, ymin,ymax] : [0,2*%pi,-%pi,%pi];
f : sin(x);
for x0 in seqn(0, 2*%pi, 60) do
  print(myqdrawp(drawing(x0)));

** «taylor-3-anim»  (to ".taylor-3-anim")
** (find-mkanim1-links "/tmp/" "" "taylor_x3" "" "")
** (find-mkanim1-links "/tmp/" "" "taylor_sin" "" "")
**
* (eepitch-bash)
* (eepitch-kill)
* (eepitch-bash)
# (find-myqdraw "mkanim2.sh" "abc-tests")
. ~/myqdraw/mkanim2.sh
ABC=/tmp/taylor_sin
DELAY=8             abcmake
DELAY=8 DENSITY=25  abcmake _small
DELAY=8 DENSITY=50  abcmake _50
DELAY=8 DENSITY=400 abcmake _400
DELAY=8 DENSITY=600 abcmake _600

ffmpeg -i /tmp/taylor_sin_600.gif /tmp/taylor_sin_600.mp4

# (find-fline "~/LATEX/2024-2-C3/")
# (find-linsfile "LATEX/2024-2-C3/" "taylor_sin.gif")






#####
#
# del
# 2023sep28
#
#####

# «del»  (to ".del")
# (find-maximanode "del")
# (find-maximanode "diff")
# (find-maximanode "derivdegree")
# (find-maximanode "depends")
# (find-maximanode "depends" "remove (<f>, dependency)")
# (find-maximanode "derivabbrev")
# (find-maximanode "gradef")
# (find-mbefile "calc1code.txt" "6.1.2  The Total Differential")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
o1 : diff(x^2);
o2 : diff(x^2*y^3);
o3 : diff(a*x^2*y^3);
subst(del(x) = dx, o1);
subst([del(x)= dx, del(y) = dy, del(a) = da],o3 );
declare (a, constant)$
diff(a*x^2*y^3);
declare([b,c],constant)$
diff( a*x^3 + b*x^2 + c*x );
properties(a);
propvars(constant);
kill(a,b,c)$
propvars(constant);
diff(a*x);
         diff([sin(x),cos(x),tan(x) ], x);
    map('diff,[sin(x),cos(x),tan(x) ] );
o : map('diff,[sin(x),cos(x),tan(x) ] )/del(x);
map('diff,o)/del(x);




#####
#
# Comparing del(y)/del(x) and 'diff(y,x)
# 2024aug14
#
#####

# «dely-div-delx»  (to ".dely-div-delx")
# (to "ode2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
[dy,dx,dydx] : [del(y),del(x),del(y)/del(x)];
diffeq1 : dydx = y;
diffeq2 : subst(dydx='diff(y,x), diffeq1);
diffeq3 : 'diff(y,x) = y;
gsol    : ode2(diffeq1,y,x);  /* err */
gsol    : ode2(diffeq2,y,x);  /* ok */





#####
#
# impdiff
# 2024apr11
#
#####

# «impdiff»  (to ".impdiff")
# (find-maximanode "Functions and Variables for impdiff")
# (find-sh "locate impdiff")
# (find-maximagitfile "")
# (find-maximagitsh "find *")
# (find-maximagitfile "share/contrib/impdiff.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load (impdiff);
f [0, 0] : x^2 + y^3 - z^4 = 0;
implicit_derivative (f, [x, y], [2, 3], z);
display_array (f);





#####
#
# Implicit differentiation of the Folium of Descartes (with pn1.mac)
# 2023sep28
#
#####

# «implicit-diff»  (to ".implicit-diff")
# «pn1-folium»     (to ".pn1-folium")
# (to "qdraw-folium")
# (find-angg "MAXIMA/pn1.mac")
# (find-angg "MAXIMA/pn1.mac" "folium-depvars")
# (find-angg "MAXIMA/pn1.mac" "folium-depvars-and-ds")
# (find-books "__analysis/__analysis.el" "stewart" "157" "2.6 Implicit Differentiation")
# (find-books "__analysis/__analysis.el" "stewart-pt" "188" "3.5 Derivação Implícita")
# https://en.wikipedia.org/wiki/Folium_of_Descartes

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("~/MAXIMA/pn1.mac")$
gradef(y(x), y_x(x));   /* these tests don't use gradef(y,x,y_x) */

/* The folium of Descartes */
e1 : x^3 + y^3 = 6*x*y;

/* Test 1: differentiate the folium implicitly,
 * using dependent variables only
*/
               pnex(e1);
          diff(pnex(e1), x);
e2 : pnsh(diff(pnex(e1), x));
e3 : solve(e2, y_x)[1];

/* Test 2: differentiate the folium implicitly,
 * using dependent variables and differentials
*/
          diff(e1);
e2 : pnsh(diff(e1));
            solve(e2, dy)[1];
     factor(solve(e2, dy)[1]);
e3 : factor(solve(e2, dy)[1]) / dx;

plotdf(rhs(e3))$
display2d : false$
e3;




#####
#
# pn1-email
# 2023oct01
#
#####

# «pn1-email»  (to ".pn1-email")
# (find-maximamsg "39730760 202309 30" "Edrx: is(equal(op(f(x,y)), 'del)) -> unknown")
# (find-maximamsg "39730815 202309 30" "RDodier: maybe you can say")
# (find-maximamsg "39794921 202310 01" "Edrx: The code of my current prototype is below")
# http://anggtwu.net/eev-maxima.html#physicists-notation
# (find-angg "MAXIMA/pn1.mac")

Hi all,

thanks for all the responses! Robert, right now what I am trying to do
is to write functions to let me handle shorthands like y=y(x) and
z=z(x,y) as "real shorthands", that can be expanded and
shortened/contracted...

For example, if both "y=y(x)" and "z=z(x,y)" are active in the list of
shorthands then "z" expands to "z=z(x,y(x))", but if only "z=z(x,y)" is
active then "z" expands to "z=z(x,y)".

The code of my current prototype is below, followed by some tests.
About tellsimp and friends: I know vaguely what they do and I'm trying
to understand some examples - and I don't have any idea if they could
be useful in this case or not...

I tried to explain the rationale for the code below here:
  http://anggtwu.net/eev-maxima.html#physicists-notation

Cheers, and please send pointers and suggestions...
  Eduardo Ochs
  http://anggtwu.net/eev-maxima.html

--snip--snip--

...
See: (find-angg "MAXIMA/pn1.mac")







#####
#
# gradef
# 2022jan15
#
#####

# «gradef»  (to ".gradef")
# (find-maximanode "derivabbrev")
# (find-maximanode "depends")
# (find-maximanode "express")
# (find-maximanode "gradef")
# (find-maximanode "gradefs")
# (find-mbe-links)
# (find-mbe-links 6 6 "6.1.3 Controlling the Form of a Derivative with gradef")
# (find-mbe06page   6 "6.1.3 Controlling the Form of a Derivative with gradef")
# (find-mbe06text   6 "6.1.3 Controlling the Form of a Derivative with gradef")
# (find-mbegrep "grep --color=auto -nH --null -e gradef *.txt")
# (find-mbefile "calc1code.txt" "6.1.3 Controlling the Form of a Derivative with gradef(..)")

# (find-maximagitgrep "grep --color=auto -niRH --null -e gradef *")
# (find-maximagitgrep "grep --color=auto -niRH --null -e gradef src/*.lisp")
# (find-maximagitgrep "grep --color=auto -niRH --null -e gradef share/*")
# (find-maximagitgrep "grep --color=auto -niRH --null -e gradef tests/*")
# (find-maximabookpage (+ 1 91) "gradef")
# (find-maximabooktext (+ 1 91) "gradef")
# (find-maximagitgrep "grep --color=auto -niRH --null -e pdiff *")
# (find-maximagitgrep "grep --color=auto -niRH --null -e pdiff share/*")
# (find-maximagitfile "share/pdiff/")
# (find-maximagitfile "share/pdiff/" "pdiff-doc")
# (code-pdf-page "pdiff" "~/bigsrc/maxima/share/pdiff/pdiff-doc.pdf")
# (code-pdf-text "pdiff" "~/bigsrc/maxima/share/pdiff/pdiff-doc.pdf")
# (find-pdiffpage)
# (find-pdifftext)
# (find-ssr-links     "gradefjan19" "2022jan19-gradef")
# (code-eevvideo      "gradefjan19" "2022jan19-gradef")
# (code-eevlinksvideo "gradefjan19" "2022jan19-gradef")
# (find-fline "/home/angg_slow_html/eev-videos/" "2022jan19-gradef.mp4")
# (find-gradefjan19video "0:00")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
? gradef
? gradefs
a_x : 22;
**
taylor(f(x + x^2), x, 1, 1);
gradef(f(x),   f_x(x))$
gradef(f_x(x), f_xx(x))$
taylor(f(x + x^2), x, 1, 2);
? taylor

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
gradef(z  (x,y), z_x (x,y), z_y (x,y));
gradef(z_x(x,y), z_xx(x,y), z_xy(x,y));
gradef(z_y(x,y), z_xy(x,y), z_yy(x,y));
gradef(y(x),     y_x (x));
gradef(y_x(x),   y_xx(x));
z     : z(x, y(x));
z__x  : diff(z,    x);
z__xx : diff(z__x, x);
gradefs;
ex : z__x;
ex : subst([y   (x)=y],      ex);
ex : subst([y_x (x)=y_x],    ex);
ex : subst([y_xx(x)=y_xx],   ex);
ex : subst([z_x (x,y)=z_x],  ex);
ex : subst([z_y (x,y)=z_y],  ex);
ex : subst([z_xx(x,y)=z_xx], ex);
ex : subst([z_xy(x,y)=z_xy], ex);
ex : subst([z_yy(x,y)=z_yy], ex);
ex : expand(ex);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
gradef(x  (t),   x_t (t));
gradef(x_t(t),   x_tt(t));
gradef(y  (t),   y_t (t));
gradef(y_t(t),   y_tt(t));
gradef(z  (x,y), z_x (x,y), z_y (x,y));
gradef(z_x(x,y), z_xx(x,y), z_xy(x,y));
gradef(z_y(x,y), z_xy(x,y), z_yy(x,y));
z     : z(x(t), y(t));
z__t  : diff(z,    t);
z__tt : diff(z__t, t);
ex : z__t;
ex : z__tt;
ex : subst([x   (t)=x],      ex);
ex : subst([x_t (t)=x_t],    ex);
ex : subst([x_tt(t)=x_tt],   ex);
ex : subst([y   (t)=y],      ex);
ex : subst([y_t (t)=y_t],    ex);
ex : subst([y_tt(t)=y_tt],   ex);
ex : subst([z_x (x,y)=z_x],  ex);
ex : subst([z_y (x,y)=z_y],  ex);
ex : subst([z_xx(x,y)=z_xx], ex);
ex : subst([z_xy(x,y)=z_xy], ex);
ex : subst([z_yy(x,y)=z_yy], ex);
ex : expand(ex);



#####
#
# gradefs on variables
# 2023sep30
#
#####

# «gradef-var»  (to ".gradef-var")
# (find-maximanode "gradef")
# (find-maximanode "gradef" "gradef (<a>, <x>, <expr>)")
# (find-maximanode "remove")
# (find-maximanode "depends")
# (find-mbefile "calc1code.txt" "6.1.3 Controlling the Form of a Derivative with gradef(..)")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
e1 : x^3 + y^3 = 6*x*y;
gradef(y, x, y_x);
diff(e1, x);
diff(e1);

gradef(y, z, y_z);
diff(e1, x);
diff(e1);
diff(y);




#####
#
# gradef-remove
# 2023sep30
#
#####

# «gradef-remove»  (to ".gradef-remove")
# (find-maximanode "gradef")
# (find-maximanode "remove")
# (find-maximanode "kill")
# (find-maximanode "depends")
# (find-maximanode "properties")
# (find-maximanode "put")
# (find-maximanode "rem")
# (find-maximanode "get")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
gradef(z(x,y), z_x(x,y), z_y(x,y));
gradef(w, x, w_x);
gradef(w, y, w_y);
gradefs;
printprops([z], gradef);
printprops([w], atomgrad);
props;
properties(z);
properties(w);

gradefs;
printprops([z], gradef);
kill(z);
printprops([z], gradef);
gradefs;

dependencies;
printprops([w], atomgrad);
kill(w);
printprops([w], atomgrad);
dependencies;

map('kill, [a,b]);



#####
#
# email-subst-2022jan17
# 2022jan17
#
#####

# «email-subst-2022jan17»  (to ".email-subst-2022jan17")
# (find-maximamsg "37419130 202201 17" "Edrx: Part 1: the groups")
# (find-maximamsg "37417646 202201 14" "RFateman: We see proposed usages")

Hi all,

ok, let me try to explain how and why I am using Maxima in my
classes... I'll have to start with a lot of context, as I'll have to
talk about several different groups of people...


Part 1: the groups that I interact with
=======================================

One of the biggest federal universities in the state of Rio de Janeiro
is called (the) UFF. The main campus of the UFF is in a (big) city
called Niterói, that is very close to Rio de Janeiro (the city - even
bigger than Niterói). The UFF has several campi in other cities, and I
work in a small campi in a (small) city called Rio das Ostras.

Bolsonaro has cut the funding for education at all levels as much as
he could, including the funding for the top universities and for the
top research institutes, that were treated as sacred in the other
governments. On top of that the pandemic came. Several universities,
including UFF, were already having to negotiate a lot every month to
get money to pay basic things like electricity and water, and the
cleaning and the security staff, and when the quarantine started the
message that we received was more or less this: "we know that most of
you have never learned how to so online teaching, so now we will give
you four months to prepare - try to do some courses, and do your best.
This is an emergency, we know that everybody will have to improvise a
lot, etc, etc."

I knew that teaching by Zoom wouldn't work for me because in my
courses I always interact a lot with the students _via writing_ - when
they have doubts I prefer to see how they are trying to write and draw
their ideas rather than to hear them - so I invented a way to teach my
courses in which most of the interaction would be by Telegram, with
people exchanging photos of what they were doing... I would often
LaTeX my ideas and answers instead of writing them by hand on paper,
but that's because I've been using LaTeX for ages and I'm quite fast
with it.

This "teaching by Telegram" thing worked very well. I also used
prerecorded videos, slides in PDF, and a few bits of material by other
people, but I'll refer to that as "teaching by Telegram".

In the middle of 2020 I discovered that a group of about 30 people
from several universities in Brazil were going to meet by Zoom once
every two weeks to discuss mainly a) how do teach online, and b) how
to adapt the contents of some courses to a context in which the
students can use computers to plot graphs and to do some calculations.
Let me call this group the "inter-university group", or the "IUG".

Actually I "discovered" the IUG because one of the organizers was a
friend of mine, and he invited me to participate. At one point I
offered to present how I was "teaching by Telegram", and in one of the
meetings I gave a talk about that, and I showed that all my material
was online - including all the parts in which I presented things in
ways that didn't work, or in which I gave exercises that I had to
change completely later. My presentation was very well-received, and I
found some people there who were also trying to make all their
material available in public places.

So we have three groups:

  UFF - big campus in a big city
  Rio das Ostras - small subcampus in a small city
  Inter-university group, a.k.a. IUG

The people from my department in Rio das Ostras did try to meet by
Zoom to discuss online teaching a few times, but we were only able to
arrange these meeting at most once every semester. We are a small
department, and it seems that each person is trying something totally
different - and everyone is reporting that the students participate
very little, that in most classes by Zoom/Google Meet/whatever very
few students keep their cameras open, and that cheating is rampant
even with their all attempts to make cheating harder... for example,
some of my colleagues learned ways to give a slightly different test
to each student, and learned features of Google Classroom that makes
it auto-correct some kinds of tests, but nothing is working.

Before giving my presentation on "teaching by Telegram" at the IUG a
gave a preliminary version of it in one of these meetings of my
department - in which very few people came - and it was well-received.
Then after my presentation at the IUG I sent the link with the
recording to my dept's mailing list, and some people in my department
FREAKED OUT. They reacted very angrily - I've reread their e-mails to
the mailing lists many times after they were sent and they still don't
look very coherent to me, so I think that "freaked out" is a good
term, at least until I find something better.

So: I was hoping that the people in my department would look at my
material, find some interesting things here and there, and react by
sharing pieces of their own teaching materials and sharing ideas...
now I think that the chance of this happening is small.

A friend of mine from Rio das Ostras is temporarily working at UFF -
the big campus, with big teams teaching each of the basic courses in
Maths - and I asked if he could share with me the material that the
people there use in Calculus 1, 2, and 3. He checked with his
superiors and told me that no, there is a kind of non-disclosure
agreement.

SUMMARY OF PART 1: interacting with the colleagues in my campus is
very hard at the moment, and interacting with the people in the big
campus of UFF is very hard too. So my priority is to interact with
people from the IUG in Portuguese, and with other people from the
internets in English.


Part 2: students
================

Many of my students have very bad internet connections, and bad
computers that they share with other people - so very often they can
only use their cell phones to participate in the classes. But some
other students have, aham, "real computers" - even in this sense:
https://dilbert.com/strip/1995-06-24 - and when they see that I have a
couple of Free Software projects that I take very seriously and that I
am learning to use Maxima (<- was SymPy before, but I gave up) they
ask if I can teach or help them to use these things. My answer is -
ta-da! - yes, but not during class, so let's create another Telegram
group for that. And right now this other Telegram group is dead, the
last message in it was more than a month ago.

Here's an incomplete list of how the students see that I am using
Maxima in the classes that I am teaching. I am using Maxima for some
2D and 3D plots; I am using it to calculate the answers to certain
exercises - for example here:

  http://angg.twu.net/LATEX/2021-2-C3-notacao-de-fisicos.pdf#page=26

so if they want to check the answers that they got by hand they will
have to decypher this slightly obfuscated notation; I am using it as
one of my excuses to stress ALL THE TIME that BASIC mathematical
notation has a very rigid syntax - each one of the books that we use
has slightly different conventions, and Maxima and GeoGebra (that some
of them learned in a previous course) use other syntaxes that are
quite different - and that in my course syntax errors will not be
tolerated...

I am having to deal with several epidemics here - besided Covid,
cheating, and lack of focus, we also have an epidemy of students that
believe that an answer to a test HAS to receive full grade, or almost,
"if the idea is right". I don't know how much this last one affects
other countries - I would really like to know - and I try to deal with
this last one by having a ton of material on how to write answers
"that everyone understands"...

I don't have any idea how my colleagues in my department, or in the
big campus, deal with the epidemy of "if the idea is right that's
enough" - I don't have enough social skills to get answers from them -
so I am sort of trying to get some people from the IUG to share the
materials on that they have, both in Portuguese and in English... and
they're answering very slowly.

About the low-end students: they don't interact, they cheat on the
tests, they're hard to distinguish from the students that are just
very introverted, and _right now_ I don't have the tools to detect
when they're cheating. My resources are limited, we're in an
emergency, I'm doing my best, and this includes that I'm choosing
carefully where to I will invest my energy... and I chose to invest it
on the students who interact, and on producing written material can be
useful to me and to the other people from the IUG in this semester and
in the future...


Part 3: substitution
====================
This is mostly an answer to this message,

  https://sourceforge.net/p/maxima/mailman/message/37417646/

that Richard sent on jan. 14...

Every semester I change my approach to substitution a bit. In this
semester I defined an operation "[:=]" that does substituition
"syntactically" and "naively". The "syntactically" means that the "="
after a substituition is special - it means "the result of this
substitution, WITHOUT ANY SIMPLIFICATIONS, is the expressions at the
right of the equals sign"; so these two lines are right,

  (2 = 3 + a * 4) [a:=5]   = (2 = 3 +  5    * 4)
  (2 = 3 + a * 4) [a:=5+6] = (2 = 3 + (5+6) * 4)

but this one is wrong, because in it the 10*4 was simplified to 40:

  (2 = 3 + a * 4) [a:=10]  = (2 = 3 + 40)

The explanation that I showed to the students is this one - that only
exists in Portuguese at the moment...

  http://angg.twu.net/LATEX/2021-2-C2-intro.pdf#page=8

I also stressed to the students that my "naive substitution", that was
"defined" by text and examples instead of rigorously, and that doesn't
distinguish between free and bound variables, will be enough for our
purposes - and that to understand the "better" substitution operations
they will have to understand free and bound variables well, and free
and bound variables will make much more sense at the end of the couse,
after they were forced to work a lot with sums, integrals,
quantifiers, and set comprehensions.

The first time that I got feedback from an "adult" on this naive
syntactical substituion was just a few weeks ago, from a colleague
that is a logician and who works in a university in the Northeast of
Brazil. He liked it very much as a pedagogical tool, and he also told
me that he's having more or less the same difficulties to deal with
his colleagues as me. Anyway, now I finally have good excuses to write
about that in English - but it's a low-priority task. =/

  Cheers,
    Eduardo Ochs
    http://angg.twu.net/#eev
    http://angg.twu.net/eev-maxima.html
    http://angg.twu.net/math-b.html




#####
#
# plot: examples from the Workbook
# 2022oct09
#
#####

# «plot-wb»  (to ".plot-wb")
# (find-books "__comp/__comp.el" "maxima-workbook")
# (find-books "__comp/__comp.el" "maxima-workbook" "5.2 Plot")
# (find-maximawbpage (+ 20 32) "5.2     Plot")
# (find-maximawbtext (+ 20 32) "5.2     Plot")
# (find-maximawbpage (+ 19 38) "5.2.2.1.3   Discrete plot")
# (find-maximawbtext (+ 19 38) "5.2.2.1.3   Discrete plot")
# (find-maximanode "Functions and Variables for Plotting" "discrete")
# (find-maximawbpage (+ 19 45) "5.3     Draw")
# (find-maximawbtext (+ 19 45) "5.3     Draw")




#####
#
# plot2d
# 2024dec01
#
#####

# «plot2d»  (to ".plot2d")
# (find-maxima-links "plot2d")
# (find-maximagitfile "src/plot.lisp" "(defmfun $plot2d")




#####
#
# plot2d-parametric
# 2022feb19
#
#####

# «plot2d-parametric»  (to ".plot2d-parametric")
# (find-maximanode "Functions and Variables for Plotting" "3. Parametric functions")
# (find-maximanode "Functions and Variables for Plotting" "Function: plot3d")
# (find-maximanode "Function and Variable Index" "plot2d")
# (find-maximanode "Function and Variable Index" "plot3d")
# (find-maximanode "plot2d")
# (find-maximanode "plot3d")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
x : cos(t)+t;
y : sin(t);
x : cos(t)+cos(4*t)/2;
y : sin(t)+sin(4*t)/2;
x : cos(t)+cos(3*t)/2;
y : sin(t)+sin(3*t)/2;
plot2d([parametric, x, y, [t, 0, 2*%pi]]);
x : cos(t);
y : sin(2*t);
plot2d([parametric, x, y, [t, 0, 2*%pi]]);
x : cos(2*t);
y : sin(3*t);
plot2d([parametric, x, y, [t, 0, 2*%pi]]);
x : sin(2*t);
y : cos(3*t);
plot2d([parametric, x, y, [t, 0, 2*%pi]]);
x : sin(2*t);
y : sin(3*t);
plot2d([parametric, x, y, [t, 0, 2*%pi]]);
x : cos(2*t);
y : cos(3*t);
plot2d([parametric, x, y, [t, 0, 2*%pi]]);



#####
#
# plot3d-parametric
# 2022feb19
#
#####

# «plot3d-parametric»  (to ".plot3d-parametric")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
plot3d (u^2 - v^2, [u, -2, 2], [v, -3, 3], [grid, 100, 100],
  nomesh_lines)$
plot3d ( log ( x^2*y^2 ), [x, -2, 2], [y, -2, 2], [z, -8, 4],
  nopalette, [color, magenta])$
plot3d (log (x^2*y^2), [x, -2, 2], [y, -2, 2],[grid, 29, 29],
  [palette, [gradient, red, orange, yellow, green]],
  color_bar, [xtics, 1], [ytics, 1], [ztics, 4],
  [color_bar_tics, 4])$

** Two surfaces in the same plot.  Ranges specific to one of the
     surfaces can be given by placing each expression and its ranges in
     a separate list; global ranges for the complete plot are also given
     after the function definitions.

plot3d ([[-3*x - y,                        [x, -2, 2], [y, -2, 2]],
         4*sin(3*(x^2 + y^2))/(x^2 + y^2), [x, -3, 3], [y, -3, 3]],
      [x, -4, 4], [y, -4, 4])$

expr_1: 5*cos(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3)-10$
expr_2: -5*sin(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3)$
expr_3: 5*(-sin(x/2)*cos(y)+cos(x/2)*sin(2*y))$
plot3d ([expr_1, expr_2, expr_3], [x, -%pi, %pi],
  [y, -%pi, %pi], [grid, 50, 50])$

     Plot of a "spherical harmonic" function, using the predefined
     transformation, 'spherical_to_xyz' to transform from spherical
     coordinates to rectangular coordinates.  See the documentation for
     'spherical_to_xyz'.

          (%i1) plot3d (sin(2*theta)*cos(phi), [theta,0,%pi], [phi,0,2*%pi],
                [transform_xy, spherical_to_xyz], [grid, 30, 60], nolegend)$

     Use of the pre-defined function 'polar_to_xy' to transform from
     cylindrical to rectangular coordinates.  See the documentation for
     'polar_to_xy'.

          (%i1) plot3d (r^.33*cos(th/3), [r,0,1], [th,0,6*%pi], nobox,
              nolegend, [grid, 12, 80], [transform_xy, polar_to_xy])$

     Plot of a sphere using the transformation from spherical to
     rectangular coordinates.  Option 'same_xyz' is used to get the
     three axes scaled in the same proportion.  When transformations are
     used, it is not convenient to eliminate the mesh lines, because
     Gnuplot will not show the surface correctly.

          (%i1) plot3d ( 5, [theta,0,%pi], [phi,0,2*%pi], same_xyz, nolegend,
            [transform_xy, spherical_to_xyz], [mesh_lines_color,blue],
            [palette,[gradient,"#1b1b4e", "#8c8cf8"]])$


#####
#
# plot3d-plotsurface
# 2024oct13
#
#####

# «plot3d-plotsurface»  (to ".plot3d-plotsurface")
# (find-maximamsg "58827881 202410 13" "JVillate: the example given in the manual")
# (find-maximamsg "58827894 202410 13" "d00521032: A more general version is")
# (find-maximamsg "58827897 202410 13" "d00521032: plotsurface")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
M:matrix([1,2,2],[4,5,3],[7,8,4],[10,11,5]);
f(x, y) := float('M [round(x), round(y)]);
plot3d(f(x,y), [x,1,3], [y,1,3], [grid,2,2], nolegend);
plot3d(f(x,y), [x,1,length(M)], [y,1,length(M[1])], [grid,length(M)-1,length(M[1])-1])$

M:matrix([1,2,2],[6,7,3],[7,10,4],[10,11,5]);
X:[1,3,5,10];
Y:[1,3,6];
plotsurface(M,X,Y):=block(
  points:makelist(makelist([X[xx],Y[yy],M[xx,yy]],xx,1,length(M)),yy,1,length(M[1])),
  draw3d(enhanced3d=true,interpolate_color=true,title="Title",
          xlabel="x",ylabel="y",zlabel="z",apply(mesh,points)));

plotsurface(M,X,Y);




#####
#
# plot2d-xmaxima
# 2022mar06
#
#####

# «plot2d-xmaxima»  (to ".plot2d-xmaxima")
# For example a plot using Xmaxima as interface:
# https://maxima.sourceforge.io/docs/manual/maxima_singlepage.html#Plotting-Formats

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
plot2d (sin(x), [x, -%pi, %pi], [plot_format, xmaxima]);




#####
#
# plot2d-style-lines
# 2024apr25
#
#####

# «plot2d-style-lines»  (to ".plot2d-style-lines")
# (find-maximamsg "58763485 202404 22" "JVillate: plot2d ... [style,[lines,1,2]]")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
plot2d ([sin(x), sin(2*x), sin(3*x)], [x, 0, 10]);
plot2d ([sin(x), sin(2*x), sin(3*x)], [x, 0, 10], [style,[lines,1,2]]);




#####
#
# plot2d-stair
# 2024apr25
#
#####

# «plot2d-stair»  (to ".plot2d-stair")
# https://mail.google.com/mail/u/0/#search/maxima/FMfcgzGxSbqkpzvrwXGwlGLswXZfXlrR
# (find-maximamsg "58757280 202404 06" "")
# (find-maximamsg "58757286 202404 06" "")
# (find-maximamsg "58757296 202404 06" "")
# (find-maximamsg "58757304 202404 06" "")
# (find-maximamsg "58757313 202404 06" "")
# (find-maximamsg "58757315 202404 06" "")
# (find-maximamsg "58757317 202404 06" "")
# (find-maximamsg "58757319 202404 06" "")
# (find-maximamsg "58757331 202404 06" "")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(x):=1/(1+x)$
E(f,x,n,a,b):=block(if x=b then return(f(b))
    else
    for i:1 thru n do if (x < a+i*(b-a)/n) then return(f(a+(i-1)/n))
);
g(x):=E(f,x,10,0,1)$
plot2d([f,g], [x,0,1]);







#####
#
# plotdf
# 2023sep30
#
#####

# «plotdf»  (to ".plotdf")
# (find-maximanode "plotdf")
# (to "direction-fields")
# (find-maximagitfile "share/dynamics/plotdf.lisp")
# (find-maximagitfile "interfaces/xmaxima/Tkmaxima/Plotdf.tcl")

# (find-sh "locate maxima | grep tcl")
# (find-sh "locate maxima | grep plotdf")
# (find-maximagitfile "interfaces/xmaxima/Tkmaxima/")
# (find-maximagitfile "interfaces/xmaxima/Tkmaxima/NPlot3d.tcl")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
plotdf(exp(-x)+y)$
plotdf(exp(-x)+y,[trajectory_at,2,-0.1])$

plotdf(x-y^2,
   [xfun,"sqrt(x);-sqrt(x)"],
   [trajectory_at,-1,3],
   [direction,forward],
   [y,-5,5], [x,-4,16])$   /* broken: "input file has syntax errors" */

plotdf([v,-k*z/m], [z,v], [parameters,"m=2,k=2"],
     [sliders,"m=1:5"], [trajectory_at,6,0])$

plotdf([y,-(k*x + c*y + b*x^3)/m],
       [parameters,"k=-1,m=1.0,c=0,b=1"],
       [sliders,"k=-2:2,m=-1:1"],[tstep,0.1])$

plotdf([w,-g*sin(a)/l - b*w/m/l], [a,w],
  [parameters,"g=9.8,l=0.5,m=0.3,b=0.05"],
  [trajectory_at,1.05,-9],[tstep,0.01],
  [a,-10,2], [w,-14,14], [direction,forward],
  [nsteps,300], [sliders,"m=0.1:1"], [versus_t,1])$




#####
#
# partial-fractions
# 2022feb22
#
#####

# «partial-fractions»  (to ".partial-fractions")
# (find-maximanode "Functions and Variables for Number Theory" "Function: partfrac")
# (find-maximanode "partfrac")
# (find-maximanode "denom")
# (find-maximanode "solve")
# (find-maximanode "rat")
# (find-maximanode "ratsimp")
# (c2m212fpp 5 "exercicio-3")
# (c2m212fpa   "exercicio-3")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
together(f) := ratsimp(f);
apart(f)    := partfrac(f,x);

f1 : A/(x-a) + B/(x-b);
f2 : ratsimp(f1);
(f1 = f2);
f3 : (c*x+d) / (x^2+e*x+f); 
f4 : subst([e=-a-b, f=a*b, c=A+B, d=-A*b-a*B], f3);
f2 - f4;
**
g1 : (2*x + 3) / (x^2 - 7*x + 10)$
g2 : partfrac(g1, x)$
(g1 = g2);

d2 : denom(f2);
d3 : denom(f3);
d2 - d3;
solve(d2 - d3, [e, f]);
rat(d2 - d3, x);
ratsimp(f2 - f3);
denom(f2)-denom(f3);
d : denom(f2)-denom(f3);
rat(d, x);
solve(denom(f2)-denom(f3), [a, b, e]);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** Formula and particular case:
f1 : A/(x-a) + B/(x-b);
f2 : ratsimp(f1);
eq1 : f1=f2;
eq2 : subst([a=3, b=5], eq1);
f3  : subst([a=3, b=5], f1);
rhs(eq2);
den1 : denom(rhs(eq2));
f4 : (3*x+4) / den1;
f5 : partfrac(f4, x);
eq3 : f3 = f5;
eq3 : f3 - f5;
ratsimp(eq3);
f6 : num(ratsimp(eq3));
c1 : coeff(f6, x, 1);
c0 : coeff(f6, x, 0);
[c1, c0];
solve([c1, c0], A);
solve([c1, c0], [A, B]);



#####
#
# Intersection of two conics
# 2022mar25
#
#####

# «two-conics»  (to ".two-conics")
# https://sourceforge.net/p/maxima/code/ci/master/tree/share/contrib/conics_04.mac
# (find-maximamsg "37630334 202203 25" "BWillis: intersection of 2 circles")



#####
#
# mnewton
# 2022jul04
#
#####

# «mnewton»  (to ".mnewton")
# (find-maximanode "mnewton")
# (find-maximanode "find_root")
# (find-maximanode "Functions and Variables for mnewton")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("mnewton")$
mnewton([2*a^a-5],[a],[1]);
f : 1/x;
mnewton([f-4],[x],[1]);

f : 1/x;
f-4;
find_root (f-4, x, 0.01, 2);
find_root (sin(x) - x/2, x, 0.1, %pi);

load(draw);
f : 1/x;
ymax :  4;
ymin : -4;
plot2d(f, [x, -4, 4]);
find_root(f-ymax, x, 0.01, 2);
find_root(f-ymin, x, -2, -0.01);

f : 1/x;
mnewton(f-4,[x],[1]);
mnewton([''f-4],[x],[1]);





#####
#
# find_root and quad_qag
# 2023oct23
#
#####

# «find_root»  (to ".find_root")
# «quad_qag»   (to ".quad_qag")
# (find-maximanode "find_root")
# (find-maximanode "quad_qag")
# (to "quad_qagi")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(x)  := 4 - (x-2)^2;
define(g(x), sqrt(1 + diff(f(x), x)^2));
[a,b] : [0,3];
o     : quad_qag(g(x),     x, a, b, 1);
yg    : o[1]/(b-a);
xg    : find_root(g(x)=yg, x, 0, 2);
g(xg) * (b-a);




#####
#
# Um caso em que o TFC2 falha
# 2022jul04
#
#####

# «TFC2-fails»  (to ".TFC2-fails")
# (c2m212intsp 5 "x^-2")
# (c2m212intsa   "x^-2")
# (find-maximanode "explicit")
# (find-maximanode "yrange")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f : x^-2;
    integrate(f, x, -1, 1);
F : integrate(f, x);
subst(x=-1, F);
subst(x=1, F);
subst(x=1, F) - subst(x=-1, F);
solve(f-4, x);
solve(F-4, x);
draw2d(yrange=[-4,4],
       explicit(f,x,-4,4),
       explicit(F,x,-4,4),
       xrange=[-4,4]);




#####
#
# numerozinhos
# 2022jun29
#
#####

# «numerozinhos»  (to ".numerozinhos")
# (find-maximanode "Matrices")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
x/(x^2+1);
display2d:false$


* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
Path.prependtopath "~/LUA/?.lua"  -- (find-angg "LUA/Path.lua")
require "ZHA1"                    -- (find-angg "LUA/ZHA1.lua" "AsciiPicture-tests")
= Path.from "path"
ap = AsciiPicture.new("    ")
x0,y0,x1,y1 = -2,-3,4,5
f = function (x,y) return 2*x + 3*y end
for y=y1,y0,-1 do ap:put(x0-1,y, format("%2d:", y)) end
for x=x0,x1    do ap:put(x,y0-1, format("%2d^", x)) end
for   y=y1,y0,-1 do
  for x=x0,x1    do
    ap:put(x, y, format("%3d", f(x,y)))
  end
end


= ap


= format("%04d", 22)
= format("%-4d", 22)
= format("%2d:", 22)

ap:put(0, 0, "foo")




#####
#
# dmiranda
# 2022jul15
#
#####

# «dmiranda»  (to ".dmiranda")
# https://danielmiranda.prof.ufabc.edu.br/maxima/index.html
# http://hostel.ufabc.edu.br/~daniel.miranda/maxima/01introducao.zip
# http://hostel.ufabc.edu.br/~daniel.miranda/maxima/02equacoeseinequacoes.zip
# http://hostel.ufabc.edu.br/~daniel.miranda/maxima/03graficos.zip
# http://hostel.ufabc.edu.br/~daniel.miranda/maxima/maxcalc.pdf




#####
#
# 2022-1-C2-P2
# 2022jul19
#
#####

# «2022-1-C2-P2»  (to ".2022-1-C2-P2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f : exp(-2*x) * cos(100*x);
plot2d (f, [x, 0, 2]);
demoivre(f);
exponentialize(f);

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
convert plot.png plot.pdf
# (find-pdf-page "/tmp/plot.pdf")



#####
#
# 2022-2-C3-P1
# 2022nov14
#
#####

# «2022-2-C3-P1»  (to ".2022-2-C3-P1")
# 3fT85: (c3m222p1p 6 "questao-2-gab")
#        (c3m222p1a   "questao-2-gab")

# (to "plotting-contours")
# (c3m222p1p 6 "questao-2-gab")
# (c3m222p1a   "questao-2-gab")
# (c3m222p1p 4 "questao-2")
# (c3m222p1a   "questao-2")
# (to "ev")
# (find-maximanode "define")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/matrixify.mac")
load       ("~/MAXIMA/matrixify.mac");
F   : 2*x^2 + -x*y - y^2;
F_x : diff(F,x);
F_y : diff(F,y);
matrixify (-2,-2, 2,2, [x,y]);
matrixify (-2,-2, 2,2, F);
matrixify (-2,-2, 2,2, [F_x, F_y]);

define(F(x,y),   F);
define(F_x(x,y), F_x);
define(F_y(x,y), F_y);

sol1(sols)   := rhs(sols[1]);
sol2(sols)   := rhs(sols[2]);
maxsol(sols) := apply('max, map('rhs, sols));
minsol(sols) := apply('min, map('rhs, sols));

sols : solve(F(x,y)=z, x);
sol1(sols);
sol2(sols);
display2d:false$
sol1(sols);
sol2(sols);
display2d:true$

** Expensive definition:
**   zmin(y) : inf({F(x,y) | x in R});
** Cheaper equivalent definitions:
**   xmin    : solve(F_x(x,y)=0, x);
**   xmin(y) : solve(F_x(x,y)=0, x);
**   zmin(y) : F(xmin(y), y);

                     solve(F_x(x,y)=0, x);
define(xmin(y), sol1(solve(F_x(x,y)=0, x)));
define(zmin(y), F(xmin(y), y));

                  solve(zmin(y)=-1, y);
           maxsol(solve(zmin(y)=-1, y));
ylim(z) := maxsol(solve(zmin(y)= z, y));
ylim(-1);

          ylim(-1);
solve(F(x,ylim(-1))=-1, x);

ev(     ylim(-1), numer);
   yl : ylim(-1);
ev(yl,            numer);

   yl : ylim(-2);
ev(yl,            numer);

** ranges for z=-1:
**   y in [ 0.943,  2], with sol1 and sol2
**   y in [-0.943, -2], with sol1 and sol2

** ranges for z=-2:
**   y in [ 1.334,  2], with sol1 and sol2
**   y in [-1.334, -2], with sol1 and sol2

** ranges for z=5:
**   y in [-1, 2] with sol1
**   y in [1, -2] with sol2

** ranges for z=2:
**   y in [-1.64, 2] with sol1
**   y in [-2, 1.64] with sol2

solve(F(2,y)=5, y);
solve(F(2,y)=2, y);
ev(solve(F(2,y)=2, y), numer);



* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
fx1 = function (y,z) return -(math.sqrt(8*z+9*y^2)-y)/4 end
fx2 = function (y,z) return  (math.sqrt(8*z+9*y^2)+y)/4 end
mkpoints = function (fx, ys, z)
    local mkpoint = function (y) return pformat("(%s,%s)", fx(y,z), y) end
    return mapconcat(mkpoint, ys, "--")
  end
nys = 5
nys = 20
paths = {}
paths[-1] = mkpoints(fx1, seqn( 2,  0.943, nys), -1) .."--\n"..
            mkpoints(fx2, seqn( 0.943,  2, nys), -1) .."\n"..
            mkpoints(fx1, seqn(-2, -0.943, nys), -1) .."--\n"..
            mkpoints(fx2, seqn(-0.943, -2, nys), -1)

paths[-2] = mkpoints(fx1, seqn( 2,  1.334, nys), -2) .."--\n"..
            mkpoints(fx2, seqn( 1.334,  2, nys), -2) .."\n"..
            mkpoints(fx1, seqn(-2, -1.334, nys), -2) .."--\n"..
            mkpoints(fx2, seqn(-1.334, -2, nys), -2)

paths[2] = mkpoints(fx1, seqn(-1.64, 2, nys), 2) .."\n"..
           mkpoints(fx2, seqn(-2, 1.64, nys), 2)

paths[5] = mkpoints(fx1, seqn(-1, 2, nys), 5) .."\n"..
           mkpoints(fx2, seqn(-2, 1, nys), 5)

= paths[-1]
= paths[-2]
= paths[2]
= paths[5]


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
myv : [-1,1,2];
myP : [6,5,0];
myP(t) := myP + t*myv;
myP(0);
myP(1);
makelist(myP(t), t, 0, 3);
expand(myP(6-x));
expand(myP(y-5));

** Beatriz:
makelist([x, 11-x, 12-2*x], x, 0, 10);

** Davi CR:
makelist([11+y, y, -10+2*y], y, 0, 10);

** Davi GPV:
makelist([x, -x+11, -2*x+12], x, 0, 10);

** Esthefanie:
makelist([x, -9-x, 1-x+     y], x, 0, 10);
makelist([x, -9-x, 1-x+(-9-x)], x, 0, 10);

** Fabricio:
makelist([x, 11-x,      y-x+1], x, 0, 10);
makelist([x, 11-x, (11-x)-x+1], x, 0, 10);

** Gabriel SK:
makelist([x, -x+11, -x+  y    +1], x, 0, 10);
makelist([x, -x+11, -x+(-x+11)+1], x, 0, 10);

** Gabriel MdSB:
makelist([0,11,12] + t*[1,1,-2], t, 0, 10);

** Katherine Z:
makelist([x, -x+11, -10+2*y],       x, 0, 10);
makelist([x, -x+11, -10+2*(-x+11)], x, 0, 10);

** João VdSH:
makelist([4,7,4] + t*[1,-1,-2], t, 0, 10);

** Lucas PMT:
makelist([x, 11-x, 1-x+y],      x, 0, 10);
makelist([x, 11-x, 1-x+(11-x)], x, 0, 10);

** Nicolas:
makelist([11-y, y, -10+2*y], y, 0, 10);

** Raphaela:
makelist([x, 11-x, 1-x+     y], x, 0, 10);
makelist([x, 11-x, 1-x+(11-x)], x, 0, 10);



#####
#
# 2023-2-C2-P1
# 2023oct10
#
#####

# «2023-2-C2-P1»  (to ".2023-2-C2-P1")
# (find-es "maxima" "subst-trig-questions")
# (to "changevar-trig-2")
# http://anggtwu.net/LATEX/2023-2-C2-Tudo.pdf#page=187
# http://anggtwu.net/LATEX/2023-2-C2-Tudo.pdf#page=191
# 2hT187: (c2m232p1p 6 "questao-2-gab")
#         (c2m232p1a   "questao-2-gab")
# 2hT191: (c2m232p1p 6 "questao-2-gab")
#         (c2m232p1a   "questao-2-gab")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* Questao 1 */
assume(c>0);
ex0   : 'integrate(s^3*sqrt(1-s^2)^3, s);
ex1   : changevar(ex0, s=sin(th), th, s);
  ex1 : map(rootscontract, ex1);
  ex1 : subst([sqrt(1-sin(th)^2)=cos(th)], ex1);
ex2   : changevar(ex1, c=cos(th), c, th);
ex3   : ev(ex2, 'integrate);
ex4   : subst([c=cos(th)], ex3);
ex5   : subst([th=asin(s)], ex4);
ex0 = ex5;
diff(ex5, s);
linel : 100;
align_eqs([ex0, ex1, ex2, ex3, ex4, ex5]);

/* Questao 2
 * (find-angg "MAXIMA/3-changevars1.mac")
 * (find-angg "MAXIMA/3-changevars1.mac" "2023-2-C2-P1")
*/
load("~/MAXIMA/3-changevars1.mac");
load("~/MAXIMA/barematrix1.mac");
f1(y) := sin(y) / 4;
f2(y) := y^4;
f3(y) := log(y);
substs : foo('[[f,f1],[g,f2],[h,f3]]);
OO : subst(substs, MM2);
bare(OO);

/* Questao 3 */
f  : (3*x + 2)/((x+4)*(x-5));
F0 : 'integrate(f, x);
F1 :  integrate(f, x);
F0 = F1;



#####
#
# 2023-2-C2-P2
# 2023dec07
#
#####

# «2023-2-C2-P2»  (to ".2023-2-C2-P2")
# (c2m232p2p 4 "questao-1-gab")
# (c2m232p2a   "questao-1-gab")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* Questao 1 */

e1 : 'diff(y,x) = 1/(-2*(y-1));
e2 :  ode2(e1, y, x);
e2 : -ode2(e1, y, x);
e2 : -ode2(e1, y, x) + 1;
e3 : subst([%c=C+1], e2);
e3 : subst([%c=-C+1], e2);
sols : solve(e3, y);
define(fpos(x), rhs(sols[2]));
define(fneg(x), rhs(sols[1]));

e4 : y = fpos(x);
e5 : subst([x=3,y=2], e4);
     solve(e5, C);
e6 : solve(e5, C)[1];
e7 : subst(e6, e4);

e4 : y = fneg(x);
e5 : subst([x=2,y=0], e4);
     solve(e5, C);
e6 : solve(e5, C)[1];
e7 : subst(e6, e4);


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* Questao 2 */
y_x  : 'diff(y,x);
y_xx : 'diff(y,x,2);
e1 : y_xx + 3*y_x -10*y = 0;
e2 : y_xx + 3*y_x -10*y = sin(2*x);
ode2(e1,y,x);
define(f3(x), subst([%k1=aa, %k2=bb], rhs(ode2(e1,y,x))));
define(f3_x(x), diff(f3(x), x)); 
e3 : [f3(0)=3, f3_x(0)=-1];
e4 : solve(e3, [aa,bb])[1];
define(f4(x), subst(e4, f3(x)));

e5 : ode2(e2,y,x);
e6 : subst([%k1=0, %k2=0], e5);
define(f4(x), rhs(e6));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* Questao 2 por s e c */
D_degree (f) := hipow(f, D);
D_to_Dx  (f) := sum(diff(ratcoef(f,D,k),x,k), k, 0, D_degree(f));
ss : sin(2*x);
cc : cos(2*x);
  abbrev(f) := subst([ss=s, cc=c], f);
unabbrev(f) := subst([s=ss, c=cc], f);
             abbrev(diff(unabbrev(s), x));
             abbrev(diff(unabbrev(c), x));
gradef(s, x, abbrev(diff(unabbrev(s), x)));
gradef(c, x, abbrev(diff(unabbrev(c), x)));

L : D^2 + 3*D - 10;
        L*s;
D_to_Dx(L*s);

f1  : A*c + B*s;
      D_to_Dx(L*f1);
e1  : D_to_Dx(L*f1) = s;
ec  : subst([c=1,s=0], e1);
es  : subst([c=0,s=1], e1);
ecs : [ec, es];
      solve(ecs, [A,B]);
eAB : solve(ecs, [A,B])[1];
     subst(eAB, e1);
f2 : subst(eAB, f1);
       D_to_Dx(L*f2);
expand(D_to_Dx(L*f2));

/* (find-angg "MAXIMA/LI_split1.mac")
*/
load("~/MAXIMA/LI_split1.mac");
LI_matreq (e1, [s,c], [A,B]);
LI_matreq3(e1, [s,c], [A,B]);



* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* Questao 3 */
y_x  : 'diff(y,x);
e1 : y_x - 2*y/x = 3*x;
ode2(e1, y, x);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* Questao 4 */
load("~/MAXIMA/mac1.mac");
mac1 : mac(1,2,-3,4,5,...);
mac2 : 1/mac1;
mac_ify(mac2);




#####
#
# 2023-2-C2-VR
# 2023dec12
#
#####

# «2023-2-C2-VR»  (to ".2023-2-C2-VR")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)



#####
#
# 2023-2-C2-VS
# 2023dec22
#
#####

# «2023-2-C2-VS»  (to ".2023-2-C2-VS")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
display2d_unicode : false;
display2d_unicode : true;

assume(c>0);
I_x    : 'integrate(x^3*sqrt(1-25*x^2), x);
I_s    : changevar(I_x, s=5*x, s, x);
  I_s  : map(rootscontract, I_s);
I_th   : changevar(I_s, s=sin(th), th, s);
  I_th : map(rootscontract, I_th);
  I_th : subst([sqrt(1-sin(th)^2)=cos(th)], I_th);
I_c    : changevar(I_th, c=cos(th), c, th);
F_c    : ev(I_c, 'integrate);
F_th   : subst([c=cos(th)], F_c);
F_s    : subst([th=asin(s)], F_th);
F_x    : subst([s=5*x], F_s);
I_x = F_x;
diff(I_x, x);
diff(I_s, s);

align_eqs([I_x, I_s, I_th, I_c, F_c, F_th, I_s, F_x]);

R : sqrt(1-25*x^2);
F_x / R;
expand(F_x / R);
factor(expand(F_x / R));




#####
#
# 2023-2, Cálculo 2: como eu expliquei o laurent2
# 2023nov10
#
#####

# «2023-2-C2-laurent2»  (to ".2023-2-C2-laurent2")
# (find-angg "MAXIMA/laurent2.mac")
# (c2m232ncp 5 "maxima")
# (c2m232nca   "maxima")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("~/MAXIMA/laurent2.mac");
texput(th, "\\theta ");
load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp")$
load("~/MAXIMA/barematrix1.lisp")$
display2d:'emaxima$
linenum:0;
p : 4*x^2 + 5*x^1 + 6*x^0 + 7*x^-1 + 8*x^-2;
q : 4*E^2 + 5*E^1 + 6*E^0 + 7*E^-1;
lpdot(p, x);
lpdot(q, E);
f :  cos(th)^3;
g : ccos(th)^3;
lpe(f);
lpe(g);

                       exponentialize(f);
                expand(exponentialize(f));
       demoivre(expand(exponentialize(f)));
expand(demoivre(expand(exponentialize(f))));
     subst(th_E,expand(exponentialize(f)));
     subst(th_E,expand(exponentialize(g)));

lpE(f);
lpE(g);
lpE(  ccos(th)^3);
lpE(  ccos(th));
lpE(3*ccos(th));
lpE(ccos(3*th));
lpE(ccos(3*th)+3*ccos(th));

lpE( ccos(th)   );
lpE( ccos(th)^2 );
lpE( ccos(th)^3 );
lpE( csin(th)     );
lpE( csin(th)^2   );
lpE( csin(th)^3   );
lpE( csin(2*th)   );
lpE( csin(2*th)^2 );



#####
#
# 2023-2-edos-lineares
# 2023nov14
#
#####

# «2023-2-edos-lineares»  (to ".2023-2-edos-lineares")
# (c2m232edolsp 5 "maxima")
# (c2m232edolsa   "maxima")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
e1 : 'diff(y,x) + 1/x * y = 2;
e2 : ode2(e1,y,x);
     solve(e2, %c);
e3 : solve(e2, %c)[1];
e4 : subst([x=2,y=5], e2);
     solve(e4, %c);
e4 : solve(e4, %c)[1];
                  subst(e4,e2);
define(f2(x), rhs(subst(e4,e2)));
e5 : subst([y=f2(x)], e1);
ev(e5, diff);




#####
#
# 2023-2-gradefs
# 2023nov10
#
#####

# «2023-2-gradefs»  (to ".2023-2-gradefs")
# (c3m232dicasp1p 3 "gradefs")
# (c3m232dicasp1a   "gradefs")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
columnvector(x) := transpose(matrix(x))$
vtolist(v)      := transpose(v)[1]$
mytexputs([ps]) := map(lambda([p],apply('texput,p)), ps);
mytexputs([z_x,"z_x"], [z_xx,"z_{xx}"], [z_xy,"z_{xy}"]);
mytexputs([z_y,"z_y"], [z_yx,"z_{yx}"], [z_yy,"z_{yy}"]);
mytexputs([x_t,"x_t"], [x_tt,"x_{tt}"]);
mytexputs([y_t,"y_t"], [y_tt,"y_{tt}"]);

load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp")$
load("~/MAXIMA/barematrix1.lisp")$
display2d:'emaxima$
linenum:0;
diff(z);
diff(z, t);
diff(z, t, 2);

gradef(z, x, z_x)$
gradef(z, y, z_y)$
gradef(x, t, x_t)$
gradef(y, t, y_t)$
gradef(z_x, x, z_xx)$
gradef(z_x, y, z_xy)$
gradef(z_y, x, z_xy)$
gradef(z_y, y, z_yy)$
gradef(x_t, t, x_tt)$
gradef(y_t, t, y_tt)$
       diff(z);
       diff(z, t);
       diff(z, t, 2);
expand(diff(z, t, 2));

gradef(x_t, t, 0);
gradef(y_t, t, 0);
       diff(z, t, 2);
expand(diff(z, t, 2));

M    : matrix([z_xx,z_xy], [z_xy,z_yy]);
xy_t : columnvector([x_t,y_t]);
ab   : columnvector([a,b]);
cd   : columnvector([c,d]);
ab * cd;
ab . cd;
 M . xy_t;
(M . xy_t) . xy_t;
diff(z, t, 2);



#####
#
# 2023-2-DDs
# 2023nov16
#
#####

# «2023-2-DDs»  (to ".2023-2-DDs")
# (c3m232dicasp1p 6 "diferencas")
# (c3m232dicasp1a   "diferencas")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
columnvector(x):=transpose(matrix(x))$
DD(L)  := makelist(L[i+1]-L[i], i, 1, length(L)-1);
DDs(L) := columnvector([L, DD(L), DD(DD(L)), DD(DD(DD(L)))]);
A : [1,10,100,1000,10000];
DDs(A);
A : [0,3,6,9,12,15,18,21];
DDs(A);
A : [1,4,9,16,25,36,49];
DDs(A);
      DD(makelist(a + b*n,                 n, 1, 10));
   DD(DD(makelist(a + b*n + c*n^2,         n, 1, 10)));
DD(DD(DD(makelist(a + b*n + c*n^2 + d*n^3, n, 1, 10))));



#####
#
# 2023-2-EDOLCCs
# 2023nov18
#
#####

# «2023-2-EDOLCCs»  (to ".2023-2-EDOLCCs")
# (find-anggfile "MAXIMA/laurent2.mac")
# (find-books "__analysis/__analysis.el" "boyce-diprima" "133" "3.5 Nonhomogeneous Equations")
# (find-books "__analysis/__analysis.el" "zill-cullen" "125" "4.1.3 Nonhomogeneous Equations")
# (find-books "__analysis/__analysis.el" "lebl" "104" "2.5 Nonhomogeneous equations")
# (c2m232cdp 2 "links")
# (c2m232cda   "links")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
L : (D-2)*(D-3);
L : (D-4)*(D+1);
g : 0;
Ldegree()   := hipow(expand(L), D);
Lcoef  (k)  := ratcoef(L, D, k);
Ldiffy ()   := sum(Lcoef(k)*'diff(y,x,k), k, 0, Ldegree());
Ldiff  (f)  := sum(Lcoef(k)* diff(f,x,k), k, 0, Ldegree());
Lf0    ()   := rhs(ode2(Ldiffy()=g, y, x));
Lf1    ()   := subst([%k1=1, %k2=0, %k3=0], Lf0());
Lf2    ()   := subst([%k1=0, %k2=1, %k3=0], Lf0());
Lf3    ()   := subst([%k1=0, %k2=0, %k3=1], Lf0());

Ldiffy();
Ldiff (x^2);
Ldiff (exp(2*x));
Lf0();
Lf1();
Lf2();
Lf3();

Ldiff (exp(2*x));
g  : 3*exp(2*x);
Lf3();

Ldiff (sin(x));
Ldiff (cos(x));
g : 2*sin(x);
Lf3();

Ldiff (1);
Ldiff (x);
Ldiff (x^2);
g : 4*x^2 - 1;
Lf3();




L . f;

define(f0(x), Lf0());
solve([f0(0)=2, f0(1)=3], [%k1, %k2]);

ode2(Ldiffy()=0, y, x);
ode2(Ldiffy()=x, y, x);
ode2(Ldiffy()=x^2, y, x);
ode2(Ldiffy()=x^3, y, x);
ode2(Ldiffy()=exp(x), y, x);



#####
#
# 2023-2-C3-P1
# 2023nov22
#
#####

# «2023-2-C3-P1»  (to ".2023-2-C3-P1")
# (to "2024-1-C3-P1-Q3")
# (c3m232p1p 4 "questao-3")
# (c3m232p1a   "questao-3")
# (find-maximanode "hessian")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-es  "maxima" "2022-2-C3-P1")
** (find-angg "MAXIMA/matrixify.mac")
load       ("~/MAXIMA/matrixify.mac");
u   : y - 2*x;
v   : x+y;
matrixify (-2,-2, 2,2, u);
matrixify (-2,-2, 2,2, v);
matrixify (-2,-2, 2,2, u*v);

F   : 2*x^2 + -x*y - y^2;

F   : 2*x^2 + -x*y - y^2;
F_x : diff(F,x);
F_y : diff(F,y);
matrixify (-2,-2, 2,2, y-2*x);
matrixify (-2,-2, 2,2, x+y);
matrixify (-2,-2, 2,2, F);
matrixify (-2,-2, 2,2, [F_x, F_y]);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-es  "maxima" "2022-2-C3-P1")
** (find-angg "MAXIMA/matrixify.mac")
load       ("~/MAXIMA/matrixify.mac");
u : x + y - 5;
v : y - 2;
s : 3 + u*v;
p : 4 + u^2 + v^2;
[x0,y0] : [3,2];
matrixify (x0-1,y0-1, x0+1,y0+1, [x,y]);
matrixify (x0-1,y0-1, x0+1,y0+1, u);
matrixify (x0-1,y0-1, x0+1,y0+1, v);
matrixify (x0-1,y0-1, x0+1,y0+1, s);
matrixify (x0-1,y0-1, x0+1,y0+1, p);

hessian(s, [x,y]);
hessian(p, [x,y]);

FNW : matrixify (0,0, 10,10, 6);
FN  : matrixify (0,0, 10,10, 12-2*x);
FW  : matrixify (0,0, 10,10, y-2);
FC  : matrixify (0,0, 10,10, y-x+1);
FR  : matrixify (0,0, 10,10, 0);

/* (6,5,0) + t(-1,1,2) */





#####
#
# Figuras sobre raio de convergência
# 2023nov27
#
#####

# «2023-2-raio-conv»  (to ".2023-2-raio-conv")
# (to "qdraw-taylor")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
derivsn(n,f)  := makelist(diff(f,x,k), k, 0,n)$
derivs0n(n,f) := subst([x=0], derivsn(n,f))$
taylorize(L)  := makelist(L[j]*x^(j-1)/(j-1)!, j, 1,length(L))$
taylorize(L)  := sum     (L[j]*x^(j-1)/(j-1)!, j, 1,length(L))$

load_qdraw();
myqdraw([lists]) := apply('qdraw, apply('append, lists))$
colors : [black, red, orange, forest_green, blue, dark_violet]$

derivsn (7, sin(x));
derivs0n(7, sin(x));
taylorize(derivs0n(7, sin(x)));
Tn(n, f) := taylorize(derivs0n(n, f))
Tn(4, sin(x));

Tn3(N, f, cc) := ex1(Tn(N, f), x, -r,r, lc(colors[cc]))$
Tn3(4, sin(x), 2);
Tns(N, f) := makelist(Tn3(NN, f, NN), NN, 1, N);
Tns(4, sin(x));

r : 2*%pi;
r : 4*%pi;
myqdraw([xr(-r,r),yr(-r,r)], Tns(6, 1/(x-1)));



myexs_1(ii)      := ex1(fs[ii], x, -r,r, lc(colors[ii]))$


myexs()          := makelist(myexs_1(ii), ii, length(fs))$

myexs();





derivsf0     : subst([x=0], derivsf);
derivsfk(k)  := diff(f,x,k);
derivsf0k(k) := subst([x=0], derivsfk(k));
termk(k)     := derivsf0k(k) * x^k/k!;
newf(K)      := sum(termk(k), k, 0, K);
newf(7);






#####
#
# How do I do just the first half of "plotting contour levels"?
# 2022nov19
#
#####

# «plotting-contours»  (to ".plotting-contours")
# (to "2022-2-C3-P1")
# (find-maximamsg "37736745 202211 18" "Edrx: first half of plotting contour levels?")
# (find-maximamsg "37736853 202211 18" "MTalon: gnuplot contours")
# (find-maximamsg "37737021 202211 18" "Stavros: ratprint / float")
# (find-maximamsg "37737109 202211 18" "RDodier: draw2d-implicit")

Hi list,

a few days ago I had to draw some level curves of

  F(x,y) := 2*x^2 - x*y - y^2;

in TikZ. I was in a hurry, so I wrote something that was an uglier
version of this,

  F(x,y)  := 2*x^2 - x*y - y^2;
  xs(y,z) := solve(F(x,y)=z, x);
  maxsol(sols) := apply('max, map('rhs, sols));
  minsol(sols) := apply('min, map('rhs, sols));
  leftx (y,z)  := minsol(xs(y,z));
  rightx(y,z)  := maxsol(xs(y,z));
  seqn(a,b,n)    := makelist(a + (b-a)*k/n, k, 0, n);
  leftxys (ys,z) := ev(makelist([leftx (y,z), y], y, ys), numer);
  rightxys(ys,z) := ev(makelist([rightx(y,z), y], y, ys), numer);
  leftxys (seqn(2, 0.943, 10), -1);
  rightxys(seqn(0.943, 2, 10), -1);

but with more calls to "leftxys" and "rightxys" at the end, and then I
converted the output to a series of "\draw" commands for TikZ using a
throway-ish Lua program.

I'm not in a hurry anymore, and now I can try to learn better ways to
find the points in level curves.

Questions: 1) I got lots of messages like this one:

  rat: replaced 0.110751 by 110751/1000000 = 0.110751

How do I silence them?

And: 2) plot2d knows how to plot "contour levels". It certainly has
separate functions for calculating the points of a level curve and for
converting those points into commands for, say, gnuplot... is it easy
to call just the function that calculates the points? How do I do
that?

  Thanks in advance!
    Eduardo Ochs
    http://angg.twu.net/eev-maxima.html




#####
#
# plotting-contours-2
# 2022nov19
#
#####

# «plotting-contours-2»  (to ".plotting-contours-2")
# (to "2022-2-C3-P2-Q4")
# (find-es "gnuplot" "tikz")
# (find-maximagitfile "share/draw/draw_gnuplot.dem")
# (find-maximagitfile "share/draw/draw_gnuplot.dem" "Implicit 2D")
# (find-maximagitfile "share/draw/draw_gnuplot.dem" "Map contours")
# (find-maximagitfile "share/draw/draw_gnuplot.dem" "= eps")
# (find-maximagitfile "share/draw/draw_gnuplot.dem" "= animated_gif")
# (find-maximamsg "37737109 202211 18" "RDodier: draw2d-implicit")
# (find-maximanode "draw2d")
# (find-maximanode "plot2d")
# (find-maximanode "gnuplot_term")
# (find-maximanode "gnuplot_out_file")
# (find-fline "~/LOGS/2022nov21.emacs" "MAXIMA> (apropos \"draw_gnuplot\")")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
F(x,y)        := 2*x^2 - x*y - y^2;

set_plot_option ([gnuplot_term,     "tikz"]);
set_plot_option ([gnuplot_out_file, "/tmp/myplot.tikz"]);
plot2d ([contour, F(x, y)], [x, -2, 2], [y, -2, 2]);

to_lisp();
  (apropos "draw_gnuplot")
  *PACKAGE*
  (to-maxima)

level(z)      := implicit(F(x,y)=z, x,-2,2, y,-2,2);
clevel(clr,z) := [color=clr, level(z)];
clevels       :  [clevel(red,   -2),
                  clevel(orange,-1),
                  clevel(green,  0),
                  clevel(blue,   2),
                  clevel(violet, 5)];
draw2d(clevels);
draw2d(file_name="/tmp/myplot", terminal=eps,  clevels);
/* ^ These two "draw2d"s work as expected */

draw2d(file_name="/tmp/myplot", terminal=tikz, clevels);
/* ^ Fails with: "draw: illegal terminal specification: tikz"
 *   Fixed! See: (find-fline "/tmp/myplot.tikz")
*/

set_plot_option ([gnuplot_term,     "tikz"]);
set_plot_option ([gnuplot_out_file, "/tmp/myplot.tikz"]);
draw2d(clevels);
/* ^ The options are ignored */

set_plot_option ([gnuplot_term,     "eps"]);
set_plot_option ([gnuplot_out_file, "/tmp/myplot2.eps"]);
draw2d(clevels);
/* ^ The options are ignored */


/* Lower-level tests: */
draw2d(level(0), level(2), level(5), level(-1), level(-2));
draw2d(level(0), level(2), color=red, level(5), level(-1), level(-2));
draw2d([color=red,    level(-2)],
       [color=orange, level(-1)],
       [color=green,  level(0)],
       [color=blue,   level(2)],
       [color=violet, level(5)]);
draw2d(clevel(red,   -2),
       clevel(orange,-1),
       clevel(green,  0),
       clevel(blue,   2),
       clevel(violet, 5));




#####
#
# "terminal=tikz" doesn't work: e-mail
# 2022nov20
#
#####

# «terminal-tikz»  (to ".terminal-tikz")
# (to "qdraw-to-pdf")
# https://mail.google.com/mail/u/0/#sent/QgrcJHrjBQxRMBcWKGMPCNwbccRSMJcMqXL
# (find-maximamsg "37737497 202211 20" "Edrx: terminal=tikz?")
# (find-maximamsg "37737637 202211 20" "RDodier: draw2d and plot2d are separate bodies")
# (find-maximamsg "37737671 202211 20" "MTalon: In grcommon.lisp add $tikz")
# (find-maximamsg "37738749 202211 23" "Edrx: $pict2e also works")
# (find-maximamsg "37738762 202211 23" "RDodier: plot2d is more lenient")
# (find-maximamsg "37738817 202211 23" "Edrx: fails with dimension too large")
# (find-maximagitfile "share/draw/grcommon.lisp")
# (find-maximagitfile "share/draw/grcommon.lisp" "update-terminal")
# (find-maximagitfile "share/draw/gnuplot.lisp")
# (find-maximagitfile "share/draw/gnuplot.lisp" "($gif (format")
# (find-maximagitfile "share/draw/gnuplot.lisp" "($pict2e")
# (find-sh "locate grcommon.lisp")
# (find-sh "locate gnuplot.lisp")
# (find-maximanode "terminal")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
  draw2d(file_name="/tmp/toto",terminal=tikz,explicit(cos(x),x,1,10));
                        [gr2d(explicit)]


Hi Robert and all,

I am still trying to digest all the hints in this thread...

  https://sourceforge.net/p/maxima/mailman/message/37737109/

First problem: setting the terminal to "tikz" doesn't work for me. I
am running this version of Maxima,

  Maxima branch_5_46_base_555_g6fa201ff5

that I git-pull'ed and compiled a few minutes ago, and a gnuplot from
2020...  but I followed the instructions here

  http://www.gnuplot.info/docs/latex_demo.pdf

to check if my gnuplot supports tikz, and the answer seems to be yes -
I ran "set terminal tikz" in a gnuplot REPL and got:

  gnuplot> set terminal tikz

  Terminal type is now 'tikz'
  Options are 'latex nopreamble color nostandalone nogparrows
  notikzarrows nogppoints picenvironment nooriginreset bitmap rgbimage
  noclip notightboundingbox noexternalimages '

Here's what I tried to do in Maxima (inspired by the file
share/draw/draw_gnuplot.dem):

  F(x,y)        := 2*x^2 - x*y - y^2;
  level(z)      := implicit(F(x,y)=z, x,-2,2, y,-2,2);
  clevel(clr,z) := [color=clr, level(z)];
  clevels       :  [clevel(red,   -2),
                    clevel(orange,-1),
                    clevel(green,  0),
                    clevel(blue,   2),
                    clevel(violet, 5)];
  draw2d(clevels);
  draw2d(file_name="/tmp/myplot", terminal=eps,  clevels);
  /* ^ These two "draw2d"s work as expected */
  
  draw2d(file_name="/tmp/myplot", terminal=tikz, clevels);
  /* ^ Fails with: "draw: illegal terminal specification: tikz" */
  
  set_plot_option ([gnuplot_term,     "tikz"]);
  set_plot_option ([gnuplot_out_file, "/tmp/myplot.tikz"]);
  draw2d(clevels);
  /* ^ The options are ignored */
  
  set_plot_option ([gnuplot_term,     "eps"]);
  set_plot_option ([gnuplot_out_file, "/tmp/myplot2.eps"]);
  draw2d(clevels);
  /* ^ The options are ignored */

I also tried to grep the source tree of Maxima for "tikz"
case-insensitively, and got no matches...

Thanks in advance!
  Eduardo Ochs
  http://angg.twu.net/eev-maxima.html


* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -fv /tmp/my*

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
  F(x,y)        := 2*x^2 - x*y - y^2;
  level(z)      := implicit(F(x,y)=z, x,-2,2, y,-2,2);
  clevel(clr,z) := [color=clr, level(z)];
  clevels       :  [clevel(red,   -2),
                    clevel(orange,-1),
                    clevel(green,  0),
                    clevel(blue,   2),
                    clevel(violet, 5)];
  draw2d(file_name="/tmp/mydraw", terminal=tikz,   clevels);
  draw2d(file_name="/tmp/mydraw", terminal=pict2e, clevels);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
  F(x,y) := 2*x^2 - x*y - y^2;
  set_plot_option ([gnuplot_term,     "tikz"]);
  set_plot_option ([gnuplot_out_file, "/tmp/myplot.tikz"]);
  plot2d([contour, F(x, y)], [x, -2, 2], [y, -2, 2]);
  set_plot_option ([gnuplot_term,     "pict2e"]);
  set_plot_option ([gnuplot_out_file, "/tmp/myplot.pict2e"]);
  plot2d([contour, F(x, y)], [x, -2, 2], [y, -2, 2]);

/* (find-2a '(find-fline "/tmp/mydraw.pict2e")
            '(find-fline "/tmp/myplot.pict2e"))
   (find-2a '(find-fline "/tmp/mydraw.tikz")
            '(find-fline "/tmp/myplot.tikz"))
*/

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /usr/share/texmf/tex/
cp -v gnuplot-lua-tikz-common.tex /tmp/
cp -v gnuplot-lua-tikz.sty        /tmp/

cd /tmp/

cat > mydraw-tikz.tex <<'---'
  \documentclass{article}
  \usepackage{tikz}
  \usepackage{gnuplot-lua-tikz}
  \begin{document}
  \input mydraw.tikz
  \end{document}
---

cat > mydraw-pict2e.tex <<'---'
  \documentclass{article}
  \usepackage{pict2e}
  \usepackage{xcolor}
  \usepackage{graphicx}
  \begin{document}
  \input mydraw.pict2e
  \end{document}
---

cat > myplot-tikz.tex <<'---'
  \documentclass{article}
  \usepackage{tikz}
  \usepackage{gnuplot-lua-tikz}
  \begin{document}
  \input myplot.tikz
  \end{document}
---

cat > myplot-pict2e.tex <<'---'
  \documentclass{article}
  \usepackage{pict2e}
  \usepackage{xcolor}
  \usepackage{graphicx}
  \begin{document}
  \input myplot.pict2e
  \end{document}
---

# These work:
lualatex myplot-tikz.tex
lualatex myplot-pict2e.tex
xpdf myplot-tikz.pdf
xpdf myplot-pict2e.pdf

# These don't:
lualatex mydraw-tikz.tex
lualatex mydraw-pict2e.tex



  lualatex mydraw-pict2e.tex

fails with:



  lualatex mydraw-pict2e.tex

fails with:

  ! Dimension too large.
  <recently read> \unitlength 
  l.11 \begin{picture}(360000,300000)(0,0)

and

  lualatex mydraw-tikz.tex

fails with:

  ! Dimension too large.
  <recently read> \pgf@xx 
  l.4 \path (0.000,0.000) rectangle (600.000,500.000)
                                                   ;
and




#####
#
# 2022-2-C3-P2-Q4
# 2022dec13
#
#####

# «2022-2-C3-P2-Q4»  (to ".2022-2-C3-P2-Q4")
# (c3m222p2p 3 "questao-4")
# (c3m222p2a   "questao-4")
# (to "plotting-contours-2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
H(x,y) := x*y;
E(x,y) := x^2 + 4*y^2;
Hlevel(z)      := implicit(H(x,y)=z, x,-4,4, y,-4,4);
Elevel(z)      := implicit(E(x,y)=z, x,-4,4, y,-4,4);
Hclevel(clr,z) := [color=clr, Hlevel(z)];
Eclevel(clr,z) := [color=clr, Elevel(z)];

clevels        :  [Eclevel(black, 16),
                   Hclevel(red,   -4),
                   Hclevel(orange,-3),
                   Hclevel(green,  0),
                   Hclevel(blue,   3),
                   Hclevel(violet, 4)
                  ];
draw2d(clevels);



#####
#
# 2022-2-C3-VR
# 2022dec16
#
#####

# «2022-2-C3-VR»  (to ".2022-2-C3-VR")
# (c3m222vrp 2 "questao-1")
# (c3m222vra   "questao-1")
# (find-angg "MAXIMA/findchanges1.mac")
# (to "binsearch")
# (find-maximanode "append")
# (find-maximanode "push")
# (find-maximanode "makelist")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
C(x,y)       := x^2 + y^2;
Cth(th)      := [2*cos(th), 2*sin(th)];
insideC(x,y) := is(C(x,y) <= 4);

H(x,y)        := x*y;
Htp(t)        := [t, 1/t];
Htn(t)        := [t, -1/t];
insideH(x,y)  := -1 <= H(x,y) and H(x,y) <= 1;

insideCH(x,y) := insideC(x,y) and insideH(x,y);

seqn(a,b,n) := makelist(a + (b-a)*k/n, k, 0, n);
seq (a,b)   := makelist(i, i, a, b);

binsearch(f,a,b,n) :=
  block([va,vb,c,vc],
        [va,vb] : [f(a),f(b)],
        for i: 1 thru n do
          (c  : (a+b)/2,
           vc : f(c),
           if equal(va,vc) then [a,va]:[c,vc] else [b,vb]:[c,vc]),
        c)$

binsearchins(Fboo,F,points,n, tag) :=
  block([npoints,results,fboo,a,b,xa,ya,xb,yb,c],
        npoints : length(points),
        results : [],
        fboo(t) := Fboo(F(t)[1], F(t)[2]),
        for i: 1 thru npoints-1 do
          (a : points[i],
           b : points[i+1],
           if not equal(fboo(a), fboo(b)) then
	     (c : float(binsearch(fboo,a,b,n)),
              push([F(c), c, tag], results)
             )
          ),
        reverse(results))$

binsearchins(insideH, Cth, seqn( 0,2*%pi,20), 20, "Cth");
binsearchins(insideC, Htp, seqn( 0.1, 10,20), 20, "Htp");
binsearchins(insideC, Htp, seqn(-0.1,-10,20), 20, "Htp");
binsearchins(insideC, Htn, seqn( 0.1, 10,20), 20, "Htn");
binsearchins(insideC, Htn, seqn(-0.1,-10,20), 20, "Htn");

xytfs : float([
[[1.931851704273888, 0.5176378972738332], 0.2617992879306086, Cth], 
[[1.931852068901062, 0.5176379786516739], 1.931852068901062, Htp],
[[0.5176378393173217, 1.931852588904308], 0.5176378393173217, Htp], 
[[0.5176378972738334, 1.931851704273888], 1.308997038864288, Cth], 
[[- 0.5176378972738331, 1.931851704273888], 1.832595614725505, Cth], 
[[- 0.5176378393173217, 1.931852588904308], - 0.5176378393173217, Htn],
[[- 1.931852068901062, 0.5176379786516739], - 1.931852068901062, Htn],
[[- 1.931851704273888, 0.5176378972738335], 2.879793365659185, Cth], 
[[- 1.931851704273888, - 0.517637897273833], 3.403391941520402, Cth], 
[[- 1.931852068901062, - 0.5176379786516739], - 1.931852068901062, Htp],
[[- 0.5176378393173217, - 1.931852588904308], - 0.5176378393173217, Htp],
[[- 0.5176378972738345, - 1.931851704273887], 4.450589692454081, Cth], 
[[0.5176378972738338, - 1.931851704273888], 4.974188268315299, Cth], 
[[0.5176378393173217, - 1.931852588904308], 0.5176378393173217, Htn], 
[[1.931852068901062, - 0.5176379786516739], 1.931852068901062, Htn],
[[1.931851704273887, - 0.5176378972738346], 6.021386019248977, Cth],
[[1.931851704273888, 0.5176378972738332], 0.2617992879306086 + 2*%pi, Cth]
])$

myangle(x, y) := imagpart(float(log(x + y*%i)));
atf(xytf) := [myangle(xytf[1][1], xytf[1][1]), xytf[2], xytf[3]];
atf(xytfs[1]);
atfs : makelist(atf(xytf), xytf, xytfs);

myparametric(i) :=
  block([a1,a2,t1,t2,f],
        a1 : xytfs[i],
        a2 : xytfs[i+1],
        t1 : a1[2],
        t2 : a2[2],
        f  : a1[3],
        parametric(f(t)[1], f(t)[2], t, min(t1,t2), max(t1,t2)))$

myparametric(2);

draw(gr2d(
  myparametric(2),
  myparametric(4),
  myparametric(6),
  myparametric(8),
  myparametric(10),
  myparametric(12),
  myparametric(14),
  myparametric(16)
));

C6 : [myparametric(2),
      myparametric(4),
      myparametric(6),
      myparametric(8),
      myparametric(10),
      myparametric(12),
      myparametric(14),
      myparametric(16)
  ]$

uv0 : [1,0];
uu  : [1,1];
vv  : [-1,1];
M(k,t) := uv0 + t*uu + (k/t)*vv;
Mk(t)  := M(k,t);
k : 2;
Mk(1);
Mk(2);
Mk(0.5);

binsearchins(insideCH, Mk, seqn(0.1,-10,20), 20, "Foo");





# (find-maximanode "parametric")







#####
#
# myangle
# 2022dec17
#
#####

# «myangle»  (to ".myangle")
# (find-maximanode "realpart")
# (find-maximanode "imagpart")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
myangle(x, y) := imagpart(float(log(x + y*%i)));
myangle(4, 0);
myangle(0, 4);
myangle(-4, 0);
myangle(0, -4);










#####
#
# Early references on undefined variables?
# 2022jul27
#
#####

# «early-references-on-und»  (to ".early-references-on-und")
# (find-maximamsg "37686311 202207 27" "Early references on undefined variables?")
# (find-maximamsg "37686436 202207 27" "Richard 1")
# (find-maximamsg "37686954 202207 28" "Stavros 2")
# (find-maximamsg "37687067 202207 28" "Richard 3")
# http://jmc.stanford.edu/articles/lisp.html History of Lisp
# http://jmc.stanford.edu/articles/lisp/lisp.pdf
# https://dl.acm.org/doi/pdf/10.1145/367177.367199 McCarthy: Recursive Functions...
# https://cicm-conference.org/2022/cicm.php


Early references on undefined variables?

Hi list, especially Richard,

I've read a part of Richard's PhD thesis,

  https://apps.dtic.mil/sti/pdfs/AD0740132.pdf

and it gave me the impression that this would be a good place to ask
this... so here it goes. But first a little story.

In the middle of my master's degree, ages ago, I switched from trying
to do research on Maths (that I was finding boring) to trying to do
research on Logic (that looked much more fun). The people in the Logic
group in my university were working mostly on Proof Theory, and every
time that they would start to work on a new logical system they would
try to prove strong normalization for it - and they would usually
succeed, because they had a lot of knowledge about which systems
"looked like something that they would be able to prove strong
normalization for"... systems that were not strongly normalizable were
"bad" to them, and they were put in the box of the toys that they
didn't want to play with. I somehow managed to 1) not learn how to do
strong normalization proofs, and to 2) focus more on Lambda Calculus
than on Proof Theory... so I know a lot of the terminology about
reductions and normalization, but only a few of the techniques.

End of the little story.

So: in Maxima we can change how our reductions work by changing lots
of flags, and in some contexts we can set, say, w to 42, and this
tells the system that from that point onwards every w should be
reduced to 42. And if we turn off most of the actions of the
simplifier we can make both of these expressions

  expr1 : (x + y)(x - y)
  expr2 : (x + y)(x - y) - (x^2 - y^2)

reduce to themselves.

I _guess_ that:

  1. when the first Lisps were being created people saw very quickly
     that evaluation should be different from β-reduction... in
     β-reduction and its variants a free variable like x reduces to
     itself, but it's better to define evaluation in a way in which
     evaluating an undefined variable yields an error... and:

  2. when the first Computer Algebra systems were being created people
     saw very quickly that variables should be treated in other, more
     complex, ways - both expr1 and expr2 above are valid expressions
     that can be manipulated in many ways, but that can't evaluated
     numerically or plotted because they both depend on both x and
     y... and I guess that even the first CASs had simple functions,
     that didn't work in all cases, that could compare expr1 and expr2
     to 0, and answer that "expr1 is not 0 because expr1 depends on x
     and y and 0 doesn't" - and the same for expr2 (ta-da).

My question is: can you recommend good early references that discuss
this, i.e., that discuss how the notion of free/undefined variables in
CASs was invented?

  Thanks in advance!
    Cheers =),
      Eduardo Ochs
      http://angg.twu.net/eev-maxima.html




#####
#
# Classical Mechanics with Maxima
# 2022aug10
#
#####

# «cm-maxima»  (to ".cm-maxima")
# https://sites.berry.edu/ttimberlake/teaching/cm_maxima/
# https://sites.berry.edu/ttimberlake/wp-content/uploads/sites/37/2015/07/AnnotatedCode.zip

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "~/usrc/cm_maxima/")
rm -Rv ~/usrc/cm_maxima/
mkdir  ~/usrc/cm_maxima/
cd     ~/usrc/cm_maxima/
unzip $S/https/sites.berry.edu/ttimberlake/wp-content/uploads/sites/37/2015/07/AnnotatedCode.zip



#####
#
# defrule
# 2022aug23
#
#####

# «defrule»  (to ".defrule")
# (find-maximanode "defrule")
# (find-maximanode "apply1")
# (find-maximanode "applyb1")
# (find-maximanode "apply2")
# (find-maximanode "matchdeclare")
# (find-maximanode "Introduction to Rules and Patterns")
# (find-maximanode "let")
# (find-maximanode "letsimp")

# (find-angg "MAXIMA/step_by_step.mac")
# (find-maximanode "sublist")



#####
#
# step_by_step.mac
# 2023jul16
#
#####

# «step_by_step.mac»  (to ".step_by_step.mac")
# (find-maximamsg "37871522 202307 16" "RDodier: step_by_step.mac")
# (find-angg "MAXIMA/step_by_step.mac")




#####
#
# simplifying
# 2022aug28
#
#####

# «simplifying»  (to ".simplifying")
# (find-maximamsg "37699419 202208 27" "BWillis: simpfunmake")
# (find-maximamsg "37699698 202208 29" "Edrx: Here's a beginner's approach")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(simplifying)$
ex: simpfunmake("+",[2,3]);
expand(%);

texput(ldots, "\\ldots");

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
o : lambda([], 2 + 3);
o : lambda([], 1/(2+3/(4+5/(6+7/(8+9)))));
o : lambda([], 1/(2+3/(4+5/(6+7/(8+ldots)))));
simp : false;
o();
tex(o());




#####
#
# twenty-and-thirty
# 2022sep05
#
#####

# «twenty-and-thirty»  (to ".twenty-and-thirty")
# (find-maximamsg "37702635 202209 04" "Stavros: and *thirty *as a simplifying function")
# (find-maximamsg "37703046 202209 05" "Stavros: (defun simp-thirty")



#####
#
# mfuncall: Calling user-defined function from lisp
# 2022sep12
#
#####

# «mfuncall»  (to ".mfuncall")
# https://mail.google.com/mail/u/0/#inbox/FMfcgzGqQSLWkHhdjXXqPtvzGhHnfSvg
# (find-maximamsg "37703882 202209 07" "TBaruchel: original question")
# (find-maximamsg "37703894 202209 07" "RDodier: (mfuncall '$foo x y z)")
# (find-maximamsg "37703900 202209 07" "RFateman: :lisp (meval '(($f) 4))")
# (find-maximamsg "37703934 202209 07" "TBaruchel:")
# (find-maximamsg "37704291 202209 08" "LButler: You need to declare a toplevel. This works:")
# (find-maximamsg "37704328 202209 08" "TBaruchel:")
# (find-maximamsg "37705348 202209 10" "MTalon: https://www.xach.com/lisp/buildapp/")



#####
#
# apropos
# 2022oct28
#
#####

# «apropos»  (to ".apropos")
# (find-maximamsg "37727454 202210 28" "KrisKatt: root_by_bisection")
# (find-maximanode "find_root")
# (find-maximanode "bf_find_root")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
apropos ("bisect");
cool_bisection_function_without_args ();
apropos ("bisect");



#####
#
# plot-src
# 2022nov18
#
#####

# «plot-src»  (to ".plot-src")
# (find-maximagitfile "")
# (find-maximagitsh "find * | sort | grep -i plot")
# (find-maximagitgrep "grep --color=auto -nRH --null -e gnuplot *")
# (find-maximagitgrep "grep --color=auto -niH --null -e gnuplot $(find * | sort | grep -i plot)")
# (find-maximagitfile "plotting/mgnuplot")
# (find-maximagitfile "plotting/mgnuplot.in")
# (find-maximagitfile "share/draw/")
# (find-maximagitfile "share/draw/gnuplot.lisp")
# (find-maximagitfile "share/draw/draw_gnuplot.dem")
# (find-maximagitfile "src/gnuplot_def.lisp")
# (find-maximagitfile "src/plot.lisp")
# (find-maximagitfile "tests/rtest_plot.mac")
# (find-maximagitfile "tests/rtest_plotoptions.mac")



#####
#
# draw_gnuplot.dem
# 2022nov18
#
#####

# «draw_gnuplot.dem»  (to ".draw_gnuplot.dem")
# (find-maximagitfile "share/draw/")
# (find-maximagitfile "share/draw/draw_gnuplot.dem")
# (find-maximanode "demo")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
demo("draw_gnuplot.dem");
demo("~/bigsrc/maxima/share/draw/draw_gnuplot.dem");

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cp -v ~/bigsrc/maxima/share/draw/draw_gnuplot.dem /tmp/
# (find-fline "/tmp/draw_gnuplot.dem")



#####
#
# maxima-packages
# 2022nov24
#
#####

# «maxima-packages»  (to ".maxima-packages")
# https://github.com/maxima-project-on-github/maxima-packages
# (find-git-links "https://github.com/maxima-project-on-github/maxima-packages" "maximapackages")
# (code-c-d "maximapackages" "~/usrc/maxima-packages/")
# (find-maximapackagesfile "")
# (find-maximapackagesfile "yitzchak/texify/README.md")



#####
#
# lexical_symbols.mac
# 2022nov24
#
#####

# «lexical_symbols.mac»  (to ".lexical_symbols.mac")
# (to "buildq")
# (find-maximamsg "37739038 202211 23" "RDodier: lexical-symbols")
# (code-c-d "mlexical" "~/usrc/maxima-packages/robert-dodier/lexical_symbols/")
# (find-mlexicalfile "")
# (find-mlexicalfile "README.md")
# (find-mlexicalfile "lexical_symbols.mac")
# (find-maximanode "sconcat")
# (find-maximanode "file_search_lisp")
# (find-maximanode "file_search_maxima")
# (find-maximanode "file_search_demo")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
d: "~/usrc/maxima-packages/robert-dodier/lexical_symbols";
push (sconcat (d, "/###.lisp"), file_search_lisp);
push (sconcat (d, "/###.mac"),  file_search_maxima);
push (sconcat (d, "/###.demo"), file_search_demo);
load ("lexical_symbols.mac");
F  : lambda([a], lambda([b], 10*a+b));
o4 : F(2);
get_envs (o4);
o4(3);
F(2)(3);




#####
#
# lexical-symbols-branch
# 2022nov24
#
#####

# «lexical-symbols-branch»  (to ".lexical-symbols-branch")
# (find-es "git" "git-diff")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd ~/bigsrc/maxima/
export PAGER=cat
git diff master lexical-symbols | tee /tmp/o.diff

# (find-gitk "~/bigsrc/maxima/")




#####
#
# Tutorial by Boris Gaertner - has a section about lexical vs dynamic
# 2023feb03
#
#####

# «gaertner-tutorial»  (to ".gaertner-tutorial")
# «gaertner-dynamic»  (to ".gaertner-dynamic")
# https://maxima.sourceforge.io/docs/tutorial/en/gaertner-tutorial-revision/Contents.htm
# https://maxima.sourceforge.io/docs/tutorial/en/gaertner-tutorial-revision/Pages/Programming0003.htm
  ^ lexical vs dynamic

# (find-wgetrecursive-links "https://maxima.sourceforge.io/docs/tutorial/en/gaertner-tutorial-revision/Contents.htm")


Which opinions?
This looks impeccably written to me:

  Maxima was written when Lisp was a dynamically scoped language. Huge
  parts of Maxima still require the availability of dynamic scope
  rules.

and I have to confess that I loved the "Regrettably, scope rules were
later complicated as a consequence of...", and it made me laugh a lot.
DISCLAIMER: I am the author of an Emacs package that needs dynamic
binding in several places, and I think that the right way to teach
Lisp to beginner is to start with dynamic binding and present lexical
binding later.

  Cheers =),
    Eduardo Ochs
    http://anggtwu.net/#eev
    http://anggtwu.net/eev-maxima.html
    http://anggtwu.net/eev-intros/find-lexical-intro.html






#####
#
# EDOLCCs
# 2022nov21
#
#####

# «EDOLCCs»  (to ".EDOLCCs")
# (c2m222edolsp 4 "maxima")
# (c2m222edolsa   "maxima")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
Dplus0 : lambda([k,f], (D+k)*f);
Dplus1 : lambda([k,f], Dx(f)+k*f);
Dx1    : lambda([f], diff(f,x));
subst0 : lambda([r],    subst([Dplus=Dplus0], r));
subst1 : lambda([r,ss], subst([Dplus=Dplus1, ss, Dx=Dx1], r));

r : Dplus(-10, Dplus(2, f));

subst0(r);
subst1(r, f=exp(2*x));
subst1(r, f=exp(-2*x));

subst([Dplus=Dplus0], r);
subst([Dplus=Dplus1], r);
subst([Dplus=Dplus1, f=exp(10*x)], r);
subst([Dplus=Dplus1, f=exp(10*x), Dx=Dx1], r);

gradef(f(x),   f_x (x));
gradef(f_x(x), f_xx(x));

       subst1(r, f=f(x));
expand(subst1(r, f=f(x)));



#####
#
# Definitions by cases
# 2022nov29 / 2024oct17
#
#####

# «by-cases»  (to ".by-cases")
# (to "parametric-fix")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
F1 : x;
F2 : 2*x;
f1 : diff(F1,x);
f2 : diff(F2,x);
F  : if x<2 then F1 else F2;
f  : if x<2 then diff(F1,x) else diff(F2,x);
f  : if x<2 then f1 else f2;
plot2d(F, [x, 0, 4]);
plot2d(f, [x, 0, 4]);




#####
#
# relational
# 2022dec07
#
#####

# «relational»  (to ".relational")
# (find-maximanode "Relational operators")
# (find-maximanode "is")
# (find-maximanode "if")
# (find-maximanode "and")
# (find-maximanode "and" "forces evaluation")




#####
#
# binsearch
# 2022dec07
#
#####

# «binsearch»  (to ".binsearch")
# (find-maximanode "block")
# (find-maximanode "for")
# (find-maximanode "if")
# (find-maximanode "for" "newton (f, x)")
# (find-maximanode "find_root")
# (find-maximagitsh "find * | sort | grep mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
binsearch(f,a,b,n) :=
  block([va,vb,c,vc],
        [va,vb] : [f(a),f(b)],
        for i: 1 thru n do
          (c  : (a+b)/2,
           vc : f(c),
           if equal(va,vc) then [a,va]:[c,vc] else [b,vb]:[c,vc]),
        c);

f : lambda([x], is(x< 666));
f : lambda([x], is(x<=666));
float(binsearch(f, 0, 1024, 12));




#####
#
# doc/info/figures/
# 2022dec07
#
#####

# «doc-info-figures»  (to ".doc-info-figures")
# (find-maximagitfile "doc/info/")
# (find-maximagitfile "doc/info/docdraw.mac")
# (find-maximagitfile "doc/info/figures/")
# (find-maximagitfile "doc/info/figures/README" "ADDING FIGURES TO THE MANUAL")
# (find-maximagitfile "doc/info/figures/README" "maxima -b plotting6.mac")
# (find-maximagitsh "find * | sort | grep texi")
# (find-maximagitfile "doc/info/Plotting.texi")
# (find-maximanode "Plotting")
# (find-maximagitsh "find * | grep 'mac$'")
# (find-maximagitsh "find * | grep 'mac$' | grep doc/info")





#####
#
# columnvector
# 2022dec09
#
#####

# «columnvector»  (to ".columnvector")
# (find-maximanode "covect")
# (find-maximanode "columnvector")
# (find-maximagitfile "share/matrix/eigen.mac" "columnvector(x):=")
# (find-angg "MAXIMA/crossproduct1.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
A : matrix([a,b],[c,d]);
v : matrix([2], [3]);
load ("eigen");
v : columnvector([2, 3]);
v : covect      ([2, 3]);
colv([entries]) := covect(entries);
colv(2, 3);
                                  map("[", [2,3]);
                   apply('matrix, map("[", [2,3]));
colv([entries]) := apply('matrix, map("[", entries));
colv(2, 3);
A . v;

B : matrix([x,y],[z,w]);
A . B;
A . v;

A . colv(10, 20);


w : covect([2, 3]);
A . w;
transpose(v) . w;
dotproduct(v, w);

op(v);
args(v);
op([2,3]);

"["(2, 3);
list(2, 3);
array(2, 3);
? apply
apply("[", 2, 3);
apply("+", [2, 3]);

dotproduct([2,3], [x,y]);
matrix(2, 3);

colv([entries]) := covect(entries);
colv(2, 3, 4);



#####
#
# mycolumnvector and myrowvector
# 2023aug20
#
#####

# «mycolumnvector»  (to ".mycolumnvector")
# «myrowvector»     (to ".myrowvector")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* column vectors: */
V([entries]) := transpose(matrix(entries))$
getx(v)      := v[1][1]$
gety(v)      := v[2][1]$
getxy(v)     := [getx(v),gety(v)]$

   V(2,3);
10*V(2,3) + V(4,5);
getx(V(2, 3));
gety(V(2, 3));

/* row vectors: */
V([entries]) := matrix(entries);
getx(v)      := v[1][1]$
gety(v)      := v[1][2]$
getxy(v)     := [getx(v),gety(v)]$

   V(2,3);
10*V(2,3) + V(4,5);
getx(V(2, 3));
gety(V(2, 3));

P    : V(cos(t), sin(t));
Pt   : diff(P, t);
Ptt  : diff(P, t, 2);
P01  : [P, Pt];
P012 : [P, Pt, Ptt];
P012(t1) := subst(['t=t1], P012);
P012(0);
P012(%pi/8);




#####
#
# basis
# 2023oct07
#
#####

# «basis»  (to ".basis")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
columnvector(x):=transpose(matrix(x))$
basisvector(size,pos) := columnvector(makelist(if is(i=pos) then 1 else 0, i, size));
basisvector(size,pos) := columnvector(makelist(if is(i=pos) then 1 else 0, i, 1,size));
basisvector(5, 2); 




#####
#
# crossproduct
# 2023jul06
#
#####

# «crossproduct»  (to ".crossproduct")
# (find-angg "MAXIMA/crossproduct1.mac")
# (to "2023-1-C4-P2")
# (find-maximanode "determinant")
# (find-maximanode "matrix")
# (find-maximanode "matrixmap")
# (find-maximanode "map")
# (find-maximanode "fullmap")
# (find-maximanode "fullmapl")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
columnvector(x) := transpose(matrix(x));
ii : columnvector([1,0,0]);
jj : columnvector([0,1,0]);
kk : columnvector([0,0,1]);
getx(v) := v[1][1];
gety(v) := v[2][1];
getz(v) := v[3][1];
vtolist(v) := [getx(v), gety(v), getz(v)];
precrossproduct(v, w) := matrix([ii, jj, kk], vtolist(v), vtolist(w));
crossproduct   (v, w) := determinant(precrossproduct(v, w));
div(F) := getx(diff(F, x)) + gety(diff(F, y)) + getz(diff(F, z));

vtolist(ii);
abc : columnvector([a, b, c]);
def : columnvector([d, e, f]);
precrossproduct(abc, def);
   crossproduct(abc, def);



#####
#
# coeff
# 2022dec09
#
#####

# «coeff»  (to ".coeff")
# (find-maximanode "dotproduct")
# (find-maximanode "matrix")
# (find-maximanode ":=")
# (find-maximanode ":=" "variable number of")




#####
#
# ratcoef
# 2022dec09
#
#####

# «ratcoef»  (to ".ratcoef")
# «polytoabcdef»  (to ".polytoabcdef")
# (find-maximanode "coeff")
# (find-maximanode "ratcoef")
# (find-maximanode "lambda")
# (find-maximanode "local")
# (find-angg "MAXIMA/laurent1.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
abcdeftopoly :
  lambda([abcdef],
         local(a,b,c,d,e,f,poly),
         [a,b,c,d,e,f] : abcdef,
         poly : a
              + b*x + c*y
              + d*x^2 + e*x*y + f*y^2,
         poly);

polytoabcdef :
  lambda([poly],
         local(polycoef,a,b,c,d,e,f),
         polycoef(px,py) := ratcoef(ratcoef(poly, 'x, px), 'y, py),
         a : polycoef(0,0),
         b : polycoef(1,0),
         c : polycoef(0,1),
         d : polycoef(2,0),
         e : polycoef(1,1),
         f : polycoef(0,2),
         [a,b,c,d,e,f]);

p : abcdeftopoly([2,3,4,5,6,7]);
polytoabcdef(p);




#####
#
# Sistemas de coordenadas: (x,y) <-> (u,v)
# 2022dec11
#
#####

# «sistemas-de-coordenadas»  (to ".sistemas-de-coordenadas")
# (mpgp 18 "sistemas-de-coordenadas")
# (mpga    "sistemas-de-coordenadas")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
uu : [2,0];
vv : [-1,1];
x(u, v) := u*uu[1] + v*vv[1];
y(u, v) := u*uu[2] + v*vv[2];
eq_x : x = x(u,v);
eq_y : y = y(u,v);
[eq_u,eq_v] : linsolve([eq_x, eq_y], [x,y]);
define(u(x,y), rhs(eq_u));
define(v(x,y), rhs(eq_v));
x(2,0);



#####
#
# coord-systems-2: (x,y) <-> (u,v)
# 2023oct05
#
#####

# «coord-systems-2»  (to ".coord-systems-2")
# (find-angg "MAXIMA/crossproduct1.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
columnvector(x) := transpose(matrix(x));
vtolist(v)      := transpose(v)[1];

M : matrix([a, b], [c, d]);
A  : columnvector([e, f]);

                   A + M . columnvector([x, y]);
[uu, vv] : vtolist(A + M . columnvector([x, y]));

               [u=uu, v=vv];
eqs : linsolve([u=uu, v=vv], [x,y]);
           subst(eqs, [x,y]);
[xx, yy] : subst(eqs, [x,y]);

define(u(x,y), uu);
define(v(x,y), vv);
define(x(u,v), xx);
define(y(u,v), yy);

AA : [u(0,0),v(0,0)];
[u(1,0), v(1,0)];
[u(1,0), v(1,0)] - AA;
[u(0,1), v(0,1)] - AA;



#####
#
# coord-systems-3
# 2023oct07
#
#####

# «coord-systems-3»  (to ".coord-systems-3")
# «coefmatrix»       (to ".coefmatrix")
# «augcoefmatrix»    (to ".augcoefmatrix")
# (find-maximanode      "coefmatrix")
# (find-maxima-links    "coefmatrix")
# (find-maximanode   "augcoefmatrix")
# (find-maxima-links "augcoefmatrix")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
columnvector(x) := transpose(matrix(x));
vtolist(v)      := transpose(v)[1];
Mtolist(M)      := args(M);
lastrow(M)      := M[length(M)];
lastcolumn(M)   := transpose(lastrow(transpose(M)));
M  : matrix([a, b], [c, d]);
A  : columnvector([e, f]);
xy : columnvector([x, y]);
uv : columnvector([u, v]);
    M.xy;
A + M.xy;
A + M.xy = uv;
eqs : maplist("=", vtolist(M.xy), vtolist(uv));
              coefmatrix(eqs, [x, y]);
           augcoefmatrix(eqs, [x, y]);
lastcolumn(augcoefmatrix(eqs, [x, y]));

eqs2 : A+M.xy=uv;
map('vtolist, eqs2);  /* bad */
map("=", lhs(eqs2), rhs(eqs2));
map("=", vtolist(lhs(eqs2)), vtolist(rhs(eqs2)));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
? augcoefmatrix
? coefmatrix
m: [2*x - (a - 1)*y = 5*b, c + b*y + a*x = 0];
augcoefmatrix (m, [x, y]);
m: [2*x-(a-1)*y+5*b = 0, b*y+a*x = 3];
coefmatrix(m, [x,y]);




#####
#
# Superseded by LI_Axb, below
# 2023dec08
#
#####

# «LI_split»  (to ".LI_split")
# (find-angg "MAXIMA/LI_split1.mac")
# (to "linsolve_ify")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
LI_delta(i,j)       := if is(ii=k) then 1 else 0;
LI_s(vs, k)         := makelist(vs[ii]=LI_delta(ii,k), ii,1,length(vs));
LI_subst(ex, vs, k) := subst(LI_s(vs, k), ex);
LI_split(ex, vs)    := makelist(LI_subst(ex, vs, k), k,1,length(vs));

LI_split(A*s+B*c=C*s, [s,c]);




#####
#
# linsolve_ify
# 2024apr22
#
#####

# «linsolve_ify»  (to ".linsolve_ify")
# (to "basis")
# (to "LI_split")
# (find-angg "MAXIMA/LI_Axb1.mac")

# (find-strang4page (+ 10 1) "1.1 Introduction")
# (find-strang4page (+ 10 2) "Ax = b")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
mycolumnvector([entries])   := transpose(matrix(entries))$
LI_2to1              (eqs2) := makelist(lhs(eqs2[ii])-rhs(eqs2[ii]), ii,1,length(eqs2))$
LI_delta              (i,j) := if is(i=j) then 1 else 0$
LI_makesubsts    (vars,pos) := makelist(vars[ii]=LI_delta(ii,pos),   ii,1,length(vars))$
LI_b0       (eqs1,vars)     := -subst(LI_makesubsts(vars,0), eqs1)$
LI_b        (eqs1,vars)     := apply('mycolumnvector, LI_b0(eqs1,vars));
LI_eqs1b    (eqs1,vars)     := eqs1 + LI_b0(eqs1,vars);
LI_A00      (eqs1,vars,pos) := subst(LI_makesubsts(vars,pos), LI_eqs1b(eqs1,vars))$
LI_A0       (eqs1,vars)     := makelist(LI_A00(eqs1,vars,ii),        ii,1,length(vars))$
LI_A        (eqs1,vars)     := apply('matrix, LI_A0(eqs1, vars));
LI_x             (vars)     := apply('mycolumnvector, vars);
LI_Axb      (eqs1,vars)     := [LI_A(eqs1,vars), LI_x(vars), LI_b(eqs1,vars)];

myvars  : [x,y];
myeqs2  : [1*x + 2*y = 3, 4*x + 5*y = 6];
myeqs1  :   LI_2to1(myeqs2);
mycolumnvector(2,3,4);
LI_makesubsts          (myvars, 2);
LI_makesubsts          (myvars, 1);
LI_makesubsts          (myvars, 0);
LI_b0          (myeqs1, myvars);
LI_b           (myeqs1, myvars);
LI_eqs1b       (myeqs1, myvars);
LI_A00         (myeqs1, myvars, 1);
LI_A00         (myeqs1, myvars, 2);
LI_A0          (myeqs1, myvars);
LI_A           (myeqs1, myvars);
LI_x                   (myvars);
LI_Axb         (myeqs1, myvars);




#####
#
# Treat some variables as linearly independent vectors, and split (something)
# 2024apr22
#
#####

# «LI_Axb»  (to ".LI_Axb")
# (to "linsolve_ify")
# (find-angg "MAXIMA/LI_Axb1.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("~/MAXIMA/LI_Axb1.mac");





#####
#
# format.mac
# 2023jan19
#
#####

# «format.mac»  (to ".format.mac")
# (find-maximamsg "37765019 202301 18" "RDodier: Bruce Miller")
# (find-maximamsg "37764945 202301 18" "Stavros: pickapart")
# (find-maximamsg "37764915 202301 18" "CSangwin: format.mac")
# (find-maximamsg "37764894 202301 18" "RFateman: spreadsheet / Bruce Miller")
# https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nistir5618.pdf An Expression Formatter for MACSYMA
# https://sourceforge.net/p/maxima/code/ci/master/tree/share/contrib/format/
# (find-maximagitfile "share/contrib/format/")
# (find-maximagitsh "find * | sort | grep format")
# (find-sh "locate format.mac")





#####
#
# How to solve a differential equation defined by differentials?
# 2023feb02
#
#####

# «ODEs-by-differentials»  (to ".ODEs-by-differentials")
# (find-maximamsg "37772984 202302 02" "TFinke: ODEs defined by differentials?")
# (find-maximamsg "37773011 202302 02" "MTalon: answer")
MMenzel:
https://www.acadpubl.eu/jsi/2017-117-11-14/articles/14/18.pdf

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
declare([cp, cv], constant);      /* heat capacity         */
u : cv * T;                       /* spec. internal energy */
h : cp * T;                       /* spec. enthalpy        */
U : m * u;                        /* internal energy       */
E : diff(U) = -h * diff(m);       /* energy conservation   */

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
declare(cp,constant);
declare(cv,constant);
ode2(cv*m*'diff(T,m)+(cp+cv)*T=0,T,m);




#####
#
# semicirculo
# 2023feb05
#
#####

# «semicirculo»  (to ".semicirculo")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f : sqrt(1-x^2);
define(F(x), integrate(f, x));
F(1) - F(0);
F(1) - F(sqrt(2)/2);



#####
#
# gruntz-and-tlimit
# 2023mar02
#
#####

# «gruntz-and-tlimit»  (to ".gruntz-and-tlimit")
# (find-maximamsg "37785498 202303 02" "RFateman: gruntz / tlimit")
# (find-maximanode "gruntz")





#####
#
# 2023-1-C4-P1
# 2023jun11
#
#####

# «2023-1-C4-P1»  (to ".2023-1-C4-P1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
F   : x^3 * y;
G   : subst([x=r*cos(th), y=r*sin(th)], F);
GG  : integrate(G*r, th, 0, %pi/2);
GGG : integrate(GG,  r,  1, 2);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
vprod(v, w) := v[1]*w[1] + v[2]*w[2];
vprod([1,2], [10, 200]);

F : [x^2*y^2, x];
xt : 2;
yt : t;
xt_t : diff(xt, t);
yy_t : diff(yt, t);
vp : vprod(F, [xt_t, yt_t]);




#####
#
# 2023-1-C4-P2
# 2023jul06
#
#####

# «2023-1-C4-P2»  (to ".2023-1-C4-P2")
# (to "crossproduct")
# (c4m231p2p 2 "questao-1")
# (c4m231p2a   "questao-1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
columnvector(x) := transpose(matrix(x));
vtolist(v)      := transpose(v)[1];
ii : columnvector([1,0,0]);
jj : columnvector([0,1,0]);
kk : columnvector([0,0,1]);
precrossproduct(v, w) := matrix([ii, jj, kk], vtolist(v), vtolist(w));
crossproduct   (v, w) := determinant(precrossproduct(v, w));
prenorm(v) :=      v.v;
norm   (v) := sqrt(v.v);
getx(v) := v[1][1];
gety(v) := v[2][1];
getz(v) := v[3][1];
div(F)  := getx(diff(F, x)) + gety(diff(F, y)) + getz(diff(F, z));

/* Spherical coordinates, as a substitution */
ssph : [x = ρ*sin(ϕ)*cos(θ),
        y = ρ*sin(ϕ)*sin(θ),
        z = ρ*cos(ϕ)];

/* Item a: calcula o divergente */
FF : (x^3+y^3)*ii + (y^3+z^3)*jj + (z^3+x^3)*kk;
F0 : div(FF);

 /* Pra um teste que calcula o volume da esfera:
F0 : 1;
 */

/* Item c: calcula a integral tripla do F0 */
G0 : subst(ssph, F0) * ρ^2 * sin(ϕ);
G1 : integrate(G0, ρ, 0, 2);
G2 : integrate(G1, ϕ, 0,   %pi);
G3 : integrate(G2, θ, 0, 2*%pi);

/* Item b: calcula a integral de superficie */
suv   : [ρ = 2,
         ϕ = u,
         θ = v];
subst(suv, ssph);
                  subst(ssph, columnvector([x, y, z]));
rr   : subst(suv, subst(ssph, columnvector([x, y, z])));
rr_u : diff(rr, u);
rr_v : diff(rr, v);

nn0  : crossproduct(rr_u, rr_v);
nnn  : norm   (nn0);
nn   : nn0 / nnn;

mysimp(a) := ratsimp(expand(demoivre(expand(exponentialize(expand(a))))));
nn   : mysimp(nn);

nn2  : prenorm(nn0);
nn2  : expand(nn2);
nn2  : exponentialize(nn2);
nn2  : expand(nn2);
nn2  : demoivre(nn2);
nn2  : expand(nn2);

plot3d ( nnn, [u, 0, 1], [v, 0, 1])$





#####
#
# inversas
# 2023jun16
#
#####

# «inversas»  (to ".inversas")
# (to "assume")
# (to "separable")
# (c2m211edovsp 15 "funcoes-inversas")
# (c2m211edovsa    "funcoes-inversas")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
eq1 : y = 2 + 3 * sqrt(5*x+6);
assume(y > 2);
         solve(eq1, x);
  sol1 : solve(eq1, x)[1];
forget(y > 2);
assume(y < 2);
         solve(eq1, x);
  eq2  : solve(eq1, x)[1];
  eq3  : lhs(eq2)^2 = rhs(eq2)^2;
         solve(eq3, x);
  sol2 : solve(eq3, x)[1];
forget(y < 2);
facts();
sol1;
sol2;

       subst(sol1, eq1);
       subst(sol2, eq1);
s2   : rhs(subst(sol2, eq));
expand(s2);
plot2d (s2, [y, -4, 4]);



#####
#
# maxima-by-example
# 2023jul09
#
#####

# «maxima-by-example»  (to ".maxima-by-example")
# (setq eepitch-preprocess-regexp "^(%i[0-9]+) ?")
# (find-mbefile "mbe6calc1.tex")
# (find-mbefile "qdraw.mac")
# (find-mbefile "" "qdraw.mac")
# (find-sh "cp -v $S/https/home.csulb.edu/~woollett/qdraw.mac /tmp/")
# (find-mbe13page)
# (find-mbe13text)
# (find-mbe-links)
# (find-mbe-links 13 6 "cos(x)")
# (find-mbe13page    6 "cos(x)")
# (find-mbe13text    6 "cos(x)")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
file_search_maxima: append (file_search_maxima, ["/tmp/###.mac"])$
load(qdraw);
qdraw ( ex (cos(x), x, 0, 6));
qdraw ( ex1 (cos(x), x, 0, 6, lc(red)))$

qdraw ( ex1 (cos(x), x, 0, 6, lc(red)),
     more (xlabel = "X", ylabel = "COS(X)", title = "single function"))$
qdraw ( ex1 (cos(x), x, 0, 6, lc(red)),
    line ( 0,0,6,0, lc(brown), lw(1)),
    more (xlabel = "X", ylabel = "COS(X)", title = "single function"))$
qdraw ( ex1 (cos(x), x, 0, 6, lc(red)), yr (-1.2, 1.2),
   line ( 0,0,6,0, lc(brown), lw(1)),
   more (xlabel = "X", ylabel = "COS(X)", title = "single function"))$
qdraw ( ex ( [x,x^2,x^3],x,-3,3),
      line ( -3,0,3,0, lc(brown), lw(1)),
      more (xlabel = "X", title = "Using ex(..) for three functions"))$
qdraw ( ex ( [x,x^2,x^3],x,-3,3), yr (-2, 2),
 line ( -3,0,3,0, lc(brown), lw(1)), key (bottom),
  more (xlabel = "X", title = "Using ex(..) for three functions"))$
qdraw ( ex ( [x,x^2,x^3],x,-3,3), yr (-2, 2),
        line ( -3,0,3,0, lc(brown), lw(1)), key (bottom),
        pts ( [ [-1,-1], [0,0],[1,1] ] ),
        more (xlabel = "X", title = "Using ex(..) for three functions"))$
qdraw ( ex ( [x,x^2,x^3],x,-3,3), yr (-2, 2),
 line ( -3,0,3,0, lc(brown), lw(1)), key (bottom),
 pts ( [ [-1,-1], [0,0],[1,1] ], ps(2), pc(magenta)),
 more (xlabel = "X", title = "Using ex(..) for three functions"))$
qdraw ( ex ( [x,x^2,x^3],x,-3,3), yr (-2, 2),
  line ( -3,0,3,0, lc(brown), lw(1)), key (bottom),
  pts ( [ [-1,-1], [0,0],[1,1] ], ps(2), pc(magenta), pk("intersections")),
  more (xlabel = "X", title = "Using ex(..) for three functions"))$
default_colors(15)$
(L1:[[-1,-1],[-1,0],[-1,1]], L2:[[1,-1],[1,0],[1,1]],
       qdraw ( pts(L1), pts(L2), xr(-2,2),yr(-2,2)))$






#####
#
# Maxima by Example: download the chapters with a recursive wget
# 2023jul17
#
#####

# «maxima-by-example-dl»  (to ".maxima-by-example-dl")
# https://home.csulb.edu/~woollett/
# https://home.csulb.edu/~woollett/mbe.html
# https://home.csulb.edu/~woollett/mbe5matrix.pdf
#
# (find-wgetrecursive-links "https://home.csulb.edu/~woollett/")
# (find-sh-at-dir "/tmp/wget-recursive/" "find * | sort")
# (find-sh-at-dir "/tmp/wget-recursive/" "find * | sort | grep pdf")

# (find-angg "LUA/QPDFMerge.lua")




#####
#
# Maxima by Example: the "code-c-d"s pointing to individual chapters
# 2023jul17
#
#####

# «maxima-by-example-ccds»  (to ".maxima-by-example-ccds")
# (find-angg ".emacs.papers"     "maxima-by-example")
# (find-books "__comp/__comp.el" "maxima-by-example")




#####
#
# Maxima by Example: how to use it from eev
# 2023jul18
#
#####

# «maxima-by-example-eev»  (to ".maxima-by-example-eev")
# (find-es "mbe")



#####
#
# qdraw
# 2023jul09
#
#####

# «qdraw»  (to ".qdraw")
# «qdraw-pts»  (to ".qdraw-pts")
# (find-es "qdraw" "ex")
# (find-es "qdraw" "para")
# (find-es "qdraw" "line")
# (find-es "qdraw" "more")
# (find-angg ".maxima/maxima-init.mac" "load_qdraw")
# (find-mbefile "" "mbe13qdraw.pdf")
# (find-mbe13page)
# (find-mbe13text)
# (find-mbefile "" "qdraw.mac")
# (find-mbefile "qdraw.mac")
# (find-mbefile "qdrawcode.txt")
# (find-mbe-links 13  1 "")
# (find-mbe-links 13  8 "")
# (find-mbe-links 13 39 "11.1       line(...)")
# (find-mbe-links 13 18 "4    Parametric plots with para(...)")
# (find-mbe13page    18 "4    Parametric plots with para(...)")
# (find-mbe13text    18 "4    Parametric plots with para(...)")
# (find-mbe13page    47 "11.5     vector(...)")
# (find-mbe13text    47 "11.5     vector(...)")
# (find-mbe13page    56 "13 Even More with more(...)")
# (find-mbe13text    56 "13 Even More with more(...)")
# (find-mbe13page     9 "pts ( [ [-1,-1], [0,0],[1,1] ], ps(2), pc(magenta))")
# (find-mbe13text     9 "pts ( [ [-1,-1], [0,0],[1,1] ], ps(2), pc(magenta))")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
qdraw(
  ex ( [x,x^2,x^3],x,-3,3),
  line ( -3,0,3,0, lc(brown), lw(1)),
  more (xlabel = "X", title = "Using ex(..) for three functions")
  )$

qdraw(xr(-1.5,2),yr(-2,2),
   para(sin(t),sin(2*t),t,0,2*%pi ),
   pts( [ [0,0] ],ps(1),pc(brown),pk("t = 0")),
   pts( [ [sin(%pi/8),sin(%pi/4)] ],ps(1),pc(red),pk("t = pi/8")),
   pts( [ [1,0] ],ps(1),pc(green),pk("t = pi/2")),
   more (title = "parametric plot", xlabel = "sin(t)", ylabel = "sin(2*t)"))$




#####
#
# qdraw-to-pdf
# 2024jul20
#
#####

# «qdraw-to-pdf»  (to ".qdraw-to-pdf")
# «terminal-pdf»  (to ".terminal-pdf")
# (to "terminal-tikz")
# (find-maximanode "Plotting Options" "Plot option: pdf_file")
# (find-maximanode "Gnuplot Options" "gnuplot_term [gnuplot_term, <terminal_name>]")
# (find-angg ".maxima/maxima-init.mac" "load_qdraw")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/zpts1.mac")
load       ("~/MAXIMA/zpts1.mac")$

myqdraw(
  xr(0,2*%pi), yr(-2,2), more(proportional_axes=xy),
  ex([sin(x), cos(x)], x,0,2*%pi)
  );
myqdraw0(
  more(terminal=pdf, file_name="/tmp/test"),
  more(terminal=pdf, file_name="/tmp/test"),
  myqdraw_body
  );

myqdraw0(
  more(terminal=pdf),
  more(file_name="/tmp/test"),
  myqdraw_body
  );

** (find-fline "/tmp/" "test.pdf")
** (find-pdf-page "/tmp/test.pdf")






#####
#
# Draw boxes on the 5 "simplest" points of a parabola using qdraw
# 2023sep25
#
#####

# «qdraw-poly»      (to ".qdraw-poly")
# «parabola-boxes»  (to ".parabola-boxes")
# (find-mbe-links 13  5 "poly(")
# (find-mbe13page     5 "poly(")
# (find-mbe13text     5 "poly(")
# (find-TH "eev-maxima" "maxima-by-example")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
myqdraw([lists]) := apply('qdraw, apply('append, lists));
P   : [cos(t), sin(t)];
Pt  : diff(P, t);
Ptt : diff(P, t, 2);
define(P(t),   P);
define(Pt(t),  Pt);
define(Ptt(t), Ptt);

t0 : %pi/4;
t0 : 0;

[A,uu,vv] : [P(t0), Pt(t0), Ptt(t0)];
B(u,v)    := A + u*uu + v*vv/2;
B(0,0);
Q         : P(t0) + t*Pt(t0) + t^2*Ptt(t0)/2;
define(Q(t), Q);

qdraw(
  xr(-4.5,4.5), yr(-4,4),
  poly([B(0,0), B( 1,0), B( 1,1), B(0,1)], lc(brown)),
  poly([B(0,0), B(-1,0), B(-1,1), B(0,1)], lc(brown)),
  poly([B(0,0), B( 2,0), B( 2,4), B(0,4)], lc(brown)),
  poly([B(0,0), B(-2,0), B(-2,4), B(0,4)], lc(brown)),
  para(P[1],P[2], t, 0,2*%pi, lc(red)),
  para(Q[1],Q[2], t, -2,2,    lc(orange))
)$

[Q(0),  Q(1) , Q(2)];
[Q(0), Q(-1), Q(-2)];



#####
#
# parabolas-2024.1
# 2024mar27
#
#####

# «parabolas-2024.1»  (to ".parabolas-2024.1")
# «myqdraw-flatten»  (to ".myqdraw-flatten")
# (find-angg ".maxima/maxima-init.mac" "load_qdraw")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
myqdraw0([lists]) := apply('qdraw, flatten([lists]));
myqdraw ([lists]) := block([], myqdraw_body : lists, apply('myqdraw0, lists));
mypoly([pts])     := poly(pts, lc(orange));
myvec(xy, dxdy)   := vector(xy, dxdy, hl(0.1), lw(5), lc(purple));

defs1() := block([],
  define(Pt(t),  diff(P(t),t)),
  define(Ptt(t), diff(P(t),t,2)),
  [A,uu,vv] : [P(0), Pt(0), Ptt(0)],
  B(u,v)    := A + u*uu + v*vv/2,
  PP(t)     := A + t*uu + t^2/2 * vv
  )$

parabola_rects() := [
  mypoly(B(0,0), B( 1,0), B( 1,1), B(0,1)),
  mypoly(B(0,0), B(-1,0), B(-1,1), B(0,1)),
  mypoly(B(0,0), B( 2,0), B( 2,4), B(0,4)),
  mypoly(B(0,0), B(-2,0), B(-2,4), B(0,4))
  ]$
parabola_vecs() := [
  myvec(P(0), Pt(0)),
  myvec(P(1), Pt(1)),
  myvec(P(-1), Pt(-1)),
  myvec(P(-2), Pt(-2))
  ]$

P(t) := [3,1] + t*[1,0] + t^2*[0,1];
defs1();
P(t);
PP(t);

P(t) := [cos(t), sin(t)];
defs1();
P(t);
PP(t);

P(t) := [2,6] + t*[1,1] + t^2*[2,-1];
defs1();
myqdraw(
  xr(0,12), yr(0,8), more(proportional_axes=xy),
  parabola_rects(),
  parabola_vecs(),
  para(P(t)[1],P(t)[2], t, -2,2, lc(red))
  )$

myqdraw0(
  more(terminal=pdf, file_name="/tmp/parabola"),
  myqdraw_body
  )$

** (find-maximanode "flatten")
** (find-pdf-page "/tmp/parabola.pdf")
** (find-pdf-text "/tmp/parabola.pdf")








#####
#
# qdraw-taylor
# 2023oct03
#
#####

# «qdraw-taylor»  (to ".qdraw-taylor")
# (to "2023-2-raio-conv")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
DDef1(fxy) := buildq([f:op(fxy),xy:args(fxy)], define(f(splice(xy)),f));
DDef([fxys]) ::= map('DDef1,fxys);
colors : [black, red, orange, forest_green, blue, dark_violet]$

f            : sin(x);
derivsf      : makelist(diff(f,x,k), k, 0,7);
derivsf0     : subst([x=0], derivsf);
derivsfk(k)  := diff(f,x,k);
derivsf0k(k) := subst([x=0], derivsfk(k));
termk(k)     := derivsf0k(k) * x^k/k!;
newf(K)      := sum(termk(k), k, 0, K);
newf(7);
f0 : newf(0);
f1 : newf(1);
f3 : newf(3);
f5 : newf(5);
f7 : newf(7);

r : 2*%pi;
r : 3*%pi;
qdraw(xr(-r,r), yr(-r,r),
      ex1(f,  x, -r,r, lc(colors[1]), lk("orig")),
      ex1(f0, x, -r,r, lc(colors[2]), lk("grau 0")),
      ex1(f1, x, -r,r, lc(colors[3]), lk("grau 1")),
      ex1(f3, x, -r,r, lc(colors[4]), lk("grau 3")),
      ex1(f5, x, -r,r, lc(colors[5]), lk("grau 5")),
      ex1(f7, x, -r,r, lc(colors[6]), lk("grau 7"))
     );

define(f7(x), f7);
sin(0.1);
f7(0.1);
sin(0.1) - f7(0.1);

define(f5(x), f5);
sin(0.1);
f5(0.1);
sin(0.1) - f5(0.1);




#####
#
# qdraw-imp
# 2023sep28
#
#####

# «qdraw-imp»  (to ".qdraw-imp")
# (find-mbe-links 13 20 "6     Implicit plots with imp(...) and imp1(...)")
# (find-mbe13page    20 "6     Implicit plots with imp(...) and imp1(...)")
# (find-mbe13text    20 "6     Implicit plots with imp(...) and imp1(...)")
# (to "matrixify")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
e : sin(2*x)*cos(y)$
qdraw(imp( e=0.4,x,-3,3,y,-3,3 ),
      cut(key),
      more(title=" sin(2 x) cos(y) = 0.4 ",
      xlabel = "x",
      ylabel = "y"))$
qdraw(imp( [e=0.4,e=0.7,e=0.9],x,-3,3,y,-3,3 ),
      cut(key),
      more(title=" sin(2 x) cos(y) = 0.4,0.7,0.9 ",
      xlabel = "x",
      ylabel = "y"))$




#####
#
# qdraw-orbita
# 2023sep26
#
#####

# «qdraw-orbita»  (to ".qdraw-orbita")
# See: (c3m232trp     9 "orbita")
#      (c3m232tra       "orbita")
#      (c3m221orbitap 3 "orbita")
#      (c3m221orbitaa   "orbita")
# Based on: (to "C3-lissajous")
# Uses:     (to "DDef")
# See:      (to "2024.2-C3-traj-9")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
myqdraw([lists]) := apply('qdraw, apply('append, lists));
seqn(a,b,n)      := makelist(a + (b-a)*k/n, k, 0, n);
DDef1(fxy)       := buildq([f:op(fxy),xy:args(fxy)], define(f(splice(xy)),f));
DDef([fxys])    ::= map('DDef1,fxys);

h                : 2*%pi / 12;

/* configs */
[adjvel,adjacc,r,ts] : [1,   1,   9, seqn(0*h, 12*h, 6)];
[adjvel,adjacc,r,ts] : [1/4, 1/4, 3, seqn(0*h, 12*h, 6)];
[adjvel,adjacc,r,ts] : [1/4, 1/10, 3, seqn(0*h, 12*h, 6)];
[adjvel,adjacc,r,ts] : [1/4, 1/4, 3, seqn(0*h, 12*h, 3)];
[adjvel,adjacc,r,ts] : [1/4, 1/4, 3, seqn(2*h, 14*h, 3)];
[adjvel,adjacc,r,ts] : [1,   1,   9, seqn(0*h, 12*h, 3)];
[adjvel,adjacc,r,ts] : [1,   1,   9, seqn(2*h, 14*h, 3)];
[adjvel,adjacc,r,ts];

P       :       [cos(t),   sin(t)];
R       : 1/2 * [cos(4*t), sin(4*t)];
S       : P + R;
St      : diff(S, t);
Stt     : diff(S, t, 2);
vel     : vector([S[1],S[2]], [St [1],St [2]]*adjvel, hl(0.1), lc(orange));
acc     : vector([S[1],S[2]], [Stt[1],Stt[2]]*adjacc, hl(0.1), lc(purple));
define(vel(t), vel);
define(acc(t), acc);
vels    : makelist(vel(t), t, ts);
accs    : makelist(acc(t), t, ts);
bbox    : [ xr(-r,r), yr(-r,r) ];
orbit   : [ para(S[1],S[2], t, 0,2*%pi, lc(red)) ];

myqdraw(bbox, orbit, vels, accs);

vel(0);
vel(%pi);
acc(0);
acc(%pi);



vels;
adjvel  : 1;
adjacc  : 1;
myqdraw(orbit, vels, accs);

acc(0);
acc(%pi);

myqdraw([ xr(-2,2),yr(-2,2),
          para(S[1], S[2], t, 0,2*%pi, lc(red))
        ]);

S(t)[1];
S(t);




#####
#
# Exercises on Lissajous figures (for Calculus 3)
# 2023oct07
#
#####

# «qdraw-lissajous»  (to ".qdraw-lissajous")
#    «C3-lissajous»  (to ".C3-lissajous")
# (c3m232trp 8 "lissajous")
# (c3m232tra   "lissajous")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
myqdraw([lists]) := apply('qdraw, apply('append, lists));
seqn(a,b,n)      := makelist(a + (b-a)*k/n, k, 0, n);

P       : [cos(t), sin(2*t)];   /* trajectory */
ts      : seqn(0, 2*%pi, 8);    /* times      */
shrink  : 4;                    /* how much to shrink the vectors */

Pt      : diff(P, t)    / shrink;
Ptt     : diff(P, t, 2) / shrink;
vel     : vector([P[1],P[2]], [Pt [1],Pt [2]], hl(0.1), lc(orange));
acc     : vector([P[1],P[2]], [Ptt[1],Ptt[2]], hl(0.1), lc(purple));
vel(t1) := subst([t=t1], vel);
acc(t1) := subst([t=t1], acc);
vels    : makelist(vel(t1), t1, ts);
accs    : makelist(acc(t1), t1, ts);

myqdraw([ xr(-2,2),yr(-2,2),
          para(P[1],P[2], t, 0,2*%pi, lc(red))
        ], vels, accs);

/* original: */
qdraw( xr(-2,2),yr(-2,2),
       para(P[1],P[2], t, 0,2*%pi, lc(red)),
       vel(0),
       acc(0) );



#####
#
# qdraw-linearize
# 2023oct03
#
#####

# «qdraw-linearize»  (to ".qdraw-linearize")
# (find-mbe-links 13 18 "4    Parametric plots with para(...)")
# (find-mbe13page    18 "4    Parametric plots with para(...)")
# (find-mbe13text    18 "4    Parametric plots with para(...)")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
myqdraw([lists]) := apply('qdraw, apply('append, lists));
colors;
colors : [red, orange, forest_green, blue, dark_violet];

F   : sqrt(1-x^2);
x0  : 0.3;
x1  : 0.8;
[xx1,xx2,xx3,xx4] : [-1.5,-1,1,1.5];

Fx  : diff(F, x);
DDef(F(x), Fx(x));
L   : F(x0) + (x-x0)*Fx(x0);
DDef(L(x));

qdraw(xr(xx1,xx4),yr(xx1,xx4),
      ex1(F, x, xx2, xx3, lc(colors[1])),
      ex1(L, x, xx1, xx4, lc(colors[2])),
   pts( [ [x0,0], [x0,F(x0)], [0,F(x0)] ],ps(1.5),pc(colors[3]),pk("(x0,f(x0))")),
   pts( [ [x1,0], [x1,F(x1)], [0,F(x1)] ],ps(1.5),pc(colors[4]),pk("(x1,f(x1))")),
   pts( [         [x1,L(x1)], [0,L(x1)] ],ps(1.5),pc(colors[5]),pk("(x1,L(x1))"))
   )$

FL(x1) := [F(x1), L(x1), F(x1)-L(x1)];
FL(4.1);
FL(4.01);
FL(4.001);



#####
#
# qdraw-proportional
# 2023nov18
#
#####

# «qdraw-proportional»  (to ".qdraw-proportional")
# (find-anggfile "MAXIMA/eigshow1.mac" "proportional_axes")
# (find-maximanode "Functions and Variables for draw" "proportional_axes")
# (find-mbe-links 13 56 "13 Even More with more(...)")
# (find-mbe13page    56 "13 Even More with more(...)")
# (find-mbe13text    56 "13 Even More with more(...)")



#####
#
# qdraw-colors
# 2023oct03
#
#####

# «qdraw-colors»  (to ".qdraw-colors")
# (find-mbe-links 13 10 "3.1 Default colors and available colors")
# (find-mbe13page    10 "3.1 Default colors and available colors")
# (find-mbe13text    10 "3.1 Default colors and available colors")

# (find-maximanode "")
# (find-maximanode "set_plot_option")
# (find-maximanode "color")
# (find-maximanode "proportional_axes")
# (find-maximanode "Functions and Variables for draw" ": color")
# (find-maximanode "Functions and Variables for draw" "#23ab0f")
# (find-maximanode "Functions and Variables for draw" "proportional_axes")

/* Missing: light_magenta, light_turquoise, dark_pink, dark_yellow */

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();

show_colors([white, black, gray0, grey0, gray10, grey10, gray20,
  grey20, gray30, grey30, gray40, grey40, gray50, grey50, gray60,
  grey60, gray70, grey70, gray80, grey80, gray90, grey90, gray100,
  grey100, gray, grey, light_gray, light_grey, dark_gray, dark_grey],
  20);

show_colors([red, light_red, dark_red, yellow, light_yellow], 12);

show_colors([green, light_green, dark_green, spring_green,
  forest_green, sea_green], 12);

show_colors([blue, light_blue, dark_blue, midnight_blue, navy,
  medium_blue, royalblue, skyblue], 12);

show_colors([cyan, light_cyan, dark_cyan, magenta, dark_magenta,
  turquoise, dark_turquoise, pink, light_pink], 12);

show_colors([coral, light_coral, orange_red, salmon, light_salmon,
  dark_salmon,
  orange, dark_orange,
  aquamarine, khaki,
  light_goldenrod,
  dark_khaki, goldenrod,
  dark_goldenrod,
  brown,  gold, beige,
  violet, dark_violet, plum, purple], 12);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
show_colors([red, orange, yellow], 3);
show_colors([red, orange, yellow], 2);




#####
#
# qdraw-ex-and-ex1
# 2023nov09
#
#####

# «qdraw-ex-and-ex1»  (to ".qdraw-ex-and-ex1")
# (find-mbe-links 13  6 "3     Quick Plots for Explicit Functions: ex(...) and ex1(...)")
# (find-mbe13page     6 "3     Quick Plots for Explicit Functions: ex(...) and ex1(...)")
# (find-mbe13text     6 "3     Quick Plots for Explicit Functions: ex(...) and ex1(...)")
# (find-mbe-links 13 10 "3.1 Default colors and available colors")
# (find-mbefile "qdraw.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
qdraw();
qdraw1();

 /*(%i3)*/ qdraw ( ex (cos(x), x, 0, 6))$
 /*(%i4)*/ qdraw ( ex (cos(x), x, 0, 6, lc(red)))$
 /*(%i5)*/ qdraw ( ex1 (cos(x), x, 0, 6, lc(red)))$
 /*(%i6)*/ qdraw ( ex1 (cos(x), x, 0, 6, lc(red)),
                   more (xlabel = "X", ylabel = "COS(X)", title = "single function"))$
 /*(%i7)*/ qdraw ( ex1 (cos(x), x, 0, 6, lc(red)),
                   line ( 0,0,6,0, lc(brown), lw(1)),
                   more (xlabel = "X", ylabel = "COS(X)", title = "single function"))$
 /*(%i8)*/ qdraw ( ex1 (cos(x), x, 0, 6, lc(red)), yr (-1.2, 1.2),
                   line ( 0,0,6,0, lc(brown), lw(1)),
                   more (xlabel = "X", ylabel = "COS(X)", title = "single function"))$
 /*(%i9)*/ qdraw ( ex ( [x,x^2,x^3],x,-3,3),
                   line ( -3,0,3,0, lc(brown), lw(1)),
                   more (xlabel = "X", title = "Using ex(..) for three functions"))$
/*(%i10)*/ qdraw ( ex ( [x,x^2,x^3],x,-3,3), yr (-2, 2),
                   line ( -3,0,3,0, lc(brown), lw(1)), key (bottom),
                   more (xlabel = "X", title = "Using ex(..) for three functions"))$
/*(%i11)*/ qdraw ( ex ( [x,x^2,x^3],x,-3,3), yr (-2, 2),
                   line ( -3,0,3,0, lc(brown), lw(1)), key (bottom),
                   pts ( [ [-1,-1], [0,0],[1,1] ] ),
                   more (xlabel = "X", title = "Using ex(..) for three functions"))$
/*(%i12)*/ qdraw ( ex ( [x,x^2,x^3],x,-3,3), yr (-2, 2),
                   line ( -3,0,3,0, lc(brown), lw(1)), key (bottom),
                   pts ( [ [-1,-1], [0,0],[1,1] ], ps(2), pc(magenta)),
                   more (xlabel = "X", title = "Using ex(..) for three functions"))$
/*(%i13)*/ qdraw ( ex ( [x,x^2,x^3],x,-3,3), yr (-2, 2),
                   line ( -3,0,3,0, lc(brown), lw(1)), key (bottom),
                   pts ( [ [-1,-1], [0,0],[1,1] ], ps(2), pc(magenta), pk("intersections")),
                   more (xlabel = "X", title = "Using ex(..) for three functions"))$
/*(%i14)*/ default_colors(15)$
/*(%i15)*/ (L1:[[-1,-1],[-1,0],[-1,1]], L2:[[1,-1],[1,0],[1,1]],
           qdraw ( pts(L1), pts(L2), xr(-2,2),yr(-2,2)))$
/*(%i16)*/ mycL : [aquamarine,beige,blue,brown,cyan,gold,goldenrod,green,khaki,
            magenta,orange,pink,plum,purple,red,salmon,skyblue,turquoise,
            violet,yellow ]$
/*(%i17)*/ show_colors(mycL,10)$
/*(%i18)*/ qdraw( ex1(bessel_j(0,x),x,0,20,lc(red),lw(6),lk("bessel_j ( 0, x)") ),
          ex1(bessel_j(1,x),x,0,20,lc(blue),lw(5),lk("bessel_j ( 1, x)")),
          ex1(bessel_j(2,x),x,0,20,lc(brown),lw(4),lk("bessel_j ( 2, x)") ),
          ex1(bessel_j(3,x),x,0,20,lc(green),lw(3),lk("bessel_j ( 3, x)") ) )$
/*(%i19)*/ qdraw(line(0,0,50,0,lc(red),lw(2) ),
               ex1(bessel_j(0, sqrt(x)),x,0,50 ,lc(blue),
                lw(7),lk("J0( sqrt(x) )") ) )$




#####
#
# qdraw-3Daxes
# 2023oct14
#
#####

# «qdraw-3Daxes»  (to ".qdraw-3Daxes")
# (find-angg "MAXIMA/crossproduct1.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
M1 : matrix([ cos(aa), sin(aa),     0  ],
            [-sin(aa), cos(aa),     0  ],
            [    0,       0,        1  ]);

M2 : matrix([    1,       0,        0  ],
            [    0,    cos(bb), sin(bb)],
            [    0,   -sin(bb), cos(bb)]);
M2.M1;

columnvector(x) := transpose(matrix(x));
vtolist(v)      := transpose(v)[1];
ii : columnvector([1,0,0]);
jj : columnvector([0,1,0]);
kk : columnvector([0,0,1]);
getx   (v) := v[1][1];
gety   (v) := v[2][1];
getz   (v) := v[3][1];
getxy  (v) := [getx(v), gety(v)];

aa : 0.2;
bb : 0.5;

AA : [0,0];
BB : ev(getxy(M2.M1.ii));
CC : ev(getxy(M2.M1.jj));
DD : ev(getxy(M2.M1.kk));

** (find-myqdraw "myqdraw3.mac")
load_myqdraw();
[xmin,ymin, xmax,ymax] : [-2,-2, 2,2];
myqdraw(xyrange(),
        vector(AA,BB, hl(0.1)),
        vector(AA,CC, hl(0.1)),
        vector(AA,DD, hl(0.1)) );




#####
#
# qdraw-homogeneous
# 2023oct16
#
#####

# «qdraw-homogeneous»  (to ".qdraw-homogeneous")
# (to "radcan-homogeneous")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
myqdraw([lists]) := apply('qdraw, apply('append, lists));
colors  : [red, orange, forest_green, blue, dark_violet];
colors2 : [gray60, gray40];

f(x)       := a*x^k;
exf(a,n)   := ex1(a*x^k, x, -r, r, lc(colors [n]));
vline(x,n) := poly([[x,-r],[x,r]], lc(colors2[n]), lw(6));
qdraw_h()  := qdraw(
      xr(-r,r), yr(-r,r),
      exf(-1,    1),
      exf(-1/2,  2),
      exf( 0,    3),
      exf( 1/2,  4),
      exf( 1,    5),
      vline(b,   1),
      vline(c,   2)
     );

r          :  2;
b          : 4/4;
c          : 5/4;

k:0; qdraw_h();   /* k=0 */
k:1; qdraw_h();   /* k=1 */
k:2; qdraw_h();   /* k=2 */
k:3; qdraw_h();   /* k=3 */




#####
#
# The magical points - `m_i's - in a Riemann sum
# 2023oct21
#
#####

# «qdraw-mis»  (to ".qdraw-mis")
# (c2m232coap 7 "pontos-magicos-2")
# (c2m232coaa   "pontos-magicos-2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
y : 4 - (x-2)^2;
define(f (x), y);
define(fp(x), diff(f(x),x));
sols : solve(y-y0, x);
define(g1(y0), rhs(sols[1]));
define(g2(y0), rhs(sols[2]));
g1(3);
g2(3);
define(I(a,b),  integrate(f(x), x, a, b));
define(m(a,b),          g2(I(a,b)/(b-a)));
define(m1(a,b), ratsimp(g1(I(a,b)/(b-a))));
define(m2(a,b), ratsimp(g2(I(a,b)/(b-a))));
m(3, 4);
m(2, 3);
display2d : false;
m(a,b);
display2d : true;

[a,b] : [2,4];
define(xi(i,N), a+(b-a)*i/N);
define(ai(i,N), xi(i-1,N));
define(bi(i,N), xi(i,N));
assume(N > 0);
define(mi(i,N), ratsimp(m(ai(i,N),bi(i,N))));

load_qdraw();
myqdraw([lists]) := apply('qdraw, apply('append, lists));
colors : [red, orange, blue, dark_violet];
colors : [red, orange, forest_green, blue, dark_violet];
colors : [red, orange, yellow, blue];
myrect(y,a,b,c)  := rect(a,0, b,y, lw(0.01), fill(colors[c]));

myrect_low_ab (a,b) := myrect(f(b),     a,b,1);
myrect_mid_ab (a,b) := myrect(f(m(a,b)),a,b,2);
myrect_high_ab(a,b) := myrect(f(a),     a,b,3);
myrect_low_iN (i,N) := myrect_low_ab (ai(i,N),bi(i,N));
myrect_mid_iN (i,N) := myrect_mid_ab (ai(i,N),bi(i,N));
myrect_high_iN(i,N) := myrect_high_ab(ai(i,N),bi(i,N));
myrects_low     (N) := makelist(myrect_low_iN (i,N), i, 1, N);
myrects_mid     (N) := makelist(myrect_mid_iN (i,N), i, 1, N);
myrects_high    (N) := makelist(myrect_high_iN(i,N), i, 1, N);

mypoint_mid_xy(x,y) := pts([[x,0],[x,y]], ps(2), pc(colors[4]));
mypoint_mid_ab(a,b) := mypoint_mid_xy(m(a,b), f(m(a,b)));
mypoint_mid_iN(i,N) := mypoint_mid_ab(ai(i,N),bi(i,N));
mypoints_mid    (N) := makelist(mypoint_mid_iN(i,N), i, 1, N);

myqdraw_mids (N) :=
  myqdraw([xr(0,4), yr(0,4)],
           myrects_high(N),
           myrects_mid(N),
           myrects_low(N),
          [ex1(f(x), x, 0,4, lc(black))],
           mypoints_mid(N),
          []);

myqdraw_mids(1);
myqdraw_mids(2);
myqdraw_mids(4);
myqdraw_mids(8);

/* 2023oct24 */
mypts(myps)         := pts(myps, ps(2), pc(colors[4]));
myline(xa,ya,xb,yb) := line(xa,ya,xb,yb, lw(2), lc(colors[4]));

myslope(x0,y0,slope,xa,xb) := block([ya,yb],local(f),
  f(x1) := y0 + (x1-x0)*slope,
  ya : apply('f,[xa]),
  yb : apply('f,[xb]),
  [mypts([[xa,ya],[x0,y0],[xb,yb]]),
   myline(xa,ya,          xb,yb)
  ]);

[a,b] : [0,3];
slop : (f(b)-f(a))/(b-a);
xs : rhs(solve(fp(x)=slop,x)[1]);
ys : f(xs);

myqdraw([xr(0,6), yr(0,6)],
        [ex1(f(x), x, 0,4, lc(black))],
        myslope(xs,ys,fp(xs),a,b),
        [myline(a,f(a), b,f(b))],
        []);

define(g(x), sqrt(1+diff(f(x),x)^2));
o     : quad_qag(g(x),     x, a, b, 1);
yg    : o[1]/(b-a);
xg    : find_root(g(x)=yg, x, 0, 2);
g(xg) * (b-a);

myqdraw([xr(0,7), yr(0,7)],
        [ex1(g(x), x, 0,4, lc(black))],
     /* [myline(a,g(a), b,g(b))], */
        [mypts([[xg,0],[xg,yg]])],
        [myline(a,yg, b,yg)],
        []);

myqdraw([xr(0,7), yr(0,7)],
        [ex1(f(x), x, 0,4, lc(black))],
        myslope(xs,ys,fp(xs),a,b),
        myslope(xg,f(xg),fp(xg),a,b),
        [myline(a,f(a), b,f(b))],
        []);




ml : m1(0,4);
mr : m2(0,4);
     ratsimp(f(ml));
     ratsimp(f(mr));
ym : ratsimp(f(ml));

myqdraw([xr(0,4), yr(0,4)],
        [myrect(ym,0,4,2)],
        [ex1(f(x), x, 0,4, lc(black))],
        [mypoint_mid_xy(ml,ym),
         mypoint_mid_xy(mr,ym)],
        []);

show_colors(colors, 12);



#####
#
# qdraw-folium
# 2023oct28
#
#####

# «qdraw-folium»  (to ".qdraw-folium")
# (to "pn1-folium")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
e1 : x^3 + y^3 = 6*x*y;
sols : solve(e1, y);
sols[1];
sols[2];
sols[3];
define(f1(x), rhs(sols[1]));
define(f2(x), rhs(sols[2]));
define(f3(x), rhs(sols[3]));
load_qdraw();
qdraw(xr(-4,4),
      yr(-4,4),
      ex([f1(x), f2(x), f3(x)],x,-4,4));

e1 - x^3;
factor(e1 - x^3);


#####
#
# qdraw-4-inverses
# 2023nov05 / 2024dec18
#
#####

# «qdraw-4-inverses»  (to ".qdraw-4-inverses")
# (c2m242edovsp 12 "4-inversas")
# (c2m242edovsa    "4-inversas")
# (c2m232edovsp 13 "4-inversas-maxima")
# (c2m232edovsa    "4-inversas-maxima")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-myqdraw "myqdraw3.mac")
load_myqdraw();
[xmin,ymin, xmax,ymax] : [-2,-2, 2,2];
colors : [gray, red, orange, forest_green, blue, dark_violet];
colors : [gray, blue, forest_green, orange, red, dark_violet];
f(x)   := (x^2-1)^2;
sols   :  solve(y=f(x), x);
define(g1(y), rhs(sols[1]));
define(g2(y), rhs(sols[3]));
define(g3(y), rhs(sols[4]));
define(g4(y), rhs(sols[2]));
myqdrawp(xyrange(),
         ex1(f(x), x, -4, 4, lc(colors[1])),
         ex1(g1(y), y, 0, 4, lc(colors[2])),
         ex1(g2(y), y, 0, 1, lc(colors[3])),
         ex1(g3(y), y, 0, 1, lc(colors[4])),
         ex1(g4(y), y, 0, 4, lc(colors[5])));
f(g1(y));
f(g2(y));
f(g3(y));
f(g4(y));
g1(f(x));
g2(f(x));
g3(f(x));
g4(f(x));
myqdrawp(xyrange(), myex1(g1(f(x)), lc(colors[2])));
myqdrawp(xyrange(), myex1(g2(f(x)), lc(colors[3])));
myqdrawp(xyrange(), myex1(g3(f(x)), lc(colors[4])));
myqdrawp(xyrange(), myex1(g4(f(x)), lc(colors[5])));




#####
#
# qdraw-eigenvectors
# 2023nov18
#
#####

# «qdraw-eigenvectors»  (to ".qdraw-eigenvectors")
# (find-angg "MAXIMA/eigshow1.mac")
# (to "eigenvalues")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
M1: matrix([1, 2],
           [2, 5]);
[vals, vecss]: eigenvectors (M1);
[[vals, multiplicities], vecss]: eigenvectors (M1);
vals;
la1 : vals[1];
la2 : vals[2];
vecss;
vecss[1];
vecss[2];
x1 : columnvector(vecss[1][1]);
x2 : columnvector(vecss[2][1]);



#####
#
# qdraw1
# 2023nov21
#
#####

# «qdraw1»  (to ".qdraw1")
# (find-mbefile "qdraw.mac" "qdraw calls qdraw1 then passes drlist")
# (find-maximanode "point_size")
# (find-maximanode "line_width")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
drlist : qdraw1(
  xr(-2,2),yr(-2,2),
  more(line_width=4),
  ex1(x,x,-3,3),
  more(line_width=8),
  ex1(x+1,x,-3,3)
  );
grind(drlist);




#####
#
# qdraw-contour
# 2023nov28
#
#####

# «qdraw-contour»  (to ".qdraw-contour")
# (to "2024.1-stewart-p856-ex10")
# (find-mbe-links 13 20 "6     Implicit plots with imp(...) and imp1(...)")
# (find-mbe13page    20 "6     Implicit plots with imp(...) and imp1(...)")
# (find-mbe13text    20 "6     Implicit plots with imp(...) and imp1(...)")
# (find-mbe-links 13 26 "6.6 Implicit Plots with Greater Control: imp1(...)")
# (find-mbe13page    26 "6.6 Implicit Plots with Greater Control: imp1(...)")
# (find-mbe13text    26 "6.6 Implicit Plots with Greater Control: imp1(...)")
# (find-mbe-links 13 27 "7    Contour Plots with contour(...)")
# (find-mbe13page    27 "7    Contour Plots with contour(...)")
# (find-mbe13text    27 "7    Contour Plots with contour(...)")



#####
#
# qdraw-bezier1
# 2024apr01
#
#####

# «qdraw-bezier1»  (to ".qdraw-bezier1")
# (find-angg "MAXIMA/bezier1.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
towt(A, B) := A + t*(B-A);
[Q0, Q1, Q2] : [towt(P0,P1), towt(P1,P2), towt(P2,P3)];
[R0, R1]     : [towt(Q0,Q1), towt(Q1,Q2)];
[S0]         : [towt(R0,R1)];
define(S0(t), ev(S0));

[P0,P1,P2,P3] : [[0,0], [0,1], [1,1], [1,0]];
[P0,P1,P2,P3] : [[0,0], [0,1], [2,1], [1,0]];
define(S0(t), ev(S0));

load_qdraw();
qdraw(xr(-2,2),yr(-2,2),
      para(S0(t)[1], S0(t)[2], t,0,1 )
     );




#####
#
# qdraw-label
# 2024jul24
#
#####

# «qdraw-label»  (to ".qdraw-label")
# (find-mbe13page 50 "The qdraw.mac function label")
# (find-mbe13text 50 "The qdraw.mac function label")
# (find-mbe13page 52 "label_align(c)")
# (find-mbe13text 52 "label_align(c)")
# (find-maximanode "label")
# (find-maximanode "label_alignment")
# (find-maximanode "Functions and Variables for draw" "Graphic object: label")
# (find-angg "MAXIMA/zpts1.mac")
# (find-angg "MAXIMA/myqdraw1.mac" "mylabels-tests")
# https://riotorto.users.sourceforge.net/Maxima/gnuplot/index.html
# https://riotorto.users.sourceforge.net/Maxima/gnuplot/label/index.html
# https://riotorto.users.sourceforge.net/Maxima/gnuplot/explicit/index.html#explicit7

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
qdraw(xr(0,5),yr(0,4), more(proportional_axes=xy),
      label(["mytext",1,1,lc(blue)]),
      label_align(c),
      label(["32",3,2,lc(red)])
     );

qdraw(xr(0,4),yr(0,2),
      line(0,0,4,0,lc(black),lw(2)),
      line(0,0,2,2,lc(blue), lw(3)),
      ellipse(0,0,1,1,0,45),
      arrowhead(0.707,0.707,135,0.15),
      label(["{/=36 {/Symbol q   \\254 } The Angle}",1,0.4]),
      cut(all))$







#####
#
# defstruct
# 2023jul13
#
#####

# «defstruct»  (to ".defstruct")
# (find-maximanode "Introduction to Structures")
# (find-maximanode "defstruct")
# (find-maximanode "build_info")
# (find-maximagitgrep "grep --color=auto -nRH --null -e struct *")
# (find-maximagitgrep "grep --color=auto -nRH --null -e defstruct *")
# (find-maximagitgrep "grep --color=auto -nRH --null -e defstruct tests/*")
# (find-maximagitfile "archive/share/trash/defstruct.lisp")
# (find-maximagitfile "tests/rtest_mset.mac")
# (find-maximagitfile "tests/rtestdefstruct.mac")
# (find-maxima-links "@")
# (find-maximagitfile "src/mlisp.lisp")

# (find-man "grep")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
structures;
build_info();
display2d : false;
build_info();
display2d : true;
op  (build_info());
args(build_info());

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
defstruct (foo (a, b, c));
structures;
new (foo);
defstruct (bar (v, w, x = 123, y = %pi));
structures;
new (bar);
kill (foo);
structures;
defstruct (foo (w, x = %e, y = 42, z));
new (foo);
new (foo (1, 2, 4, 8));
defstruct (foo (x, y, z));
u : new (foo (123, a - b, %pi));
u@z;
u@z : %e;
u;
kill (u@z);
u;
u@z;
defstruct (bar (g, h));
x : new (bar);
x@h : 42;
h : 123;
x@h;
x@h : 19;
x;
h;







#####
#
# compile_file
# 2023jul15
#
#####

# «compile_file»  (to ".compile_file")
# «translate»     (to ".translate")
# (to "translated")
# (find-maximamsg "37870260 202307 15" "RFateman: compile_file(filename)")
# (find-maximanode "compile_file")
# (find-maxima-links "compile_file")
# (find-maxima-links "translate")
# (find-maxima-links "translate-function")
# (find-maximagitfile "src/transs.lisp" "(defmspec $translate ")
# (find-maximagitfile "src/transl.lisp" "(defun translate-function ")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
foo(a,b) := 10*a + b;
fundef(foo);
properties(foo);
:lisp (describe     '$foo)
:lisp (symbol-plist '$foo)
translate(foo);
fundef(foo);
properties(foo);
:lisp (describe     '$foo)
:lisp (symbol-plist '$foo)

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
foo(a,b) := 10*a + b;
translate(foo);
:lisp (describe '$foo)





#####
#
# debugmode
# 2023jul19
#
#####

# «debugmode»  (to ".debugmode")
# (find-maximamsg "37868332 202307 10" "MTalon: debugmode(true)")
# (find-maximanode "Source Level Debugging")
# (find-maximanode "debugmode")
# (find-maximanode "get")
# (find-maximanode "put")
# (find-maximanode "properties")
# (find-angg "MAXIMA/laurent1.mac")
# (find-maxima-links "lpx")
# (find-es "lisp" "get")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("~/MAXIMA/laurent1.mac");
fundef(lpx);
properties(lpx);
:lisp (describe '$lpx)
:lisp (symbol-plist '$lpx)
:lisp (get '$lpx 'lineinfo)

:br lpx
lpx(x^4);



#####
#
# ratpow
# 2023jul19
#
#####

# «ratpow»  (to ".ratpow")
# (find-maximamsg "37872009 202307 17" "Edrx: Internal representation of")
# (find-maximamsg "37872053 202307 17" "Stavros: ratpow")
# (find-maximamsg "37872061 202307 17" "RDodier: ratdisrep")
# (find-maximamsg "37872132 202307 17" "RFateman: Fateman-Salz_Simplifier")
# (find-maximamsg "37872775 202307 19" "Edrx: Laurent polynomials")

# (find-books "__comp/__comp.el" "maxima-fatemansimp")
# (find-maximagitfile "share/contrib/ratpow.lisp")
# (find-maximagitfile "share/contrib/ratpow.lisp" "showratvars")
# (find-maximagitgrep "grep --color=auto -nRH --null -e showratvars *")
# (find-maximagitfile "")
# (find-maximanode "ratp")
# (find-maximanode "ratdisrep")
# (find-maximanode "showratvars")
# (find-maximanode "print")
# (find-maximanode "rat")
# (find-maximanode "%edispflag")
# (find-maximanode "exptdispflag")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a : taylor(exp(2*x),x,0,5);
b : ratdisrep(a);
:lisp #$b$
:lisp #$a$
load("ratpow.lisp")$
ratp_hipow(a, x);
ratp_lopow(a, x);
ratp_coeffs(a, x);
ratp_dense_coeffs(a, x);
ratp_dense_coeffs_lo(a, x);

Hi all, especially Stavros...
First: thanks for all the hints!
Second: this is a simple demo of ratpow.lisp:

  a : taylor(exp(2*x),x,0,5);
  b : ratdisrep(a);
  :lisp #$b$
  :lisp #$a$
  load("ratpow.lisp")$
  ratp_hipow(a, x);
  ratp_lopow(a, x);
  ratp_coeffs(a, x);
  ratp_dense_coeffs(a, x);
  ratp_dense_coeffs_lo(a, x);

Third: this _almost_ gives me a very nice way to implement a method
that I always teach to my students!!! Suppose that E is exp(%i*x);
this code

  f  : sin(x)^4 * cos(x)^2;
  f1 : expand(exponentialize(f));
  f2 : subst([x=1/%i, %e=E], f1);
  f3 : rat(f2, E);

converts f to a rational function of E. What do I need to use instead
of the "rat" in the last step to convert f to a _Laurent polynomial_
of E instead of a _rational function_ of E?

  Thanks in advance!
  Cheers,
    Eduardo Ochs


:lisp (describe '$ratdisrep)




Internal representation of "Taylor sums"
Hi list,

a few hours ago I tried to use my luatree thing -
http://anggtwu.net/eev-maxima.html#luatree - to understand the
low-level representation of Taylor series, and I discovered that

  1) it doesn't recognize the difference between "Taylor sums" - this
     is an informal term; the correct term is canonical rational
     expressions, a.k.a. CREs - and normal sums,

  2) op and args also don't recognize the difference,

  3) the internal representation of "Taylor sums" and "normal sums" is
     very different, and ratp distinguishes them.

We can see all that in this example:

  a : taylor(sin(x),x,0,5);
  b : x - x^3/6 + x^5/120;
  op(a);
  op(b);
  args(a);
  args(b);
  :lisp #$a$
  :lisp #$b$
  ratp(a);
  ratp(b);

it yields:

  (%i1) a : taylor(sin(x),x,0,5);
                                    3    5
                                   x    x
  (%o1)/T/                     x - -- + --- + . . .
                                   6    120
  (%i2) b : x - x^3/6 + x^5/120;
                                    5     3
                                   x     x
  (%o2)                            --- - -- + x
                                   120   6
  (%i3) op(a);
  (%o3)                                  +
  (%i4) op(b);
  (%o4)                                  +
  (%i5) args(a);
                                         3   5
                                        x   x
  (%o5)                           [x, - --, ---]
                                        6   120
  (%i6) args(b);
                                    5      3
                                   x      x
  (%o6)                           [---, - --, x]
                                   120    6
  (%i7) :lisp #$a$
  
  ((MRAT SIMP (((%SIN SIMP) $X) $X) (sin(x)490 X491)
    (($X ((5 . 1)) 0 NIL X491 . 2)) TRUNC)
   PS (X491 . 2) ((5 . 1)) ((1 . 1) 1 . 1) ((3 . 1) -1 . 6) ((5 . 1) 1 . 120))
  (%i7) :lisp #$b$
  
  ((MPLUS SIMP) $X ((MTIMES SIMP) ((RAT SIMP) -1 6) ((MEXPT SIMP) $X 3))
   ((MTIMES SIMP) ((RAT SIMP) 1 120) ((MEXPT SIMP) $X 5)))
  (%i7) ratp(a);
  (%o7)                                true
  (%i8) ratp(b);
  (%o8)                                false
  (%i9) 

In the example above a is a MRAT and b is a MPLUS. Is there a standard
way to access the components of an MRAT from Maxima? What do people
use when they need to inspect the innards of MRATs from Maxima?

Thanks in advance!
  Eduardo Ochs
  http://anggtwu.net/eev-maxima.html




  exptdispflag : false;
  f2 ;
  f4 : taylor(f2 * E^6, E, 0, 12);
  rat(f4, E);
? taylor




#####
#
# ratsubst
# 2023jul19
#
#####

# «ratsubst»  (to ".ratsubst")
# (find-maxima-links "ratsubst")
# (find-maximanode "ratsubst")
# (find-maximanode "fullratsubst")
# (find-maximanode "fullratsubstflag")
# (find-maximanode "lratsubst")
# (find-maximanode "ratsubst")
# (find-mbe-links 1 26 "1.8.6 Examples of subst, ratsubst, part, and substpart")
# (find-maximagitfile "src/nrat4.lisp" "(defmfun $ratsubst ")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
e0 : a*f(x) + b*g(y);
e1 : ratsubst(cos(z), f(z), e0);
e1 : ratsubst(cos(x), f(x), e0);
e2 : ratsubst(x^3*sin(x), g(x), e1);
e2 : ratsubst(x^3*sin(y), g(y), e1);
:lisp (describe '$ratsubst);


 -- Function: bothcoef (<expr>, <x>)

     Returns a list whose first member is the coefficient of <x> in
     <expr> (as found by 'ratcoef' if <expr> is in CRE form otherwise by
     'coeff') and whose second member is the remaining part of <expr>.
     That is, '[A, B]' where '<expr> = A*<x> + B'.

     Example:

          (%i1) islinear (expr, x) := block ([c],
                  c: bothcoef (rat (expr, x), x),
                  is (freeof (x, c) and c[1] # 0))$
          (%i2) islinear ((r^2 - (x - r)^2)/x, x);
          (%o2)                         true

 -- Function: coeff
          coeff (<expr>, <x>, <n>)
          coeff (<expr>, <x>)




#####
#
# Laurent polynomials: first notes
# 2023jul19
#
#####

# «laurent»  (to ".laurent")
# (find-angg "MAXIMA/laurent1.mac")
# (find-angg "MAXIMA/laurent2.mac")
# (find-maximamsg "37873006 202307 19" "RFateman: ratexpand(ratsubst(...))")
# (find-maximamsg "37873482 202307 20" "Edrx: laurent1.mac")
# (find-maximamsg "37873595 202307 20" "Edrx: most of the students ... very weak")
# (find-maximanode "powerdisp")
# (find-maximanode "ratexpand")
# (find-maximanode "declare_index_properties")
# (find-maximanode "makelist")
# (find-maximanode "sum")

ratexpand(f3) produces this display  (it looks better in 2-D)...
1/16+1/(64*E^6)-1/(32*E^4)-1/(64*E^2)-E^2/64-E^4/32+E^6/64.
It takes the E^0 term out front, which may not fit the pattern you are
looking for.  

or just
powerdisp:true;
ratexpand(ratsubst(E, exp(%i*x),exponentialize(f)));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f   : sin(x)^4 * cos(x)^2;
f1  : expand(exponentialize(f));
f2a : ratexpand(ratsubst(E, exp(%i*x), f1));
f2  : subst([x=1/%i, %e=E], f1);
f3  : rat(f2, E);
powerdisp:false;
exptdispflag:false;
declare_index_properties(EE, [postsuperscript]);
f4  : ratexpand(f3);
f5  : makelist(ratcoef(f4,E,k)*EE[k], k, 6, -6, -2);
f6  : apply("+", f5);

concat([10, 20, 30], [400, 500]);
matrix(append([10, 20, 30], ["."], [400, 500]));

f4 : ratexpand(ratsubst(E, exp(%i*x),exponentialize(f)));


g1 : 10*x^2 + 20*x^1 + 30*x^0 + 40*x^-1 + 50*x^-2;


g1 : 4*x^2 + 5*x^1 + 6*x^0 + 7*x^-1 + 8*x^-2;
subst([x=10], g1), float;
mycoeffs    (ex,var,a,b) := makelist(ratcoef(ex,var,k), k, a, b, -1);
dottedcoeffs(ex,var,a,b) :=
  matrix(append(mycoeffs(ex,var,a,0), ["."],
         mycoeffs(ex,var,-1,b)));
dottedcoeffs(g1,x,2,-2);


poscoeffs(ex,var,a,b) 

ratcoef(f4, E, -2);
ratcoef(f4, E, 0);
         ratcoef (<expr>, <x>, <n>)
 
makelist(k, k, -6, 6, 2);
makelist(k, k, 6, -6, -2);
makelist([ratcoef(f4,E,k),k], k, 6, -6, -2);


EE[42];

# (find-maxima-links "degree")

Hi Richard,

most of the students in my courses are very weak, and many of them are
so weak that the idea of creating auxiliary notations to visualize
what some objects "mean" is totally alien to them.

In my course on integration and basic ODEs there are several topics
that I introduce by saying: in this part of the course you will learn
how to do some calculations by hand, and this will be practically
useless to you later, because after you grow up you will always do
these calculations using a CAS... but there are some parts of the
course that are useful because of their side effects - for example,
_most_ people who spend many hours doing integrations by partial
fractions by hand learn how to visualize polynomials in ways similar
to this,

          4*10^2 + 5*10^1 + 6*10^0 + 7*10^-1 + 8*10^-2
  --->  [ 4        5        6      . 7         8       ]

and this is something that will be useful in several places later.

I always present these auxiliary notations as something that is
totally optional, but what happens is that some students understand
these notations in seconds, and they start to use them; then the other
students see that these students are now solving problems that looked
huge very quickly, and they decide to learn these notations too - and
they lose a bit of their fear of auxiliary notations.

In the pre-pandemic times I always had time to cover trigonometric
identities in the course, and I showed the students that we could
solve something like this

  integrate(sin(4*x)^2 * cos(5*x)^2, x);

either in way that is most commonly taught, i.e., by applying several
trigonometric identities, or by exponentialization and demoivrization;
and with the right auxiliary notations the exponentialization and
demoivrization can be done by hand very quickly. In that specific case
the notation like "[ 1 0 -1 . 0 1 ]" for the Laurent polynomials on E
is not very adequate because the degree is too high, but other
auxiliary notations work well.

I hope that this makes sense...
  Cheers,
    E.




#####
#
# mpg-p17
# 2023aug20
#
#####

# «mpg-p17»  (to ".mpg-p17")
# (mpgp 17 "intersecoes-de-retas")
# (mpga    "intersecoes-de-retas")
# MpgP17
# (to "myrowvector")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* (to "myrowvector")
*/
V([entries]) := matrix(entries);
getx(v)      := v[1][1]$
gety(v)      := v[1][2]$
getxy(v)     := [getx(v),gety(v)]$
tolist(v)    := makelist(v[1][i], i, length(v[1]))$

R(t) := V(3,3) + t*V(2,-1);
S(u) := V(4,1) + u*V(-1,1);
[V(1,4), R(-1), S(3)];

              R(t)-S(u);
sys1 :  getxy(R(t)-S(u));
sys1 : tolist(R(t)-S(u));
tu   : linsolve(sys1, [t,u]);
    subst(tu, [R(t), S(u)]);
P : subst(tu,  R(t));

/* a) */
R(t) := V(1,0) + t*V(0,3);
S(u) := V(0,4) + u*V(2,0);

/* b) */
R(t) := V(1,0) + t*V(3,1);
S(u) := V(0,2) + u*V(2,3);

/* c) */
R(t) := V(1+3*t, t);
S(u) := V(2*u, 2+3*u);

/* d) */
R(t) := V(0,3) + t*V(2,-1);
S(u) := V(1,0) + u*V(1,3);

[R(t), S(u)];
sys1 : tolist(R(t)-S(u));
tu   : linsolve(sys1, [t,u]);
P    : subst(tu, [R(t), S(u)]);




#####
#
# ordering
# 2023jul19
#
#####

# «ordering»  (to ".ordering")
# (find-maximamsg "37870989 202307 14" "RDodier: orderlessp")
# (find-maximamsg "37871041 202307 14" "RFateman: depends on culture and context")
# (find-maximanode "orderlessp")
# (to "unlambda")



#####
#
# maw-emails
# 2023aug25
#
#####

# «maw-emails»  (to ".maw-emails")

Hi Robert,

Thanks! I found this before your e-mail,

  https://robert-marik.github.io/wiki
  https://github.com/robert-marik
  https://github.com/robert-marik/maw-html
  https://github.com/robert-marik/maw-html/issues/1

where the last link points to a question that I sent to the author,
and that he answered... the Maxima code in not in maw-html, though. To
download it we have to go to this link that you sent,

  https://sourceforge.net/projects/mathassistant/

and click on the "Download" button. It downloads a shell script that
runs this,

hg clone http://mathassistant.hg.sourceforge.net:8000/hgroot/mathassistant/maw
hg clone http://mathassistant.hg.sourceforge.net:8000/hgroot/mathassistant/maw-html

unzips a zip file, and a does a few other (mostly) trivial things. The
code that solves integrals in several steps is in this file,

  maw/integral/matchint.mac

and I'll see if I can make it work from a Maxima REPL...

  Cheers =),
    Eduardo




#####
#
# Maw - Mathematical Assistant on Web
# 2023aug25
#
#####

# «maw»  (to ".maw")
# (find-maximamsg "37887419 202308 25" "Edrx:")
# (find-maximamsg "37887392 202308 25" "RDodier:")
# (find-maximamsg "37887193 202308 24" "Przemek:")
# (find-maximamsg "37886977 202308 24" "Edrx:")

# (find-fline "~/usrc/maw/")
# (find-fline "~/usrc/maw/maw/")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rv ~/usrc/maw/
mkdir  ~/usrc/maw/
cd     ~/usrc/maw/
cp -iv /tmp/install_maw .

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rv ~/usrc/maw/maw/
mkdir  ~/usrc/maw/maw/
cd     ~/usrc/maw/maw/
sh ../install_maw

# (find-fline "~/usrc/maw/")
# (code-c-d "maw" "~/usrc/maw/maw/maw/")
# (find-mawfile "")
# (find-mawfile "integral/")
# (find-mawfile "integral/matchint.mac")




#####
#
# mysubst
# 2023sep26
#
#####

# «mysubst»  (to ".mysubst")
# (find-angg "MAXIMA/mysubst.mac")
# (to "operator-subst")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
mysubst_f(fxye) := buildq([
    f  : op  (lhs(fxye)),
    xy : args(lhs(fxye)),
    e  :      rhs(fxye)],
  f = lambda([splice(xy)],e))$
mysubst_1(ab) := if is(equal(op(ab), ":="))
                 then mysubst_f(ab)
                 else ab$
mysubst_ify(fxyes) := map('mysubst_1, fxyes);

            '[f(x,y):=10*x+y, g(x):=10*x, a=42];
mysubst_ify('[f(x,y):=10*x+y, g(x):=10*x, a=42]);

gradef(g(x), g_x(x));
gradef(F(u), f(u));

BB : F(g(x));
CC : F(u);
aa : diff(BB, x);
dd : diff(CC, u);
AA : integrate(aa, x);
DD : integrate(dd, u);

M4(a,b,c,d) := matrix([a,"=",b], ["","=",c], ["","=",d])$
MM : M4(AA,BB,CC,DD);

substs0 : '[g(x):=2*x, g_x(x):=2];
substs0 : '[g(x):=2*x, g_x(x):=2, F(u):=sin(u), f(u):=cos(u)];
substs  : mysubst_ify(substs0);
MM2     : subst(substs, MM);
MM3     : ev(MM2, 'integrate);
MM4     : subst([u=2*x], MM3);




#####
#
# total-derivative
# 2023sep30
#
#####

# «total-derivative»  (to ".total-derivative")
# (find-angg "MAXIMA/pn1.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("~/MAXIMA/pn1.mac");

  "Use z=z(x,y) and y=y(x)"$
map('kill, [z,y]);
gradef(z(x,y), z_x(x,y), z_y(x,y));
gradef(y(x),   y_x(x));
gradefs;
pnas : [z(x,y),z_x(x,y),z_y(x,y), y(x),y_x(x)];

          pnex(z);
     diff(pnex(z),x);
pnsh(diff(pnex(z),x));

  "Use only z=z(x,y)"$
map('kill, [z,y]);
gradef(z(x,y), z_x(x,y), z_y(x,y));
gradefs;
pnas : [z(x,y),z_x(x,y),z_y(x,y)];

          pnex(z);
     diff(pnex(z),x);
pnsh(diff(pnex(z),x));



o1 : pnexpand(p2, z);
o2 : diff(o1, x);
o3 : pnshortenr(p2, o2);

o1 : pnexpand(p1, z);
o2 : diff(o1, x);
o3 : pnshortenr(p1, o2);




o1 : subst([z=z(x,y)],        z);
o2 : subst([z=z(x,y),y=y(x)], z);
o3 : diff(o1, x);
o4 : diff(o2, x);
o5 : diff(o1);
o6 : diff(o2);
subst([del(x)=dx, del(y)=dy], o5);
subst([del(x)=dx, del(y)=dy], o6);


shorten_del(delx) := buildq([delx, dx:concat('d,args(delx)[1])], delx=dx)$
shorten_f  (zxyz) := buildq([
    z  : op  (lhs(zxyz)),
    xy : args(lhs(zxyz))],
  z(splice(xy)) = z)$
shorten_1 (pexpr) := if is(op(pexpr)='del)
                     then shorten_del(pexpr)
                     else shorten_f(pexpr)$
shorten(pexprs,o) := subst(map('shorten_1,pexprs), o);

shorten_ify([y(x),del(x)]);

shorten([y(x),del(x)], (y(x1)-y(x))*del(x));

 [z(a,b,c), y(x), del(z), del(x)]);

map('shorten_1, [z(a,b,c), y(x), del(z), del(x)]);


shorten_del(del(w));

shorten_del(del(w));
op(del(w));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
is(equal(op(del(w)), 'del));
is(equal(op(f(x,y)), 'del));
if is(equal(op(del(w)), 'del)) then "yes" else "no";
if is(equal(op(f(x,y)), 'del)) then "yes" else "no";
if is(eql  (op(f(x,y)), 'del)) then "yes" else "no";
if is(      op(f(x,y))= 'del ) then "yes" else "no";
? eql
??eql
??equal

is(a=33);


Hi list,

if I run these expressions in the REPL

  is(equal(op(del(w)), 'del));
  is(equal(op(f(x,y)), 'del));
  if is(equal(op(del(w)), 'del)) then "yes" else "no";
  if is(equal(op(f(x,y)), 'del)) then "yes" else "no";

I get this:

  (%i1) is(equal(op(del(w)), 'del));
  (%o1)                                true
  (%i2) is(equal(op(f(x,y)), 'del));
  (%o2)                               unknown
  (%i3) if is(equal(op(del(w)), 'del)) then "yes" else "no";
  (%o3)                                 yes
  (%i4) if is(equal(op(f(x,y)), 'del)) then "yes" else "no";
  (%o4)                     if unknown then yes else no
  (%i5) 

The is(equal(op(o),'del)) returns "true", "false", or "unknown". How
do I replace it by something that converts the "unknown"s to "false"s?

  Thanks in advance!
    Eduardo Ochs
    http://anggtwu.net/eev-maxima.html




#####
#
# tellsimpafter
# 2023oct01
#
#####

# «tellsimpafter»  (to ".tellsimpafter")
# (find-maximamsg "39730837 202309 30" "BWillis: Avoiding trig in calculus solutions")




#####
#
# intermediate-vars
# 2023oct03
#
#####

# «intermediate-vars»  (to ".intermediate-vars")
# (find-books "__analysis/__analysis.el" "stewart" "951" "intermediate variables")
# (find-stewart7page (+ 32 951) "intermediate variables")
# (find-stewart7text (+ 32 951) "intermediate variables")
# Stew14p53
# See: (to "depends")
#
# Example 4: f=f(x,y,z,t), x=x(u,v), y=(u,v), z=z(u,v), t=t(u,v)

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
depends (f,[x,y,z,t]);
depends (  [x,y,z,t],[u,v]);
dependencies;
diff(f);
diff(f,x);
diff(f,u);
diff(f,v);

diff(f);
diff(x,u);
              diff(x);
                        diff(f);
subst([del(x)=diff(x)], diff(f));

o : diff(f);
traverse(o);
traverse(o, 1);
traverse(o, 1,1);
traverse(o, 1,1,op);
traverse(o, 1,1,args);
traverse(o, 1,2);
traverse(o, 1,2,op);
traverse(o, 1,2,args);


diff (r.s, u);
diff (r.s, t);
remove (r, dependency);
diff (r.s, t);




#####
#
# limit
# 2023oct09
#
#####

# «limit»  (to ".limit")
# (find-maximanode "limit")
# (find-maxima-links "limit")
# (to "2024.2-C2-teste-niv")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
F(k,a,b) := integrate(t^k, t, a, b);
F(2,10,100);
assume(x-1>0);
F(-2,1,x);
limit(F(-2,1,x), x, inf);
limit(1/x^4,     x, inf);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
limit((f(x0+eps)-f(x0))/eps, eps,0);
limit((f(42+eps)-f(42))/eps, eps,0);
f(x) := x^2;
limit((f(42+eps)-f(42))/eps, eps,0);
kill(f);
limit((f(42+eps)-f(42))/eps, eps,0);
gradef(f(x), f_x(x))$
limit((f(42+eps)-f(42))/eps, eps,0);
diff(f(42+eps)-f(42), eps);

example(limit);

upper : f(42+eps)-f(42);
lower : eps;
limit(upper, eps,0);

lhospitallim;
lower;




#####
#
# How do I tell limit that f is continuous?
# 2024nov18
#
#####

# «limit-f-cont»  (to ".limit-f-cont")
# (find-maximamsg "58842072 202411 16" "Edrx 1")
# (find-maximamsg "58843104 202411 18" "BWillis 2")
# (find-maximamsg "58843658 202411 20" "Edrx 3")
# (find-maximanode "denom")
# (find-maximanode "num")
# https://mail.google.com/mail/u/0/#inbox/KtbxLvhKPbKSjTZrbrpBxPsNRSdJMQgpLV

Hi list,

How do I tell "limit" that a function f is continuous, or smooth?
I was hoping that the first limit below would yield f_x(42), but it
doesn't without assumptions like continuity and differentiability...

  gradef(f(x), f_x(x))$
  limit((f(42+eps)-f(42))/eps, eps,0);
  limit((sin(42+eps)-sin(42))/eps, eps,0);

Thanks in advance!
  Eduardo Ochs
  http://anggtwu.net/eev-qdraw.html  <- (work in progress)


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f : (sin(42+eps)-sin(42))/eps;
[num(f), denom(f)];
diff(num(f), eps);
at(diff(num  (f), eps), eps=0);
at(diff(denom(f), eps), eps=0);
f_upper 

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
limit_H(frac, var, val) :=
  at(diff(num  (frac), var), var=val) /
  at(diff(denom(frac), var), var=val)$

limit_H((sin(42+eps)-sin(42))/eps, eps, 0);

gradef(f(x), f_x(x))$
limit  ((f(42+eps)-f(42))/eps, eps,0);
limit_H((f(42+eps)-f(42))/eps, eps,0);

gradef(F(x,y), F_x(x,y), F_y(x,y));
g(t) := F(x0+t*a, y0+t*b);
diff(g(t), t);

limit_H(frac, var, val) :=
  at(diff(num  (frac), var), var=val) /
  at(diff(denom(frac), var), var=val)$

limit  ((g(t)-g(0))/t, t,0);
limit_H((g(t)-g(0))/t, t,0);
limit_H((f(x)-f(5))/(x-5), x,5);





#####
#
# improper-integral
# 2023nov28
#
#####

# «improper-integral»  (to ".improper-integral")
# (find-maximanode "limit")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(x) := 1/x;
f(x) := 1/x^2;

F(x) := integrate(f(t), t, 1, x);
F(10);
F(1000);
assume(x-1>0);
assume(x>42);
limit(F(x), x, inf, minus);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
assume(N>1);
f    :  1 / 2^x;
F    :  integrate(f, x);
F(N) := integrate(f, x, 1, N);
F(N);
limit(F(N), N, inf);

f    :  1 / x;
F    :  integrate(f, x);
F(N) := integrate(f, x, 1, N);
F(N);
limit(F(N), N, inf);

limit(      sum(1/x, x, 1, N), N, inf);
limit(integrate(1/x, x, 1, N), N, inf);

            sum(1/2^k, k, 1, 10);
limit(      sum(1/2^k, k, 1,  N), N, inf);




#####
#
# at and atvalue
# 2023oct17
#
#####

# «at»       (to ".at")
# «atvalue»  (to ".atvalue")
# (find-maximanode "at")
# (find-maximanode "atvalue")
# (find-maximamsg "45940337 202310 17" "DVolinski:")
# (find-maximamsg "45940361 202310 17" "LButler:")
# (find-maximamsg "45940395 202310 17" "DVolinksi:")
# (find-maximamsg "58764589 202404 25" "RDodier: g(x) := at (diff (f(u), u), u = x);")
# (find-maxima-links "at")
# (find-maximagitfile "src/comm2.lisp" "(defmfun $at ")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
 at(F(x),x=a);
'at(F(x),x=a);

g(x) := at (diff(f(u),u), u=x)$
g(0);
f(x) := x^2 + 3*x + 7 $
g(0);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
atvalue (f(x,y), [x = 0, y = 1], a^2);
atvalue ('diff (f(x,y), x), x = 0, 1 + y);
printprops (all, atvalue);
diff (4*f(x, y)^2 - u(x, y)^2, x);
at (%, [x = 0, y = 1]);
e1:I(t)=C*diff(U(t),t)$
e2:U(t)=L*diff(I(t),t)$
at(e1,e2);
subst(e2,e1);
ev(e1,e2,diff);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "luatree/luatree.mac")
load       ("~/luatree/luatree.mac");
** (find-angg "luatree/luatree2.mac")
load       ("~/luatree/luatree2.mac");
** (find-anchor "~/lisptree/lisptree.mac")
load           ("~/lisptree/lisptree.mac");

o : ['at(F(x),x=a), lambda([], at(F(x),x=a), 'at(F(x),x=a))];
luatree(o);
luatree2(o);
luatree(a+b);
luatree(a+b);
lisptree(o);
lisptree_config(s4,  q)$  lisptree(o);
lisptree_config(s4, nq)$  lisptree(o);
lisptree_config(s0,  q)$  lisptree(o);
lisptree_config(s0, nq)$  lisptree(o);




#####
#
# gf
# 2023oct26
#
#####

# «gf»  (to ".gf")
# (find-maximanode "modulus")
# https://www.math.wustl.edu/~victor/classes/ma450/gf_manual.pdf
# (code-c-d      "gf"       "~/bigsrc/maxima/share/contrib/gf/")
# (code-pdf-page "gfmanual" "~/bigsrc/maxima/share/contrib/gf/gf_manual.pdf")
# (code-pdf-text "gfmanual" "~/bigsrc/maxima/share/contrib/gf/gf_manual.pdf")
# (find-gffile "")
# (find-gffile "gf.mac")
# (find-gfmanualpage)
# (find-gfmanualtext)
# (find-gffile "gf_manual.tex")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
F16 : gf_set_data(2, x^4+x+1);
gf_info()$

a : x^3+x;
b : x^3+x^2+1;
gf_add(a, b);
gf_mult(a, b);
gf_inv(b);
gf_div(a, b);
gf_mult(a, gf_inv(b));
gf_exp(a, 14);
gf_exp(a, 15);
makelist(gf_random(), i,1,3);
gf_primitive();
a : x^3+x$
gf_index(a);
is(a = gf_exp(x, 9));


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
modulus : 5;
m(o) := mod(o, modulus);
m(-4);
:lisp (get '$+ 'lbp)
:lisp (get '$+ 'rbp)
:lisp (get '$* 'lbp)
:lisp (get '$* 'rbp)
infix ("_+", 101, 101);
infix ("_-", 101, 101);
infix ("_*", 121, 121);
infix ("_^", 131, 131);
"_+"(a, b) := m(a+b);
"_-"(a, b) := m(a-b);
"_*"(a, b) := m(a*b);
"_^"(a, b) := m(a^b);

2 _+ 4;
2 _- 4;
2 _* 4;
4 _^ 2;

# This takes ages (to scroll):
# (find-gffile "aes.mac")

# (find-maximagitfile "share/contrib/gf/gf.mac")
# (find-maximagitfile "src/numth.lisp")



#####
#
# chaosgame
# 2023oct26
#
#####

# «chaosgame»  (to ".chaosgame")
# (find-maximanode "fractals-pkg")
# (find-maximanode "chaosgame")
# (find-maximagitfile "share/dynamics/")
# (find-maximagitfile "share/dynamics/dynamics.mac" "chaosgame")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
chaosgame([[0, 0], [1, 0], [0.5, sqrt(3)/2]], [0.1, 0.1], 1/2,
           3000, [style, dots]);



#####
#
# orbits
# 2024jul21
#
#####

# «orbits»  (to ".orbits")
# (find-maximanode "orbits")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(dynamics);
orbits(a-x^2 , 0, 50, 200, [a, 0, 2], [style, dots]);



#####
#
# staircase
# 2024jul27
#
#####

# «staircase»  (to ".staircase")
# (find-maximanode "staircase")
# (find-maximanode "evolution")
# (find-maximamsg "58800039 202407 27" "DWiley: staircase")
# (find-maximamsg "58800052 202407 27" "JVillate: evolution")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)q
staircase(2*y*(1-y),1,11,[y,0,1]);
staircase(cos(y),   1,11,[y,0,1]);
evolution(cos(y),   1,11);
evolution(2*y*(1-y),1,11);



#####
#
# radcan
# 2023oct28
#
#####

# «radcan»  (to ".radcan")
# (find-maximamsg "49227967 202310 28" "Edrx: is(somefunction((a*b)^k=a^k*b^k)) -> true")
# (find-maximamsg "49227995 202310 28" "BWillis: assume(a>0,b>0)")
# (find-maximamsg "49228000 202310 28" "RFateman: assumptions about branches")
# (find-maximamsg "49228016 202310 29" "RDodier: is(foo = bar) and is(equal(foo, bar))")
# (find-maximamsg "49385023 202310 29" "Edrx: thanks")
# (find-maximanode "ratsimp")
# (find-maximanode "ratexpand")
# (find-maximanode "radcan")

Hi list,

is there a function that simplifies, or expands, (a*b)^k to a^k*b^k?
I've tried this,

  o1 : a^k*b^k = (a*b)^k;
  o2 : a^k*b^k + a^k*c^k = a^k*(b^k+c^k);
  is(o1);             /* false */
  is(o2);             /* false */
  is(ratsimp(o1));    /* false */
  is(ratsimp(o2));    /* true */
  is(ratexpand(o1));  /* false */
  is(ratexpand(o2));  /* true */

I've also tried "is(somefunction(o1))" for all somefunctions in:

(info "(maxima)Functions and Variables for Polynomials")
https://maxima.sourceforge.io/docs/manual/maxima_80.html#Functions-and-Variables-for-Polynomials-1

and I couldn't find anything that makes is(somefunction(o1)) return
true...

  Thanks in advance - and I hope I haven't committed any typos in my
  tests...
    Eduardo Ochs
    http://anggtwu.net/eev-maxima.html


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)

  o1 : a^k*b^k = (a*b)^k;
  o2 : a^k*b^k + a^k*c^k = a^k*(b^k+c^k);
  is(o1);             /* false */
  is(o2);             /* false */
  is(ratsimp(o1));    /* false */
  is(ratsimp(o2));    /* true */
  is(ratexpand(o1));  /* false */
  is(ratexpand(o2));  /* true */
  is(radcan(o1));     /* true */
  is(radcan(o2));     /* true */
  radcan(o1);
  radcan(o2);
  is(lhs(o1) = rhs(o1))



#####
#
# radcan-homogeneous
# 2023oct28
#
#####

# «radcan-homogeneous»  (to ".radcan-homogeneous")
# (to "qdraw-homogeneous")
# (c3m232fhp 10 "maxima")
# (c3m232fha   "maxima")

** (find-Maxima2-links "contas1")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
  load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp")$
  display2d:'emaxima$
texput(x0,"x_0");
texput(y0,"y_0");
  linenum:0;
/* f:R->R, homogeneous of degree k */
f(x) := a * x^k;
f(x0);
f(m*x0);
o  : f(m*x0) = m^k * f(x0);
o2 : radcan(o);
is(o);    /* false because "is" is dumb */
is(o2);   /* true */

  /* f:R->R, homogeneous of degree 2 */
     f(   x,   y) := a*x^2 + b*x*y + c*y^2;
     f(  x0,  y0);
     f(m*x0,m*y0);
o  : f(m*x0,m*y0) = m^2 * f(x0,y0);
o2 : radcan(o);
is(o);    /* false because "is" is dumb */
is(o2);   /* true */

  /* f:R->R, homogeneous of degree 3 */
     f(   x,   y) := a*x^3 + b*x^2*y + c*x*y^2 + d*y^3;
     f(  x0,  y0);
     f(m*x0,m*y0);
o  : f(m*x0,m*y0) = m^3 * f(x0,y0);
o2 : radcan(o);
is(o);    /* false because "is" is dumb */
is(o2);   /* true */

a^k * (b * c)^k; 




#####
#
# graphs
# 2023oct29
#
#####

# «graphs»  (to ".graphs")
# (find-maximanode "graphs-pkg")
# (find-maximanode "Introduction to graphs")
# (find-maximanode "Functions and Variables for graphs")
# (find-maximanode "draw_graph")
# (find-maximagitfile "share/graphs/")
# (find-maximagitfile "share/graphs/graphs.mac")
# (find-maximagitfile "share/graphs/graphs.system")
# https://mail.google.com/mail/u/0/#inbox/FMfcgzGwHVHXWSDFNLCHplZXQMFKSgSG

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load(graphs);
draw_graph(cycle_graph(10));
draw_graph(flower_snark(5));
draw_graph(cube_graph(3));
draw_graph(cube_graph(3), program=planar_embedding);
draw_graph(cube_graph(4));
draw_graph(cube_graph(4), show_id=true);
draw_graph(cube_graph(5));

load("graphs")$
g: petersen_graph(20, 2);
draw_graph(g, redraw=true, program=planar_embedding);
load("graphs")$
t: tutte_graph();
draw_graph(t, redraw=true, fixed_vertices=[1,2,3,4,5,6,7,8,9]);



#####
#
# package_graph
# 2023nov17
#
#####

# «package_graph»  (to ".package_graph")
# (find-maximamsg "51785058 202311 16" "Stavros: Which could be `good' graph properties of a package?")
# (find-maximamsg "51784571 202311 15" "ElObs: Which could be `good' graph properties of a package?")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("absimp.mac");
package_graph():=block(
   A:map(op,functions),
   len:length(A),
   B:map(lambda([x],rhs(apply(fundef,[x]))),A),
   C:makelist([i,A[i]],i,len),
   D:unique(map(sort,delete(false,map(lambda([x],if x[1]#x[2] and
     ssearch(string(A[x[1]]),string(B[x[2]]))#false then
     x),create_list([i,j],i,1,len,j,1,len))))),
   load(graphs),
   create_graph(C,D)
)$
package_graph();
(draw_graph(%,show_label=true));

file_search(nusum)$
load(%)$
package_graph();
(draw_graph(%,show_label=true));

file_search(sarag)$
load(%)$
package_graph();
(draw_graph(%,show_label=true));




#####
#
# finite_model_theory
# 2023oct29
#
#####

# «finite_model_theory»  (to ".finite_model_theory")
# https://github.com/austinlorenz/finite_model_theory
# (find-git-links "https://github.com/austinlorenz/finite_model_theory" "finitemt")
# (code-c-d "finitemt" "~/usrc/finite_model_theory/")
# (find-finitemtfile "")
# (find-finitemtfile "README.md")
# (find-finitemtfile "MaximaLogic")
# (find-finitemtfile "MaximaLogic2")
# (find-finitemtfile "MaximaLogic.mac")
# (find-finitemtfile "MaximaLogic2.mac")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rfv ~/usrc/finite_model_theory/
cd      ~/usrc/
git clone https://github.com/austinlorenz/finite_model_theory
cd      ~/usrc/finite_model_theory/
cp -v MaximaLogic  MaximaLogic.mac
cp -v MaximaLogic2 MaximaLogic2.mac

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
file_search_maxima : append (file_search_maxima,
  ["~/usrc/finite_model_theory/###.mac"])$

/* batch(MaximaLogic); */
load("MaximaLogic.mac")$
load("MaximaLogic2.mac")$

G : complete_graph(10);
fa(x, fa(y, x != y implies E(x,y)));

G : cycle_graph(10);
fa(x, fa(y, x != y implies E(x,y)));

phi : '(exz(y, exz(z, E(x,y) and E(x,z) and y!=z)));
B   : petersen_graph();
phi : '(exz(y, exz(z, E(x,y) and E(x,z) and y!=z)));
LFP(B,phi);

draw_graph(B);





#####
#
# maxima-bezier
# 2023nov01
#
#####

# «maxima-bezier»  (to ".maxima-bezier")
# https://github.com/t-o-k/Maxima-bezier
# (find-git-links "https://github.com/t-o-k/Maxima-bezier" "maximabezier")
# (code-c-d "maximabezier" "~/usrc/Maxima-bezier/")
# (find-maximabezierfile "")



#####
#
# simplify_sum
# 2023nov06
#
#####

# «simplify_sum»  (to ".simplify_sum")
# (find-maximamsg "51780404 202311 06" "RDodier: simplify_sum")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
o2 : sum (binomial (k + i, i)*binomial (n - 1, n - k), k, 0, n);
o3 : sum (binomial (n - 1, n - i) * %o2, i, 0, n);
load (simplify_sum)$
simplify_sum (o3);
simplify_sum (o2);




#####
#
# Strang p.1: 1*x+2*y=3 and 4*x+5*y=6
# 2024jan30
#
#####

# «strang-p1»  (to ".strang-p1")
# (find-books "__alg/__alg.el" "strang")
# (find-books "__alg/__alg.el" "strang" "(+ 10   1)")
# (find-strang4page (+ 10   1) "1 Matrices and Gaussian Elimination")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
eq1 : 1*x + 2*y = 3;
eq2 : 4*x + 5*y = 6;
eq3 :         4*eq1;
eq4 :  expand(4*eq1);
eq5 : eq2 - eq4;
eq6 : eq5 / -3;
            eq6;
                 eq1;
eq7 : subst(eq6, eq1);
eq8 : eq7 - 4;
             [eq8,eq6];
                        eq1;
                             eq2;
eq9  : subst([eq8,eq6], eq1);
eq10 : subst([eq8,eq6],      eq2);

matrix(['eq1, ":", eq1],
       ['eq2, ":", eq2],
       ['eq3, ":", eq3],
       ['eq4, ":", eq4],
       ['eq5, ":", eq5],
       ['eq6, ":", eq6],
       ['eq7, ":", eq7],
       ['eq8, ":", eq8],
       ['eq9, ":", eq9],
       ['eq10, ":", eq10]);





#####
#
# Strang p.3: 1*x+2*y=3 and 4*x+8*y=6
# 2024jan30
#
#####

# «strang-p3»  (to ".strang-p3")
# (find-books "__alg/__alg.el" "strang")
# (find-books "__alg/__alg.el" "strang" "(+ 10   3)")
# (find-strang4page (+ 10   3)       "That singular case")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
eq1 : 1*x + 2*y = 3;
eq2 : 4*x + 8*y = 6;
             4*eq1;
      expand(4*eq1);
eq3 : expand(4*eq1);
eq4 : eq2 - eq3;

matrix(['eq1, ":", eq1],
       ['eq2, ":", eq2],
       ['eq3, ":", eq3],
       ['eq4, ":", eq4]);




#####
#
# pontos-mais-faceis-1
# 2024mar21
#
#####

# «pontos-mais-faceis-1»  (to ".pontos-mais-faceis-1")
# (c3m241introp 3 "pontos-mais-faceis")
# (c3m241introa   "pontos-mais-faceis")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
ex0 : f(t) = a + ((t-b)/(c-d))*e;
ex1 : subst([f(t)=45,    t=23], ex0);
ex2 : subst([f(t)=45+56, t=34], ex0);
expand([ex1, ex2]);

ex1 : 45    = a  + ((23-b) /(c-d))*e;
ex2 : 45+56 = a  + ((34-b) /(c-d))*e;
expand  ([ex1, ex2]);
linsolve([ex1, ex2], [a, e]);

ex1 : 45    = a  + ((23-b) /(c-d))*e;
      45    = 45 + ((23-23)/(c-d))*e;
ex2 : 45+56 = a  + ((34-b) /(c-d))*e;
      45+56 = 45 + ((34-23)/(c-d))*e;
      45+56 = 45 + ((34-23)/(34-23))*e;
      45+56 = 45 + ((34-23)/(34-23))*56;

ex3 : f(t)  = _45 + ((t-_23)/(_34-_23))*_56;
ex4 : subst([_45=f(t0), _23=t0], ex3);
ex4 : subst([_45=f(t0), _23=t0, _34=t1], ex3);
ex4 : subst([_45=f(t0), _23=t0, _34=t1, _56=f(t1)-f(t0)], ex3);
subst([t=t0], ex4);
subst([t=t1], ex4);




#####
#
# log-constants-anim
# 2024apr07
#
#####

# «log-constants-anim»  (to ".log-constants-anim")
# (find-fline "~/2024.1-C2/")
# (find-fline "~/2024.1-C2/" "log-constants-anim.gif")
# http://anggtwu.net/2024.1-C2/log-constants-anim.gif

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "/tmp/qdraw/")
rm -Rv /tmp/qdraw/
mkdir  /tmp/qdraw/
cd     /tmp/qdraw/

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_qdraw();
myqdraw0([lists]) := apply('qdraw, flatten([lists]));
myqdraw ([lists]) := block([], myqdraw_body : lists, apply('myqdraw0, [lists]));
g(a,b,x) := if is(x<0) then log(-x)+a else log(x)+b;
h(a,b)   := buildq([a,b], lambda([x], g(a,b,x)));

h(2,3);
h(2,3)(4);
h(2,3)(-4);

mycurve(a,b)    := ex1(h(a,b), x, -4,4, lc(red))$
myfilename(n)   := format("/tmp/qdraw/a_~3,'0d", n)$
myqdraw_n(n)    := more(terminal=pdf, file_name=myfilename(n))$
myqdraw_fixed() := [xr(-4,4),yr(-4,4)]$

myqdraw_abn(a,b,n) := myqdraw(myqdraw_fixed(), mycurve(a,b), myqdraw_n(n))$
myqdraw_ab (a,b)   := myqdraw(myqdraw_fixed(), mycurve(a,b))$

** myqdraw_ab (0,0);
** myqdraw_ab (0,1);
myqdraw_abn(0,   0  , 0);
myqdraw_abn(0,   0.5, 1);
myqdraw_abn(0,   1.0, 2);
myqdraw_abn(0,   1.5, 3);
myqdraw_abn(0.5, 1.5, 4);
myqdraw_abn(1.0, 1.5, 5);
myqdraw_abn(1.5, 1.5, 6);
myqdraw_abn(1.5, 1.0, 7);
myqdraw_abn(1.5, 0.5, 8);
myqdraw_abn(1.5, 0.0, 9);
myqdraw_abn(1.0, 0.0, 10);
myqdraw_abn(0.5, 0.0, 11);

** (find-pdfanim-links "/tmp/qdraw/" "a_" "all")




#####
#
# freeof
# 2024apr15
#
#####

# «freeof»      (to ".freeof")
# «listofvars»  (to ".listofvars")
# (find-maximanode "freeof")
# (find-maximanode "lfreeof")
# (find-maximanode "listofvars")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
expr: z^3 * cos(a[1]) * b^(c+d);
freeof (z, expr);
freeof (cos, expr);
freeof (a[1], expr);
freeof (cos (a[1]), expr);
freeof (b^(c+d), expr);
freeof ("^", expr);
freeof (w, sin, a[2], sin (a[2]), b*(c+d), expr);

expr: (a+b)^5$
c: a$
freeof (c, expr);

expr: (a+b)^5$
expand (expr);
freeof (a+b, %);
freeof (a+b, expr);
exp (x);
freeof (exp, exp (x));
freeof (i, 'sum (f(i), i, 0, n));
freeof (x, 'integrate (x^2, x, 0, 1));
freeof (x, 'integrate (x^2, x));




#####
#
# Exercícios da p.374 do Stewart em português
# 2024apr14
#
#####

# «stewart-pt-p374»  (to ".stewart-pt-p374")
# (find-books "__analysis/__analysis.el" "stewart-pt" "374" "Exercícios")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
myintegrate3(label,f,var) := [label, 'integrate(f,var), "=", integrate(f,var)];
myintegrate1(item)        := apply('myintegrate3, item);
myintegrates([items])     := apply('matrix, map('myintegrate1, items));

i5(label,f,oldvar,newvar,chvar) :=
  [label, 'integrate(f,oldvar), "=", integrate(f,oldvar)]$

i3(label,f,chvar) := block(
  [newvar,oldvar,intf,intg],
   newvar : lhs(chvar),
   oldvar : listofvars(rhs(chvar))[1],
   intf   : 'integrate(f,oldvar),
   intg   : changevar(intf, chvar, newvar, oldvar),
   [intf, "=", intg, chvar])$

  i3("3.", x^2*sqrt(x^3+1), u=x^3);




   [label, 'integrate(f,oldvar), "=", newvar, integrate(f,oldvar)])$

changevar(x^2*sqrt(x^3+1), u=x^3, u, x);


ex0 : 'integrate((3*cos(2 + sqrt(3*x+4))) / (2*sqrt(3*x+4)), x, a, b);
ex0 : 'integrate((3*cos(2 + sqrt(3*x+4))) / (2*sqrt(3*x+4)), x);
ex2 : changevar(ex0, u=3*x, u, x);
ex3 : changevar(ex2, v=u+4, v, u);




  ["3.", x^2*sqrt(x^3+1),   x],


myintegrate3( "1.", cos(3*x), x);
myintegrate1(["1.", cos(3*x), x]);
myintegrates(
  ["1.", cos(3*x),          x],
  ["2.", x*(4+x^2)^10,      x],
  ["3.", x^2*sqrt(x^3+1),   x],
  ["4.", 1/(1-6*t)^4,       t],
  ["5.", cos(th)^3*sin(th), th],
  ["6.", sec(1/x)^2/x^2,    x]
);



#####
#
# Exercícios da p.302 do Leithold em português
# 2024apr14
#
#####

# «leithold-pt-p302»  (to ".leithold-pt-p302")
# (find-books "__analysis/__analysis.el" "leithold" "302" "Exercícios 5.2")
# (find-maximanode "while")
# (find-maximanode "return")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/gabmv1.mac")
load       ("~/MAXIMA/gabmv1.mac")$
assume(n>1)$
items : [
  ["1.", sqrt(1-4*y),         u=1-4*y],
  ["2.", (3*x - 4)^(1/3),     u=3*x-4],
  ["3.", (6 - 2*x)^(1/3),     u=6-2*x],
  ["4.", sqrt(5*r + 1),       u=5*r+1],
  ["5.", x*sqrt(x^2 - 9),     u=x^2-9],
  ["6.", 3*x*sqrt(4 - x^2),   u=4-x^2],
  ["7.", x^2*(x^3-1)^10,      u=x^3-1],
  ["8.", x*(2*x^2+1)^6,       u=2*x^2+1],
  ["9.", 5*x*(9-4*x^2)^(2/3), u=9-4*x^2],
  ["10.", x/(x^2+1)^3,        u=x^2+1]
  ]$
lfc_solve_m (items);
lfc_change_m(items);

myintegrates1(items);




#####
#
# miranda-p191
# 2024apr14
#
#####

# «miranda-p191»  (to ".miranda-p191")
# (find-books "__analysis/__analysis.el" "miranda" "191" "Exercícios")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-fline "~/MAXIMA/gabmv1.mac")
load          ("~/MAXIMA/gabmv1.mac")$
assume(n>1)$
items : [
  ["1.", x,       x],
  ["2.", 3*x+1,   x],
  ["3.", x^n,     x],
  ["4.", x^2+x+1, x],
  ["5.", 1/x^2,   x],
  ["6.", x+1/x^3, x],
  ["7.", x^(1/3), x],
  ["8.", 3*x^(2/7)+cos(x), x]
  ]$
lfv_solve_m(items);




#####
#
# miranda-p196
# 2024apr15
#
#####

# «miranda-p196»  (to ".miranda-p196")
# (find-books "__analysis/__analysis.el" "miranda" "196" "Exercícios")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-fline "~/MAXIMA/gabmv1.mac")
load          ("~/MAXIMA/gabmv1.mac")$
assume(n>1)$
items : [
  ["1.", 3*x^2*(x^3-5)^7,         u=x^3-5],
  ["2.", (2*x-5)*(x^2-5*x+7)^3,   u=x^2-5*x+7],
  ["3.", x*(x^2+1)^8,             u=x^2+1],
  ["4.", (12*x+14)*(3*x^2+7*x-1), u=3*x^2+7*x-1]
  ]$
lfc_change_m(items);
lfc_solve_m (items);




#####
#
# integral-calculator
# 2024apr17
#
#####

# «integral-calculator»  (to ".integral-calculator")
# https://www.integral-calculator.com/
# https://news.ycombinator.com/item?id=40034869 Integral Calculator (integral-calculator.com)
# https://stackoverflow.com/questions/76607102/is-there-a-way-to-get-maxima-to-show-its-steps-of-integration



#####
#
# mixima
# 2024apr25
#
#####

# «mixima»  (to ".mixima")
# https://github.com/maxima-project-on-github/mixima
# (find-maximamsg "58764586 202404 25" "RDodier: see the fork")





#####
#
# joel-moses
# 2024apr25
#
#####

# «joel-moses»  (to ".joel-moses")
# https://www.softwarepreservation.org/projects/LISP/MIT/MIT-LCS-TR-047-corrected-ocr.pdf
# https://infinite.mit.edu/video/joel-moses-phd-%E2%80%9967
# https://en.wikipedia.org/wiki/Joel_Moses




#####
#
# cabs
# 2024apr25
#
#####

# «cabs»  (to ".cabs")
# (find-maximanode "cabs")
# (find-maxima-links "cabs")
# (find-maximamsg "58758284 202404 09" "Stavros: Maxima is not very smart about the *conjugate*")
# (find-maximamsg "58758329 202404 09" "Torsten: unfortunately cabs(f) only works if")
# (find-maximamsg "58758346 202404 09" "Stavros: You changed the problem")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
depends([x,y],t);
o : cabs(x+%i*y);
diff(o,t);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
declare(f, complex, t, real); /* to be as clear as possible */
depends(f, t);
diff(cabs(f), t);




#####
#
# scalarmatrixp
# 2024apr25
#
#####

# «scalarmatrixp»  (to ".scalarmatrixp")
# (find-maxima-links "scalarmatrixp")
# (find-maximanode "scalarmatrixp")
# (find-maximamsg "58753998 202403 27" "LButler: scalarmatrixp : false")





#####
#
# 2024.1-dois-metodos
# 2024jul08
#
#####

# «2024.1-dois-metodos»  (to ".2024.1-dois-metodos")
# (c3m241dmp 3 "metodo-1")
# (c3m241dma   "metodo-1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f(t) := a + (t-b)/c * d;
eq1 : f(12)    = 34;
eq2 : f(12+23) = 34+56;
solve([eq1, eq2], [a,c]);
solve([eq1, eq2], [a,d]);
solve([eq1, eq2], [b,c]);
solve([eq1, eq2], [b,d]);
eq3 : f(x0) = y0;
eq4 : f(x1) = y1;
solve([eq3, eq4], [a,c]);
solve([eq3, eq4], [a,d]);
solve([eq3, eq4], [b,c]);
solve([eq3, eq4], [b,d]);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f1(x) := 1;
f2(x) := x;
f3(x) := 8-x;
f4(x) := 2;

f12(x) := max(f1(x),f2(x));
f34(x) := max(f3(x),f4(x));
f1234(x) := min(f12(x),f34(x));
plot2d (f1234(x), [x, 0, 7]);

g1234(x) :=
  if     x < 1 then f1(x)
  elseif x < 4 then f2(x)
  elseif x < 6 then f3(x)
  else              f4(x);
plot2d (g1234(x), [x, 0, 7]);

      subst([x=t-2], g1234(x));
grind(subst([x=t-2], g1234(x)));




#####
#
# aroundx0y0
# 2024jul11
#
#####

# «aroundx0y0»  (to ".aroundx0y0")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/mkmatrix1.mac")
load       ("~/MAXIMA/mkmatrix1.mac");
  
[x0,y0] : [3,2];
[Dx,Dy] : [x-x0,y-y0];
mkmatrix ([x,0,x0+1], [y,y0+1,0,-1], [x,y]);
mkmatrix ([x,0,x0+1], [y,y0+1,0,-1], ev([Dx,Dy]));
a : mkmatrix ([x,x0-1,x0+1], [y,y0+1,y0-1,-1], [x,y]);
b : mkmatrix ([x,x0-1,x0+1], [y,y0+1,y0-1,-1], ev([Dx,Dy]));

aroundx0y0(expr) ::= mkmatrix0([x,x0-1,x0+1], [y,y0+1,y0-1,-1], expr);

c : aroundx0y0([x,y]);
d : aroundx0y0(ev([Dx,Dy]));





#####
#
# aroundx0
# 2024jul11
#
#####

# «aroundx0»  (to ".aroundx0")
# https://mail.google.com/mail/u/0/#inbox/KtbxLzGWwnbcGLfddSgSzcswknJRwjtsGB
# (find-maximamsg "58794330 202407 11" "Edrx: mkmatrix?")
# (find-maximamsg "58794359 202407 11" "Stavros: without macros at all")
# (find-maximamsg "58794393 202407 11" "RDodier: macroexpand")
# (find-maximamsg "58794418 202407 12" "Edrx: Todo-listed!!!")
# (find-maximanode "ev")
# (find-maximanode "trace")
# (find-maximanode "macroexpand")
# (find-maximanode "apply")
# (find-maximanode "create_list")
# (find-maximanode "genmatrix")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
mklist_(xs, expr) := buildq([xs,expr], makelist(expr, splice(xs)))$
aroundx0_  (expr) := buildq([expr], mklist_([x,x0-1,x0+1], expr))$
mklist (xs, expr) ::= mklist_(xs, expr)$
aroundx0   (expr) ::= aroundx0_  (expr)$

mklist([x,2,4], 10*x);
aroundx0       (10*x);

a : '(aroundx0(10*x));
b : apply('macroexpand, [a]);
c : apply('macroexpand, [b]);
d : ev(b);


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
[a:b,b:c,c:d,d:e];
m(x) ::= x$
m(a);
m(x) ::= buildq([x], x)$
m(a);
m(x) ::= buildq([x], [1, 2, splice(x), 4])$
m([a]);


buildq([x:2], [1, 2, splice([3, 33]), 4]);
buildq([x:2], [1, 2, splice([3]), 4]);


o0 : '(m(a));

 'm( a);
  m('a);
'(m( a));

o1 :   macroexpand(m(a));
o2 : ev(macroexpand(m(a)));
o3 : apply('ev, [macroexpand(m(a))]);
ev(a)
;

a;
ev(a);
ev(ev(a));
ev(ev(ev(a)));
ev(ev(ev(ev(a))));

macroexpand(aroundx0(10*x));
macroexpand(macroexpand(aroundx0(10*x)));

makelist(10*x, x, 2, 4);
makelist(10*x, x, x0-1, x0+1);

trace(all);




#####
#
# aroundx0-tools
# 2024jul14
#
#####

# «aroundx0-tools»  (to ".aroundx0-tools")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
Hi list,

I am still confused about by original problem, but now I have better
questions... and the main one is open-ended: there are many cases in
which I don't understand how Maxima executes things, and I would like
to have tools to "single step these cases by hand". There is an
example below, and it's evident that my current tools are not very
good - can you send suggestions?

/* A reduced version of my original problem
*/
mklist0(xs, expr) := buildq([xs, expr], makelist(expr, splice(xs)))$
mklist (xs, expr) ::= mklist0(xs, expr)$
aroundx0   (expr) ::= mklist0([x,2,4], expr)$

[x0,y0] : [3, 2];
[Dx,Dy] : [x-x0, y-y0];
aroundx0(Dx);         /* Bad:  [x - 3, x - 3, x - 3] */
aroundx0('Dx);        /* Bad:  [Dx, Dx, Dx]          */
aroundx0(ev(Dx));     /* Good: [- 1, 0, 1]           */

/* Some tools - see the link below */
/* simp:false$ */
simp:true$
dosimp(ex)    := block([simp:true],  expand(ex,0,0))$
doeval(ex)    := block([simp:false], ?meval(ex))$
fulleval(ex)  := block([simp:true],  ?meval(ex))$
macroexp1(ex) := apply('macroexpand1, [ex])$

/* An attempt to "single-step an example by hand":
*/
o0 : '(aroundx0(ev(Dx)));   /* aroundx0(ev(Dx)) */
o1 : macroexp1(o0);         /* makelist(ev(Dx), x, 2, 4) */
  o2 : 'Dx;                 /* Dx */
  o3 : doeval(o2);          /* x - 3 */
  o4 : block([x:2], ''o3);  /* - 1 */
  o5 : block([x:3], ''o3);  /* 0 */
  o6 : block([x:4], ''o3);  /* 1 */
  o7 : [o4, o5, o6];        /* [- 1, 0, 1] */
o8 : apply('ev, [o1]);      /* [- 1, 0, 1] */
o8 : doeval(o1);            /* err: ...must evaluate to a number */
o8 : fulleval(o1);          /* [- 1, 0, 1] */

Thanks in advance!
  Eduardo Ochs
  http://anggtwu.net/eev-maxima.html


P.S.: some of the "tools" are from Stavros, from:
https://sourceforge.net/p/maxima/mailman/message/37417447/




#####
#
# mycolorlerp1
# 2024sep24
#
#####

# «mycolorlerp1»  (to ".mycolorlerp1")
# (to "foo-and-foo")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("~/MAXIMA/mycolorlerp1.lisp");
/* t=0 is white,
 * t=1 is color1
*/
colorlerps(color1, ts) :=
  makelist(my_color_lerp("#ffffff", color1, t), t, ts);

[color1, color2, color3, color4] :
  colorlerps("#ff0000", [0.2, 0.5, 0.8, 1]);
[color1, color2, color3, color4] :
  colorlerps("#ff0000", [0.2, 0.4, 0.7, 1]);

load_qdraw();
fs : [x,x^2,x^3,x^4];

colors : [red, orange, forest_green, blue, dark_violet]$
colors : [color1, color2, color3, color4];
myqdraw([lists]) := apply('qdraw, apply('append, lists))$
myexs_1(ii)      := ex1(fs[ii], x, -2,2, lc(colors[ii]))$
myexs_1(ii)      := ex1(fs[ii], x, -2,2, lc(colors[ii]), lk(fs[ii]))$
myexs()          := makelist(myexs_1(ii), ii, length(fs))$
myexs();

myqdraw([xr(-2,2),yr(-2,2)], myexs());





#####
#
# 2024.1: Taylor in one and two dimensions for C3, version 1
# 2024jul15
#
#####

# «2024.1-taylor-1»  (to ".2024.1-taylor-1")
# (c3m241tap 20 "at-x-and-x0")
# (c3m241taa    "at-x-and-x0")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/mkmatrix1.mac")
load       ("~/MAXIMA/mkmatrix1.mac");
derivs    (maxn, f) := mklist   ([n,0,maxn],    diff(f, x, n))$
derivs_h  (maxn, f) := mkhmatrix([n,0,maxn],    diff(f, x, n))$
derivs_v  (maxn, f) := mkvmatrix([n,0,maxn],    diff(f, x, n))$
derivs0   (maxn, f) := mklist   ([n,0,maxn], at(diff(f, x, n), x=0))$
derivs0_h (maxn, f) := mkhmatrix([n,0,maxn], at(diff(f, x, n), x=0))$
derivs0_v (maxn, f) := mkvmatrix([n,0,maxn], at(diff(f, x, n), x=0))$
derivsx0  (maxn, f) := mklist   ([n,0,maxn], at(diff(f, x, n), x=x0))$
derivsx0_h(maxn, f) := mkhmatrix([n,0,maxn], at(diff(f, x, n), x=x0))$
derivsx0_v(maxn, f) := mkvmatrix([n,0,maxn], at(diff(f, x, n), x=x0))$

derx           (k, f) :=    diff(f, x, k)$
derxat0        (k, f) := at(diff(f, x, k), x=0)$
derxatx0       (k, f) := at(diff(f, x, k), x=x0)$
derxat0div     (k, f) := at(diff(f, x, k), x=0)  / k!$
derxatx0div    (k, f) := at(diff(f, x, k), x=x0) / k!$
derxat0divmul  (k, f) := at(diff(f, x, k), x=0)  / k! * x^k$
derxatx0divmul (k, f) := at(diff(f, x, k), x=x0) / k! * (x-x0)^k$
at0reconstruct (n, f) := sum(derxat0divmul (k, f), k,0,n)$
atx0reconstruct(n, f) := sum(derxatx0divmul(k, f), k,0,n)$

derivs   (5, f(x));
derivs_h (5, f(x));
derivs_h (5, sin(x));
derivs0_h(5, sin(x));

derivs_v (5, f(x));

p(x) := a + b*x + c*x^2 + d*x^3 + e*x^4;
derx          (3, p(x));
derxat0       (3, p(x));
derxat0div    (3, p(x));
derxat0divmul (3, p(x));
derxat0divmul (4, p(x));
       at0reconstruct(4, p(x));
       at0reconstruct(3, p(x));
p(x) - at0reconstruct(3, p(x));

at0reconstruct(7, sin(x));

q(x) := a + b*(x-x0) + c*(x-x0)^2 + d*(x-x0)^3 + e*(x-x0)^4;
derivs_v  (5, q(x));
derivsx0_v(5, q(x));
       atx0reconstruct(4, q(x));
       atx0reconstruct(3, q(x));
q(x) - atx0reconstruct(3, q(x));




#####
#
# 2024.1-taylor-2
# 2024jul15
#
#####

# «2024.1-taylor-2»  (to ".2024.1-taylor-2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/mkmatrix1.mac")
load       ("~/MAXIMA/mkmatrix1.mac");

mkhmatrix([x,2,5],    x);
mkvmatrix([y,2,5],    y);
mkvmatrix([y,5,2,-1], y);
mkmatrix ([x,0,2], [y,5,4,-1], [x,y]);

diffxnyn(f, xn, yn) := diff(diff(f, x, xn), y, yn);
mkmatrix([xn,0,4], [yn,3,0,-1], [xn,yn]);
mkmatrix([xn,0,2], [yn,2,0,-1],    diffxnyn(F(x,y),  xn, yn));
mkmatrix([xn,0,3], [yn,3,0,-1],    diffxnyn(x^2*y^2, xn, yn));
mkmatrix([xn,0,3], [yn,3,0,-1], at(diffxnyn(x^2*y^2, xn, yn), [x=0,y=0]));
mkmatrix([xn,0,3], [yn,3,0,-1],    diffxnyn((x-x0)^2*(y-y0)^2, xn, yn));
mkmatrix([xn,0,3], [yn,3,0,-1], at(diffxnyn((x-x0)^2*(y-y0)^2, xn, yn), [x=x0,y=y0]));

aroundx0y0(expr) ::= mkmatrix0([x,2,4], [y,3,1,-1], expr);
aroundx0y0([x,y]);

[x0,y0] : [3, 2];
[Dx,Dy] : [x-x0, y-y0];
aroundx0y0(ev(Dx));

mkmatrix([x,0,4], [y,3,0,-1], [x,y]);
mkmatrix([x,2,4], [y,3,1,-1], [x,y]);
aroundx0y0(ev([x,y]));

aroundx0y0(ev(Dx^2));
aroundx0y0(ev(Dy^2));
aroundx0y0(ev(Dx^2+Dy^2));
aroundx0y0(ev(Dx^2-Dy^2));
aroundx0y0(ev(Dx*Dy));

aroundx0y0(ev(2+Dx^2));
aroundx0y0(ev(2+Dy^2));
aroundx0y0(ev(2+Dx^2+Dy^2));
aroundx0y0(ev(2+Dx^2-Dy^2));
aroundx0y0(ev(2+Dx*Dy));


"3hT102";



#####
#
# 2024.1-intervals
# 2024jul18
#
#####

# «2024.1-intervals»  (to ".2024.1-intervals")
# (c2m241srp 38 "maxima-intervals")
# (c2m241sra    "maxima-intervals")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
a : 2;
b : 4;
b[i] := a + i*(b-a)/6;
a[i] := b[i-1];
I[i] := [a[i], b[i]];

[I[1], I[2], I[3], I[4], I[5], I[6]];
makelist(I[i], i, 1, 6);




#####
#
# Prova relâmpago 1 para Cálculo 2 - dia 1
# 2024jul18
#
#####

# «2024.1-C2-PR1-1»  (to ".2024.1-C2-PR1-1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)

/* Gabriel: */
f  : x*log(x*2);
F0 :  integrate(f, x);
F1 : 'integrate(f, x);
F2 : changevar(F1, u=2*x, u, x);
            ev(F2, integrate);
F3 : expand(ev(F2, integrate));
F4 : subst(u=2*x, H);
f2 : diff(F4, x);

/* Wesley: */
f  : (x+2)*log(x+3);
F  : integrate(f, x);
f2 : diff(F, x);
plot2d([f, f2+0.1], [x, 0, 6]);

/* Letícia: */
f : x * sqrt(1-x^2);
F  : integrate(f, x);
f2 : diff(F, x);

/* Amanda: */
f  : x * sin(2*x);
F  : integrate(f, x);
f2 : diff(F, x);

/* Laís: */
f : x^2 * sqrt(x-2);
F  : integrate(f, x);
f2 : diff(F, x);
f3 : expand(f2);
plot2d([f, f2+1], [x, 0, 6]);

/* Paula: */
f  : x * sin(x-2);
F  : integrate(f, x);
f2 : diff(F, x);
f3 : expand(f2);

sum(10^k, k, 3, 6);

eq1 : 2*x+5*y = 3;
eq2 : 4*x-y = 2;
   solve([eq1,eq2], [x,y]);
linsolve([eq1,eq2], [x,y]);




#####
#
# Prova relâmpago 1 para Cálculo 2 - dia 2
# 2024jul20
#
#####

# «2024.1-C2-PR1-2»  (to ".2024.1-C2-PR1-2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* Integral definida */
integrate(x^2, x,1,5);

/* Questão sobre somatório numa partição */
a : 2;
b : 4;
N : 6;
b[i] := a + i*(b-a)/N;
a[i] := b[i-1];
I[i] := [a[i], b[i]];

s : f(a[i])*(b[i]-a[i]);
f(x) := x^2;
sum(f(a[i])*(b[i]-a[i]), i,1,6);

/* Gráfico */
plot2d(x^2, [x, 0, 6]);

/* Integre e teste */
f : x*sqrt(1-x^2);
F : integrate(f, x);
f2 : diff(F, x);

f: (x^2+2*x+3) / (x^2-3*x+4);
F: integrate(f,x);
diff(F, x);
radcan(diff(F, x));




#####
#
# 2024.1-completing-squares
# 2024jul28
#
#####

# «2024.1-completing-squares»  (to ".2024.1-completing-squares")
# (setq last-kbd-macro (kbd "M-3 M-e M-> M-e M-o"))
# (find-maximamsg "34160689 201506 01" "MikeV:")
# (find-maximamsg "34160701 201506 01" "MikeV:")
# (find-maximamsg "34160709 201506 01" "MikeV:")
# (find-maximamsg "34163615 201506 01" "MikeV:")
# (find-maximamsg "34163715 201506 01" "BWillis:")
# (find-maximamsg "34163788 201506 01" "MikeV")
# (find-maximamsg "34163829 201506 01" "BWillis: block and local")
# (find-maximamsg "34164126 201506 01" "MikeV: final code for complete_square (?)")
# (find-maximamsg "34167187 201506 02" "MikeV:")
# (find-maximamsg "34167487 201506 02" "BWillis:")
# (find-maximamsg "34167651 201506 02" "MikeV:")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
p       : 2*(x-2)*(x+4);
a       : ratcoef(p,x,2);
p1      : p / a;
sols    : solve(p=0, x);
[r1,r2] : [rhs(sols[1]), rhs(sols[2])];  /* roots */
m       : (r1+r2)/2;                     /* midpoint */
pm      : at(p,  x=m);
p1m     : at(p1, x=m);
q1      :    (x-m)^2+p1m;
q       : a*((x-m)^2+p1m);
eq1     : p = q;
expand(eq1);




#####
#
# 2024.1-intro-complex
# 2024jul20
#
#####

# «2024.1-intro-complex»  (to ".2024.1-intro-complex")
# (find-LATEX "2024-1-C2-numeros-complexos.tex" "dots")
# https://en.wikipedia.org/wiki/Complex_number#Matrix_representation_of_complex_numbers
# (find-maximanode "imagpart")
# (find-maximanode "realpart")
# (to "2024.2-C2-intro-complex")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/myqdraw1.mac")
** (find-angg "MAXIMA/zpts1.mac")
load       ("~/MAXIMA/zpts1.mac")$
includegraphics_dir : "2024-1-C2/";
myQdraw([args]) := apply('myQdraw_pdf,  args)$  myps(s):=ps(s/5);
myQdraw([args]) := apply('myQdraw_draw, args)$  myps(s):=ps(s);

as_33 : create_list(x+%i*y, y, seqn(2,0,2), x, seqn(0,2,2));
as_55 : create_list(x+%i*y, y, seqn(2,0,4), x, seqn(0,2,4));
as    : as_33;
xyrange(r) := [xr(-r,r), yr(-r,r), more(proportional_axes=xy)];

myqdraw_nhr(n,h,r,[rest]) :=
  myQdraw(format("complex-~a",n), format("height=~acm",h), xyrange(r), rest);

myqdraw_nhr(1,5,4, zpts(as_33,    myps(4),pc(red)));
myqdraw_nhr(2,5,4, zpts(as_55,    myps(4),pc(orange)));
myqdraw_nhr(3,5,4, zpts(as_55+1,  myps(4),pc(orange)));
myqdraw_nhr(4,5,4, zpts(as_55+%i, myps(4),pc(orange)));
myqdraw_nhr(5,5,4, zpts(as_55*2,  myps(4),pc(orange)));
myqdraw_nhr(6,5,4, zpts(as_55*(1+%i), myps(4),pc(orange)));

linenum:11;
asq_33 : makelist(z^2, z, as_33);
asq_55 : makelist(z^2, z, as_55);
myqdraw_nhr(7,5,8, zpts(asq_33, myps(4),pc(red)));
myqdraw_nhr(8,5,8, zpts(asq_55, myps(1),pc(red)));

as_22   : create_list(x+%i*y, y, seqn(0,1,1), x, seqn(0,1,1));
as_332  : create_list(z+w,    z, as_33, w, as_22*0.2);
asq_332 : makelist(z^2, z, as_332);
myqdraw_nhr( 9,5,10,  zpts(as_332, myps(1),pc(red)));
myqdraw_nhr(10,5,10, zpts(asq_332, myps(1),pc(red)));


** (find-pdf-page "~/LATEX/2024-1-C2/complex-1.pdf")
** (find-pdf-page "~/LATEX/2024-1-C2/complex-2.pdf")
** (find-pdf-page "~/LATEX/2024-1-C2/complex-3.pdf")
** (find-pdf-page "~/LATEX/2024-1-C2/complex-4.pdf")
** (find-pdf-page "~/LATEX/2024-1-C2/complex-5.pdf")
** (find-pdf-page "~/LATEX/2024-1-C2/complex-6.pdf")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
Re(z)    := realpart(z)$
Im(z)    := imagpart(z)$
sqhyp(z) := Re(z)^2 + Im(z)^2$
tom(z)   := matrix([Re(z),-Im(z)], [Im(z),Re(z)])$
det(M)   := determinant(M)$

z : a + %i*b;
w : c + %i*d;
eq1 :     tom(z*w)  =     tom(z) .    tom(w);
eq2 : det(tom(z*w)) = det(tom(z))*det(tom(w));
eq3 :   sqhyp(z*w)  =   sqhyp(z) *  sqhyp(w);
expand(eq1);
expand(eq2);
expand(eq3);






#####
#
# 2024.1-polyx
# 2024jul22
#
#####

# «2024.1-polyx»  (to ".2024.1-polyx")
# (find-angg "MAXIMA/polyx1.mac")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
polyx([coefs]) := block([revcoefs,degree],
  degree : length(coefs)-1,
  revcoefs : reverse(coefs),
  sum(revcoefs[k+1]*x^k, k,0,degree))$

polycoefs3(poly, var, degree) := makelist(ratcoef(poly,var,_k_), _k_,degree,0,-1);
polycoefs2(poly, var)         := polycoefs3(poly, var, hipow(poly, var));
topolyx   (poly)              := funmake('polyx, polycoefs2(poly, 'x));

        polyx(20,30,40);
topolyx(polyx(20,30,40));
topolyx(polyx(20,30,40) + polyx(1,2));


:lisp   (trace meval)
funmake('polyx, [20, 30]);
funmake('polyx, [20, 30+3]);
topolyx(20*x^2 + 30*x + 40);
:lisp (untrace meval)













































#####
#
# 2024-1-C2-P1
# 2024jul23
#
#####

# «2024-1-C2-P1»  (to ".2024-1-C2-P1")
# (c2m241p1p 2 "questoes-12")
# (c2m241p1a   "questoes-12")
# (c2m241p1p 5 "questao-1-gab")
# (c2m241p1a   "questao-1-gab")
# (find-maximanode "changevar")
# (find-maximanode "rootscontract")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
texput(th, "\\theta ");
linel : 100$

f : x^3 * sqrt(1-4*x^2);
F1 : 'integrate(f, x);
F2 : changevar(F1, u=2*x, u, x);
F2 : rootscontract(F2);
F3 : changevar(F2, u=sin(th), th, u);
F3 : rootscontract(F3);
F3 : subst([sqrt(1-sin(th)^2)=cos(th)], F3);
F4 : changevar(F3, c=cos(th), c, th);
F5 : ev(F4, 'integrate);
F5 : expand(F5);
F6 : subst([c=cos(th)], F5);
F7 : subst([th=asin(u)], F6);
F8 : subst([u=2*x], F7);
align_eqs([F1, F2, F3, F4,
           F5, F6, F7, F8]);

                         diff(F9, x);
                  radcan(diff(F9, x));
    rootscontract(radcan(diff(F9, x)));
f = rootscontract(radcan(diff(F9, x)));




#####
#
# 2024-1-C2-P1: questão de revisão / vista de prova pro Lucas
# 2024aug26
#
#####

# «2024-1-C2-P1-rev»  (to ".2024-1-C2-P1-rev")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/changevarbyhand1.mac")
load       ("~/MAXIMA/changevarbyhand1.mac");

f  : x^3 * sqrt(4-x^2);
F1 : changevar0_nop    (f, x=2*u, u, x);
F8 : ev(F1, 'integrate);
F9 : radcan(F8);
rootscontract(F9);

F2 : changevar0_byhand (f, x=2*u, u, x);

F1 : changevar0_nop    (f, x=2*sin(th), th, x);
F1 : changevar0_byhand (f, x=2*sin(th), th, x);
F2 : changevar0_byhand (f, x=2*u, u, x);

F8 : ev(F2, 'integrate);
F9 : subst(u=x/2, F8);

F8 : ev(F1, 'integrate);

changevar0_maxima (sin(x^2)*2*x, u=x^2, u, x);
changevar0_byhand (sin(x^2)*2*x, u=x^2, u, x);

diff((4-x^2)^(7/2), x);
diff((4-x^2)^(5/2), x);





#####
#
# 2024-1-C2-P2
# 2024aug20
#
#####

# «2024-1-C2-P2»  (to ".2024-1-C2-P2")
# (c2m241p2p 3 "questao-1")
# (c2m241p2a   "questao-1")
# (to "ev-derivative-quirk")

** Questão 1
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
star1 : 'diff(y,x) = -2*(x-1) / (2*(y-1));
e1    : star1;
e2    : ode2(e1,y,x);
e3    : solve(e2,y);
[solneg,solpos] : e3;
solpos;
epos  : subst([x=-3,y=4], solpos);
cpos  : solve(epos, %c)[1];
e1d   : subst(cpos, solpos);

solneg;
eneg : subst([x=-3,y=-2], solneg);
cneg : solve(eneg, %c)[1];
e1e  : subst(cneg, solneg);

/* Mini-gabarito: */
solpos;
solneg;
e1c : subst(solneg, star1);
ev(e1c, 'derivative);
e1d;
e1e;

** Questão 2
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
star2 : 'diff(y,x,2) - 3*'diff(y,x) - 10*y = 0;
star3 : 'diff(y,x,2) + 4*'diff(y,x) + 29*y = 0;
         ode2(star2,y,x);
g  : rhs(ode2(star2,y,x));  /* item a */
gp : diff(g,x);
e1 : at([g=3,gp=-1], x=0);
e2 : solve(e1, [%k1,%k2]);
h  : subst(e2, g);          /* item b */

     ode2(star3,y,x);

/* Mini-gabarito: */
g  : rhs(ode2(star2,y,x));
f1 : subst([%k1=1,%k2=0], g);
f2 : subst([%k1=0,%k2=1], g);
h;
ode2(star3,y,x);


** Questão 3
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
/* Mini-gabarito: */
star4 : 'diff(y,x) - 2*y/x = 3*x;
sol   : ode2(star4,y,x);
e1    : subst(sol, star4);
e2    : ev(e1, 'derivative);


** Questão 4
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
[z_x,z_y] : [2*x*y^3, 3*x^2*y^2];
exact5 : diff(z_x,y) = diff(z_y,x);
star5  : z_x*dx + z_y*dy = 0;
star5b : subst([dy='diff(y,x)*dx], star5/dx);
star5b : expand(star5b);
sol5   : ode2(star5b, y, x);
sol5   : radcan(sol5);

eq     : sol5;
eq     : eq * x^(2/3);
eq     : eq^3;

test5  : subst(sol5, star5b);
ev(test5, 'derivative);

[z_x,z_y] : [2*x^2*y^3, 3*x^3*y^2];
star6     : z_x*dx + z_y*dy = 0;
notexact6 : diff(z_x,y) = diff(z_y,x);

/* Mini-gabarito: */
exact5;
notexact6;
sol5;
test5;
ev(test5, 'derivative);

** Questão 5
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
e1 : y = 4-2*x;
e2 : solve(e1,x)[1];
define(raio(y), rhs(e2));
define(area(y), %pi * raio(y)^2);
integrate(area(y),y,0,2);




#####
#
# 2024-1-C2-VS
# 2024aug28
#
#####

# «2024-1-C2-VS»  (to ".2024-1-C2-VS")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (c2m241vsp 3 "questao-1")
** (c2m241vsa   "questao-1")
f : (10*x - 7) / ((x-2)*(x+5));
integrate(f,x);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (c2m241vsp 4 "questao-2")
** (c2m241vsa   "questao-2")
star3   : 'diff(y,x) = -2*x / (8*(y-1));
sol_imp : ode2(star3,y,x);
[sol_neg,sol_pos] : expand(solve(sol_imp, y));
Pd    : [x=-3,y=3];
Pe    : [x=-3,y=-1];
eqC_d : subst(Pd, sol_pos);
eqC_e : subst(Pe, sol_neg);
C_d   : solve(eqC_d, %c);
C_e   : solve(eqC_e, %c);
sol_d : subst(C_d, sol_pos);
sol_e : subst(C_e, sol_neg);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (c2m241vsp 5 "questao-3")
** (c2m241vsa   "questao-3")
f  : (2*x+3)*sqrt(4*x+5);
F1 : 'integrate(f,x);
F2 :  integrate(f,x);
expand(F2);

/* Adriano: */
F3 : changevar(F1, u=4*x+5, u, x);

/* Duda: */
s : sqrt(4*x+5);
F : 1/20*s^5 + 1/12*s^3;
G : 1/20 * 5/2 * s^3 + 4 * 1/12 * 3/2 * s * 4;
diff(F,x);

/* Lucas: */
s : sqrt(4*x+5);
a : 5/16*s^5 + 1/12*s^3;
diff(a,x);





#####
#
# Stewart, p856, exercício 10 (sobre pontos críticos)
# 2024jul25
#
#####

# «2024.1-stewart-p856-ex10»  (to ".2024.1-stewart-p856-ex10")
# http://anggtwu.net/LATEX/2024-1-C3-pontos-criticos.pdf
# (c2m241pcp 3 "stewart-p856-ex10")
# (c2m241pca   "stewart-p856-ex10")
# (find-books "__analysis/__analysis.el" "stewart-pt" "856" "14.7 Exercícios")
# (find-pdf-page "~/LATEX/2024-1-C3/Stewart-p856-exerc10-F.pdf")
# (find-pdf-page "~/LATEX/2024-1-C3/Stewart-p856-exerc10-Fx-Fy.pdf")
# (find-fline "~/LATEX/2024-1-C3/" "Stewart-p856-exerc10-F.pdf")
# (to "qdraw-contour")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "~/MAXIMA/myqdraw1.mac")
load         ("~/MAXIMA/myqdraw1.mac");

F   : x*y * (1-x*y);
F   : x*y * (1-x-y);
Fx  : diff(F, x);
Fy  : diff(F, y);
Fxx : diff(Fx, x);
Fxy : diff(Fx, y);
Fyy : diff(Fy, y);

[xmin,ymin,xmax,ymax] : [-2,-2,2,2];
mylevel(eq,[opts]) :=
  apply('imp1, append([eq, x,xmin,xmax, y,ymin,ymax], opts));

myQdraw("Stewart-p856-exerc10-F",     "height=5cm",
        mylevel(F=0,    lk("F=0"),    lc(orange)),
        mylevel(F=0.2,  lk("F=0.2"),  lc(red)),
        mylevel(F=-0.2, lk("F=-0.2"), lc(forest_green))
       );
myQdraw("Stewart-p856-exerc10-Fx-Fy", "height=5cm",
        mylevel(Fx=0,   lk("Fx=0"),   lc(red)),
        mylevel(Fy=0,   lk("Fy=0"),   lc(orange))
       );

pontoscriticos : solve([Fx=0, Fy=0], [x,y]);
[P1,P2,P3,P4] : pontoscriticos;
at([Fxx,Fxy,Fyy], P1);
at([Fxx,Fxy,Fyy], P2);
at([Fxx,Fxy,Fyy], P3);
at([Fxx,Fxy,Fyy], P4);





#####
#
# 2024.1-depends
# 2024jul28
#
#####

# «2024.1-depends»  (to ".2024.1-depends")
# (find-maximanode "depends")
# (find-maximanode "dependencies")
# (find-maximanode "at")
# (find-maximanode "ev")
# (find-maximanode ":")
# (find-maximanode "kill")
# (find-maximanode "remvalue")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
remvalue(all);

y : x^2;
z : sin(y);
diff(z, x);
diff(z, x, 2);
values;

remvalue(all);
values;

diff(y, x);
depends(y, x);
depends(z, y);
dependencies;
diff(y, x);
diff(z, x);
diff(z, x, 2);

o1 : diff(z, x);
o2 : diff(z, x, 2);
o3 : at(o1, [z=sin(y), y=x^2]);
o4 : at(o2, [z=sin(y), y=x^2]);
o5 : ev(o3, 'derivative, 'at);
o6 : ev(o4, 'derivative, 'at);




#####
#
# 2024.1-gradefs
# 2024jul27
#
#####

# «2024.1-gradefs»  (to ".2024.1-gradefs")
# (c3m241dertotalp 4 "gradefs")
# (c3m241dertotala   "gradefs")
# (to "2023-2-gradefs")
# (to "gradef")
# (find-maximanode "texput")
# (find-maximanode "gradef")
# (find-maximanode "gradef" "Gradients are needed when")
# (find-LATEX "2024-1-C3-diferencial-total.tex" "gradefs")
# (c3m241dertotalp 4 "gradefs")
# (c3m241dertotala   "gradefs")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
diff  (sin(x), x);
gradef(sin(x), sqrt(1-sin(x)^2));
diff  (sin(x), x);

texput(y_x,  "y_x")$
texput(z_y,  "z_y")$
texput(y_xx, "y_{xx}")$
texput(z_yy, "z_{yy}")$

gradef(y,x,   y_x)$
gradef(z,y,   z_y)$
gradef(y_x,x, y_xx)$
gradef(z_y,y, z_yy)$

diff(y, x);
diff(z, x);
diff(z, x, 2);

o1 : diff(y);
o2 : diff(z);
o3 : subst([del(y)=diff(y)], o2);




#####
#
# 2024.1-difs
# 2024jul28
#
#####

# «2024.1-difs»  (to ".2024.1-difs")
# (c3m241dicasp1p 4 "atirei-difs")
# (c3m241dicasp1a   "atirei-difs")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
difs(L) := makelist(L[i+1]-L[i], i,1,length(L)-1)$
difs([a,b,c,d,e]);
difs([1,10,100,1000]);
difs([f(4),f(5),f(6),f(7),f(8)]);
f(x) := a*x+b;
     [f(4),f(5),f(6),f(7),f(8)];
difs([f(4),f(5),f(6),f(7),f(8)]);
ps : makelist(3*x^2-4*x+10, x, 1,10);
          difs(ps);
     difs(difs(ps));
difs(difs(difs(ps)));
ps : makelist(a*x^2+b*x+c, x, 1,5);
          difs(ps);
     difs(difs(ps));
difs(difs(difs(ps)));

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/mkmatrix1.mac")
load       ("~/MAXIMA/mkmatrix1.mac");
[a,b,c,d,e,f] : [2, -1,-2, 38,4,-1];
M1 : mkmatrix ([x,3,5], [y,4,2,-1], [x,y]);
M2 : mkmatrix ([x,3,5], [y,4,2,-1], F(x,y));
F(x,y) := a*(y-3)^2
        + b*(y-3) + c*(x-4)*(y-3)
        + d       + e*(x-4)       + f*(x-4)^2$
M3 : mkmatrix ([x,3,5], [y,4,2,-1], F(x,y));
M4 : mkmatrix ([x,0,5], [y,4,0,-1], F(x,y));



#####
#
# 2024.1-undet-coefs (buggy!)
# 2024aug14
#
#####

# «2024.1-undet-coefs»  (to ".2024.1-undet-coefs")
# (c2m241cdp 4 "tres-exemplos")
# (c2m241cda   "tres-exemplos")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
L(f)  :=  diff(f,x,2) - 3* diff(f,x) - 4*f;
Ly    :  'diff(y,x,2) - 3*'diff(y,x) - 4*y;
ex0   : Ly = 0;
ex1   : Ly = 3*exp(2*x);
ex2   : Ly = 2*sin(x);
ex25  : Ly = 4*x^2-1;
sol0  : ode2(ex0, y,x);
sol1  : ode2(ex1, y,x);
sol2  : ode2(ex2, y,x);
sol25 : ode2(ex25,y,x);
define(g0(x),  rhs(sol0));
define(g1(x),  rhs(sol1));
define(g2(x),  rhs(sol2));
define(g25(x), rhs(sol25));

       L(g0(x));
expand(L(g0(x)));
expand(L(g1(x)));
expand(L(g2(x)));


   subst(sol1, ex1);
ev(subst(sol1, ex1), 'derivative);
expand(ev(subst(sol1, ex1), 'derivative));

             sol0;
       subst(sol0, ex0);
o : ev(subst(sol0, ex0), 'derivative);
expand(o);                              /* not 0 */
f : rhs(sol0);
L(f);
expand(L(f));                           /* 0 */

                     ex25;
       subst(sol25, ex25);
o : ev(subst(sol25, ex25), 'derivative);
expand(o);




#####
#
# 2024.1-exact
# 2024aug14
#
#####

# «2024.1-exact»  (to ".2024.1-exact")
# (c2m241edosexatasp 5 "uma-questao-de-prova")
# (c2m241edosexatasa   "uma-questao-de-prova")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
diffeq1 : 2*x * y^3 * dx + 3*x^2 * y^2 * dy = 0;
z_y : subst([dx=0,dy=1], lhs(diffeq1));
z_x : subst([dx=1,dy=0], lhs(diffeq1));
exactness : z_xy = z_yx;
z_yx : diff(z_y,x);
z_xy : diff(z_x,y);

diffeq2 : expand(diffeq1/dx);
diffeq3 : subst(dy='diff(y,x)*dx, diffeq2);
sol : ode2(diffeq3,y,x);





#####
#
# 2024-1-C3-P1
# 2024aug05
#
#####

# «2024-1-C3-P1»  (to ".2024-1-C3-P1")
# (c3m241p1p 3 "questao-2")
# (c3m241p1a   "questao-2")
# (c3m241p1p 6 "gab-2")
# (c3m241p1a   "gab-2")
# (to "2023-2-C3-P1")
# (to   "2024.1-stewart-p856-ex10")
# (c2m241pcp 3 "stewart-p856-ex10")
# (c2m241pca   "stewart-p856-ex10")
# http://anggtwu.net/LATEX/2024-1-C3-P1.pdf

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg   "MAXIMA/mkmatrix1.mac")
load         ("~/MAXIMA/mkmatrix1.mac");
** (find-angg   "MAXIMA/myqdraw1.mac")
load         ("~/MAXIMA/myqdraw1.mac");
includegraphics_dir              : "2024-1-C3/";

f(x)   := (x+2)*(x-1);
expand(f(x));
F(x,y) := x^2 + x*y - 2*y^2;
F(x,1);
mkmatrix([x,-2,2], [y,2,-2,-1], x);
mkmatrix([x,-2,2], [y,2,-2,-1], y);
mkmatrix([x,-2,2], [y,2,-2,-1], F(x,y));

z   : F(x,y);
z_x : diff(z,x);
z_y : diff(z,y);
define(Fx(x,y), diff(F(x,y), x));
define(Fy(x,y), diff(F(x,y), y));
mkmatrix([x,-2,2], [y,2,-2,-1], [Fx(x,y),Fy(x,y)]);

z : F(x,y);

[xmin,ymin,xmax,ymax] : [-2,-2,2,2];
mylevel(eq,[opts]) :=
  apply('imp1, append([eq, x,xmin,xmax, y,ymin,ymax], opts));
myvec(xy, dxdy)    := vector(xy, dxdy, hl(0.1), lw(2), lc(gray));
myvecs : create_list(myvec([x,y], [Fx(x,y),Fy(x,y)]/10),
                     x, seq(-2,2), y, seqby(2,-2,-1))$

myQdraw("2024-1-C3-P1-level",     "height=5cm",
        xr(-4,4), yr(-3,3),
        more(proportional_axes=xy),
        mylevel(z=2,  lk("z=2"),  lc(brown)),
        mylevel(z=1,  lk("z=1"),  lc(red)),
        mylevel(z=0,  lk("z=0"),  lc(orange)),
        mylevel(z=-2, lk("z=-2"), lc(forest_green)),
        mylevel(z=-5, lk("z=-5"), lc(blue)),
        myvecs
        /* myvec([2,0], [1,2]) */
       );

** 



#####
#
# 2024-1-C3-P1-Q3
# 2024aug05
#
#####

# «2024-1-C3-P1-Q3»  (to ".2024-1-C3-P1-Q3")
# (to "2023-2-C3-P1")
# (c3m241p1p 4 "questao-3")
# (c3m241p1a   "questao-3")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg   "MAXIMA/myqdraw1.mac")
load         ("~/MAXIMA/myqdraw1.mac");
includegraphics_dir : "2024-1-C3/";
z : x * y * (3-x-y);
gradz : [diff(z,x), diff(z,y)];
gradz : factor(gradz);
crpts : solve(gradz, [x,y]);
hessz : hessian(z, [x,y]);
P1    : [x=0,y=3];
P2    : [x=1,y=1];
P3    : [x=3,y=0];
GH    : [gradz, hessz];
GH    : expand(GH);
GH1   : at(GH, P1);
GH2   : at(GH, P2);
GH3   : at(GH, P3);
[xmin,ymin,xmax,ymax] : [-1,-1,4,4]$
mylevel(eq,[opts]) :=
  apply('imp1, append([eq, x,xmin,xmax, y,ymin,ymax], opts))$
myQdraw("2024-1-C3-P1-Q3", "height=10cm",
        xr(-1,4), yr(-1,4),
        more(proportional_axes=xy),
        mylevel(z=0.98, lk("z=0.98"), lc(gray)),
        mylevel(z=0.2,  lk("z=0.2"),  lc(brown)),
        mylevel(z=0.1,  lk("z=0.1"),  lc(red)),
        mylevel(z=0,    lk("z=0"),    lc(orange)),
        mylevel(z=-0.1, lk("z=-0.1"), lc(forest_green)),
        mylevel(z=-0.2, lk("z=-0.2"), lc(blue))
       );

w    : expand(z);
w_x  : diff(w,x);
w_xx : diff(w,x,2);
w_y  : diff(w,y);
w_yy : diff(w,y,2);
w_xy : diff(w,x,1,y,1);
[P1, P2, P3];
at([w, w_x,w_y, w_xx,w_xy,w_yy], P1);
at([w, w_x,w_y, w_xx,w_xy,w_yy], P2);
at([w, w_x,w_y, w_xx,w_xy,w_yy], P3);





#####
#
# 2024.1-C3-PR1
# 2024aug18
#
#####

# «2024.1-C3-PR1»  (to ".2024.1-C3-PR1")
# http://anggtwu.net/LATEX/2024-1-C3-prova-relampago-1.pdf
# (c3m241pr1p 3 "questoes")
# (c3m241pr1a   "questoes")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/myqdraw1.mac")
load       ("~/MAXIMA/myqdraw1.mac");
includegraphics_dir : "2024-1-C3/";
f(x) := (x-1)*(x-3);
f(2);
expand(f(x));
F(x,y) := x^2 - 4*x*y + 3*y^2;
F(x,1);
factor(F(x,y));
P(t) := [cos(t), sin(t)];
P(0);
define(g(t), apply('F, P(t)));
qdraw(xr(0,2*%pi),
      yr(-5,5),
      more(proportional_axes=xy),
      ex(g(t), t,0,2*%pi));

ts : seqn(0,2*%pi,8);
ts : seqn(0,2*%pi,16);
ts : seqn(0,  %pi,8);
lines : makelist([t,float(g(t))], t,ts);
header : ["t", "F(P(t))"];
stringdisp : false;
append([header], lines);
apply('matrix, append([header], lines));

z : F(x,y);
[xmin,ymin,xmax,ymax] : [-2,-2,2,2];

mylevel(eq,[opts]) :=
  apply('imp1, append([eq, x,xmin,xmax, y,ymin,ymax], opts));
myvec(xy, dxdy)    := vector(xy, dxdy, hl(0.1), lw(2), lc(gray));

myQdraw("2024-1-C3-PR1-levels",     "height=5cm",
        xr(-1,1), yr(-1,1),
        more(proportional_axes=xy),
        mylevel(z=0.2,  lk("z=0.2"),  lc(brown)),
        mylevel(z=0.1,  lk("z=0.1"),  lc(red)),
        mylevel(z=0,    lk("z=0"),    lc(orange)),
        mylevel(z=-0.1, lk("z=-0.1"), lc(forest_green)),
        mylevel(z=-0.2, lk("z=-0.2"), lc(blue))
       );




#####
#
# 2024.1-C3-P2
# 2024aug19
#
#####

# «2024.1-C3-P2»  (to ".2024.1-C3-P2")
# http://anggtwu.net/LATEX/2024-1-C3-P2.pdf
# (c3m241p2p 3 "questao-1")
# (c3m241p2a   "questao-1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg   "MAXIMA/mkmatrix1.mac")
** (find-angg   "MAXIMA/myqdraw1.mac")
load         ("~/MAXIMA/mkmatrix1.mac");
load         ("~/MAXIMA/myqdraw1.mac");
includegraphics_dir : "2024-1-C3/";
[xmin,ymin,xmax,ymax] : [0,0,4,4];
mylevel0(eq,[opts]) := apply('imp1, flatten([[eq, opts]]))$
mylevel (eq,[opts]) := mylevel0(eq, [x,xmin,xmax, y,ymin,ymax, opts])$

FPN(x,y) := y + x^2;          /* parábola, quadrado do norte */
FCS(x,y) := x^2 + (y-2)^2;    /* círculos, quadrado do sul   */
FL (x,y) := x   + (y-2)^2;    /* parábola à esquerda         */
FL (x,y) := x^2 + (y-2)^2;    /* parábola à esquerda         */
G  (x,y) := (x-1)^2 + y^2;    /* círculos nos dois quadrados */

FPN = mkmatrix ([x,0,2], [y,4,0,-1], FPN(x,y));
FCS = mkmatrix ([x,0,2], [y,4,0,-1], FCS(x,y));
FL  = mkmatrix ([x,0,2], [y,4,0,-1], FL (x,y));
G   = mkmatrix ([x,0,2], [y,4,0,-1], G  (x,y));

bordersofD : [mylevel0(FPN(x,y)=4, [x,0,4],   [y,2,4], lc(red),          lk("FPN=4")),
              mylevel0(FL (x,y)=1, [x,0,4],   [y,0,4], lc(gray),         lk("FL=1")),
              mylevel0(y=2,        [x,1.4,2], [y,2,4], lc(brown),        lk("y=2")),
              mylevel0(FCS(x,y)=4, [x,0,2],   [y,0,2], lc(forest_green), lk("FCS=4"))]$

levelG (z)    := mylevel(G(x,y)=z, lc(orange), lk(G=z))$
levelGs([zs]) := map(levelG, reverse(zs))$
levelsofG     :  levelGs(0.1, 1, 1.7, 4.5, 9);

myqdraw(xr(-1,5), yr(-1,5), more(proportional_axes=xy),
        bordersofD, levelsofG,
        []);

P       : [x=1,y=3];
fpn     : FPN(x,y);
fcs     : FCS(x,y);
g       : G(x,y);
grad(z) := [diff(z,x), diff(z,y)]$
atP(z)  := at(z, P)$
uu      : atP(grad(fpn));
vv      : atP(grad(g));
ww      : vv-3*uu;

myvec(xy,dxdy,opts) := apply('vector, append([xy, dxdy, hl(0.1), lw(2)], opts));
myvecP  (dxdy,[opts]) := myvec([1,3], dxdy, opts);
vecsuvw : [myvecP(uu/10, lc(navy), lk("u/10")),
           myvecP(vv/10, lc(blue), lk("v/10")),
           myvecP(ww/10, lc(violet), lk("w/10"))];

myqdraw(xr(-1,5), yr(-1,5), more(proportional_axes=xy),
        bordersofD, levelsofG, vecsuvw,
        []);




#####
#
# 2024.1-C3-VRP1
# 2024aug21
#
#####

# «2024.1-C3-VRP1»  (to ".2024.1-C3-VRP1")
# (c3m241vrp1p 4 "questao-2")
# (c3m241vrp1a   "questao-2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/mkmatrix1.mac")
load       ("~/MAXIMA/mkmatrix1.mac");
F(x,y) := x+y;
G(x,y) := x-y;
H(x,y) := (x-y)^2;
P(x,y) := F(x,y)+H(x,y);
define(gradP(x,y), [diff(P(x,y),x), diff(P(x,y),y)]);

        mkmatrix ([x,-2,2], [y,2,-2,-1], [x,y]);
    F = mkmatrix ([x,-2,2], [y,2,-2,-1], F(x,y));
    G = mkmatrix ([x,-2,2], [y,2,-2,-1], G(x,y));
    H = mkmatrix ([x,-2,2], [y,2,-2,-1], H(x,y));
    P = mkmatrix ([x,-2,2], [y,2,-2,-1], P(x,y));
gradP = mkmatrix ([x,-2,2], [y,2,-2,-1], gradP(x,y));

        mkmatrix ([x,0,4], [y,4,0,-1], x+(y-2)^2);




#####
#
# 2024.1-C3-VS
# 2024aug28
#
#####

# «2024.1-C3-VS»  (to ".2024.1-C3-VS")
# (c3m241vsp 3 "questao-1")
# (c3m241vsa   "questao-1")
# (to "2024.1-C3-VRP1")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/mkmatrix1.mac")
** (find-angg "MAXIMA/myqdraw1.mac")
load       ("~/MAXIMA/mkmatrix1.mac");
load       ("~/MAXIMA/myqdraw1.mac");

F : x+y;
G : x-y;
H : (x-y)^2;
P : F+H;
M : (x-1)^2+y;
gradP : [diff(P,x), diff(P,y)];

mkmatrix ([x,-2,2], [y,2,-2,-1], [x,y]);
mkmatrix ([x,-2,2], [y,2,-2,-1], F);
mkmatrix ([x,-2,2], [y,2,-2,-1], ev(F));
mkmatrix ([x,-2,2], [y,2,-2,-1], ev(gradP));

myqdraw(xr(-1,5), yr(-1,5), more(proportional_axes=xy),
        bordersofD, levelsofG, vecsuvw,
        []);

(find-es "maxima" "2024.1-C3-P2")




#####
#
# 2024.2-C2-teste-niv
# 2024nov15
#
#####

# «2024.2-C2-teste-niv»  (to ".2024.2-C2-teste-niv")
# (c2m242tnp 3 "defs-teste")
# (c2m242tna   "defs-teste")
# (find-maximanode "limit")
# (to "limit")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
lim33 : ((1+h)^10 - 1) / h;
Lim33 : limit(lim33, h,0);

lim34 : ((16+h)^(1/4) - 2) / h;
Lim34 : limit(lim34, h,0);

lim35 : (2^x - 32) / (x - 5);
Lim35 : limit(lim35, x,5);

lim36 : (tan(x) - 1) / (x - %pi/4);
Lim36 : limit(lim36, x,%pi/4);

lim37 : (cos(%pi+h) + 1) / h;
Lim37 : limit(lim37, h,0);

lim38 : (t^4 + t - 2) / (t-1);
Lim38 : limit(lim38, t,1);




#####
#
# 2024.2-C2-MVI3
# 2024oct23
#
#####

# «2024.2-C2-MVI3»  (to ".2024.2-C2-MVI3")
# http://anggtwu.net/2024.2-C2/C2-quadros.pdf#page=27
# http://anggtwu.net/LATEX/2024-1-C2-diferenciais.pdf#page=8
# (find-angg "MAXIMA/3-changevars1.mac")
# (c2m241dip 8 "caso-A")
# (c2m241dia   "caso-A")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)

MVI3_pre() := align_eqs([
    'integrate(diff(f(g(x)), x), x),
    'integrate(diff(f(u),    u), u),
    f(u),
    f(g(x))
  ])$

MVI3_pre();

gradef(f(x), fp(x));
gradef(g(x), gp(x));
MVI3 : MVI3_pre();

f(x) := sin(x);
g(x) := x^2;

MVI3_exemplo1 : MVI3_pre();




#####
#
# 2024.2-C2-fracs-parcs
# 2024nov01
#
#####

# «2024.2-C2-fracs-parcs»  (to ".2024.2-C2-fracs-parcs")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
f : A/(x-a) + B/(x-b);
g : radcan(f);
F : 'integrate(f,x);
G : 'integrate(g,x);

M : matrix([g,  "=", f],
           [G,  "=", F],
           ["", "=", integrate(f,x)]);

S1 : [a=-10, b=-1];
S2 : [B=2, A=3];
           subst(S1, M);
subst(S2, subst(S1, M));

S1 : [a=-100, b=-1];
S2 : [B=2, A=3];
          subst(S1, M);
subst(S2, subst(S1, M));



#####
#
# 2024.2-C2-intro-complex
# 2024nov12
#
#####

# «2024.2-C2-intro-complex»  (to ".2024.2-C2-intro-complex")
# (to "2024.1-intro-complex")
# (c2m242ncp 3 "maxima-dots")
# (c2m242nca   "maxima-dots")
# (find-maximanode "realpart")
# (find-maximanode "imagpart")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-myqdraw "myqdraw3.mac")
** (find-myqdraw "topdf1.mac")
** (find-LATEX "2024-2-C3-maxima-conics.tex" "M-blocks")
** (find-Maxima2-links "dots")
** (c2m242ncp 3 "maxima-dots")
** (c2m242nca   "maxima-dots")
*
* (setq last-kbd-macro (kbd "C-a %M SPC C-a <down>"))
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp")$
:lisp (setf (get '$display2d 'assign) nil)
display2d:'emaxima$
load_myqdraw();
linenum:0;

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load_myqdraw();
[topdf_a,topdf_b,topdf_c,topdf_n] : ["~/LATEX/","2024-2-C2/","complex",0];
linenum:0;

Re(z)    := realpart(z)$
Im(z)    := imagpart(z)$
sqhyp(z) := Re(z)^2 + Im(z)^2$
tom(z)   := matrix([Re(z),-Im(z)], [Im(z),Re(z)])$
det(M)   := determinant(M)$
nm(z)    := Re(z) + %i*Im(z)$
stringdisp : false$
z : a + %i*b;
w : c + %i*d;
matrix([    z , "+",     w , "=",   nm(z+w)],
       [tom(z), "+", tom(w), "=", tom(z)+tom(w)],
       [    "",  "",     "",  "",      ""      ],
       [    z , "*",     w , "=",   nm(z*w)    ],
       [tom(z), ".", tom(w), "=", tom(z).tom(w)]);

drawzpts (zs,[opts]) := myqdrawp(xyrange(), zpts(zs, opts))$
[xmin,ymin, xmax,ymax] :  [-5,-5, 5,5]$
myqdrawp_to_screen()$  myps(size) := ps(size)$
myqdrawp_to_new_pdf()$ myps(size) := ps(size/5)$

as_33     : create_list(x+%i*y, y,seqn(2,0,2), x,seqn(0,2,2));
as_55     : create_list(x+%i*y, y,seqn(2,0,4), x,seqn(0,2,4))$
as_22     : create_list(x+%i*y, y,seqn(0,1,1), x,seqn(0,1,1))$
 D1 : drawzpts(as_33,          myps(3), pc(red))$
 D2 : drawzpts(as_55,          myps(3), pc(red))$
[D1, D2];
 D3 : drawzpts(as_55 + 1,      myps(3), pc(orange))$
 D4 : drawzpts(as_55 + %i,     myps(3), pc(orange))$
[D3, D4];
 D5 : drawzpts(as_55 * 2,      myps(3), pc(forest_green))$
 D6 : drawzpts(as_55 * (1+%i), myps(3), pc(forest_green))$
[D2, D5, D6];

topdf_opts : "height=10cm"$
as_332    : create_list(z+w, z,as_33, w,as_22*0.2)$
as_332_sq : makelist(z^2, z, as_332)$
[xmin,ymin, xmax,ymax] :  [-10,-10, 10,10];
 D7 : drawzpts(as_332,    myps(0.5))$
 D8 : drawzpts(as_332_sq, myps(0.5))$
[D7, D8];





sqhyp(z);
[cabs(z*w), sqrt(sqhyp(z*w))];
[cabs(z*w), cabs(z)*cabs(w)];

M(z,w) := align_eqs([cabs(z*w),
                    sqrt(sqhyp(z*w)),
                    sqrt(sqhyp(z)*sqhyp(w)),
                    sqrt(sqhyp(z))*sqrt(sqhyp(w)),
                    cabs(z)*cabs(w)]);
M(z,w);


xyrange(r) := [xr(-r,r), yr(-r,r), more(proportional_axes=xy)];

myqdraw_nhr(n,h,r,[rest]) :=
  myQdraw(format("complex-~a",n), format("height=~acm",h), xyrange(r), rest);

myqdraw_nhr(1,5,4, zpts(as_33,    myps(4),pc(red)));
myqdraw_nhr(2,5,4, zpts(as_55,    myps(4),pc(orange)));
myqdraw_nhr(3,5,4, zpts(as_55+1,  myps(4),pc(orange)));
myqdraw_nhr(4,5,4, zpts(as_55+%i, myps(4),pc(orange)));
myqdraw_nhr(5,5,4, zpts(as_55*2,  myps(4),pc(orange)));
myqdraw_nhr(6,5,4, zpts(as_55*(1+%i), myps(4),pc(orange)));

linenum:11;
asq_33 : makelist(z^2, z, as_33);
asq_55 : makelist(z^2, z, as_55);
myqdraw_nhr(7,5,8, zpts(asq_33, myps(4),pc(red)));
myqdraw_nhr(8,5,8, zpts(asq_55, myps(1),pc(red)));

as_22   : create_list(x+%i*y, y, seqn(0,1,1), x, seqn(0,1,1));
as_332  : create_list(z+w,    z, as_33, w, as_22*0.2);
asq_332 : makelist(z^2, z, as_332);
myqdraw_nhr( 9,5,10,  zpts(as_332, myps(1),pc(red)));
myqdraw_nhr(10,5,10, zpts(asq_332, myps(1),pc(red)));




#####
#
# 2024.2-C2-P1
# 2024dec10
#
#####

# «2024.2-C2-P1»  (to ".2024.2-C2-P1")
# (c2m242p1p 4 "questao-2")
# (c2m242p1a   "questao-2")

** (c2m242p1p 4 "questao-1" "a))
** (c2m242p1a   "questao-1" "a)")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/changevarbyhand1.mac")
load       ("~/MAXIMA/changevarbyhand1.mac");
** (find-lisptree "lisptree.mac")
load  ("~/lisptree/lisptree.mac");

f  :   x^3 * sqrt( 1-x^2)^3;
g  : 4*x^3 * sqrt(25-x^2)^3;
F  :  integrate(f,x);
G  : 'integrate(g,x);
G2 : changevar0_byhand (g, x=5*u, u, x);
lisptree(G2);
     traverse(G2, 2);
h  : traverse(G2, 2, 1, 2);
h2 : (5^2 - 5^2*u^2)^(3/2);
h3 : (5^2 * (1 - u^2))^(3/2);
display2d:false;
G2;
     2500*'integrate(u^3*(25-25*u^2)^(3/2),u);
     2500*'integrate(u^3*       h2        ,u);
G3 : 2500*'integrate(u^3*       h3        ,u);
display2d:true;
G4 : ev(G3, integrate);
G5 : subst(u=x/5, G4);
G6 : expand(G5);

F;

** (c2m242p1p 4 "questao-1" "b)")
** (c2m242p1a   "questao-1" "b)")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
sqx : sqrt(1-x^2);
F1 : 'integrate(x^3 * sqx^3, x);
F2 :  integrate(x^3 * sqx^3, x);
F3 :  sqx^7/7 - sqx^5/5;
radcan(F2);
radcan(F3);

** (c2m242p1p 4 "questao-2")
** (c2m242p1a   "questao-2")
** (to "divide")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
fup : (x^3 + 6*x^2 - 22*x - 55);
fdn :                             (x^2 + 4*x - 21);
f   : (x^3 + 6*x^2 - 22*x - 55) / (x^2 + 4*x - 21);
F   : integrate(f,x);
g   : diff(F,x);
g   : expand(g);
[q,r] : divide(fup, fdn, x);
matrix([fup, fdn],[r, q]);
factor(fdn);
together(f) := ratsimp(f);
apart(f)    := partfrac(f,x);
f1 : f;
f2 : q + r/fdn;
f3 : q + r/factor(fdn);
f4 : q + apart(r/factor(fdn));
align_eqs([f1, f2, f3, f4]);
integrate(f1,x);
integrate(f4,x);

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (c2m242p1p 4 "questao-3")
** (c2m242p1a   "questao-3")
f1 : cos(x)*(cos(5*x)^2);
f2 :                        exponentialize(f1);
f3 :                 expand(exponentialize(f1));
f4 :        demoivre(expand(exponentialize(f1)));
f4 : expand(demoivre(expand(exponentialize(f1))));
F1 : 'integrate(f1,x);
F4 :  integrate(f4,x);





#####
#
# 2024.2-C3-intro
# 2024oct23
#
#####

# «2024.2-C3-intro»  (to ".2024.2-C3-intro")
# (find-es "maxima" "MpgP18")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/myqdraw1.mac")
load       ("~/MAXIMA/myqdraw1.mac");
** (find-angg "MAXIMA/mycolorlerp1.mac")
load       ("~/MAXIMA/mycolorlerp1.mac");

u(x,y) := 2*x - y;
v(x,y) := 3*x + 4*y;

u(x,y) := x;
v(x,y) := x+y;

eqs1 : [u=u(x,y), v=v(x,y)];
eqs2 : solve(eqs1, [x,y]);
define(x(u,v), subst(eqs2, x));
define(y(u,v), subst(eqs2, y));
define(uv(x,y), [u(x,y),v(x,y)]);
define(xy(u,v), [x(u,v),y(u,v)]);

[xmin,xmax,ymin,ymax] : [-4,4,-4,4];
/*
qdraw(xr(xmin,xmax), yr(ymin,ymax), more(proportional_axes=xy),
      imp([u(x,y)=-1, u(x,y)=0, u(x,y)=1,
           v(x,y)=-1, v(x,y)=0, v(x,y)=1,
           u(x,y)^2 + v(x,y)^2 = 1],
          x,xmin,xmax,
          y,ymin,ymax));
*/

** (find-ecolors "dark orange" "#ff8c00")
** (find-ecolors      "orange" "#ffa500")
** (find-ecolors "medium blue" "#0000cd")
[coloru[-1],coloru[0],coloru[1]] : fromwhite("#ff0000", [0.4, 0.6, 1.0]);
[colorv[-1],colorv[0],colorv[1]] : fromwhite("#ff8c00", [0.4, 0.6, 1.0]);
[colorv[-1],colorv[0],colorv[1]] : fromwhite("#ffa500", [0.4, 0.6, 1.0]);
colorc : blue;
colorc : "#0000cd";

myline([args]) := apply('line, flatten([args]));

myuline(thisu,[args]) :=
  myline(xy(thisu,-2),xy(thisu,2),
         lc(coloru[thisu]),
         lk(format("u=~a",thisu)));

myvline(thisv,[args]) :=
  myline(xy(-2,thisv),xy(2,thisv),
         lc(colorv[thisv]),
         lk(format("v=~a",thisv)));

[xmin,xmax,ymin,ymax] : [-4,4,-4,4];
myimp1(expr,[opts]) := myapply('imp1, expr,x,xmin,xmax,y,ymin,ymax, opts);

myulines() := makelist(myuline(thisu), thisu, [1,0,-1]);
myvlines() := makelist(myvline(thisv), thisv, [1,0,-1]);
myuvcircle() := myimp1(u(x,y)^2+v(x,y)^2=1, lc(colorc), lk("u^2+v^2=1"));

myqdraw(xr(xmin,xmax), yr(ymin,ymax), more(proportional_axes=xy),
        myulines(), myvlines(), myuvcircle());




#####
#
# 2024.2-C3: Mais trajetórias, exercício 9 - órbita
# 2024oct17
#
#####

# «2024.2-C3-traj-9»  (to ".2024.2-C3-traj-9")
# (c3m242trajp 20 "orbita")
# (c3m242traja    "orbita")
# (to "qdraw-orbita")




#####
#
# 2024.2-C3-piramide
# 2024oct21
#
#####

# «2024.2-C3-piramide»  (to ".2024.2-C3-piramide")
# (c3m211cnp 15 "figura-piramide")
# (c3m211cna    "figura-piramide")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-myqdraw "myqdraw3.mac")
load_myqdraw();
p(t)   := min(t-2,6-t);
q(t)   := max(0,p(t));
R(x,y) := min(q(x),q(y));
plot3d (R(x,y), [x, 0, 8], [y, 0, 8]);

xyrange() := [xr(0,8), yr(-1,4), more(proportional_axes=xy)];
myqdraw(xyrange(),
        ex1(p(t), t,0,8, lc(orange)),
        ex1(q(t), t,0,8, lc(red)));




#####
#
# 2024.2-C3: Low Poly, exercícios sobre as pirâmides 1 e 2
# 2024oct30
#
#####

# «2024.2-C3-piramides-1-2»  (to ".2024.2-C3-piramides-1-2")
# (find-angg "GNUPLOT/piramide-1.dem")
# (find-angg "GNUPLOT/piramide-2.dem")
# (find-bgprocess "gnuplot ~/GNUPLOT/piramide-1.dem")
# (find-bgprocess "gnuplot ~/GNUPLOT/piramide-2.dem")
# 3hT75 <http://anggtwu.net/LATEX/2023-2-C3-Tudo.pdf#page=75> Uma pirâmide
# 3hT84 <http://anggtwu.net/LATEX/2023-2-C3-Tudo.pdf#page=84> Exercício 15
# 3hT85 <http://anggtwu.net/LATEX/2023-2-C3-Tudo.pdf#page=84> Exercício 16

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
mkmatrix5(x,xs,y,ys,expr) ::=
  buildq([x,xs,y,ys,expr],
         apply('matrix,
               makelist(makelist(expr,x,xs),y,ys)));

z_N : 7 - y;
z_E : 7 - x;
z_W : x - 1;
z_S : y - 1;
z_B : 0;
z_P : max(z_B, min(z_N, z_W, z_E, z_S));

z_SW1 : 1;
z_SW2 : -4 + x + y;
z_SW  : max(z_SW1, z_SW2);
z_P2  : min(z_P, z_SW);

mkmatrix5(x,seq(0,8), y,seqby(8,0,-1), [x,y]);
mkmatrix5(x,seq(0,8), y,seqby(8,0,-1), ''z_P);
mkmatrix5(x,seq(0,8), y,seqby(8,0,-1), ''z_SW);
mkmatrix5(x,seq(0,8), y,seqby(8,0,-1), ''z_P2);

plot3d (z_P,  [x, 0, 8], [y, 0, 8]);
plot3d (z_P2, [x, 0, 8], [y, 0, 8]);

/* Exercício 15
 * 3hT84 - http://anggtwu.net/LATEX/2023-2-C3-Tudo.pdf#page=84
*/
define(F(x,y), z_P);

"a)"$  F(1.5, 3);
"b)"$  F(1.1, 3);
"c)"$  F(5.1, 3);
"d)"$  F(5.1, 2);

"e)"$  F(5.2, 2.3);
"f)"$  F(5.2, 1.9);
"g)"$  F(3.1, 2.1);
"h)"$  F(2.9, 1.9);

/* Exercício 16
 * 3hT85 - http://anggtwu.net/LATEX/2023-2-C3-Tudo.pdf#page=85
*/
define(F(x,y), z_P2);

"a)"$  F(2.1, 2.1);
"b)"$  F(2.5, 2.5);
"c)"$  F(2.6, 2.6);

/* Exercício 17
 * 3hT86 - http://anggtwu.net/LATEX/2023-2-C3-Tudo.pdf#page=86
*/
define(f(x,y), z_P);
pp : [2,3];
vv : [2,0];
foo (t) :=            pp+t*vv;
bar (t) :=  apply('f, pp+t*vv);
plic(t) :=  apply('f, pp+t*vv) - apply('f, pp);
ploc(t) := (apply('f, pp+t*vv) - apply('f, pp)) / t;

"a)"$ ploc(1);
"b)"$ ploc(2);
"c)"$ ploc(3);
"d)"$ ploc(1/2);

"e)"$ ploc(1/4);
"f)"$ ploc(-1);
"g)"$ ploc(-1/2);
"h)"$ ploc(-1/4);

line(t) := [t, foo(t), bar(t), plic(t)];
topline : rhs(fundef(line));
ts : [-1, 0, 1, 1, 2, 3];
apply('matrix, append([topline], map('line, ts)));

line(t) := [t, foo(t), bar(t), plic(t), ploc(t)];
topline : rhs(fundef(line));
ts : [-1, -1/2, -1/4, 1/4, 1/2, 1, 2, 3];
apply('matrix, append([topline], map('line, ts)));



#####
#
# 2024.2-C3-2022.2-P1
# 2024nov11
#
#####

# «2024.2-C3-2022.2-P1»  (to ".2024.2-C3-2022.2-P1")
# (c3m222p1p 4 "questao-2-gab")
# (c3m222p1p 6 "questao-2-gab")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
linel : 110;
mkmatrix1(expr) ::=
  buildq([expr],
         apply('matrix,
               makelist(makelist(expr,x,[-2,-1,0,1,2]),y,[2,1,0,-1,-2])));

F     : 2*x^2 - x*y - y^2;
gradF : [diff(F,x), diff(F,y)];
define(    F(x,y),     F);
define(gradF(x,y), gradF);

mkmatrix1([x,y]);
mkmatrix1(x);
mkmatrix1(''F);
mkmatrix1(''gradF);

gradF;                /* 4x-y, -2y-x */
[mkmatrix1(4*x    ),
 mkmatrix1(    - y),
 mkmatrix1(4*x - y)];

[mkmatrix1(-2*y    ),
 mkmatrix1(     - x),
 mkmatrix1(-2*y - x)];

mkmatrix1(''gradF);





#####
#
# 2024.2-C3-eigenvectors
# 2024dec03
#
#####

# «2024.2-C3-eigenvectors»  (to ".2024.2-C3-eigenvectors")

* (setq last-kbd-macro (kbd "C-a %M SPC C-a <down>"))
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp")$
:lisp (setf (get '$display2d 'assign) nil)
display2d:'emaxima$
load_myqdraw();
linenum:0;

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-myqdraw "myqdraw3.mac")
load_myqdraw();

[topdf_a,topdf_b,topdf_c,topdf_n] : ["~/LATEX/", "2024-2-C3/", "eigenvectors", 0];
myqdrawp_to_screen (); myps(s):=ps(s);
myqdrawp_to_new_pdf(); myps(s):=ps(s/5);  "Skip this line to draw to the screen"$
linenum:0;

[[r1,r2], k, [zneg,zpos]] : [[-2,-1], 10, [-5,10]];
[xmin,ymin,xmax,ymax] : [-5,-5, 5,5];

f : k * (x -   r1) * (x -   r2);
F : k * (x - y*r1) * (x - y*r2);
f : expand(f);
F : expand(F);
define(f(x),   f);
define(F(x,y), F);

solve(f(x)=0, x);
[r1,r2];

drawlevels() :=
  [myimp1(F=zpos, lc(red),    lk(z=zpos)),
   myimp1(F=0,    lc(orange), lk(z=0)),
   myimp1(F=zneg, lc(blue),   lk(z=zneg))]$
drawroots() := pts([[r1,1], [r2,1]], pc(forest_green), pk("r1,r2"), myps(3))$
drawunitcircle() := mypara([cos(th),sin(th)], th,0,2*%pi, lc(gray))$

myqdrawp(xyrange(), drawlevels(), drawroots(), drawunitcircle());

/* (find-myqdraw "myqdraw3.mac" "myex")
*/
myexth(fth,[opts]) := myapply_fl('ex1, fth, th,0,2*%pi, opts);

F;
z1 : subst([y=cos(th), x=sin(th)], F);
block(
  [xmin,xmax,ymin,ymax],
  [xmin,xmax,ymin,ymax] : [0,2*%pi, -40,40],
  myqdrawp(xyrange0(), myexth(z1))
  );

F_x  : diff(F,x);
F_y  : diff(F,y);
F_xx : diff(F,x,2);
F_xy : diff(F,x,1,y,1);
F_yy : diff(F,y,2);

M : matrix([F_xx, F_xy],
           [F_xy, F_yy]);
determinant(M);

[vals,vectors]    : eigenvectors(M)$
[lambda1,lambda2] : vals[1];
[v1,v2]           : [vectors[1][1], vectors[2][1]];

fpprintprec;
fpprintprec : 3;
float([lambda1,v1]);
float([lambda2,v2]);

       lambda1 * lambda2;
expand(lambda1 * lambda2);
[M, determinant(M)];

myvector(v,[opts]) := myapply_fl('vector, [0,0], v, hl(0.2), opts)$
draweigenvectors() :=
  [myvector(v1, lc(gray)),
   myvector(v2, lc(gray))]$

myqdrawp(xyrange(), drawlevels(), drawroots(),
         drawunitcircle(), draweigenvectors());

/* (find-fline "~/LATEX/2024-2-C3/")
*/



#####
#
# 2024.2-C3-P1-Q1
# 2024dec11
#
#####

# «2024.2-C3-P1-Q1»  (to ".2024.2-C3-P1-Q1")
# (c3m242p1p 3 "questao-1")
# (c3m242p1a   "questao-1")
# (to "2024.2-C3-piramides-1-2")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
mkmatrix5(x,xs,y,ys,expr) ::=
  buildq([x,xs,y,ys,expr],
         apply('matrix,
               makelist(makelist(expr,x,xs),y,ys)));
linel : 115;

** (c3m242p1p 7 "gab-1" "(1a)")
** (c3m242p1a   "gab-1")

** (c3m242p1p 3 "questao-1" "(1b)")
** (c3m242p1a   "questao-1"   "b)")
z_N  : 6;
z_S  : 0;
z_W  : y - 1;
z_C  : y - x + 1;
z_E  : -12 + 2*y;
z_NE : -4 + y;
z_MR : min(z_E, z_NE);            /* middle right */
z_M  : min(z_W, max(z_C, z_MR));  /* middle */
z    : min(z_N, max(z_S, z_M));
mkmatrix5(x,seq(0,9), y,seqby(11,0,-1), [x,y]);
mkmatrix5(x,seq(0,8), y,seqby(11,0,-1), ''z);
** (find-angg "GNUPLOT/2024-2-C3-P1.dem")
** (find-angg "GNUPLOT/2024-2-C3-P1.dem" "bgprocess")
/*
plot3d (z,   [x,0,8],   [y,0,11]);
*/

** (c3m242p1p 3 "questao-1" "(1c)")
** (c3m242p1a   "questao-1"   "c)")
            [zr_=z_C, zr_=z_E];
      solve([zr_=z_C, zr_=z_E], [y,zr_]);
eqc : solve([zr_=z_C, zr_=z_E], [y,zr_])[1];
define(yr_(x), subst(eqc, y));
define(zr_(x), subst(eqc, zr_));
xyzr(x)    := [x, yr_(x), zr_(x)];
xyzr_top   : rhs(fundef(xyzr));
xyzr_lines : makelist(xyzr(x), x,2,9);
apply('matrix, append([xyzr_top], xyzr_lines));

** (c3m242p1p 3 "questao-1" "(1d)")
** (c3m242p1a   "questao-1"   "d)")
[x, yr_(x), zr_(x)];

** (c3m242p1p 3 "questao-1" "(1e)")
** (c3m242p1a   "questao-1"   "e)")
define(z(x,y), z);
eps : 1/4;
z_xr (x,y) := (z(x+eps,y)-z(x,y))/ eps;
z_xl (x,y) := (z(x-eps,y)-z(x,y))/-eps;
z_yu (x,y) := (z(x,y+eps)-z(x,y))/ eps;
z_yd (x,y) := (z(x,y-eps)-z(x,y))/-eps;
gradz(x,y) := if (z_xr(x,y) = z_xl(x,y)) and
                 (z_yu(x,y) = z_yd(x,y))
              then [z_xr(x,y), z_yu(x,y)]
              else "X";
mkmatrix5(x,seq(0,8), y,seqby(11,0,-1), gradz(x,y));

** (c3m242p1p 3 "questao-1" "(1f)")
** (c3m242p1a   "questao-1"   1f)")
** (find-myqdraw "myqdraw3.mac")
load_myqdraw();
[xmin,xmax, ymin,ymax] : [0,9, 0,7];
Q(t) := [0,2] + t*[1,1];
define(xQ(t), Q(t)[1]);
define(yQ(t), Q(t)[2]);
                   [x=xQ(t),x=yQ(t)];
define(h(t), at(z, [x=xQ(t),y=yQ(t)]));
myqdraw(xyrange(), myex1(h(x), lc(red)));




#####
#
# 2024.2-C3-P1-Q1-latex
# 2024dec16
#
#####

# «2024.2-C3-P1-Q1-latex»  (to ".2024.2-C3-P1-Q1-latex")
# (c3m242p1p 6 "gab-1-maxima")
# (c3m242p1a   "gab-1-maxima")

* (setq last-kbd-macro (kbd "C-a %M SPC C-a <down>"))
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp")$
:lisp (setf (get '$display2d 'assign) nil)
display2d:'emaxima$
load_myqdraw();
[topdf_a,topdf_b,topdf_c,topdf_n] : ["~/LATEX/", "2024-2-C3/", "P1-Q1", 0];
myqdrawp_to_screen (); myps(s):=ps(s);
myqdrawp_to_new_pdf(); myps(s):=ps(s/5);  "Skip this line to draw to the screen"$
linenum:0;
linel : 115;
linenum:0;
mkmatrix5(x,xs,y,ys,expr) ::=
  buildq([x,xs,y,ys,expr],
         apply('matrix,
               makelist(makelist(expr,x,xs),y,ys)))$
/* (1a) */
/* (1b) */
z_N  : 6;
z_S  : 0;
z_W  : y - 1;
z_C  : y - x + 1;
z_E  : -12 + 2*y;
z_NE : -4 + y;
z_MR : min(z_E, z_NE);            /* middle right */
z_M  : min(z_W, max(z_C, z_MR));  /* middle */
z    : min(z_N, max(z_S, z_M));
mkmatrix5(x,seq(0,9), y,seqby(11,0,-1), [x,y]);
mkmatrix5(x,seq(0,8), y,seqby(11,0,-1), ''z);
/*
plot3d (z,   [x,0,8],   [y,0,11]);
*/

/* (1c) */
            [zr_=z_C, zr_=z_E];
      solve([zr_=z_C, zr_=z_E], [y,zr_]);
eqc : solve([zr_=z_C, zr_=z_E], [y,zr_])[1];
define(yr_(x), subst(eqc, y));
define(zr_(x), subst(eqc, zr_));
xyzr(x)    := [x, yr_(x), zr_(x)];
xyzr_top   : rhs(fundef(xyzr));
xyzr_lines : makelist(xyzr(x), x,2,9);
apply('matrix, append([xyzr_top], xyzr_lines));

/* (1d) */
[x, yr_(x), zr_(x)];

/* (1e) */
define(z(x,y), z);
eps : 1/4;
z_xr (x,y) := (z(x+eps,y)-z(x,y))/ eps;
z_xl (x,y) := (z(x-eps,y)-z(x,y))/-eps;
z_yu (x,y) := (z(x,y+eps)-z(x,y))/ eps;
z_yd (x,y) := (z(x,y-eps)-z(x,y))/-eps;
gradz(x,y) := if (z_xr(x,y) = z_xl(x,y)) and
                 (z_yu(x,y) = z_yd(x,y))
              then [z_xr(x,y), z_yu(x,y)]
              else "X";
mkmatrix5(x,seq(0,8), y,seqby(11,0,-1), gradz(x,y));

/* (1f) */
[xmin,xmax, ymin,ymax] : [0,9, 0,7];
Q(t) := [0,2] + t*[1,1];
define(xQ(t), Q(t)[1]);
define(yQ(t), Q(t)[2]);
                   [x=xQ(t),x=yQ(t)];
define(h(t), at(z, [x=xQ(t),y=yQ(t)]));
myqdrawp(xyrange(), myex1(h(x), lc(red)));






#####
#
# 2024.2-C3-P1-Q2
# 2024dec11
#
#####

# «2024.2-C3-P1-Q2»  (to ".2024.2-C3-P1-Q2")
# (c3m242p1p 5 "questao-2")
# (c3m242p1a   "questao-2")

** (c3m242p1p 4 "algumas-defs")
** (c3m242p1a   "algumas-defs")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
gradef(W  (x,y), W_x (x,y), W_y (x,y));
gradef(W_x(x,y), W_xx(x,y), W_xy(x,y));
gradef(W_y(x,y), W_xy(x,y), W_yy(x,y));

diff6(F)         := [F,
                     diff(F,x),   diff(F,y),
                     diff(F,x,2), diff(F,x,1,y,1), diff(F,y,2)]$
M6_(a,b,c,d,e,f) := matrix([a,"",""], [b,c,""], [d,e,f])$
T6_(a,b,c,d,e,f) := a + b*Dx + c*Dy + d*Dx^2/2 + e*Dx*Dy + f*Dy^2$
M6 (abcdef)      := apply('M6_, abcdef)$
T6 (abcdef)      := apply('T6_, abcdef)$
atxy(expr,x0y0)  := at(expr, [x=x0y0[1], y=x0y0[2]])$
D2(F)            := M6(diff6(F))$
T2(x0y0,F)       := T6(atxy(diff6(F),x0y0))$
DxDyat(x0y0)     := [Dx=x-x0y0[1], Dy=y-x0y0[2]]$
T2exp(x0y0,F)    := subst(DxDyat(x0y0), T2(x0y0,F))$

M6_ (1,2,3,4,5,6);
M6 ([1,2,3,4,5,6]);
        D2(W(x,y));
     diff6(W(x,y));
atxy(diff6(W(x,y)),[x0,y0]);
DxDyat([3,4]);
T2    ([3,4],W(x,y));
T2exp ([3,4],W(x,y));

** (c3m242p1p 5 "questao-2")
** (c3m242p1a   "questao-2")
F  : x*y*(6 -2*x -y);
F  : expand(F);
P1 : [0,6];
P2 : [1,2];
P3 : [3,0];
P4 : [0,0];

** (c3m242p1p 5 "questao-2" "(2a)")
** (c3m242p1a   "questao-2"   "a)")
D2F   :      D2(F);

** (c3m242p1p 5 "questao-2" "(2b)")
** (c3m242p1a   "questao-2"   "b)")
D2FP1 : atxy(D2(F),P1);
D2FP2 : atxy(D2(F),P2);
D2FP3 : atxy(D2(F),P3);
D2FP4 : atxy(D2(F),P4);

** (c3m242p1p 5 "questao-2" "(2c)")
** (c3m242p1a   "questao-2"   "c)")
T2(P1,F);
T2(P2,F);
T2(P3,F);
T2(P4,F);

** (c3m242p1p 5 "questao-2" "(2d)")
** (c3m242p1a   "questao-2"   "d)")
grad(F) := [diff(F,x),diff(F,y)]$
   H(F) := hessian(F, [x,y])$
detH(F) := determinant(H(F))$
crit(F) := [F, grad(F), H(F), detH(F)]$
crit(W(x,y));
atxy(crit(F), P1);
atxy(crit(F), P2);
atxy(crit(F), P3);
atxy(crit(F), P4);

** (c3m242p1p 5 "questao-2" "(2e), preparação")
** (c3m242p1a   "questao-2"   "e)")
F;
    T2   (P2,F);
G : T2exp(P2,F);
G : expand(G);

atxy(D2(F),P2);
atxy(D2(G),P2);

numsB(expr) :=
  apply(matrix,
        makelist(makelist(ev(expr), x,0,3),
                 y, seqby(6,0,-1)))$
numsB([x,y]);

** (c3m242p1p 5 "questao-2" "(2e)")
** (c3m242p1a   "questao-2"   "e)")
numsB(F);

** (c3m242p1p 5 "questao-2" "(2f)")
** (c3m242p1a   "questao-2"   "f)")
numsB(G);

** (c3m242p1p 5 "questao-2" "(2g)")
** (c3m242p1a   "questao-2"   "g)")
** (find-myqdraw "myqdraw3.mac")
** (find-myqdraw "myqdraw3.mac" "myimp")
load_myqdraw()$
[xmin,ymin, xmax,ymax] : [-1,-1, 4,7]$
level(zz,color) := myimp1(F=zz, lc(color), lk(z=zz))$
levels() := [level( 3.95, gray),
             level( 3.90, gray),
             level( 3.85, gray),
             level( 3,    red),
             level( 2,    orange),
             level( 1,    gold),
             level( 0,    forest_green),
             level(-1,    blue)]$

** As curvas de nível da F, sem os vetores gradientes:
level(zz,color) := myimp1(F=zz, lc(color), lk(z=zz))$
myqdraw(xyrange(), levels());

** As curvas de nível da G, sem os vetores gradientes:
level(zz,color) := myimp1(G=zz, lc(color), lk(z=zz))$
myqdraw(xyrange(), levels());

** Os conjuntos B e C:
B : create_list([x,y], y,seqby(6,0,-1), x,seq(0,3));
eq1 : y = 6 - 2*x;
eq2 : solve(eq1,x);
subst(eq2, x);
define(xmaxC(y), subst(eq2, x));
C : create_list([x,y], y,seqby(6,0,-1), x,seq(0,xmaxC(y)));

** (find-es "qdraw" "pts")
myqdraw(xyrange(), pts(B, pc(red)));
myqdraw(xyrange(), pts(C, pc(red)));

** O gradiente da F nos pontos de B:
numsB(     grad(F)       );
numsB(atxy(grad(F),[x,y]));

** O gradiente da F nos pontos de C:
** (find-myqdraw "myqdraw3.mac" "myPv")
define(v_at (xy), atxy(grad(F)/10,xy));
define(Pv_at(xy), myPv(xy,v_at(xy),[ps(1)],hl(0.15)));
Pv_at([1,3]);
grads_at_C : makelist(Pv_at(xy), xy, C)$
myqdraw(xyrange(), grads_at_C);

** O gradiente da F nos pontos de C e as curvas de nível:
level(zz,color) := myimp1(F=zz, lc(color), lk(z=zz))$
myqdraw(xyrange(), levels(), grads_at_C);




#####
#
# 2024.2-C3-P1-Q2-latex
# 2024dec16
#
#####

# «2024.2-C3-P1-Q2-latex»  (to ".2024.2-C3-P1-Q2-latex")

* (setq last-kbd-macro (kbd "C-a %M SPC C-a <down>"))
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("/usr/share/emacs/site-lisp/maxima/emaxima.lisp")$
:lisp (setf (get '$display2d 'assign) nil)
display2d:'emaxima$
load_myqdraw();
[topdf_a,topdf_b,topdf_c,topdf_n] : ["~/LATEX/", "2024-2-C3/", "P1-Q2", 0];
myqdrawp_to_screen (); myps(s):=ps(s);
myqdrawp_to_new_pdf(); myps(s):=ps(s/5);  "Skip this line to draw to the screen"$
linenum:0;
linel : 115;
linenum:0;
mkmatrix5(x,xs,y,ys,expr) ::=
  buildq([x,xs,y,ys,expr],
         apply('matrix,
               makelist(makelist(expr,x,xs),y,ys)))$

/* Algumas definicoes */
gradef(W  (x,y), W_x (x,y), W_y (x,y))$
gradef(W_x(x,y), W_xx(x,y), W_xy(x,y))$
gradef(W_y(x,y), W_xy(x,y), W_yy(x,y))$

diff6(F)         := [F,
                     diff(F,x),   diff(F,y),
                     diff(F,x,2), diff(F,x,1,y,1), diff(F,y,2)]$
M6_(a,b,c,d,e,f) := matrix([a,"",""], [b,c,""], [d,e,f])$
T6_(a,b,c,d,e,f) := a + b*Dx + c*Dy + d*Dx^2/2 + e*Dx*Dy + f*Dy^2$
M6 (abcdef)      := apply('M6_, abcdef)$
T6 (abcdef)      := apply('T6_, abcdef)$
atxy(expr,x0y0)  := at(expr, [x=x0y0[1], y=x0y0[2]])$
D2(F)            := M6(diff6(F))$
T2(x0y0,F)       := T6(atxy(diff6(F),x0y0))$
DxDyat(x0y0)     := [Dx=x-x0y0[1], Dy=y-x0y0[2]]$
T2exp(x0y0,F)    := subst(DxDyat(x0y0), T2(x0y0,F))$

M6_ (1,2,3,4,5,6);
M6 ([1,2,3,4,5,6]);
        D2(W(x,y));
     diff6(W(x,y));
atxy(diff6(W(x,y)),[x0,y0]);
DxDyat([3,4]);
T2    ([3,4],W(x,y));
T2exp ([3,4],W(x,y));

F  : x*y*(6 -2*x -y);
F  : expand(F);
P1 : [0,6]$
P2 : [1,2]$
P3 : [3,0]$
P4 : [0,0]$

/* (2a) */
D2F   :      D2(F);

/* (2b) */
D2FP1 : atxy(D2(F),P1);
D2FP2 : atxy(D2(F),P2);
D2FP3 : atxy(D2(F),P3);
D2FP4 : atxy(D2(F),P4);

/* (2c) */
T2(P1,F);
T2(P2,F);
T2(P3,F);
T2(P4,F);

/* (2d) */
grad(F) := [diff(F,x),diff(F,y)]$
   H(F) := hessian(F, [x,y])$
detH(F) := determinant(H(F))$
crit(F) := [F, grad(F), H(F), detH(F)]$
crit(W(x,y));
atxy(crit(F), P1);
atxy(crit(F), P2);
atxy(crit(F), P3);
atxy(crit(F), P4);

/* (2e), preparacao */
F;
    T2   (P2,F);
G : T2exp(P2,F);
G : expand(G);

atxy(D2(F),P2);
atxy(D2(G),P2);

numsB(expr) :=
  apply(matrix,
        makelist(makelist(ev(expr), x,0,3),
                 y, seqby(6,0,-1)))$
numsB([x,y]);

/* (2e) */
numsB(F);

/* (2f) */
numsB(G);

/* (2g) */
[xmin,ymin, xmax,ymax] : [-1,-1, 4,7]$
level(zz,color) := myimp1(F=zz, lc(color), lk(z=zz))$
levels() := [level( 3.95, gray),
             level( 3.90, gray),
             level( 3.85, gray),
             level( 3,    red),
             level( 2,    orange),
             level( 1,    gold),
             level( 0,    forest_green),
             level(-1,    blue)]$

/* As curvas de nivel da F, sem os vetores gradientes: */
level(zz,color) := myimp1(F=zz, lc(color), lk(z=zz))$
myqdrawp(xyrange(), levels());

/* As curvas de nivel da G, sem os vetores gradientes: */
level(zz,color) := myimp1(G=zz, lc(color), lk(z=zz))$
myqdrawp(xyrange(), levels());

/* Os conjuntos B e C: */
B : create_list([x,y], y,seqby(6,0,-1), x,seq(0,3));
eq1 : y = 6 - 2*x;
eq2 : solve(eq1,x);
subst(eq2, x);
define(xmaxC(y), subst(eq2, x));
C : create_list([x,y], y,seqby(6,0,-1), x,seq(0,xmaxC(y)));

[myqdrawp(xyrange(), pts(B, pc(red), myps(3))),
 myqdrawp(xyrange(), pts(C, pc(red), myps(3)))];

/* O gradiente da F nos pontos de B: */
numsB(     grad(F)       );
numsB(atxy(grad(F),[x,y]));

/* O gradiente da F nos pontos de C: */
define(v_at (xy), atxy(grad(F)/10,xy))$
define(Pv_at(xy), myPv(xy,v_at(xy),[ps(1)],hl(0.15)))$
Pv_at([1,3]);
grads_at_C : makelist(Pv_at(xy), xy, C)$
myqdrawp(xyrange(), grads_at_C);

/* O gradiente da F nos pontos de C e as curvas de nivel: */
level(zz,color) := myimp1(F=zz, lc(color), lk(z=zz))$
myqdrawp(xyrange(), levels(), grads_at_C);






#####
#
# parse_string-unicode
# 2024oct10
#
#####

# «parse_string-unicode»  (to ".parse_string-unicode")
# (find-maximamsg "58826853 202410 09" "EricMajzoub: use the unicode character for hbar")
# (find-maximamsg "58826857 202410 09" "RFateman: Just using a fixed-width font helps.")
# (find-maximamsg "58826854 202410 09" "RDodier: parse_string(unicode(...))")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
M: matrix([a,b],[c,d]);
1/hbar * M;
hbar: parse_string(unicode("latin small letter h with stroke"));
1/hbar * M;




#####
#
# qm-maxima
# 2024oct12
#
#####

# «qm-maxima»  (to ".qm-maxima")
# (find-maximamsg "58827564 202410 12" "EricMajzoub: qm-maxima package")
# https://github.com/QMeqGR/qm-maxima
# (find-git-links "https://github.com/QMeqGR/qm-maxima" "qmmaxima")
# (code-c-d "qmmaxima" "~/usrc/qm-maxima/")
# (find-qmmaximafile "")
# (find-qmmaximafile "README.txt")
# (find-qmmaximafile "qm.mac")
# (find-qmmaximafile "qm.lisp" "for ket(a) to be displayed as |a>")
# (find-maximagitgrep "grep --color=auto -niH --null -e dimension $(cat .files.lisp) | grep -a setf")
# (find-maximagitgrep "grep --color=auto -niH --null -e dimension-defstruct $(cat .files.lisp)")
# (find-es "maxima" "file_search_maxima")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
file_search_maxima : append(["~/usrc/qm-maxima/**/*.mac"],  file_search_maxima);
file_search_lisp   : append(["~/usrc/qm-maxima/**/*.lisp"], file_search_lisp);
load("qm.mac");
load("qm-index.lisp");

mbra([a,b]);
psi_bra:a*dagger(zp)+b*dagger(zm);
ket([a,b])+ket([c,d]);
mket([a,b]);
mbra([a,b]);
bell:(1/sqrt(2))*(ket([u,d])-ket([d,u]));
dagger(bell);
braket(bra([a1,b1]),ket([a2,b2]));

declare([a,b],complex);
psi:a*ket([1])+b*ket([2]);
psidag:dagger(psi);
psidag . psi;

declare([c1,c2],complex,r,real);
k:mket([c1,c2,r]);
b:dagger(k);
b . k;

** (find-lisptree "lisptree.mac")
load  ("~/lisptree/lisptree.mac");
         ket([c,d]);
lisptree(ket([c,d]));

? ket
properties(ket);
:lisp (describe '$ket)
:lisp (symbol-plist '$ket)






#####
#
# unlambda / ((MPLUS SIMP FACTORED) 2 3) -> "3 + 2"
# 2024oct27
#
#####

# «unlambda»  (to ".unlambda")
# (find-maximamsg "58834201 202410 27" "Edrx: ((MPLUS SIMP FACTORED) 2 3) -> 3 + 2")
# (find-maximamsg "58834345 202410 27" "Stavros: in reverse order")
# (find-maximamsg "58835081 202410 29" "BWillis:")
# (find-maximamsg "58835290 202410 29" "Stavros:")
# (find-maximamsg "58835345 202410 29" "Stavros:")
# (find-maximamsg "58835362 202410 29" "Stavros:")
# (find-maximamsg "58835378 202410 29" "Stavros:")
# (find-maximamsg "58835385 202410 29" "BWillis:")
# (find-maximamsg "58835413 202410 29" "Stavros:")

# https://mail.google.com/mail/u/0/#sent/QgrcJHshbMdQfDRKwnhjKtWkGWXtPkfZRtb
# (to "factor")
# (to "ordering")

Hi list,

I know that this is not supposed to work, but I think that the
question is interesting anyway...

In this thread from mid-august -

  https://sourceforge.net/p/maxima/mailman/message/58807287/

...I learned that the result of factor(12345678) is not simplified
because is starts with (MTIMES SIMP FACTORED). A few hours ago I
decided to test if I could use that same trick with other arithmetic
expressions, and it ALMOST worked. These three expressions

  factor(12345678);
  lambda([], 2 * 3^2 * 47 * 14593);
  lambda([], 2+3);

are, respectively:

        ((MTIMES SIMP FACTORED) 2 ((MEXPT SIMP) 3 2) 47 14593)
  ((LAMBDA SIMP) ((MLIST)) ((MTIMES) 2 ((MEXPT) 3 2) 47 14593))
  ((LAMBDA SIMP) ((MLIST)) ((MPLUS) 2 3))

I tried to run this in a REPL,

  format0(o) := format("~s",o);

  o  : factor(12345678);
  o2 : lambda([], 2 * 3^2 * 47 * 14593);
  o3 : lambda([], 2+3);

  format0(o);
  format0(o2);
  format0(o3);

  to_lisp();
      (defun $unlambda (olambda)
        (let* ((obody (cddr olambda))
               (oop   (caaar obody))
               (oargs (cdar obody)))
          `((,oop simp factored) ,@oargs)
          ))
      #$o$
      #$o2$
      #$o3$
      ($unlambda #$o2$)
      ($unlambda #$o3$)
    (to-maxima)

  unlambda(o2);
  unlambda(o3);
  format0(unlambda(o3));

And ta-da: the result of

  format0(unlambda(lambda([], 2+3)));

is this,

  ((MPLUS SIMP FACTORED) 2 3)

that looks promising... but Maxima prints the result of

  unlambda(lambda([], 2+3));

as

  3 + 2

instead of the "2 + 3" that I was hoping for.

Any comments?
  Cheers =) =) =),
    Eduardo Ochs




#####
#
# lisptree-demo1
# 2024oct27
#
#####

# «lisptree-demo1»  (to ".lisptree-demo1")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rfv /tmp/lisptree/
cd      /tmp/
git clone https://github.com/edrx/lisptree
cd      /tmp/lisptree/


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-anchor "/tmp/lisptree/lisptree.mac")
load           ("/tmp/lisptree/lisptree.mac");

          fundef(format);
lisptree (fundef(format));
lisptree0_config(q,s1)$
lisptree (fundef(format));
lisptree0_config(nq,s0)$
lispytree(fundef(format));

lisptree (2+3);
lisptreeq(2+3);




#####
#
# ppshort.lisp
# 2024oct29
#
#####

# «ppshort.lisp»  (to ".ppshort.lisp")
# (find-angg "MAXIMA/ppshort.lisp")




#####
#
# mktable
# 2024oct28
#
#####

# «mktable»  (to ".mktable")
# (to "special-nouns")

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
mktable1(f,as) := block([topline,otherlines,alllines],
  topline    : rhs(apply('fundef,[f])),
  otherlines : map(f,as),
  alllines   : append([topline], otherlines),
  apply('matrix, alllines))$

mktable(f,abs) := block([topline,otherlines,alllines],
  topline    : rhs(apply('fundef,[f])),
  otherlines : makelist(apply(f,ab), ab, abs),
  alllines   : append([topline], otherlines),
  apply('matrix, alllines))$

ff(o)      := [o, 10*o, 100*o, 1000*o];
gg(o,post) := [o, 10*o, 100*o, 1000*o, post];
mktable1(ff, [1,2,3]);
mktable (gg, [[1,"bla"], [2,"plic"], [3,"ploc"]]);



#####
#
# wxmaxima
# 2024nov09
#
#####

# «wxmaxima»  (to ".wxmaxima")
# (find-sh "locate -i wxmaxima")
# (find-maximagitgrep "grep --color=auto -niH --null -e wxmaxima $(find * -type f | sort)")
# (find-maximagitgrep "grep --color=auto -niH --null -e imaxima $(find * -type f | sort)")
# (find-node "(imaxima)Top")
# https://wxmaxima-developers.github.io/wxmaxima/download.html
# https://github.com/wxMaxima-developers/wxmaxima/releases/tag/Version-24.08.0
# https://github.com/wxMaxima-developers/wxmaxima
# file:///usr/local/share/doc/wxmaxima/wxmaxima.html
# file:///usr/local/share/doc/wxmaxima/wxmaxima.html#embedding-animations-into-the-spreadsheet
# https://htmlpreview.github.io/?https://github.com/wxMaxima-developers/wxmaxima/blob/main/info/wxmaxima.html#embedding-animations-into-the-spreadsheet
# (find-git-links "https://github.com/wxMaxima-developers/wxmaxima" "wxmaxima")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# rm -Rfv ~/bigsrc/wxmaxima/
cd      ~/bigsrc/
git clone https://github.com/wxMaxima-developers/wxmaxima
cd      ~/bigsrc/wxmaxima/

export PAGER=cat
git branch --list -a
git for-each-ref
git log --oneline --graph --all -20

# (find-fline "~/bigsrc/")
# (find-fline "~/bigsrc/wxmaxima/")
# (find-gitk  "~/bigsrc/wxmaxima/")

# (code-c-d "wxmaxima" "~/bigsrc/wxmaxima/")
# (find-wxmaximafile "")
# (find-wxmaximafile "README.md" "disable Wayland and use X11 instead")
# (find-wxmaximafile "Compiling.md")
# (find-wxmaximafile "Compiling.md" "mkdir -p ../build-wxm")
# (find-wxmaximafile "Compiling.md" "Ubuntu or Debian build prerequisites")
# (find-wxmaximash "find * | sort")
# (find-wxmaximagrep "grep --color=auto -nRH --null -e with_slider_draw *")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
sudo apt-get install build-essential libwxbase3.0-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev ibus-gtk ibus-gtk3 checkinstall gettext cmake pandoc po4a

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rfv ~/bigsrc/wxmaxima-build/
mkdir   ~/bigsrc/wxmaxima-build/
cd      ~/bigsrc/wxmaxima-build/
cmake ../wxmaxima        |& tee ocm
 cmake --build .         |& tee ocmb
#cmake --build . -- -j 2
sudo cmake --build . -- install   |& tee ocmbi

# (find-fline "~/bigsrc/wxmaxima-build/")



#####
#
# spreadsheet
# 2024nov22
#
#####

# «spreadsheet»  (to ".spreadsheet")
# https://lobste.rs/s/yn0ibw/why_is_mathematica_so_bad_at_being




#####
#
# pythagorean-triples
# 2024nov22
#
#####

# «pythagorean-triples»  (to ".pythagorean-triples")
# https://richardt.io/stereo_stern/ The stereographic projection of the Stern–Brocot tree
# https://news.ycombinator.com/item?id=42201936 A binary tree of all Pythagorean triples (richardt.io)
# https://en.wikipedia.org/wiki/Pythagorean_triple#Generating_a_triple

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
pt(m,n) := [m^2-n^2, 2*m*n, m^2+n^2];
[pt(2,1), pt(3,1), pt(4,1), pt(5,1), pt(6,1)];
         [pt(3,2), pt(4,2), pt(5,2), pt(6,2)];





#####
#
# edrx-maxima.tgz
# 2024aug06
#
#####

# «edrx-maxima.tgz»  (to ".edrx-maxima.tgz")
# (find-telegachat "985384349#235916" "find-flines")
# (find-maximagitfile "interfaces/emacs/emaxima/" "maxima.el")
# (find-maximagitfile "interfaces/emacs/emaxima/maxima.el")
# (find-windows-beginner-intro "12. Install qdraw")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd
cp -v $S/https/home.csulb.edu/~woollett/qdraw.mac ~/MAXIMA/
cp -v ~/bigsrc/maxima/interfaces/emacs/emaxima/{maxima,maxima-font-lock}.el ~/MAXIMA/

'ls' .maxima/*.{mac,lisp} \
      MAXIMA/*.{mac,lisp} \
      MAXIMA/maxima*.el \
      MAXIMA/edrx-maxima.el \
      luatree/*.{mac,lisp,lua} \
      lisptree/*.{mac,lisp} \
      myqdraw/*.{mac,lisp,sh} \
       | sort | tee /tmp/o
tar -cvzf /tmp/edrx-maxima.tgz $(cat /tmp/o)
laf       /tmp/edrx-maxima.tgz
# (find-cp-angg-links "edrx-maxima.tgz" "/tmp/" "tmp/")
scp       /tmp/edrx-maxima.tgz $LINP/tmp/
scp       /tmp/edrx-maxima.tgz $LINS/tmp/
rm -v     /tmp/edrx-maxima.tgz

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
# (find-fline "/tmp/2/")
cd /tmp/
wget -N http://anggtwu.net/tmp/edrx-maxima.tgz
rm -Rv /tmp/2/
mkdir  /tmp/2/
cd     /tmp/2/
tar -C /tmp/2/ -xvzf /tmp/edrx-maxima.tgz
find   /tmp/2/ | sort

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
wget -N http://anggtwu.net/tmp/edrx-maxima.tgz
tar -C ~/ -xvzf /tmp/edrx-maxima.tgz

# (find-fline "~/.maxima/")
# (find-fline "~/MAXIMA/")
# (find-fline "~/luatree/")

* (eepitch-/tmp/2/)
* (eepitch-kill)
* (eepitch-/tmp/2/)
tar -C /tmp/2 -xvzf edrx-maxima.tgz
tar -C ~/ -xvzf edrx-maxima.tgz




#####
#
# maxima-interface: Simple interface between Common Lisp and Maxima
# 2024dec07
#
#####

# «maxima-interface»  (to ".maxima-interface")
# https://sr.ht/~jmbr/
# https://sr.ht/~jmbr/maxima-interface/
# https://superadditive.com/
# https://superadditive.com/notes/
# (find-angggrep "grep --color=auto -nH --null -e jmbr 2024dec08*")
# https://git.sr.ht/~jmbr/maxima-interface
# (find-git-links "https://git.sr.ht/~jmbr/maxima-interface" "maximainterface")
# (code-c-d "maximainterface" "~/usrc/maxima-interface/")
# (find-maximainterfacefile "")
# (find-maximainterfacefile "README.md")
# (find-maximainterfacefile "README.md" "ASDF registry")
# (find-fline "~/quicklisp/local-projects/")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -v                         ~/quicklisp/local-projects/maxima-src
rm -v                         ~/quicklisp/local-projects/maxima-interface
ln -s ~/bigsrc/maxima/src     ~/quicklisp/local-projects/maxima-src
ln -s ~/usrc/maxima-interface ~/quicklisp/local-projects/maxima-interface
ls -lAF                       ~/quicklisp/local-projects/

* (eepitch-sbcl)
* (eepitch-kill)
* (eepitch-sbcl)
(load #P"~/quicklisp/asdf.lisp")
(load #P"~/quicklisp/setup.lisp")
(ql:register-local-projects)
(ql:quickload :maxima-interface)   ;; or with :silent t
(use-package :maxima-interface)
(diff '(* x x) 'x)








# (info "(maxima)Functions and Variables for Polynomials")
# (info "(maxima)Functions and Variables for Polynomials")




# (find-maximagitfile "interfaces/emacs/emaxima/maxima-font-lock.el")
# (find-maximagitfile "interfaces/emacs/emaxima/maxima.el")
# (find-maximagitfile "interfaces/emacs/emaxima/emaxima.el")

# (find-fline "~/bigsrc/maxima/interfaces/emacs/emaxima/maxima.el")

(add-to-list 'load-path "~/bigsrc/maxima/interfaces/emacs/emaxima/")





# https://sourceforge.net/p/maxima/mailman/maxima-discuss/?viewmonth=202208&style=threaded&limit=250

https://sourceforge.net/p/maxima/mailman/maxima-discuss/thread/DM5PR17MB1625F1175AA81CEB6297E021B6749%40DM5PR17MB1625.namprd17.prod.outlook.com/#msg37699419
https://sourceforge.net/p/maxima/mailman/message/37699419/




* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
?? plot
   none
? plot2d
? Introduction to Plotting
? draw
?? draw
   none
? draw2d


# 2021dec22
# [Maxima-discuss] improve integration by change of variable

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
k: exp(atan(v))/ (v^2+1)^(3/2);
integrate(k,v);
changevar(%,v=tan(u),u,v);
%,integrate;








# (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")





# 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);



* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
eq1:x=y+25;
eq2:x+10=2*(y+10);
sol:solve([eq1, eq2], [x, y]);


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
plot3d(x*y / sqrt(x^2 + y^2), [x, -1, 1], [y, -1, 1]);
plot3d(x*y                  , [x, -1, 1], [y, -1, 1]);
** (find-maximaindex-links "draw plot3d")
plot3d (u^2 - v^2, [u, -2, 2], [v, -3, 3], [grid, 100, 100], nomesh_lines)$
plot3d (u^2 - v^2, [u, -2, 2], [v, -3, 3], [grid, 100, 100])$
plot3d (u^2 - v^2, [u, -2, 2], [v, -3, 3])$




https://wxmaximafor.wordpress.com/

https://news.ycombinator.com/item?id=29289989 Maxima (Software) (wikipedia.org)
https://wxmaxima-developers.github.io/wxmaxima/

https://stackoverflow.com/users/688021/stavros-macrakis

https://www.maplesoft.com/support/help/maple/view.aspx?path=D

https://edu.kde.org/cantor/
https://maxima.sourceforge.io/misc/maxima-opinions.pdf
https://news.ycombinator.com/item?id=24465595 Maxima – A Computer Algebra System built with Lisp (sourceforge.net) - Sage is a python wrapper around other systems such as Maxima or Fricas.

https://www.emacswiki.org/emacs/MaximaMode

https://personal.math.ubc.ca/~cbm/aands/toc.htm A&S
https://dlmf.nist.gov/front/foreword DMLF

# (find-maximamsg "37677504 202207 06" "RDodier: Javascript from Maxima")
# (find-maximamsg "37677924 202207 09" "Stavros: Evaluation happens *before*")

# (find-maximanode "inflag")
# (find-maximamsg "37688002 202207 31" "Maxima functions for plusp, timesp, and exptp in src?")
# (find-maximamsg "37687988 202207 31" "Maxima functions for plusp, timesp, and exptp in src?")
# (find-maximamsg "37687979 202207 31" "Maxima functions for plusp, timesp, and exptp in src?")
# (find-maximamsg "37687732 202207 31" "diff of a block generated by optimize")

# (find-maximamsg "37305728 202106 18" "MTalon: About gentran and cffi")
# (find-maximamsg "37730225 202211 04" "FSFarimani: Discord")

https://www.quora.com/Are-there-higher-forms-of-the-quadratic-formula-such-as-to-find-quartic-or-quintic-polynomials/answer/Stavros-Macrakis

http://michel.gosse.free.fr/exemples/fraccont/fraction-continue-ang.pdf

https://mail.google.com/mail/u/0/#inbox/FMfcgzGqQJkVmvgxvbndhPcpRCFWHnnK matrixmap

https://github.com/mame/quine-relay
https://news.ycombinator.com/item?id=33105706 A Ruby program that generates itself through a 128-language quine loop (github.com/mame)

https://sourceforge.net/p/maxima/mailman/message/37707884/
[Maxima-discuss] remote package installation, was: share package contribution policy, was: A piece of code for computing the Carleman matrix
From: Robert Dodier <rober...@gm...> - 2022-09-15 15:19:27

# (find-maximamsg "37735225 202211 14" "AZorine: Iterated at")
# (find-maximamsg "37750831 202212 19" "Stavros: *map* maps over the *constituents*")
# (find-maximamsg "37779735 202302 17" "RAbert: Unexpected result from Trig-sub integral")
# (find-maximamsg "37801210 202304 07" "MTalon: A determinant computation")

https://maxima.sourceforge.io/misc/Fateman-Salz_Simplifier_Paper.pdf

https://wxmaximafor.wordpress.com/
https://wxmaximafor.files.wordpress.com/2015/06/wxmaxima_for_calculus_i_cq.pdf

# Fun example of the adaptive plot routine
# (find-maximamsg "37855544 202306 08" "RDodier: Fun ... adaptive plot")
# (find-maximamsg "37855477 202306 08" "RToy")
# (find-maximamsg "37855467 202306 08" "GKoenigsmann")

# (find-maximamsg "37884015 202308 15" "RDodier: cbrt / matchdeclare")
# (find-maximamsg "37883630 202308 14" "RDodier: work in progress: reshape")
# (find-maximamsg "38268418 202309 23" "HBaker: Stupid question re '??'")
# (find-maximamsg "38268394 202309 23" "JVillate: plot2d: make 'lines' share same style")

# (find-maximamsg "58738797 202402 17" "RDodier: modes of use of nonlexical symbols illuminated by lexical symbol stuff")
# (find-maximamsg "58738780 202402 17" "RDodier: progress report on lexical symbols stuff")
# (find-maximamsg "58738963 202402 18" "MTalon:  Re: progress report on lexical symbols stuff")
# (find-maximamsg "58739478 202402 19" "RToy:    Re: progress report on lexical symbols stuff")
# (find-maximamsg "58739110 202402 19" "RDodier: Re: progress report on lexical symbols stuff")
# (find-maximamsg "58741521 202402 25" "RFateman: numerics, NaNs, etc")


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
plot2d([sin,cos],[x,0,2*%pi],[style,[lines,2,1]]);
plot2d([sin,cos],[x,0,2*%pi],[style,[lines,2,1],[lines,2,1]]);



https://maxima.common-lisp.dev/
https://maxima.common-lisp.dev/docs/maxima.pdf
http://www.austromath.at/daten/maxima/zusatz/Graphics_with_Maxima.pdf
https://maxima.sourceforge.io/docs/tutorial/en/minimal-maxima.pdf
https://maxima.sourceforge.io/docs/tutorial/en/talon-pattern.pdf

https://www.youtube.com/watch?v=V0h_6qdfIUY

https://frinklang.org/ It tracks units of measure (feet, meters, kilograms, watts, etc.) through all calculations
https://news.ycombinator.com/item?id=38125256 Frink is a programming language designed to make physical calculations simple (frinklang.org)

https://aezarebski.github.io/notes/maxima-notes.html#org2d0976c

https://def.fe.up.pt/pipermail/maxima-discuss/2008/021771.html powerdisp
https://def.fe.up.pt/pipermail/maxima-discuss/2008/021800.html global modulus
https://def.fe.up.pt/pipermail/maxima-discuss/2008/021808.html ^^-1 and invert
https://def.fe.up.pt/pipermail/maxima-discuss/2008/021842.html multiadditive
https://def.fe.up.pt/pipermail/maxima-discuss/2008/021845.html multiadditive
https://def.fe.up.pt/pipermail/maxima-discuss/2008/021849.html multiadditive
https://def.fe.up.pt/pipermail/maxima-discuss/2008/021968.html piecewise
https://def.fe.up.pt/pipermail/maxima-discuss/2008/021982.html curried
https://def.fe.up.pt/pipermail/maxima-discuss/2008/022034.html defrule and tellsimpafter
https://dl.acm.org/doi/10.1145/355694.355696 Analysis of Algorithms, A Case Study: Determinants of Matrices with Polynomial Entries
https://sourceforge.net/p/maxima/bugs/365/ orderless


# (find-maximamsg "58767797 202405 03" "submatrix assignment ala Matlab")
# (find-maximamsg "58768057 202405 03" "submatrix assignment ala Matlab")
# (find-maximamsg "58767855 202405 03" "Correct Syntax for Greek Letters in .macs for LaTeX Export")
# (find-maximamsg "58767855 202405 03" "Correct Syntax for Greek Letters in .macs for LaTeX Export")
# (find-maximamsg "58767860 202405 03" "Correct Syntax for Greek Letters in .macs for LaTeX Export")
# (find-maximamsg "58767880 202405 03" "Correct Syntax for Greek Letters in .macs for LaTeX Export")
# (find-maximamsg "58767881 202405 03" "Correct Syntax for Greek Letters in .macs for LaTeX Export")
# (find-maximamsg "58767884 202405 03" "Correct Syntax for Greek Letters in .macs for LaTeX Export")
# (find-maximamsg "58768025 202405 03" "Correct Syntax for Greek Letters in .macs for LaTeX Export")
# (find-maximamsg "58768059 202405 03" "Correct Syntax for Greek Letters in .macs for LaTeX Export")
# (find-maximamsg "58768066 202405 03" "Correct Syntax for Greek Letters in .macs for LaTeX Export")
# (find-maximamsg "58768098 202405 03" "Correct Syntax for Greek Letters in .macs for LaTeX Export")

https://themaximalist.org/page/4/ ***
https://lindnerdrwg.github.io/
https://lindnerdrwg.github.io/LAi1-matrix-algebra.pdf
https://georgeweigt.github.io/manual/eigenmath.pdf
https://github.com/georgeweigt/eigenmath

https://stackoverflow.com/questions/35969712/difference-between-throw-return-and-break-in-maxima

* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
:lisp (defun foo (&rest rest) "Foo")
:lisp (defun foo () "Foo")
?foo();
:lisp (defun foo (&rest rest) (break) "Foo")
?foo();



makelist
thru
map
vector

# (find-maximanode "Functions and Variables for Lists")
# (find-maximanode "append")
# (find-maximanode "cons")
# (find-maximanode "create_list")
# (find-maximanode "makelist")
# (find-maximanode "args")
# (find-maximanode "map")
# (find-maximanode "maplist")
# (find-maximanode "do")
# (find-maximanode "infolists")
# (find-maximanode "for")

# (find-maximanode "Function and Variable Index" "* for:")
# (find-maximanode "Introduction to Expressions")
# (find-maximanode "Introduction to Lists")
# (find-maximanode "makelist")
# (find-maximanode "create_list")

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


# http://anggtwu.net/LATEX/2024-1-C3-prova-relampago-1.pdf
# (c3m241pr1p 3 "questoes")
# (c3m241pr1a   "questoes")


# Open post in the window at the right:
# (setq last-kbd-macro (kbd "M-3 M-e M-> M-e M-o"))
# (find-angg ".emacs.templates" "eewrap-maximamsg")
# (find-angg ".emacs.templates" "eewrap-maximamsg" "tomm")








#  Local Variables:
#  coding:               utf-8-unix
#  modes: (fundamental-mode maxima-mode)
#  End: