-
Notifications
You must be signed in to change notification settings - Fork 0
/
GalerkinMethods.m
60 lines (50 loc) · 1.41 KB
/
GalerkinMethods.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(* ::Package:: *)
(* ::Input:: *)
(*(*Galerkin Methods for Deveriation Equation*)*)
(*(*y''+y=x^2,y[0]=0,y'[1]=1*)*)
(*ClearAll["Global`*"]*)
(*phi0[x_]:=x;*)
(*phi1[x_]:=x(2-x);*)
(*phi2[x_]:=x^2(1-2/3 x);*)
(*y[x_]:=phi0[x]+a1 phi1[x]+a2 phi2[x];*)
(*Tuf[x_]:=y''[x]+y[x]-x^2;*)
(*Solve[{*)
(*Integrate[Tuf[x]phi1[x],{x,0,1}]==0,*)
(*Integrate[Tuf[x]phi2[x],{x,0,1}]==0*)
(*}*)
(*,{a1,a2}]*)
(* ::Input:: *)
(*(*Galerkin Methods for Eigen Value*)*)
(*(*y''+lambda(1+x^2)y=0,y(-1)=y(1)=0*)*)
(*ClearAll["Global`*"]*)
(*phi0[x_]:=(1-x^2);*)
(*phi1[x_]:=(1-x^2)x^2;*)
(*y[x_]:=a0 phi0[x]+a1 phi1[x];*)
(*Tuf[x_]:=y''[x]+lambda(1+x^2)y[x];*)
(*Solve[{*)
(*Integrate[Tuf[x]phi0[x],{x,-1,1}]==0,*)
(*Integrate[Tuf[x]phi1[x],{x,-1,1}]==0*)
(*}*)
(*,{lambda,a1,a2}]*)
(* ::Input:: *)
(*5*)
(* ::Input:: *)
(*ClearAll["Global`*"]*)
(*Needs["VariationalMethods`"]*)
(*F[x_]:=6y[x]^2+x^2y'[x]^2;*)
(*(*Result =Simplify[DSolve[VariationalD[F[x],y[x],x]\[Equal]lambda y[x],y[x],x]]*)
(*y[x_]=y[x]/.First@ Result*)
(*Integrate[y[x],{x,1,Exp[1]}]*)
(*Solve[{*)
(*ExpToTrig[Refine[Integrate[y[x]^2,{x,1,Exp[1]}],Assumptions\[Rule]25-2lambda<0]]\[Equal]1&&*)
(*y[1]\[Equal]0&&*)
(*y[Exp[1]]\[Equal]0*)
(*},*)
(*{*)
(*C[1],*)
(*C[2],*)
(*lambda*)
(*},Complexes]*)*)
(*DEigenvalues[{-Laplacian[y[x],{x}]DirichletCondition[y[x]==0,True]},y[x],{x,0,Exp[1]},2]*)
(*DEigenvalues[{D[u[x],{x}]==0,DirichletCondition[u[x]==1,True]},u[x],{x,0,5},2]*)
(**)