|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
/*
* This file:
* http://anggtwu.net/MAXIMA/2025-1-s.mac.html
* http://anggtwu.net/MAXIMA/2025-1-s.mac
* (find-angg "MAXIMA/2025-1-s.mac")
* Author: Eduardo Ochs <eduardoochs@gmail.com>
*
* This file defines the infix substitution operator "_s_".
* See: (c2m242introp 6 "manga")
* (c2m242introa "manga")
* http://anggtwu.net/LATEX/2024-2-C2-intro.pdf#page=6
*
* (find-es "maxima" "operator-subst")
* (find-lisptree "lisptree.mac" "lisptree0")
* (find-maximanode "psubst")
* (find-maximanode "sublis")
* (find-telegachat "-1002074960141#3276" "eu acabei de melhorar")
* (find-telegachatm "-1002074960141#3276" "eu acabei de melhorar")
*
* «.load» (to "load")
* «.core» (to "core")
* «.core-tests» (to "core-tests")
* «.Aipim» (to "Aipim")
* «.RC» (to "RC")
* «.RC-tests» (to "RC-tests")
* «.DefDeriv» (to "DefDeriv")
* «.DefDeriv-tests» (to "DefDeriv-tests")
* «.TFC2» (to "TFC2")
* «.TFC2-tests» (to "TFC2-tests")
* «.S_f_g» (to "S_f_g")
* «.S_f_g-tests» (to "S_f_g-tests")
* «.MV» (to "MV")
* «.MV-tests» (to "MV-tests")
* «.DFI» (to "DFI")
* «.DFI-tests» (to "DFI-tests")
* «.EDOVS» (to "EDOVS")
* «.EDOVS-tests» (to "EDOVS-tests")
* «.EDOLCC» (to "EDOLCC")
* «.EDOLCC-tests» (to "EDOLCC-tests")
* «.E5» (to "E5")
* «.E5-tests» (to "E5-tests")
*/
/* «load» (to ".load")
* Based on: (find-myqdraw "myqdraw3.mac" "load")
* See: (find-fline "~/MAXIMA/lazynouns.lisp")
* (find-fline "~/MAXIMA/2025-displa-tex.lisp")
* (find-fline "~/MAXIMA/dim-antideriv.lisp")
*/
__s_dir : pathname_directory(load_pathname);
load(concat(__s_dir, "lazynouns.lisp"));
load(concat(__s_dir, "2025-displa-tex.lisp"));
load(concat(__s_dir, "dim-antideriv.lisp"));
nary("=.");
/* «core» (to ".core")
*/
__s_getfxye(fxye) := block([fxy,e,f,xy],
fxy : lhs (fxye),
f : op (fxy),
xy : args(fxy),
e : rhs (fxye),
[f,xy,e]);
__s_unlambda1_(fxye) := block([f,xy,e],
[f,xy,e] : __s_getfxye(fxye),
buildq([f,xy,e], f=lambda(xy,e)));
__s_unlambda1(oe) :=
if atom(lhs(oe))
then (lhs(oe)=rhs(oe))
else __s_unlambda1_(oe);
__s_flatten(oes) := flatten([oes]);
__s_prep (oes) := map('__s_unlambda1, __s_flatten(oes));
__s_Vprep (oes) := transpose(matrix(__s_prep(oes)));
/* __s_V1 (oe) := block([a,b], a:lhs(oe), b:rhs(oe), buildq([a,b], a:=b)); */
__s_V1 (oe) := vira(lhs(oe),rhs(oe));
__s_V (oes) := transpose(matrix(map('__s_V1, __s_flatten(oes))));
/* V (oes) := __s_V(oes); */
V (oes) := apply('bmatrix, args(__s_V(oes)));
"_s_" (o,oes) := psubst(__s_prep(oes), o);
"_ss_" (o,oes) := (o *. V(oes));
"_sss_" (o,oes) := (o *. V(oes)) = "_s_"(o, oes);
infix("_s_" ,99,101);
infix("_ss_" ,99,101);
infix("_sss_",99,101);
/* «core-tests» (to ".core-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
"Low-level functions:"$
__s_getfxye (g(a,b)=c);
__s_unlambda1_(g(a,b)=c);
__s_unlambda1 (g(a,b)=c);
__s_unlambda1 (a=42);
__s_V1 (g(a,b)=c);
__s_V1 (a=42);
S1 : [f(x)=x^2+x^3];
S2 : [a=b,b=a];
S3 : [S2, S1];
__s_prep (S3);
__s_Vprep(S3);
__s_V (S3);
V (S3);
f(a)/b _s_ S2;
f(a)/b _ss_ S2;
f(a)/b _sss_ S2;
f(a)/b _sss_ S3;
tex1(%);
*/
/* «Aipim» (to ".Aipim")
*/
Aipim : (sqrt(a^2 + b^2) = a + b);
Aipim2 : (sqrt(a^2 - b^2) = a - b);
Aipim3 : matrix([y, "=", sqrt(a^2 - x^2) + c],
["","=", a - x + c]);
/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
Aipim2 _sss_ [a="5",b= "4"];
Aipim2 _sss_ [a= 5 ,b= 4 ];
Aipim3 _sss_ [a="5",c="-2"];
Aipim3 _sss_ [a= 5 ,c= -2 ];
Aipim3 _sss_ [a= 5 ,c= -2, x=4 ];
Aipim3 _sss_ [a= 5 ,c= -2, x=4, y=1];
*/
/* «RC» (to ".RC")
*/
RC : (_diff(f(g(x)),x,1) = fp(g(x)) *. gp(x));
RCV : matrix(["", _diff(f(g(x)),x,1)], ["=", fp(g(x)) *. gp(x)]);
RCL : _diff(f(g(x)),x,1);
/*
** «RC-tests» (to ".RC-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
S1 : [f (x) = sin(x),
fp(x) = cos(x),
g (x) = 42*x,
gp(x) = 42];
RCV _sss_ S1;
RC _ss_ S1;
RC _s_ S1;
RC _s_ S1 _s_ [x = t];
add2(S) := [S, fp(x)=diff(f(x) _s_ S, x),
gp(x)=diff(g(x) _s_ S, x)];
RCL _sss_ [f(x)=sin(x)];
RCL _sss_ [f(x)=sin(x), g(x)=x^2];
RCV _sss_ add2([f(x)=sin(x), g(x)=x^2]);
*/
/* «DefDeriv» (to ".DefDeriv")
*/
_At(fx,x,a) := _at(fx,x=a);
DefAt : _At(f(x),x,a) = f(a);
DefDeriv : _At(_diff(f(x),x,1),x,a) = _limit((f(a+.eps)-f(a))/eps,eps,0);
DefDeriv2 : _At(_diff(f(x),x,1),x,a) = _limit((f(x)-f(a))/(x-a),x,a);
/*
** «DefDeriv-tests» (to ".DefDeriv-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
DefAt;
DefDeriv;
DefDeriv2;
*/
/* «TFC2» (to ".TFC2")
* See: (find-fline "~/MAXIMA/antideriv.lisp")
* (c2m251exsubstp 9 "uma-integral")
* (c2m251exsubsta "uma-integral")
* 2jT68: (c2m242exsubstp 9 "uma-integral")
* (c2m242exsubsta "uma-integral")
*/
_Integrate(fx,x,a,b) := _integrate(fx, x, x=a,x=b);
displa_delegate('_At2, '_At2_translate);
_At2_translate (o) := apply(_At2_, args(o));
_At2_ (fx,x,a,b) := matrix(["", "|", x=b],
[fx, "|", ""],
["", "|", x=a]);
DefDif : (_At2(F(x),x,a,b) = F(b)-F(a));
TFC2 : (_Integrate(Fp(x), x,a,b) = _At2(F(x),x,a,b));
/* «TFC2-tests» (to ".TFC2-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
DefDif;
TFC2;
TFC2 _s_ [F(x)=x^3, Fp(x)=3*x^2];
*/
/* «S_f_g» (to ".S_f_g")
*/
S_gx (gx) := [g(x)=gx, gp(x)=diff(gx,x)];
S_gx_fu (gx,fu) := [g(x)=gx, gp(x)=diff(gx,x),
f(u)=fu, fp(u)=diff(fu,u)];
S_gx_fpu(gx,fpu) := [g(x)=gx, gp(x)=diff(gx,x),
fp(u)=fpu];
/* «S_f_g-tests» (to ".S_f_g-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
V([a=aa,b=bb]);
[V(S_gx (x^2)),
V(S_gx_fu (x^2, sin(u))),
V(S_gx_fpu(x^2, cos(u)))];
add_gpx(S) := [S, gp(x) = diff(g(x) _s_ S, x)];
add_fpu(S) := [S, fp(u) = diff(f(u) _s_ S, u)];
add_gpx_fpu(S) := add_fpu(add_gpx(S));
S : [f(u)=sin(u), g(x)=x^2];
[V(S), V(add_gpx(S)), V(add_gpx_fpu(S))];
*/
/* «MV» (to ".MV")
* 2jT87: (c2m242dip 7 "MVDs-e-MVIs-color")
* (c2m242dia "MVDs-e-MVIs-color")
* (find-angg "MAXIMA/2025-1-MV-setembro.mac")
*/
MVD1 : _Integrate(fp(g(x)) *. gp(x), x,a,b)
= _Integrate(fp(u), u,g(a),g(b));
MVI1 : _integrate(fp(g(x)) *. gp(x), x)
= _integrate(fp(u), u);
MVD4_ : _Integrate(fp(g(x)) *. gp(x), x,a,b)
=. _At2 (f (g(x)), x,a,b)
=. (f(g(b)) -. f(g(a)))
=. _At2 (f (u), u,g(a),g(b))
=. _Integrate(fp(u), u,g(a),g(b));
MVI3_ : _integrate(fp(g(x)) *. gp(x), x)
=. f (g(x))
=. f (u)
=. _integrate(fp(u), u);
MVD4 : align_eqs (MVD4_);
MVD4V : align_eqs_1c(MVD4_);
MVI3 : align_eqs (MVI3_);
MVI3V : align_eqs_1c(MVI3_);
MVs : matrix([MVI1, MVD1],
[MVI3V, MVD4V]);
/* «MV-tests» (to ".MV-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
S4 : S_gx_fu (x^2, sin(u))$
S3 : S_gx_fpu(x^2, cos(u))$
[V(S3), V(S4)];
MVI1;
MVI3;
MVI3V;
MVD1;
MVD4;
MVD4V;
MVI1 _s_ S3;
MVD4V _s_ S4;
linel : 110;
[MVD4, V(S4)];
MVD4 _s_ S4;
MVs
;
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
S4 : S_gx_fu (sin(x), log(u)^4)$
S3 : S_gx_fpu(sin(x), 4*log(u)^3 / u)$
[V(S3), V(S4)];
MVI1 _s_ S3;
MVD4 _s_ S4;
*/
/* «DFI» (to ".DFI")
* 2jT97: (c2m242fpp 4 "1-sobre-x")
* (c2m242fpa "1-sobre-x")
* 2jT117: (c2m242dfip 3 "introducao")
* (c2m242dfia "introducao")
*/
DFI6 : align_eqss([[f(g(x)), x],
[_diff(f(g(x)),x), _diff(x,x), 1],
[_diff(f(g(x)),x), fp(g(x)) *. gp(x)],
[fp(g(x)) *. gp(x), 1],
[gp(x), 1/fp(g(x))]]);
DFI2 : align_eqss([[f(g(x)), x],
[gp(x), 1/fp(g(x))]]);
/* «DFI-tests» (to ".DFI-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
linel : 110;
Sg : [g(x)=Log(x), gp(x)=Logp(x)];
Sf : [f(x)=Exp(x), fp(x)=Expp(x)];
DFI6;
DFI6 _s_ Sg;
DFI6 _s_ Sg _s_ Sf;
DFI2;
DFI2 _s_ Sg _s_ Sf;
DFI2 _sss_ [Sg,Sf];
*/
/* «EDOVS» (to ".EDOVS")
* (find-angg "MAXIMA/2024-2-C2-EDOVS.mac")
*/
EDOVS_M : matrix(
[ _diff(y,x,1), "=", g(x) /. h(y) ],
[ h(y)*del(y), "=", g(x)*del(x) ],
[ _integrate(h(y),y), "=", _integrate(g(x),x) ],
[ "||", "", "||" ],
[ H(y) +. C1, "=", G(x) +. C2 ],
[ H(y), "=", G(x) +. C3 ],
[ Hinv(H(y)), "=", Hinv(G(x) +. C3) ],
[ "||", "", "" ],
[ y, "", "" ])$
EDOVS_edo : 'diff(y,x) = g(x) / h(y);
EDOVS_imp : H(y) = G(x) + C3;
EDOVS_exp : y = Hinv(G(x) + C3);
EDOVS_f : Hinv(G(x) + C3);
/* «EDOVS-tests» (to ".EDOVS-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
linel : 110;
S4 : [g(x) = -2*x, h(y) = 2*y,
G(x) = -x^2, H(y) = y^2]$
S5p : [S4, Hinv(y) = sqrt(y)]$
S5n : [S4, Hinv(y) = -sqrt(y)]$
[V(S4), V(S5p), V(S5n)];
EDOVS_M _sss_ S5p;
[EDOVS_M, EDOVS_M _s_ S4];
[EDOVS_M _s_ S5p, EDOVS_M _s_ S5n];
EDOVS_edo _s_ S5p;
EDOVS_imp _s_ S5p;
EDOVS_exp _s_ S5p;
EDOVS_f _s_ S5p;
edo : EDOVS_edo _s_ S4;
sol0 : ode2(edo,y,x);
sols0 : solve(sol0, y);
s0 : C3 = -2*%c;
s1 : solve(s0, %c);
sols1 : subst(s1, sols0);
define(fp(x), EDOVS_f _s_ S5p);
define(fn(x), EDOVS_f _s_ S5n);
P1 : [x=3,y=4];
eq1 : subst(P1, y=fp(x));
eq2 : solve(eq1, C3);
define(fp_P1(x), subst(eq2, fp(x)));
subst(P1, y=fp_P1(x));
P2 : [x=3,y=-4];
eq1 : subst(P2, y=fn(x));
eq2 : solve(eq1, C3);
define(fn_P2(x), subst(eq2, fn(x)));
subst(P1, y=fn_P2(x));
*/
/* «EDOLCC» (to ".EDOLCC")
*/
EDOLCC : matrix(
[ "f''" +. (-a-b)*."f'" +. (a*b) * f, "=", 0],
[ D^2*.f +. (-a-b)*.D*.f +. (a*b) * f, "=", 0],
[(D^2 +. (-a-b)*.D +. (a*b))*.f, "=", 0],
[(D-a)*.(D-b)*.f, "=", 0],
[(D-a)*.(D-b)*.exp(b*x), "=", 0],
[(D-a)*.(D-b)*.exp(a*x), "=", 0]);
EDOLCC_edo : 'diff(y,x,2) + (-a-b)*'diff(y,x) + a*b*y = 0;
/* «EDOLCC-tests» (to ".EDOLCC-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
SR : [a=2, b=-3];
SC : [a=2+3*%i, b=2-3*%i];
EDOLCC;
EDOLCC _s_ SR;
expand(EDOLCC _s_ SC);
edo : EDOLCC_edo _s_ SR;
sol : ode2(edo,y,x);
edo : EDOLCC_edo _s_ SC;
sol : ode2(edo,y,x);
*/
/* «E5» (to ".E5")
* (find-angg "MAXIMA/2025-1-exact.mac")
* (c2m251edosexatasp 3 "metodo-e-exemplo")
* (c2m251edosexatasa "metodo-e-exemplo")
*/
E5 : matrix(
[d *. z, "=", z_x *. dx +. z_y *. dy , "=", 0],
[_diff(z,x,1), "=", z_x +. z_y *. _diff(y,x,1), "=", 0],
[z, "=", C , "", ""]);
E5_edo : z_x + z_y*'diff(y,x) = 0;
E5_imp : z = C;
/* «E5-tests» (to ".E5-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("2025-1-s.mac");
S1 : [z=x^2+y^2, z_x=2*x, z_y=2*y];
E5;
E5 _s_ S1;
edo : E5_edo _s_ S1;
imp : E5_imp _s_ S1;
imp2 : ode2(edo,y,x);
solve(imp, y);
solve(imp2,y);
*/
/*
* Local Variables:
* coding: utf-8-unix
* End:
*/