Method of Weighted Residual on the HP 28S
03-11-2017, 03:18 AM (This post was last modified: 03-17-2017 11:01 PM by mbrethen.)
Post: #1
 mbrethen Junior Member Posts: 35 Joined: Dec 2013
Method of Weighted Residual on the HP 28S
Prior to development of the Finite Element Method, there existed an approximation technique for solving differential equations called the Method of Weighted Residuals (MWR). In order to explain the method, consider the example problem in the attached pdf. A trial function, u = ax(1-x), is selected as an approximate solution to the differential equation. The trial function is chosen such that it satisfies the boundary conditions and it has one unknown coefficient to be determined. Once a trial function is selected, the residual R is computed by substituting the trial function into the differential equation. Because u is different from the exact solution, the residual does not vanish for all values of x within the boundary values. The next step is to determine the unknown constant a such that the chosen test function best approximates the exact solution. For Galerkin's method, the test function w comes from the chosen trial function, i.e. w = du/da and the weighted average of the residual over the problem domain is set to zero.

GALERKN ( Galerkin method of weighted residuals ) Program
Code:
<<    OVER SIZE -> n   << LIST-> DROP      1. n        FOR m        "I" 48 m + CHR + STR->      NEXT n ->LIST      -> uc x a b wr     << DUP x        DEQ        'R' STO        { }        1. n        FOR i          OVER          uc i GET          ∂ +        NEXT         'W' STO         1. n        FOR j          'W' j GET          R *          x 6 ∫ DUP          a b          FOR k             k x STO EVAL SWAP          NEXT -          wr j GET STO          x PURGE        NEXT        wr uc 1        DO                          GETI 1E-3 SWAP STO        UNTIL           46 FS?        END         DROP        1E-5 DUP        MSLV CLMF DROP        EVAL     >>   >> >>
Note: Symbolic integration requires that one specify the degree of the polynomial. HP 28S RPL does not contain a command that returns the degree of a polynomial, so I have used a static value of 6.

The most straightforward method of defining R is to store the program DEQ:
Code:
<< -> u x << u x ∂ x ∂ u - x + >> >>

Execute GALERKN with three arguments, as follows:
1. The level 3 argument is an algebraic object that represents the trial function, e.g. 'A*X*(1-X)'.
2. The level 2 argument is a list containing the unknown coefficients, e.g. { A }.
3. The level 1 argument is a list containing the independent variable and boundary values, e.g. { 'X' 0 1}.

The program returns the trial function with a = 0.22727 (runtime ~1 min 48 sec). It is shown plotted with the exact solution for 0<x<1. In order to improve the approximation another term is added to the trial function, u = a1x(1-x) + a2x^2(1-x). This solution took about 31 min.

RPL calculators never had a simultaneous equation solver until the MSLV function on the 49 series. Mike Ingle wrote the code TMSLV for the 48GX and HP-28C&S. It can be found elsewhere on the web.

Edit: I have included Matlab output in the pdf comparing the second solution for 2 unknown coefficients in the trial function.

Attached File(s)
galerkin_ex1.pdf (Size: 721.45 KB / Downloads: 16)
GALERKN.txt (Size: 2.92 KB / Downloads: 9)
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)