X-Git-Url: https://ruderich.org/simon/gitweb/?p=config%2Fdotfiles.git;a=blobdiff_plain;f=misc%2Fmaxima%2Fmaxima-init.mac;fp=misc%2Fmaxima%2Fmaxima-init.mac;h=1dedac1ba79932fc63ab1222536bf25db42be6a6;hp=0000000000000000000000000000000000000000;hb=8ccb9052dca010073caa5df18c71e6c2a7200fcc;hpb=54e498cc877f4e05b5788b0a886ee02546f41a47 diff --git a/misc/maxima/maxima-init.mac b/misc/maxima/maxima-init.mac new file mode 100644 index 0000000..1dedac1 --- /dev/null +++ b/misc/maxima/maxima-init.mac @@ -0,0 +1,46 @@ +/* + * Maxima (computer algebra system) configuration file, Maxima part. + * + * Also have a look at maxima/maxima-init.lisp. + * + * Notes: + * + * Solve Ax = b, thanks to Florian. + * + * A : matrix([1,2,0],[0,2,3],[0,0,4])$ + * b : matrix([1],[3],[5])$ + * linsolve_by_lu(A,b); + */ + +/* + * Copyright (C) 2011-2012 Simon Ruderich + * + * This file is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this file. If not, see . + */ + + +/* CUSTOM FUNCTIONS */ + +/* Didn't find any euclid norm in Maxima, so here it is. */ +norm(x) := sqrt(transpose(x) . x); + +/* Maxima's mat_norm() can't calculate the 2-norm. Thanks to Wolfgang Lindner + * (http://www.ma.utexas.edu/pipermail/maxima/2007/006300.html) for an + * improved version. */ +mat_norm2(x) := sqrt(lmax(eigenvalues(transpose(conjugate(x)) . x)[1])); + +/* Shortcut to perform lu factorization. */ +lu(x) := block(x : lu_factor(x), get_lu_factors(x)); + +/* vim: ft=maxima */