1 /* 2 This file is to be run by the EXAMPLE command, and may not 3 otherwise work. 4 The following are either acceptable lines to Maxima, or they are 5 two successive '&' characters 6 and then followed by the name of the section of examples, and then followed by 7 a sequence of Maxima forms, e.g. 8 9 '&'& topic (without the quotes) 10 11 /* This is a comment */ 12 <Maxima form 1>; 13 <Maxima form 2>; 14 ... 15*/ 16 17&& additive 18 19 declare(f,additive); 20 f(2*a+3*b); 21 22&& algsys 23 24 f1:2*x*(1-l1)-2*(x-1)*l2$ 25 f2:l2-l1$ 26 f3:l1*(1-x**2-y)$ 27 f4:l2*(y-(x-1)**2)$ 28 algsys([f1,f2,f3,f4],[x,y,l1,l2]); 29 f1:x**2-y**2$ 30 f2:x**2-x+2*y**2-y-1$ 31 algsys([f1,f2],[x,y]); 32 33&& allroots 34 35 (2*x+1)^3=13.5*(x^5+1); 36 allroots(%); 37 38&& antisymmetric 39 40 declare(h,antisymmetric); 41 h(x,z,y); 42 43&& append 44 45 append([y+x,0,-3.2],[2.5e20,x]); 46 47&& arrayinfo 48 49 b[1,x]:1$ 50 array(f,2,3); 51 arrayinfo(b); 52 arrayinfo(f); 53 54&& arrays 55 56 a[n]:=n*a[n-1]; 57 a[0]:1$ 58 a[5]; 59 a[n]:=n$ 60 a[6]; 61 a[4]; 62 63&& at 64 65 atvalue(f(x,y),[x=0,y=1],a^2); 66 atvalue('diff(f(x,y),x),x=0,y+1); 67 printprops(all,atvalue); 68 diff(4*f(x,y)^2-u(x,y)^2,x); 69 at(%,[x=0,y=1]); 70 71&& atvalue 72 73 kill(f,x,a,u,g); 74 atvalue(f(x,y),[x=0,y=1],a^2)$ 75 atvalue('diff(f(x,y),x),x=0,y+1); 76 printprops(all,atvalue); 77 diff(4*f(x,y)^2-u(x,y)^2,x); 78 at(%,[x=0,y=1]); 79 80&& augcoefmatrix 81 82 [2*x-(a-1)*y=5*b,a*x+b*y+c=0]$ 83 augcoefmatrix(%,[x,y]); 84 85&& bezout 86 87 bezout(a*y+x^2+1,y^2+x*y+b,x); 88 expand(determinant(%)); 89 %-expand(resultant(a*y+x^2+1,y^2+x*y+b,x)); 90 91&& block 92 93 kill(f); 94 hessian(f):=block([dfxx,dfxy,dfxz,dfyy,dfyz,dfzz], 95 dfxx:diff(f,x,2),dfxy:diff(f,x,1,y,1), 96 dfxz:diff(f,x,1,z,1),dfyy:diff(f,y,2), 97 dfyz:diff(f,y,1,z,1),dfzz:diff(f,z,2), 98 determinant(matrix([dfxx,dfxy,dfxz],[dfxy,dfyy,dfyz], 99 [dfxz,dfyz,dfzz])))$ 100 kill(x,y,z); 101 hessian(x^3-3*a*x*y*z+y^3); 102 subst(1,z,quotient(%,-54*a^2)); 103 f(x):=block([y,use_fast_arrays:false], local(a), y:4, a[y]:x, display(a[y]))$ 104 y:2$ 105 a[y+2]:0$ 106 f(9); 107 ff(x):=block([y,a,use_fast_arrays:true], y:4, a[y]:x, display(a[y]))$ 108 ff(10); 109 a[y+2]; 110 111&& bothcoeff 112 113 islinear(exp,var):=block([c], 114 c:bothcoef(rat(exp,var),var), 115 is(freeof(var,c) and c[1]#0))$ 116 islinear((r^2-(x-r)^2)/x,x); 117 118&& catch 119 120 g(l):=catch(map(lambda([x],if x<0 then throw(x) else f(x)),l))$ 121 g([1,2,3,7]); 122 g([1,2,-3,7]); 123 124&& cf 125 126 cf([1,2,-3]+[1,-2,1]); 127 cfdisrep(%); 128 cflength:4$ 129 cf(sqrt(3)); 130 cfexpand(%); 131 ev(%[1,2]/%[2,2],numer); 132 133&& cfdisrep 134 135 cf([1,2,-3]+[1,-2,1]); 136 cfdisrep(%); 137 138&& cfexpand 139 140 cflength:4$ 141 cf(sqrt(3)); 142 cfexpand(%); 143 ev(%[1,2]/%[2,2],numer); 144 145&& changevar 146 147 'integrate(%e^(sqrt(a)*sqrt(y)),y,0,4); 148 changevar(%,y-z^2/a,z,y); 149 150 sum(a[k]*x^(N-1-k), k, 0, N - 1); 151 changevar(%, m = N - 1 - k, m, k); 152&& charpoly 153 154 a:matrix([3,1],[2,4]); 155 expand(charpoly(a,lambda)); 156 (programmode:true,solve(%)); 157 matrix([x1],[x2]); 158 ev(a.%-lambda*%,%th(2)[1]); 159 %[1,1]=0; 160 x1^2+x2^2=1; 161 solve([%th(2),%],[x1,x2]); 162 163&& coeff 164 165 coeff(2*a*tan(x)+tan(x)+b=5*tan(x)+3,tan(x)); 166 coeff(y+x*%e^x+1,x,0); 167 168&& combine 169 170 combine(a/x+b/x+a/y+b/y); 171 172&& commutative 173 174 declare(h,commutative); 175 h(x,z,y); 176 177&& complex 178 179 (sqrt(-4)+sqrt(2.25))^2; 180 expand(%); 181 expand(sqrt(2*%i)); 182 183&& content 184 185 content(2*x*y+4*x^2*y^2,y); 186 187&& defmatch 188 189 nonzeroandfreeof(x,e):=is(e#0 and freeof(x,e)); 190 matchdeclare(a,nonzeroandfreeof(x),b,freeof(x)); 191 defmatch(linear,a*x+b,x); 192 linear(3*z+(y+1)*z+y**2,z); 193 matchdeclare([a,f],true); 194 constinterval(l,h):=constantp(h-l)$ 195 matchdeclare(b,constinterval(a))$ 196 matchdeclare(x,atom)$ 197 block(remove(integrate,outative), 198 defmatch(checklimits,'integrate(f,x,a,b)), 199 declare(integrate,outative))$ 200 'integrate(sin(t),t,x+%pi,x+2*%pi)$ 201 checklimits(%); 202 'integrate(sin(t),t,0,x)$ 203 checklimits(%); 204 remvalue(a,b,f,x)$ 205 206&& deftaylor 207 208 deftaylor(f(x),x^2+sum(x^i/(2^i*i!^2),i,4,inf)); 209 taylor(%e^sqrt(f(x)),x,0,4); 210 211&& delete 212 213 delete(sin(x),x+sin(x)+y); 214 215&& depends 216 217 kill(a,x,f,y,t); 218 depends(a,x); 219 diff(a.a,x); 220 depends(f,[x,y],[x,y],t); 221 diff(f,t); 222 223&& derivdegree 224 225 'diff(y,x,2)+'diff(y,z,3)*2+'diff(y,x)*x^2; 226 derivdegree(%,y,x); 227 228&& desolve 229 230 eqn1:'diff(f(x),x)='diff(g(x),x)+sin(x); 231 eqn2:'diff(g(x),x,2)='diff(f(x),x)-cos(x); 232 atvalue('diff(g(x),x),x=0,a); 233 atvalue(f(x),x=0,1); 234 desolve([eqn1,eqn2],[f(x),g(x)]); 235 /* verification */ 236 [eqn1,eqn2],%,diff; 237 238&& diff 239 240 kill(f,g,h,x,y); 241 diff(sin(x)+x^3+2*x^2,x); 242 diff(sin(x)*cos(x),x); 243 diff(sin(x)*cos(x),x,2); 244 derivabbrev:true$ 245 diff(exp(f(x)),x,2); 246 'integrate(f(x,y),y,g(x),h(x)); 247 diff(%,x); 248 249&& display 250 251 display(b[1,2]); 252 253&& divide 254 255 divide(x+y,x-y,x); 256 divide(x+y,x-y); 257 258&& do 259 260 for a:-3 thru 26 step 7 do ldisplay(a)$ 261 s:0$ 262 for i:1 while i<=10 do s:s+i; 263 s; 264 series:1$ 265 term:exp(sin(x))$ 266 for p:1 unless p>7 do 267 (term:diff(term,x)/p, 268 series:series+subst(x=0,term)*x^p)$ 269 series; 270 poly:0$ 271 for i:1 thru 5 do 272 for j:i step -1 thru 1 do 273 poly:poly+i*x^j$ 274 poly; 275 guess:-3.0$ 276 for i thru 10 do (guess:subst(guess,x,0.5*(x+10/x)), 277 if abs(guess^2-10)<0.00005 then return(guess)); 278 for count:2 next 3*count thru 20 279 do ldisplay(count)$ 280 x:1000; 281 thru 10 while x#0 do x:0.5*(x+5/x)$ 282 x; 283 remvalue(x); 284 newton(f,guess):=block([numer,y],local(f,df,x,guess), 285 numer:true, 286 define(df(x),diff(f(x),x)), 287 do (y:df(guess), if y=0 then error( 288 "derivative at",guess,"is zero"), 289 guess:guess-f(guess)/y, 290 if abs(f(guess))<5.0e-6 then return(guess)))$ 291 sqr(x):=x^2-5.0$ 292 newton(sqr,1000); 293 for f in [log, rho, atan] do ldisp(f(1.0))$ 294 ev(concat(e,linenum-1),numer); 295 296&& dotscrules 297 298 declare(l,scalar,[m1,m2,m3],nonscalar); 299 expand((1-l*m1).(1-l*m2).(1-l*m3)); 300 %,dotscrules; 301 rat(%,l); 302 303&& dpart 304 305 dpart(x+y/z^2,1,2,1); 306 expand((b+a)^4); 307 (b+a)^2*(y+x)^2; 308 expand(%); 309 %th(3)/%; 310 factor(%); 311 dpart(%th(2),2,4); 312 part(%th(3),2,4); 313 314&& echelon 315 316 matrix([2,1-a,-5*b],[a,b,c]); 317 echelon(%); 318 319&& eliminate 320 321 exp1:2*x^2+y*x+z; 322 exp2:3*x+5*y-z-1; 323 exp3:z^2+x-y^2+5; 324 eliminate([exp3,exp2,exp1],[y,z]); 325 326&& entermatrix 327 328 entermatrix(2,1); 329 330&& equations 331 332 x+1=y^2; 333 x-1=2*y+1$ 334 %th(2)+%; 335 %th(3)/y; 336 1/%; 337 338&& ev 339 340 kill(y,x,w); 341 sin(x)+cos(y)+(w+1)^2+'diff(sin(w),w); 342 ev(%,sin,expand,diff,x=2,y=1); 343 ev(x+y,x:a+y,y:2); 344 'diff(y^2+x*y+x^2,x,2,y,1); 345 346 ev(%,diff); 347 2*x-3*y=3$ 348 -3*x+2*y=-4$ 349 solve([%th(2),%]); 350 ev(%th(3),%); 351 x+1/x>gamma(1/2); 352 ev(%,numer,x=1/2); 353 ev(%,pred); 354 355&& evaluation 356 357 diff(x*f(x),x); 358 f(x):=sin(x)$ 359 ev(%th(2),diff); 360 x; 361 x:3$ 362 x; 363 'x; 364 f(x):=x^2; 365 'f(2); 366 ev(%,f); 367 '(f(2)); 368 ''%; 369 sum(i!,i,1,4); 370 'sum(i!,i,1,4); 371 remvalue(x); 372 'integrate(f(x),x,a,b); 373 for i thru 5 do s:s+i^2; 374 s; 375 ev(%,s:0); 376 ev(%th(2)); 377 'sum(g(i),i,0,n); 378 z*%e^z; 379 ev(%,z:x^2); 380 subst(x^2,z,%th(3)); 381 a:%; 382 a+1; 383 kill(a,y); 384 a; 385 /* declare(integrate,noun)$ */ 386 integrate(y^2,y); 387 ''integrate(y^2,y); 388 f(y):=diff(y*log(y),y,2); 389 f(y):=''(diff(y*log(y),y,2)); 390 ''(concat(c,linenum-1)); 391 (x+y)^3$ 392 diff(%,x); 393 y:x^2+1$ 394 ''(concat(c,linenum-2)); 395 396&& evenfun 397 398 declare(g,evenfun); 399 g(-x); 400 401&& exp 402 403 ev(%e^x*sin(x)^2,exponentialize); 404 kill(x); 405 integrate(%,x); 406 ev(%,demoivre); 407 ans:ev(%,ratexpand); 408 ev(%,x:1,numer)-ev(%,x:0,numer); 409 integrate(%e^x*sin(x)^2,x); 410 trigreduce(%); 411 %-ans; 412 ev(sin(x),%emode); 413 414&& expand 415 416 (1/(x+y)^4-3/(y+z)^3)^2; 417 expand(%,2,0); 418 expand(a.(b+c.(d+e)+f)); 419 expand((x+1)^3); 420 (x+1)^7; 421 expand(%); 422 expand(%th(2),7,7); 423 ev(a*(b+c)+a*(b+c)^2,expop:1); 424 425&& factcomb 426 427 (n+1)^2*n!^2; 428 factcomb(%); 429 430&& factor 431 432 factor(2^63-1); 433 factor(z^2*(x+2*y)-4*x-8*y); 434 x^2*y^2+2*x*y^2+y^2-x^2-2*x-1; 435 block([dontfactor:[x]],factor(%/36/(y^2+2*y+1))); 436 factor(%e^(3*x)+1); 437 factor(x^4+1,a^2-2); 438 factor(x^3+x^2*y^2-x*z^2-y^2*z^2); 439 (x+2)/(x+3)/(x+b)/(x+c)^2; 440 ratsimp(%); 441 partfrac(%,x); 442 map('factor,%); 443 ratsimp((x^5-1)/(x-1)); 444 subst(a,x,%); 445 factor(%th(2),%); 446 factor(x^12+1); 447 factor(x^99+1); 448 449&& factorsum 450 451 ev((x+1)*((u+v)^2+a*(w+z)^2),expand); 452 factorsum(%); 453 454&& featurep 455 456 declare(j,even)$ 457 featurep(j,integer); 458 459&& freeof 460 461 freeof(y,sin(x+2*y)); 462 freeof(cos(y),"*",sin(y)+cos(x)); 463 464&& fullmap 465 466 fullmap(g,a+b*c); 467 map(g,a+b*c); 468 469&& fullmapl 470 471 fullmapl("+",[3,[4,5]],[[a,1],[0,-1.5]]); 472 473&& funcsolve 474 475 funcsolve((n+1)*f(n)-(n+3)*f(n+1)/(n+1)=(n-1)/(n+2),f(n)); 476 477&& functions 478 479 kill(x,y,f,g,h); 480 f(x):=x^2+y; 481 f(2); 482 ev(f(2),y:7); 483 f(x):=sin(x)^2+1; 484 f(x+1); 485 g(y,z):=f(z)+3*y; 486 ev(g(2*y+z,-0.5),y:7); 487 h(n):=sum(i*x^i,i,0,n); 488 functions; 489 t[n](x):=ratexpand(2*x*t[n-1](x)-t[n-2](x)); 490 t[0](x):=1$ 491 t[1](x):=x$ 492 t[4](y); 493 g[n](x):=sum(ev(x),i,n,n+2); 494 h(n,x):=sum(ev(x),i,n,n+2); 495 g[2](i^2); 496 h(2,i^2); 497 p[n](x):=ratsimp(1/(2^n*n!)*diff((x^2-1)^n,x,n)); 498 q(n,x):=ratsimp(1/(2^n*n!)*diff((x^2-1)^n,x,n)); 499 p[2]; 500 p[2](y+1); 501 q(2,y); 502 p[2](5); 503 f[i,j](x,y):=x^i+y^j; 504 g(fun,a,b):=print(fun," applied to ",a," and ",b," is ",fun(a,b))$ 505 g(f[2,1],sin(%pi),2*c); 506 507&& genmatrix 508 509 h[i,j]:=1/(i+j-1)$ 510 genmatrix(h,3,3); 511 512&& get 513 514 put(%e,transcendental,type); 515 put(%pi,transcendental,type)$ 516 put(%i,algebraic,type)$ 517 typeof(x):=block([q], if numberp(x) 518 then return(algebraic), 519 if not atom(x) 520 then return(maplist(typeof,x)), 521 q:get(x,type), if q=false then 522 error("not numeric") else q)$ 523 errcatch(typeof(2*%e+x*%pi)); 524 typeof(2*%e+%pi); 525 526&& gfactor 527 528 gfactor(x^4-1); 529 530&& gradef 531 532 depends(y,x); 533 kill(f,g,j); 534 gradef(f(x,y),x^2,g(x,y)); 535 diff(f(x,y),x); 536 gradef(j(n,z),'diff(j(n,z),n), 537 j(n-1,z)-n/z*j(n,z))$ 538 ratsimp(diff(j(2,x),x,2)); 539 540&& horner 541 542 poly:1.0e-20*x^2-5.5*x+5.2e20; 543 errcatch(ev(%,x=1.0e20)); 544 horner(poly,x),keepfloat; 545 ev(%,x=1.0e20); 546 547&& if 548 549 fib[n]:=if n=1 or n=2 then 1 else fib[n-1]+fib[n-2]; 550 fib[1]+fib[2]; 551 fib[3]; 552 fib[5]; 553 eta(mu,nu):=if mu=nu then mu else if mu>nu then mu-nu else mu+nu; 554 eta(5,6); 555 eta(eta(7,7),eta(1,2)); 556 if not 5>=2 and 6<=5 or 4+1>3 then a else b; 557 558&& ilt 559 560 'integrate(sinh(a*x)*f(t-x),x,0,t)+b*f(t)=t^2; 561 laplace(%,t,s); 562 linsolve([%],['laplace(f(t),t,s)]); 563 ilt(ev(%[1]),s,t); 564 565&& inpart 566 567 x+y+w*z; 568 inpart(%,3,2); 569 'limit(f(x)^g(x+1),x,0,minus); 570 inpart(%,1,2); 571 572&& integrate 573 574 test(f):=block([u],u:integrate(f,x),ratsimp(f-diff(u,x))); 575 test(sin(x)); 576 test(1/(1+x)); 577 test(1/(1+x^2)); 578 integrate(sin(x)^3,x); 579 kill(q)$ 580 integrate(%e^x/(%e^x+2),x); 581 integrate(1/(x*log(x)),x); 582 integrate(sin(2*x+3),x); 583 integrate(%e^x*erf(x),x); 584 integrate(x/(x^3+1),x); 585 diff(%,x); 586 ratsimp(%); 587 integrate(x^(5/4)/(x+1)^(5/2),x,0,inf); 588 gradef(q(x),sin(x^2)); 589 diff(log(q(r(x))),x); 590 integrate(%,x); 591 592&& is 593 594 is(x^2>=2*x-1); 595 assume(a>1); 596 is(log(log(a+1)+1)>0 and a^2+1>2*a); 597 598&& isolate 599 600 (a+b)^4*(1+x*(2*x+(c+d)^2)); 601 isolate(%,x); 602 ratexpand(%)$ 603 ev(%); 604 (a+b)*(x+a+b)^2*%e^(x^2+a*x+b); 605 isolate(%,x),exptisolate:true; 606 607&& lambda 608 609 lambda([x,y,z],x^2+y^2+z^2); 610 %(1,2,a); 611 "+"(1,2,a); 612 613&& laplace 614 615 laplace(%e^(2*t+a)*sin(t)*t,t,s); 616 617&& lassociative 618 619 declare(g,lassociative); 620 g(g(a,b),g(c,d)); 621 g(g(a,b),g(c,d))-g(a,g(b,g(c,d))); 622 623&& let 624 625 matchdeclare([a,a1,a2],true); 626 oneless(x,y):=is(x=y-1)$ 627 let(a1*a2!,a1!,oneless,a2,a1); 628 let(a1!/a1,(a1-1)!),letrat; 629 letsimp(n*m!*(n-1)!/m),letrat; 630 let(sin(a)^2,1-cos(a)^2); 631 sin(x)^4; 632 letsimp(%); 633 634&& letrules 635 636 matchdeclare([a,a1,a2],true); 637 oneless(x,y):=is(x=y-1)$ 638 let(a1*a2!,a1!,oneless,a2,a1); 639 let(a1!/a1,(a1-1)!),letrat; 640 letsimp(n*m!*(n-1)!/m),letrat; 641 let(sin(a)^2,1-cos(a)^2); 642 sin(x)^4; 643 letsimp(%); 644 645&& limit 646 647 limit(x*log(x),x,0,plus); 648 limit((1+x)^(1/x),x,0); 649 limit(%e^x/x,x,inf); 650 limit(sin(1/x),x,0); 651 652&& linear 653 654 declare(f,linear); 655 f(2*a+3*b); 656 f(2*x+y,x); 657 658&& linsolve 659 660 x+z=y$ 661 2*a*x-y=2*a^2$ 662 y-2*z=2$ 663 linsolve([%th(3),%th(2),%],[x,y,z]),globalsolve; 664 665&& listofvars 666 667 listofvars(f(x[1]+y)/g^(2+a)); 668 669&& lists 670 671 [x^2,y/3,-2]; 672 %[1]*x; 673 [a,%th(2),%]; 674 675&& logcontract 676 677 2*(a*log(x) + 2*a*log(y)); 678 logcontract(%); 679 logcontract(log(sqrt(x+1)+sqrt(x)) + log(sqrt(x+1)-sqrt(x))); 680 681&& map 682 683 map(f,x+a*y+b*z); 684 map(lambda([u],partfrac(u,x)),x+1/(x^3+4*x^2+5*x+2)); 685 map(ratsimp, x/(x^2+x)+(y^2+y)/y); 686 map("=",[a,b],[-0.5,3]); 687 688&& matchdeclare 689 690 matchdeclare(a,true)$ 691 tellsimp(sin(a)^2,1-cos(a)^2)$ 692 sin(y)^2; 693 kill(rules); 694 nonzeroandfreeof(x,e):=is(e#0 and freeof(x,e)); 695 matchdeclare(a,nonzeroandfreeof(x),b,freeof(x)); 696 defmatch(linear,a*x+b,x); 697 linear(3*z+(y+1)*z+y**2,z); 698 matchdeclare([a,f],true); 699 constinterval(l,h):=constantp(h-l)$ 700 matchdeclare(b,constinterval(a))$ 701 matchdeclare(x,atom)$ 702 block(remove(integrate,outative), 703 defmatch(checklimits,'integrate(f,x,a,b)), 704 declare(integrate,outative))$ 705 'integrate(sin(t),t,x+%pi,x+2*%pi)$ 706 checklimits(%); 707 'integrate(sin(t),t,0,x)$ 708 checklimits(%); 709 710&& matrices 711 712 m:matrix([a,0],[b,1]); 713 m^2; 714 m.m; 715 m[1,1]*m; 716 %-%th(2)+1; 717 m^^-1; 718 [x,y].m; 719 matrix([a,b,c],[d,e,f],[g,h,i]); 720 %^^2; 721 722&& minfactorial 723 724 n!/(n+1)!; 725 minfactorial(%); 726 727&& multiplicative 728 729 declare(f,multiplicative); 730 f(2*a*b); 731 732&& multthru 733 734 x/(x-y)^2-1/(x-y)-f(x)/(x-y)^3; 735 multthru((x-y)^3,%); 736 ratexpand(%); 737 ((a+b)^10*s^2+2*a*b*s+(a*b)^2)/(a*b*s^2); 738 multthru(%); 739 multthru(a.(b+c.(d+e)+f)); 740 741&& nary 742 743 declare(j,nary); 744 j(j(a,b),j(c,d)); 745 746&& nounify 747 'limit(f(x)^g(x+1),x,0,minus); 748 is(inpart(%,0)=nounify(limit)); 749 750&& nroots 751 752 x^10-2*x^4+1/2; 753 nroots(%,-6,9.1); 754 755&& numfactor 756 757 gamma(7/2); 758 numfactor(%); 759 760&& nusum 761 762 nusum(n*n!,n,0,n); 763 nusum(n^4*4^n/binomial(2*n,n),n,0,n); 764 unsum(%,n); 765 unsum(prod(i^2,i,1,n),n); 766 nusum(%,n,1,n); 767 768&& oddfun 769 770 declare(f,oddfun); 771 f(-x); 772 773&& ode2 774 775 x^2*'diff(y,x) + 3*x*y = sin(x)/x; 776 soln1:ode2(%,y,x); 777 ic1(soln1,x=%pi,y=0); 778 'diff(y,x,2) + y*'diff(y,x)^3 = 0; 779 soln2:ode2(%,y,x); 780 ratsimp(ic2(soln2,x=0,y=0,'diff(y,x)=2)); 781 bc2(soln2,x=0,y=1,x=1,y=3); 782 783&& optimize 784 785 diff(exp(x^2+y)/(x+y),x,2); 786 optimize(%); 787 788&& ordergreat 789 790 a^2+b*x; 791 ordergreat(a); 792 a^2+b*x; 793 %-%th(3); 794 unorder(); 795 796&& orderless 797 798 y^2+b*x; 799 orderless(y); 800 y^2+b*x; 801 %-%th(3); 802 unorder(); 803 804&& outative 805 806 declare(f,outative); 807 f(2*a); 808 809&& part 810 811 x+y/z^2; 812 part(%,1,2,2); 813 remvalue(x); 814 'integrate(f(x),x,a,b)+x; 815 part(%,1,1); 816 x^2+2*x=y^2; 817 %+1; 818 lhs(%); 819 part(%th(2),2); 820 part(%,1); 821 27*y^3+54*x*y^2+36*x^2*y+y+8*x^3+x+1; 822 part(%,2,[1,3]); 823 sqrt(piece/54); 824 825&& partfrac 826 827 2/(x+2)-2/(x+1)+1/(x+1)^2; 828 ratsimp(%); 829 partfrac(%,x); 830 831&& partition 832 833 partition(2*a*x*f(x),x); 834 partition(a+b,x); 835 836&& pickapart 837 838 integrate(1/(x^3+2),x)$ 839 pickapart(%,1); 840 841&& poissimp 842 843 pfeformat:true$ 844 poissimp(sin(x)^2); 845 (2*a^2-b)*cos(x+2*y)-(a*b+5)*sin(u-4*x); 846 poisexpt(%,2)$ 847 printpois(%); 848 poisint(%th(2),y)$ 849 poissimp(%); 850 poissimp(sin(x)^5+cos(x)^5); 851 pfeformat:false$ 852 853&& polarform 854 855 rectform(sin(2*%i+x)); 856 polarform(%); 857 rectform(log(3+4*%i)); 858 polarform(%); 859 rectform((2+3.5*%i)^0.25),numer; 860 polarform(%); 861 862&& poly_discriminant 863 864 factor(poly_discriminant((x-a)*(x-b)*(x-c),x)); 865 866&& posfun 867 868 declare(f,posfun); 869 is(f(x)>0); 870 871&& powerseries 872 873 powerseries(log(sin(x)/x),x,0); 874 875&& printprops 876 877 gradef(r,x,x/r)$ 878 gradef(r,y,y/r)$ 879 printprops(r,atomgrad); 880 propvars(atomgrad); 881 882&& product 883 884 product(x+i*(i+1)/2,i,1,4); 885 886&& properties 887 888 properties(cons); 889 assume(var1>0); 890 properties(var1); 891 var2:2$ 892 properties(var2); 893 894&& propvars 895 896 gradef(r,x,x/r)$ 897 gradef(r,y,y/r)$ 898 printprops(r,atomgrad); 899 propvars(atomgrad); 900 901&& qunit 902 903 qunit(17); 904 expand(%*(sqrt(17)-4)); 905 906&& radcan 907 908 (log(x^2+x)-log(x))^a/log(x+1)^(a/2); 909 radcan(%); 910 log(a^(2*x)+2*a^x+1)/log(a^x+1); 911 radcan(%); 912 (%e^x-1)/(%e^(x/2)+1); 913 radcan(%); 914 915&& rank 916 917 matrix([2,1-a,-5*b],[a,b,c]); 918 rank(%); 919 920&& rassociative 921 922 declare(g,rassociative); 923 g(g(a,b),g(c,d)); 924 g(g(a,b),g(c,d))-g(a,g(b,g(c,d))); 925 926&& rat 927 928 rat(x^2); 929 diff(f(%),x); 930 ((x-2*y)^4/(x^2-4*y^2)^2+1)*(y+a)*(2*y+x)/(4*y^2+x^2); 931 rat(%,y,a,x); 932 (x+3)^20; 933 rat(%); 934 diff(%,x); 935 factor(%); 936 937&& ratcoeff 938 939 a*x+b*x+5$ 940 ratcoef(%,a+b); 941 942&& ratdiff 943 944 (4*x^3+10*x-11)/(x^5+5); 945 polymod(%),modulus:3; 946 ratdiff(%th(2),x); 947 948&& ratexpand 949 950 ratexpand((2*x-3*y)^3); 951 (x-1)/(x+1)^2+1/(x-1); 952 expand(%); 953 ratexpand(%th(2)); 954 955&& ratsimp 956 957 sin(x/(x^2+x))=%e^((log(x)+1)^2-log(x)^2); 958 ratsimp(%); 959 b*(a/b-x)+b*x+a; 960 ratsimp(%); 961 ((x-1)^(3/2)-(x+1)*sqrt(x-1))/sqrt(x-1)/sqrt(x+1); 962 ratsimp(%); 963 x^(a+1/a),ratsimpexpons; 964 965&& ratsubst 966 967 ratsubst(a,x*y^2,x^4*y^8+x^4*y^3); 968 1 + cos(x) + cos(x)^2 + cos(x)^3 + cos(x)^4; 969 ratsubst(1-sin(x)^2,cos(x)^2,%); 970 ratsubst(1-cos(x)^2,sin(x)^2,sin(x)^4); 971 972&& ratweight 973 974 ratweight(a,1,b,1); 975 rat(a+b+1); 976 %^2; 977 ev(%th(2)^2,ratwtlvl:1); 978 979&& realpart 980 981 (%i*v+u)/(f+%i*e)+%e^(%i*alpha); 982 realpart(%); 983 984&& realroots 985 986 realroots(x^5-x-1,5.0e-6); 987 %[1],float; 988 x^5-x-1,%; 989 990&& residue 991 992 residue(s/(s^2+a^2),s,a*%i); 993 residue(sin(a*x)/x^4,x,0); 994 995&& resultant 996 997 resultant(a*y+x^2+1,y^2+x*y+b,x); 998 999&& reveal 1000 1001 integrate(1/(x^3+2),x)$ 1002 reveal(%,2); 1003 reveal(%th(2),3); 1004 1005&& reverse 1006 1007 union({a,b,1,1/2,x^2},{-x^2,a,y,1/2}); 1008 bernpoly(x,5); 1009 maplist(numfactor,%); 1010 apply(min,%); 1011 1012&& risch 1013 1014 risch(x^2*erf(x),x); 1015 diff(%,x),ratsimp; 1016 1017&& rootscontract 1018 1019 rootsconmode:false$ 1020 rootscontract(x^(1/2)*y^(3/2)); 1021 rootscontract(x^(1/2)*y^(1/4)); 1022 rootsconmode:true$ 1023 rootscontract(x^(1/2)*y^(1/4)); 1024 rootscontract(x^(1/2)*y^(1/3)); 1025 rootsconmode:all$ 1026 rootscontract(x^(1/2)*y^(1/4)); 1027 rootscontract(x^(1/2)*y^(1/3)); 1028 rootsconmode:false$ 1029 rootscontract(sqrt(sqrt(x+1)+sqrt(x))*sqrt(sqrt(x+1)-sqrt(x))); 1030 rootsconmode:true$ 1031 rootscontract(sqrt(sqrt(5)+5)-5^(1/4)*sqrt(sqrt(5)+1)); 1032 1033&& scanmap 1034 1035 (a^2+2*a+1)*y+x^2; 1036 scanmap(factor,%); 1037 scanmap(factor,expand(%th(2))); 1038 u*v^(a*x+b)+c; 1039 scanmap('f,%); 1040 1041&& scsimp 1042 1043 exp:k^2*n^2+k^2*m^2*n^2-k^2*l^2*n^2-k^2*l^2*m^2*n^2; 1044 eq1:k^2+l^2=1; 1045 eq2:n^2-m^2=1; 1046 scsimp(exp,eq1,eq2); 1047 exq:(k1*k4-k1*k2-k2*k3)/k3^2; 1048 eq3:k1*k4-k2*k3=0; 1049 eq4:k1*k2+k3*k4=0; 1050 scsimp(exq,eq3,eq4); 1051 1052&& solve 1053 1054 solve(asin(cos(3*x))*(f(x)-1),x); 1055 solve(5^f(x)=125,f(x)),solveradcan; 1056 [4*x^2-y^2=12,x*y-x=2]; 1057 solve(%,[x,y]); 1058 solve(x^3+a*x+1,x); 1059 solve(x^3-1); 1060 solve(x^6-1); 1061 ev(x^6-1,%[1]); 1062 expand(%); 1063 x^2-1; 1064 solve(%,x); 1065 %th(2),%[1]; 1066 1067&& specint 1068 1069 assume(p>0,a>0)$ 1070 /* a laplace transform */ 1071 t^(1/2)*%e^(-a*t/4)*%e^(-p*t); 1072 specint(%,t); 1073 /* a bessel function */ 1074 t^(1/2)*%j[1](2*a^(1/2)*t^(1/2))*%e^(-p*t); 1075 specint(%,t); 1076 forget(p>0,a>0)$ 1077 1078&& sqfr 1079 1080 sqfr(4*x^4+4*x^3-3*x^2-4*x-1); 1081 1082&& substinpart 1083 1084 x.'diff(f(x),x,2); 1085 substinpart(d^2,%,2); 1086 substinpart(f1,f[1](x+1),0); 1087 1088&& substitute 1089 1090 subst(a,x+y,x+(x+y)^2+y); 1091 subst(-%i,%i,a+b*%i); 1092 subst(x,y,x+y); 1093 subst(x=0,diff(sin(x),x)); 1094 errcatch(ev(diff(sin(x),x),x=0)); 1095 integrate(x^i,x),i=-1; 1096 errcatch(subst(-1,i,integrate(x^i,x))); 1097 matrix([a,b],[c,d]); 1098 subst("[",matrix,%); 1099 1100&& substpart 1101 1102 1/(x^2+2); 1103 substpart(3/2,%,2,1,2); 1104 27*y^3+54*x*y^2+36*x^2*y+y+8*x^3+x+1; 1105 substpart(factor(piece),%,[1,2,3,5]); 1106 1/x+y/x-1/z; 1107 substpart(xthru(piece),%,[2,3]); 1108 substpart("+",%,1,0); 1109 ratsimp((k^2*x^2-1)*(cos(x)+eps)/(3*k+n[1])/(5*k-n[2])); 1110 factor(%); 1111 substpart(ratsimp(piece),%,1,[1,2]); 1112 -substpart(-piece,%,1,1); 1113 a+b/(x*(y+(a+b)*x)+1); 1114 substpart(multthru(piece),%,1,2,1); 1115 1116&& sum 1117 1118 sum(i^2+2^i,i,0,n),simpsum; 1119 sum(3^(-i),i,1,inf),simpsum; 1120 sum(i^2,i,1,4)*sum(1/i^2,i,1,inf),simpsum; 1121 sum(i^2,i,1,5); 1122 1123&& symmetric 1124 1125 declare(h,symmetric); 1126 h(x,z,y); 1127 1128&& syntax 1129 1130 matchfix("@{","@}"); 1131 infix("|"); 1132 @{x|x>0@}; 1133 @{x|x<2@}; 1134 infix(".u.")$ 1135 infix(".i.")$ 1136 %th(4).u.%th(3); 1137 %th(5).u.%th(4); 1138 @{1,2,3@}$ 1139 @{3,4,5@}$ 1140 %th(2).u.%th(2).u.%; 1141 infix(".u.",100,100)$ 1142 infix(".i.",120,120)$ 1143 %th(5).u.%th(5).u.%; 1144 remove(".u.",operator)$ 1145 errcatch(%th(7).u.%th(3)); 1146 remove(["@{","@}",".i.",".u."],operator)$ 1147 1148&& taylor 1149 1150 taylor(sqrt(1+a*x+sin(x)),x,0,3); 1151 %^2; 1152 taylor(sqrt(1+x),x,0,5); 1153 %^2; 1154 product((x^i+1)^2.5,i,1,inf)/(x^2+1); 1155 taylor(%,x,0,3),keepfloat; 1156 taylor(1/log(1+x),x,0,3); 1157 taylor(cos(x)-sec(x),x,0,5); 1158 taylor((cos(x)-sec(x))^3,x,0,5); 1159 taylor((cos(x)-sec(x))^-3,x,0,5); 1160 taylor(sqrt(1-k^2*sin(x)^2),x,0,6); 1161 taylor((1+x)^n,x,0,4); 1162 taylor(sin(x+y),x,0,3,y,0,3); 1163 taylor(sin(x+y),[x,y],0,3); 1164 taylor(1/sin(x+y),x,0,3,y,0,3); 1165 taylor(1/sin(x+y),[x,y],0,3); 1166 1167&& taytorat 1168 1169 taylor(1+x,[x,0,3]); 1170 1/%; 1171 taylor(1+x+y+z,[x,0,3],[y,1,2],[z,2,1]); 1172 1/%; 1173 taylor(1+x+y+z,[x,0,3],[y,0,3],[z,0,3]); 1174 1/%; 1175 1176&& tellrat 1177 1178 10*(1+%i)/(3^(1/3)+%i); 1179 ratdisrep(rat(%)),algebraic; 1180 tellrat(a^2+a+1); 1181 a/(sqrt(2)+sqrt(3))+1/(a*sqrt(2)-1); 1182 ratdisrep(rat(%)),algebraic; 1183 tellrat(y^2=x^2); 1184 1185&& tellsimp 1186 1187 matchdeclare(x,freeof(%i))$ 1188 %iargs:false$ 1189 tellsimp(sin(%i*x),%i*sinh(x)); 1190 trigexpand(sin(x+%i*y)); 1191 %iargs:true$ 1192 errcatch(0^0); 1193 tellsimp(0^0,1),simp:false; 1194 0^0; 1195 remrule("^",%th(2)[1]); 1196 tellsimp(sin(x)^2,1-cos(x)^2)$ 1197 (sin(x)+1)^2; 1198 expand(%); 1199 sin(x)^2; 1200 kill(rules); 1201 matchdeclare(a,true)$ 1202 tellsimp(sin(a)^2,1-cos(a)^2)$ 1203 sin(y)^2; 1204 kill(rules); 1205 1206&& triangularize 1207 1208 matrix([2,1-a,-5*b],[a,b,c]); 1209 triangularize(%); 1210 1211&& trig 1212 1213 sin(%pi/12)+tan(%pi/6); 1214 ev(%,numer); 1215 sin(1); 1216 sin(1),numer; 1217 beta(1/2,2/5); 1218 ev(%,numer); 1219 diff(atanh(sqrt(x)),x); 1220 fpprec:25$ 1221 sin(0.5b0); 1222 cos(x)^2-sin(x)^2; 1223 ev(%,x:%pi/3); 1224 diff(%th(2),x); 1225 integrate(%th(3),x); 1226 expand(%); 1227 trigexpand(%); 1228 trigreduce(%); 1229 sech(x)^2*sinh(x)*tanh(x)/coth(x)^2 + cosh(x)^2*sech(x)^2*tanh(x)/coth(x)^2 1230 + sech(x)^2*tanh(x)/coth(x)^2; 1231 trigsimp(%); 1232 ev(sin(x),exponentialize); 1233 taylor(sin(x)/x,x,0,4); 1234 ev(cos(x)^2-sin(x)^2,sin(x)^2=1-cos(x)^2); 1235 1236&& trigexpand 1237 1238 x+sin(3*x)/sin(x),trigexpand,expand; 1239 trigexpand(sin(10*x+y)); 1240 1241&& trigreduce 1242 1243 -sin(x)^2+3*cos(x)^2+x; 1244 expand(trigreduce(%)); 1245 declare(j,integer,e,even,o,odd); 1246 sin(x+(e+1/2)*%pi); 1247 sin(x+(o+1/2)*%pi); 1248 1249&& unorder 1250 1251 a^2+b*x; 1252 ordergreat(a); 1253 a^2+b*x; 1254 %-%th(3); 1255 unorder(); 1256 1257&& xthru 1258 1259 ((x+2)^20-2*y)/(x+y)^20+(x+y)^-19-x/(x+y)^20; 1260 xthru(%); 1261 1262&& zeroequiv 1263 1264 zeroequiv(sin(2*x)-2*sin(x)*cos(x),x); 1265 zeroequiv(%e^x+x,x); 1266 zeroequiv(log(a*b)-log(a)-log(b),a); 1267