kill(all)$

rem : how to load a 'packages' in Maxima

load(lrats)$

How to use in  the programming Maxima 'rules', version 1.0
peter.vlasschaert@gmail.com,12/07/2018.

     0^0 : undefined   ' maxima' : ?  How to defined.   
==========================================

simp:false;

0^0;

when use : 0^0 ,simp: true ,we get a error.
--------------------------------------------------------------

simp:true;

rem : to give value  : 0^0 =1, we can use 'tellsimp' command.

let (0^0,1)  gives 'error' can't be used.

rem : we need first only for this expression = 0^0 , simp:false.

How to solve : problem. (block : statement,tellsimp 'command')
-----------------------------------------------------------------------------------------------

qs:block([simp:false],tellsimp(0^0,1));

0^0;

rem :[,,,] are only known inside the block.
         ==============================

simp: true  , outside block for every one.

simp;

?  tellsimp           : defines a replacement for pattern , before the build in simplification.
=======================================================================
syntax : tellsimp(pattern,replacement)
?  tellsimpafter  : defines a replacement for pattern , after     the build in simplification.
=======================================================================
syntax : tellsimpafter(pattern,replacement)
--------------------------------------------------------------------------------------------------------------------------------

rem : above example 'tellsimp' and not 'tellsimpafter'.

question :replace   by ,  cos² y => 1-sin² x

pa:tellsimpafter((cos(x) )^2,1-(sin(x) )^2);

p1:2*(cos(a))^2+(sin(a))^2;

p2:2*(cos(x))^2+(sin(x))^2;

rem : only works for  'p2' because not general 'rule'

?  How to make general rule . (above : example)
rem : 'p2' will also modified.

rem : make some use ' command  = matchdeclare ' before define a rule.

question :replace   by , sin² y => 1-cos² y

p2a:matchdeclare(y,true);
tellsimpafter((sin(y) )^2,1-(cos(y) )^2);

p3:(cos(a))^2+2*(sin(a))^2;

p4:2*(sin(m))^2;

p5:2*(sin(m))^4;

three rules : avaible.

rules;

rem : general rule.
===============
=>  sin(m)^4 , rule 3 doesn't work.
=>  sin(m)^2  ,rule 3  works.

?  How  to remove rule.
===================

rules ?

p6: 2*(sin(m))^2;

remrule ("^", ?\^rule3);

we can see that ,rule 3 'removed'

rules;

p7:2*(sin(m))^2;

we can see that ,rule 2 'removed', only works 'x'
========================================

remrule ("^", ?\^rule2);

rules;

p8:2*(cos(x))^2;

rem : rules ,info  'disprule(all)'
=========================

disprule(all);

remrule ("^", ?\^rule1);

disprule(all);

rem :        0^0  gives ' error'.

How to use :  'let' ,statement.
 =>               'let,letsimp,remlet'

equation ?

p9:(b*c)^8+(a*b)^4+q^2+(a*b)^2+tt;

let  ?
====

p10:let(a*b,z^2);
p10a:let(b*c,m);
p10b:let(tt,vv);

letsimp ?  
========

p11:letsimp(p9);

remlet ?
=======
syntax : remlet(all),removes all let statements.

remlet (all);

p12:letsimp(p9);

1e) 'p'redicate : result :  'false' or 'true'.
      =============================

? subvarp;

rem :  ? integerp

? real;

see: above ,'subvarp','integerp'
==========================

subvarp( a[i]);

integerp(%pi);

evenp(4);

nonnegintegerp(-8);

rem : _p ,example : integerp
'p ' from predicate.

2e)  freeof(x1,x2,.....,expr).
        =================

p13:p12;

p14:freeof(tt,p13);

p15:freeof(m,p13);

p16:freeof(q,m,p13);

3e)  matchdeclare.
       ============
  syntax : matchdeclare(pattern1,predicate1,pattern2,predicate2,.....,.....,......,........)
  example : 'see above' , 'p2a'

examples :

matchdeclare(v,oddp)$

matchdeclare([x1,x2],evenp,[y1,y2],integerp)$

let  :  use  'matchdeclare'    =>  letsimp
================================
================================

p17:letsimp(a[2]);

ratsimp(a[2]);

p18a:part(p17,0);
p18b:part(p17,1);

rem : predicate 'integerp' from 'p18b'

p18:matchdeclare(a1,subvarp,k1,integerp);

p19:let(a1*k1,part(a1,1)*k1);

letsimp(u[3]*2);

letsimp(2*u[3]);

letsimp(3*a[7]);

rem : option 
==========
numer: true; by default 'false'

numer;

rem : option
===========
derivabbrev ; by default 'false'

form 1 : ode.
==========

p20: a*'diff(y,x,3) = b;

derivabbrev;

change option from 'false' to 'true'

derivabbrev:true;

form 2 :ode.
==========

p21:p20;

rem : ode = 'ordinary differential equations'