> with(linalg):
Warning, the protected names norm and trace have been redefined and
unprotected

> Funktionen_N := matrix(1,4,[N[1],N[2],N[3],N[4]]);

            Funktionen_N := [N[1]    N[2]    N[3]    N[4]]

> Funktionen_M := matrix(1,4,[M[1],M[2],M[3],M[4]]);

            Funktionen_M := [M[1]    M[2]    M[3]    M[4]]

> J := multiply(transpose(Funktionen_N),Funktionen_M):         K :=
> Int(evalm(J),t);

           / [N[1] M[1]    N[1] M[2]    N[1] M[3]    N[1] M[4]]
          |  [                                                ]
          |  [N[2] M[1]    N[2] M[2]    N[2] M[3]    N[2] M[4]]
    K :=  |  [                                                ] dt
          |  [N[3] M[1]    N[3] M[2]    N[3] M[3]    N[3] M[4]]
          |  [                                                ]
         /   [N[4] M[1]    N[4] M[2]    N[4] M[3]    N[4] M[4]]

> N[1] := t ->  1-(11/2)*t+9*t^2 -(9/2)*t^3;

                                            2        3
               N[1] := t -> 1 - 11/2 t + 9 t  - 9/2 t

> N[2] := t ->  9*t-(45/2)*t^2+(27/2)*t^3;

                                          2         3
                 N[2] := t -> 9 t - 45/2 t  + 27/2 t

> N[3] := t ->  -(9/2)*t+18*t^2-(27/2)*t^3;

                                          2         3
                N[3] := t -> -9/2 t + 18 t  - 27/2 t

> N[4] := t ->   t-(9/2)*t^2+(9/2)*t^3;

                                         2        3
                   N[4] := t -> t - 9/2 t  + 9/2 t

# Die Funktionen M erhlt man daraus nach der Formel M = k*N + dN/dt:
> M[1] := t ->  -11/2+18*t-(27/2)*t^2+k*(1-(11/2)*t+9*t^2-(9/2)*t^3);

  M[1] :=

                                   2                      2        3
        t -> - 11/2 + 18 t - 27/2 t  + k (1 - 11/2 t + 9 t  - 9/2 t )

> M[2] := t ->  9-45*t+(81/2)*t^2+k*(9*t-(45/2)*t^2+(27/2)*t^3);

                                  2                  2         3
    M[2] := t -> 9 - 45 t + 81/2 t  + k (9 t - 45/2 t  + 27/2 t )

> M[3] := t ->  -9/2+36*t-(81/2)*t^2+k*(-(9/2)*t+18*t^2-(27/2)*t^3);

                                    2                   2         3
  M[3] := t -> - 9/2 + 36 t - 81/2 t  + k (-9/2 t + 18 t  - 27/2 t )

> M[4] := t ->  1-9*t+(27/2)*t^2+k*(t-(9/2)*t^2+(9/2)*t^3);

                                    2               2        3
       M[4] := t -> 1 - 9 t + 27/2 t  + k (t - 9/2 t  + 9/2 t )

> K := map(int,J(t),t=0..1);

           [8 k         57   33 k     3 k                 19 k]
           [--- - 1/2 , -- + ---- , - --- - 3/10 , 7/80 + ----]
           [105         80   560      140                 1680]
           [                                                  ]
           [33 k   57     27 k       27 k   81      3 k       ]
           [---- - -- ,   ---- ,   - ---- + -- ,  - --- - 3/10]
           [560    80      70        560    80      140       ]
      K := [                                                  ]
           [  3 k              27 k   81     27 k    57   33 k]
           [- --- + 3/10 ,   - ---- - -- ,   ---- ,  -- + ----]
           [  140              560    80      70     80   560 ]
           [                                                  ]
           [19 k            3 k          33 k   57   8 k      ]
           [---- - 7/80 , - --- + 3/10 , ---- - -- , --- + 1/2]
           [1680            140          560    80   105      ]

> F:=k*T[infinity]*map(Int,Funktionen_N,t=0..1);

  F := k T[infinity]

        [   1              1              1              1        ]
        [  /              /              /              /         ]
        [ |              |              |              |          ]
        [ |   N[1] dt ,  |   N[2] dt ,  |   N[3] dt ,  |   N[4] dt]
        [ |              |              |              |          ]
        [/              /              /              /           ]
        [  0              0              0              0         ]

> F:=k*T[infinity]*map(int,Funktionen_N(t),t=0..1);

            F := k T[infinity] [1/8    3/8    3/8    1/8]

# Als Zahlenbeispiel sei k = 2 und die Umgebungstemperatur T(1) = 1/2
# wie in  7.2.1 gewhlt. Dann wird:
> M[1]:=t->-7/2+7*t+(9/2)*t^2-9*t^3: M[2]:=t->9-27*t-(9/2)*t^2+27*t^3:  
>                                   M[3]:=t->-9/2+27*t-(9/2)*t^2-27*t^3:
> M[4]:=t->1-7*t+(9/2)*t^2+9*t^3:  
> 
> N[1]:=t->1-(11/2)*t+9*t^2-(9/2)*t^3:
> N[2]:=t->9*t-(45/2)*t^2+(27/2)*t^3:        
> N[3]:=t->-(9/2)*t+18*t^2-(27/2)*t^3: N[4]:=t->t-(9/2)*t^2+(9/2)*t^3: 
> #J := multiply(transpose(Funktionen_N),Funktionen_M);        
> K := map(int,J(t),t=0..1);

                       [-73     93      -12     37 ]
                       [---     ---     ---     ---]
                       [210     112     35      336]
                       [                           ]
                       [-333     27     513     -12]
                       [----     --     ---     ---]
                       [560      35     560     35 ]
                  K := [                           ]
                       [        -621     27     93 ]
                       [9/35    ----     --     ---]
                       [        560      35     112]
                       [                           ]
                       [-109            -333    137]
                       [----    9/35    ----    ---]
                       [1680            560     210]

> F:=map(int,Funktionen_N(t),t=0..1);

                   F := [1/8    3/8    3/8    1/8]

> f:=vector([1/8,3/8,3/8,1/8]);

                      f := [1/8, 3/8, 3/8, 1/8]

# Lt man die Anfangstemperatur zunchst offen, so erhlt man die
# "triviale" Lsung
> linsolve(K,f);

                         [1/2, 1/2, 1/2, 1/2]

# Nimmt man die Anfangstemperatur T(0) = 1 an, so ergibt sich aus den
# letzten drei Gleichungen der Matrixgleichung folgende
# Knotentemperaturen:
> solve({-333/560+(27/35)*T[2]+(513/560)*T[3]-(12/35)*T[4]=3/8,
> 9/35-(621/560)*T[2]+(27/35)*T[3]+(93/112)*T[4]=3/8,  
> -109/1680+(9/35)*T[2]-(333/560)*T[3]+(137/210)*T[4]=1/8},
> {T[2],T[3],T[4]});

                        5137         881          171
                {T[3] = ----, T[2] = ----, T[4] = ---}
                        8127         1161         301

> T[2]:=evalf(881/1161); T[3]:=evalf(5137/8127); T[4]:=evalf(171/301); 

                         T[2] := 0.7588285960


                         T[3] := 0.6320905623


                         T[4] := 0.5681063123

# Die exakten Werte ergeben sich zu:
> Tau[2]:=evalf(exp(-2/3)+(1-exp(-2/3))/2);

                        Tau[2] := 0.7567085595

> Tau[3]:=evalf(exp(-4/3)+(1-exp(-4/3))/2);

                        Tau[3] := 0.6317985691

> Tau[4]:=evalf(exp(-2)+(1-exp(-2))/2);

                        Tau[4] := 0.5676676416

# Die nach der FEM ermittelten Knotenwerte stimmen mit der exakten
# Lsung gut berein!
> 
# Die folgende graphische Darstellung vergleicht die Abkhlkurven aus
# den FEM-Lsungen 7.2.1 bis 7.2.3 nach dem GALERKIN-Verfahren mit der
# exakten Lsung:
> 
# 1) lineare Anstze / zwei finite Elemente / aus  7.2.1
> T[I]:=1-2*t+2*(19/28)*t;

                                       9 t
                           T[I] := 1 - ---
                                       14

> T[II]:=2*(19/28)*(1-t)+(4/7)*(-1+2*t);

                                   11   3 t
                          T[II] := -- - ---
                                   14   14

# 2) quadratische Anstze / Einzelelement / aus  7.2.2
> Q:=1-3*t+2*t^2+4*(39/56)*t*(1-t)+(4/7)*t*(-1+2*t);

                           2   39 t (1 - t)   4 t (-1 + 2 t)
         Q := 1 - 3 t + 2 t  + ------------ + --------------
                                    14              7

# 3) kubische Anstze / Einzelelement / aus  7.2.3
> K:=1-(11/2)*t+9*t^2-(9/2)*t^3+(881/1161)*(9*t-(45/2)*t^2+(27/2)*t^3)+(
> 5137/8127)*(-(9/2)*t+18*t^2-(27/2)*t^3)+(171/301)*(t-(9/2)*t^2+(9/2)*t
> ^3);

                            285     225  2   10  3
                   K := 1 - --- t + --- t  - -- t
                            301     301      43

# 4) exakte Lsung / Gesamtbereich / aus  7.2.1
> Tau:=(1/2)*(1+exp(-2*t));

                      Tau := 1/2 + 1/2 exp(-2 t)

> with(plots);
Warning, the name changecoords has been redefined


  [animate, animate3d, animatecurve, arrow, changecoords, complexplot,

        complexplot3d, conformal, conformal3d, contourplot,

        contourplot3d, coordplot, coordplot3d, cylinderplot,

        densityplot, display, display3d, fieldplot, fieldplot3d,

        gradplot, gradplot3d, graphplot3d, implicitplot,

        implicitplot3d, inequal, interactive, listcontplot,

        listcontplot3d, listdensityplot, listplot, listplot3d,

        loglogplot, logplot, matrixplot, odeplot, pareto, plotcompare,

        pointplot, pointplot3d, polarplot, polygonplot, polygonplot3d,

        polyhedra_supported, polyhedraplot, replot, rootlocus,

        semilogplot, setoptions, setoptions3d, spacecurve,

        sparsematrixplot, sphereplot, surfdata, textplot, textplot3d,

        tubeplot]

> plot1:=plot({T[I](t)},t=0..1/2,color=black):
> plot2:=plot({T[II](t)},t=1/2..1,color=black):
> plot3:=plot({Q(t)},t=0..1,color=black):
> plot4:=plot({K(t)},t=0..1,color=black):
> plot5:=plot({Tau(t)},t=0..1,color=black):
> plots[display]({plot1,plot2,plot3,plot4,plot5});

# Im Bild erkennt man, dass die Lsung auf der Basis kubischer
# Formfunktionen nur geringfgig von der exakten Lsung abweicht. Die
# "lineare" und "quadratische" Lsung nehmen in t = 1 denselben Wert von
# 4/7 an. 
> 
