Skip to content

Instantly share code, notes, and snippets.

View Observatorio-de-Matematica's full-sized avatar

Observatorio-de-Matematica

View GitHub Profile
@Observatorio-de-Matematica
Observatorio-de-Matematica / cosine-rule.mac
Created January 15, 2024 02:29 — forked from kisp/cosine-rule.mac
Deriving the Law of cosines c^2 = a^2 + b^2 - 2*a*b*cos(θ) in maxima
/*
You can run this file with
maxima -b cosine-rule.mac
or maybe also using M-x quickrun
*/
/*
(%i1) eq1: a = b + c /d;
c
(%o1) a = - + b
d
(%i2) eq2: e = b - c*d;
(%o2) e = b - c d
(%i3) eliminate([eq1, eq2], [b]);
2
(%o3) [(- d (e - a)) - c d - c]
(%i4) expand(%);
(%i1) t: matrix([%t^3],[%t^2],[%t],[1])
;
[ 3 ]
[ %t ]
[ ]
[ 2 ]
(%o1) [ %t ]
[ ]
[ %t ]
[ ]
@Observatorio-de-Matematica
Observatorio-de-Matematica / gist:b91517e7288bc3253dd01505f3ec3128
Created January 14, 2024 18:00 — forked from raydsameshima/gist:316554199fdc17bba4459ffeb8708368
IBP identity for I(2,2) w.r.t. {I(1,1), I(1,2)} of MI
(%i1) eqn:I12 = I11*(((-d)+3)/(pp-4*m2))+I10*((d-2)/((2*m2)*pp-8*m2^2))
I10 (d - 2) I11 (3 - d)
(%o1) I12 = --------------- + -----------
2 pp - 4 m2
2 m2 pp - 8 m2
(%i2) sol:solve(eqn,[I10])
2
2 I12 m2 pp - 8 I12 m2 + (2 I11 d - 6 I11) m2
(%o2) [I10 = ----------------------------------------------]
d - 2
(%i1) eq1: a = b + c / d;
c
(%o1) a = - + b
d
(%i2) eq2: x = b - c*d;
(%o2) x = b - c d
(%i3) solve([eq1, eq2], [a,b,c,d, x]);
(%o3) [[a = %r1, b = %r2, c = (%r1 - %r2) %r3, d = %r3,
2
x = (%r2 - %r1) %r3 + %r2]]
(%i1) integrate(x^2 * %e ^ (-x ^ 2), x);
2
- x
sqrt(%pi) erf(x) x %e
(%o1) ---------------- - --------
4 2
(%i2) plot2d(%o1, [x, -1.5, 1.5]);
@Observatorio-de-Matematica
Observatorio-de-Matematica / gist:4d17aeecf34f0aeea8d171f1e95e0e3b
Created January 7, 2024 14:49 — forked from tymat/gist:d7d475a7d8c87f9be120
Maxima - Proper use of Dirac bra-ket notation.
declare(bra, nonscalar);
declare(ket, nonscalar);
dotscrules:true;
matchdeclare(m,lambda([t],featurep(t,integer)));
matchdeclare(n,lambda([t],featurep(t,integer)));
tellsimp(bra(m).ket(n), kron_delta(m,n));
simp:false;
matchdeclare(aa, true);
@Observatorio-de-Matematica
Observatorio-de-Matematica / graphs.mac
Created January 7, 2024 14:46 — forked from louisswarren/graphs.mac
Graphs in maxima
anyp(pred, seq) := lreduce(lambda([P, x], P or pred(x)), seq, false);
allp(pred, seq) := lreduce(lambda([P, x], P and pred(x)), seq, true);
walklength(seq) := (length(seq)-1)/2;
walkverts(seq) := makelist(seq[2*i-1], i, 1, walklength(seq)+1);
walkedges(seq) := makelist(seq[2*i], i, 1, walklength(seq));
closedp(seq) := is(first(seq) = last(seq));
vertexset(G) := first(G);
edgeset(G) := second(G);
/* Author Chung Chan
Copyright (C) 2021 Chung Chan */
/* remove
load(descriptive);
load(draw);
*/
/****************
helper functions
****************/
@Observatorio-de-Matematica
Observatorio-de-Matematica / animation.mac
Created January 7, 2024 02:44 — forked from umedaikiti/animation.mac
maximaで遊んだ時のコード
with_slider_draw(k,makelist(i,i,1,7),
proportional_axes = xy,
xrange = [-3,3],
yrange = [-3,3],
xaxis=true,
yaxis=true,
grid = true,
title = "animation" ,
label([sconcat("k=",k-4),-1,2]),
point_type=7,