Changeset 9de0abd in git for Singular/LIB
- Timestamp:
- Oct 14, 2010, 8:30:42 PM (14 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 47d83a1a12f99e384d92eba3cd8bc435b7666c94
- Parents:
- 8059d4af6d5b03c3046b05aedbc4b76e360f1488
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/findifs.lib
r8059d4 r9de0abd 4 4 info=" 5 5 LIBRARY: findifs.lib Tools for the finite difference schemes 6 AUTHORS: Viktor Levandovskyy, levandov@risc.uni-linz.ac.at 7 8 THEORY: We provide the presentation of difference operators in a polynomial, 6 AUTHORS: Viktor Levandovskyy, levandov@math.rwth-aachen.de 7 8 OVERVIEW: 9 We provide the presentation of difference operators in a polynomial, 9 10 semi-factorized and a nodal form. Running @code{findifs_example();} 10 will show how we generate finite difference schemes of linear PDE's 11 from given approximations. 11 will demonstrate, how we generate finite difference schemes of linear PDEs 12 from given approximations. 13 14 Theory: The method we use have been developed by V. Levandovskyy and Bernd Martin. The 15 computation of a finite difference scheme of a given single linear partial 16 differential equation with constant coefficients with a given approximation 17 rules boils down to the computation of a Groebner basis of a submodule of 18 a free module with respect to the ordering, eliminating module components. 19 20 21 Support: SpezialForschungsBereich F1301 of the Austrian FWF 12 22 13 23 PROCEDURES: 24 findifs_example(); containes a guided explanation of our approach 14 25 decoef(P,n); decompose polynomial P into summands with respect to the number n 15 26 difpoly2tex(S,P[,Q]); present the difference scheme in the nodal form 16 27 17 AUXILIARY PROCEDURES: 18 findifs_example(); containes a guided explanation of our approach 28 19 29 exp2pt(P[,L]); convert a polynomial M into the TeX format, in nodal form 20 mon2pt(P[,L]); convert a monomial M into the TeX format, in nodal form21 30 texcoef(n); converts the number n into TeX 22 31 npar(n); search for 'n' among the parameters and returns its number 23 32 magnitude(P); compute the square of the magnitude of a complex expression 24 33 replace(s,what,with); replace in s all the substrings with a given string 25 xchange(w,a,b); exchange two substrings of a string 26 par2tex(s); convert special characters to TeX in s 34 xchange(w,a,b); exchange two substrings in a given string 35 36 SEE ALSO: latex_lib, findiff_lib 27 37 "; 28 38 … … 30 40 LIB "latex.lib"; 31 41 LIB "poly.lib"; 42 43 proc tst_findif() 44 { 45 example decoef; 46 example difpoly2tex; 47 example exp2pt; 48 example texcoef; 49 example npar; 50 example magnitude; 51 example replace; 52 example xchange; 53 } 54 55 // static procs: 56 // par2tex(s); convert special characters to TeX in s 57 // mon2pt(P[,L]); convert a monomial M into the TeX format, in nodal form 58 32 59 33 60 // 1. GLOBAL ASSUME: in the ring we have first Tx, then Tt: [FIXED, not needed anymore]! … … 63 90 } 64 91 65 proc par2tex(string s)92 static proc par2tex(string s) 66 93 "USAGE: par2tex(s); s a string 67 94 RETURN: string … … 73 100 EXAMPLE: example par2tex; shows examples 74 101 "{ 102 // can be done with the help of latex_lib 103 75 104 // s is a tex string with a poly 76 105 // replace theta with \theta … … 220 249 } 221 250 222 proc mon2pt(poly M, string V)251 static proc mon2pt(poly M, string V) 223 252 "USAGE: mon2pt(M,V); M poly, V a string 224 253 RETURN: string … … 334 363 RETURN: ideal 335 364 PURPOSE: decompose polynomial P into summands with respect 336 to the presence of anumber n in the coefficients365 to the presence of the number n in the coefficients 337 366 NOTE: n is usually a parameter with no power 338 367 EXAMPLE: example decoef; shows examples … … 395 424 RETURN: string 396 425 PURPOSE: converts the number n into TeX format 397 NOTE: if n is a polynomial, texcoef adds extra brackets. 398 @* Performs some space substitutions 426 NOTE: if n is a polynomial, texcoef adds extra brackets and performs some space substitutions 399 427 EXAMPLE: example texcoef; shows examples 400 428 "{ … … 464 492 RETURN: string 465 493 PURPOSE: present the difference scheme in the nodal form 466 ASSUME: ideal S is the result of 'decoef'procedure494 ASSUME: ideal S is the result of @code{decoef} procedure 467 495 NOTE: a list P may be empty or may contain parameters, which will not 468 496 appear in denominators … … 611 639 " 612 640 { 613 // check whether i is present among the vars TODO 614 // assume i^2+1=0; 641 // check whether i is present among the vars 642 list L = ringlist(basering)[2]; // vars 643 int j; int cnt = 0; 644 for(j=size(L);j>0;j--) 645 { 646 if (L[j] == "i") 647 { 648 cnt = 1; break; 649 } 650 } 651 if (!cnt) 652 { 653 ERROR("a variable called i is expected in basering"); 654 } 655 // i is present, check that i^2+1=0; 656 // if (NF(i^2+1,std(0)) != 0) 657 // { 658 // "Warning: i^2+1=0 does not hold. Reduce the output manually"; 659 // } 615 660 poly re = subst(P,i,0); 616 661 poly im = (P - re)/i; … … 621 666 "EXAMPLE:"; echo=2; 622 667 ring r = (0,d),(g,i,sin,cos),dp; 623 poly P = d*i*sin - g*cos +d^2 ;624 magnitude(P);668 poly P = d*i*sin - g*cos +d^2*i; 669 NF( magnitude(P), std(i^2+1) ); 625 670 } 626 671 … … 637 682 return(t); 638 683 } 639 640 static proc ElimModComp(module M, int num)641 {642 // experimental, todo643 // check whether a curr.ord is elim-comp644 string s = ordstr(basering);645 int ns = size(s);646 // s[ns] = "c", "C";647 if (s[1]="c")648 {649 // num last components650 }651 if (s[1]="C")652 {653 // num first components654 }655 }656 657 684 658 685 static proc simfrac(poly up, poly down) … … 713 740 " module R = transpose(M);"; 714 741 " module S = std(R);"; 715 " poly p = S[4,1];" ;716 742 module R = transpose(M); 717 743 module S = std(R); 744 " * See the result of Groebner bases: generators are columns"; 745 " print(S);"; 746 print(S); 747 " * So, only the first column has its nonzero element in the last component"; 748 " * Hence, this polynomial is the scheme"; 749 " poly p = S[4,1];" ; 718 750 poly p = S[4,1]; // by elimination of module components 751 " print(p); "; 752 print(p); 719 753 list L; L[1]=A;L[2] = B; 720 754 ideal I = decoef(p,dt); // make splitting w.r.t. the appearance of dt
Note: See TracChangeset
for help on using the changeset viewer.