• Non ci sono risultati.

Clear @ a, b, p, q, r, w, x, aa D fp @ x_ D := 0;

N/A
N/A
Protected

Academic year: 2021

Condividi "Clear @ a, b, p, q, r, w, x, aa D fp @ x_ D := 0;"

Copied!
7
0
0

Testo completo

(1)

In[1]:=

Clear @ a, b, p, q, r, w, x, aa D fp @ x_ D := 0;

fq @ x_ D := 4;

fr @ x_ D := -4 x;

a = 0.;

b = 1.;

b = 4.;

Α = 0.;

Β = 2.;

xrange = 8 a, b + 0.2 < ;

eqdiff = y '' @ x D Š fp @ x D * y ' @ x D + fq @ x D * y @ x D + fr @ x D ; soldiff = DSolve @8 eqdiff, y @ a D Š Α , y @ b D == Β< , y @ x D , x D ; ysol @ x_ D = y @ x D  . soldiff

Out[13]=

-2 x

I 0.000670925 - 0.000670925 ã

4 x

+ ã

2 x

x M=

In[14]:=

n = 2;

h = H b - a L  n;

x @ 1 D = a;

x @ n + 1 D = b;

ww = Table @ w @ i D , 8 i, 1, n + 1 <D ; Do @ x @ i + 1 D = x @ i D + h, 8 i, 1, n <D ;

Do @ p @ i D = fp @ x @ i DD ; q @ i D = fq @ x @ i DD ; r @ i D = fr @ x @ i DD , 8 i, 1, n + 1 <D ; aa = Table @ 0, 8 i, 1, n + 1 < , 8 j, 1, n + 1 <D ;

aa @@ 1, 1 DD = 1.;

aa @@ n + 1, n + 1 DD = 1.;

MatrixForm @ aa D ;

Do @ aa @@ i, i - 1 DD = 2. + h * p @ i D ;

aa @@ i, i + 1 DD = 2. - h * p @ i D ; aa @@ i, i DD = - 2. * H 2. + h ^ 2 * q @ i DL , 8 i, 2, n <D ; MatrixForm @ aa D

bb = Table @ 2. * h ^ 2 * r @ i D , 8 i, 1, n + 1 <D ; bb @@ 1 DD = Α ;

bb @@ n + 1 DD = Β ; MatrixForm @ bb D

Out[26]//MatrixForm=

1. 0 0

2. -36. 2.

0 0 1.

Out[30]//MatrixForm=

0.

-64.

2.

In[31]:=

sol = Solve @ Dot @ aa, ww D Š bb, ww D@@ 1 DD ;

fsol = Table @8 x @ i D , w @ i D  . sol < , 8 i, 1, n + 1 <D ;

pl1 = ListPlot @ fsol, PlotStyle ® 8 PointSize @ 0.02 D , RGBColor @ 1, 0, 0 D<D ; pl2 = Plot @ ysol @ x D , 8 x, a, b <D ;

Show @ pl1, pl2, PlotRange ® 8 xrange, 8- 0.2, 3.2 <<D

Out[35]=

1 2 3 4

0.0 0.5 1.0 1.5 2.0 2.5 3.0

(2)

In[36]:=

H* ESERCIZIO 11.3.2 * L Clear @ a, b, p, q, r, w, x, aa D fp @ x_ D := 1;

fq @ x_ D := 2;

fr @ x_ D := Cos @ x D ; a = 0.;

b = 0.5 *Pi;

Α = -0.3;

Β = -0.1;

eqdiff = y '' @ x D Š fp @ x D * y ' @ x D + fq @ x D * y @ x D + fr @ x D ; soldiff = DSolve @8 eqdiff, y @ a D Š Α , y @ b D == Β< , y @ x D , x D ; ysol @ x_ D = y @ x D  . soldiff

Out[46]=

-x

I 5.4804´ 10

-17

+ 7.07106´ 10

-19

ã

3 x

- 0.3 ã

x

Cos @ x D - 0.1 ã

x

Sin @ x DM=

In[47]:=

n = 8;

h = H b - a L  n;

x @ 1 D = a;

x @ n + 1 D = b;

ww = Table @ w @ i D , 8 i, 1, n + 1 <D ; Do @ x @ i + 1 D = x @ i D + h, 8 i, 1, n <D ;

Do @ p @ i D = fp @ x @ i DD ; q @ i D = fq @ x @ i DD ; r @ i D = fr @ x @ i DD , 8 i, 1, n + 1 <D ; aa = Table @ 0, 8 i, 1, n + 1 < , 8 j, 1, n + 1 <D ;

aa @@ 1, 1 DD = 1.;

aa @@ n + 1, n + 1 DD = 1.;

MatrixForm @ aa D ;

Do @ aa @@ i, i - 1 DD = 2. + h * p @ i D ;

aa @@ i, i + 1 DD = 2. - h * p @ i D ; aa @@ i, i DD = - 2. * H 2. + h ^ 2 * q @ i DL , 8 i, 2, n <D ; MatrixForm @ aa D

bb = Table @ 2. * h ^ 2 * r @ i D , 8 i, 1, n + 1 <D ; bb @@ 1 DD = Α ;

bb @@ n + 1 DD = Β ; MatrixForm @ bb D

Out[59]//MatrixForm=

1. 0 0 0 0 0 0 0 0

2.19635 -4.15421 1.80365 0 0 0 0 0 0

0 2.19635 -4.15421 1.80365 0 0 0 0 0

0 0 2.19635 -4.15421 1.80365 0 0 0 0

0 0 0 2.19635 -4.15421 1.80365 0 0 0

0 0 0 0 2.19635 -4.15421 1.80365 0 0

0 0 0 0 0 2.19635 -4.15421 1.80365 0

0 0 0 0 0 0 2.19635 -4.15421 1.80365

0 0 0 0 0 0 0 0 1.

Out[63]//MatrixForm=

-0.3 0.0756247 0.0712369 0.0641115 0.0545224 0.042838 0.0295073 0.0150427

-0.1

(3)

In[64]:=

sol = Solve @ Dot @ aa, ww D Š bb, ww D@@ 1 DD ;

fsol = Table @8 x @ i D , w @ i D  . sol < , 8 i, 1, n + 1 <D ;

pl1 = ListPlot @ fsol, PlotStyle ® 8 PointSize @ 0.02 D , RGBColor @ 1, 0, 0 D<D ; pl2 = Plot @ ysol @ x D , 8 x, a, b <D ;

Show @ pl1, pl2, PlotRange ® 8- 0.4, -0.1 <D

Out[68]=

0.0 0.5 1.0 1.5

-0.35 -0.30 -0.25 -0.20 -0.15 -0.10

In[69]:=

H* ESERCIZIO LIBERO * L Clear @ a, b, p, q, r, w, x, aa D fp @ x_ D := 0;

fq @ x_ D := -9;

fr @ x_ D := 0;

a = 0.;

b = 1.;

Α = 1.;

Β = 0.5;

xrange = 8 a, b < ; yrange = 8- 20, 20 < ;

eqdiff = y '' @ x D Š fp @ x D * y ' @ x D + fq @ x D * y @ x D + fr @ x D ; soldiff = DSolve @8 eqdiff, y @ a D Š Α , y @ b D == Β< , y @ x D , x D ; ysol @ x_ D = y @ x D  . soldiff

Out[81]=

8 1. Cos @ 3 x D + 10.5583 Sin @ 3 x D<

(4)

In[82]:=

n = 4;

h = H b - a L  n;

x @ 1 D = a;

x @ n + 1 D = b;

ww = Table @ w @ i D , 8 i, 1, n + 1 <D ; Do @ x @ i + 1 D = x @ i D + h, 8 i, 1, n <D ;

Do @ p @ i D = fp @ x @ i DD ; q @ i D = fq @ x @ i DD ; r @ i D = fr @ x @ i DD , 8 i, 1, n + 1 <D ; aa = Table @ 0, 8 i, 1, n + 1 < , 8 j, 1, n + 1 <D ;

aa @@ 1, 1 DD = 1.;

aa @@ n + 1, n + 1 DD = 1.;

MatrixForm @ aa D ;

Do @ aa @@ i, i - 1 DD = 2. + h * p @ i D ;

aa @@ i, i + 1 DD = 2. - h * p @ i D ; aa @@ i, i DD = - 2. * H 2. + h ^ 2 * q @ i DL , 8 i, 2, n <D ; MatrixForm @ aa D

bb = Table @ 2. * h ^ 2 * r @ i D , 8 i, 1, n + 1 <D ; bb @@ 1 DD = Α ;

bb @@ n + 1 DD = Β ; MatrixForm @ bb D

Out[94]//MatrixForm=

1. 0 0 0 0

2. -2.875 2. 0 0

0 2. -2.875 2. 0

0 0 2. -2.875 2.

0 0 0 0 1.

Out[98]//MatrixForm=

1.

0 0 0 0.5

In[99]:=

sol = Solve @ Dot @ aa, ww D Š bb, ww D@@ 1 DD ;

fsol = Table @8 x @ i D , w @ i D  . sol < , 8 i, 1, n + 1 <D ;

pl1 = ListPlot @ fsol, PlotStyle ® 8 PointSize @ 0.02 D , RGBColor @ 1, 0, 0 D<D ; pl2 = Plot @ ysol @ x D , 8 x, a, b <D ;

Show @ pl1, pl2, PlotRange ® 8 xrange, yrange <D

Out[103]=

0.2 0.4 0.6 0.8 1.0

-20 -10 0 10 20

(5)

In[104]:=

H* ESERCIZIO 11.3.3b * L Clear @ a, b, p, q, r, w, x, aa D fp @ x_ D := -4.  x;

fq @ x_ D := 2.  x ^ 2;

fr @ x_ D := - H 2.  x ^ 2 L * Log @ x D ; a = 1.;

b = 2.;

Α = -0.5;

Β = Log @ 2. D ; xrange = 8 a, b < ; yrange = 8- 0.5, 1 < ;

eqdiff = y '' @ x D Š fp @ x D * y ' @ x D + fq @ x D * y @ x D + fr @ x D ; soldiff = DSolve @8 eqdiff, y @ a D Š Α , y @ b D == Β< , y @ x D , x D ; ysol @ x_ D = y @ x D  . soldiff

Out[116]=

: H- 1.04353 + 0. ä L + H 1.5 + 0. ä L x

3.56155

- H 0.956473 + 0. ä L x

4.12311

+ H 1. + 0. ä L x

3.56155

Log @ x D

x

3.56155

>

In[117]:=

n = 2;

h = H b - a L  n;

x @ 1 D = a;

x @ n + 1 D = b;

ww = Table @ w @ i D , 8 i, 1, n + 1 <D ; Do @ x @ i + 1 D = x @ i D + h, 8 i, 1, n <D ;

Do @ p @ i D = fp @ x @ i DD ; q @ i D = fq @ x @ i DD ; r @ i D = fr @ x @ i DD , 8 i, 1, n + 1 <D ; aa = Table @ 0, 8 i, 1, n + 1 < , 8 j, 1, n + 1 <D ;

aa @@ 1, 1 DD = 1.;

aa @@ n + 1, n + 1 DD = 1.;

MatrixForm @ aa D ;

Do @ aa @@ i, i - 1 DD = 2. + h * p @ i D ;

aa @@ i, i + 1 DD = 2. - h *p @ i D ; aa @@ i, i DD = - 2. * H 2. + h ^ 2 * q @ i DL , 8 i, 2, n <D ; MatrixForm @ aa D

bb = Table @ 2. * h ^ 2 * r @ i D , 8 i, 1, n + 1 <D ; bb @@ 1 DD = Α ;

bb @@ n + 1 DD = Β ; MatrixForm @ bb D

Out[129]//MatrixForm=

1. 0 0

0.666667 -4.44444 3.33333

0 0 1.

Out[133]//MatrixForm=

-0.5 -0.180207

0.693147

(6)

In[134]:=

sol = Solve @ Dot @ aa, ww D Š bb, ww D@@ 1 DD ;

fsol = Table @8 x @ i D , w @ i D  . sol < , 8 i, 1, n + 1 <D ;

pl1 = ListPlot @ fsol, PlotStyle ® 8 PointSize @ 0.02 D , RGBColor @ 1, 0, 0 D<D ; pl2 = Plot @ ysol @ x D , 8 x, a, b <D ;

Show @ pl1, pl2, PlotRange ® 8 xrange, yrange <D

Out[138]=

1.2 1.4 1.6 1.8 2.0

-0.4 -0.2 0.0 0.2 0.4 0.6 0.8 1.0

In[289]:=

H* ESERCIZIO 11.3.3c * L Clear @ a, b, p, q, r, w, x, aa D fp @ x_ D := - H x + 1 L ;

fq @ x_ D := 2;

fr @ x_ D := H 1 - x ^ 2 L * Exp @- x D ; a = 0;

b = 1;

Α = -1;

Β = 0;

xrange = 8 a - 0.1, b + 0.1 < ; yrange = 8- 1.1, 0.1 < ;

eqdiff = y '' @ x D Š fp @ x D * y ' @ x D + fq @ x D * y @ x D + fr @ x D ; soldiff = NDSolve @8 eqdiff, y @ a D Š Α , y @ b D == Β< , y @ x D , x D ;

In[301]:=

ysol @ x_ D = y @ x D  . soldiff;

In[302]:=

n = 2;

h = H b - a L  n;

x @ 1 D = a;

x @ n + 1 D = b;

ww = Table @ w @ i D , 8 i, 1, n + 1 <D ; Do @ x @ i + 1 D = x @ i D + h, 8 i, 1, n <D ;

Do @ p @ i D = fp @ x @ i DD ; q @ i D = fq @ x @ i DD ; r @ i D = fr @ x @ i DD , 8 i, 1, n + 1 <D ; aa = Table @ 0, 8 i, 1, n + 1 < , 8 j, 1, n + 1 <D ;

aa @@ 1, 1 DD = 1.;

aa @@ n + 1, n + 1 DD = 1.;

MatrixForm @ aa D ;

Do @ aa @@ i, i - 1 DD = 2. + h * p @ i D ;

aa @@ i, i + 1 DD = 2. - h *p @ i D ; aa @@ i, i DD = - 2. * H 2. + h ^ 2 * q @ i DL , 8 i, 2, n <D ; MatrixForm @ aa D

bb = Table @ 2. * h ^ 2 * r @ i D , 8 i, 1, n + 1 <D ; bb @@ 1 DD = Α ;

bb @@ n + 1 DD = Β ; MatrixForm @ bb D

Out[314]//MatrixForm=

1. 0 0

1.25 -5. 2.75

0 0 1.

Out[318]//MatrixForm=

-1 0.227449

0

(7)

In[319]:=

sol = Solve @ Dot @ aa, ww D Š bb, ww D@@ 1 DD ;

fsol = Table @8 x @ i D , w @ i D  . sol < , 8 i, 1, n + 1 <D ;

pl1 = ListPlot @ fsol, PlotStyle ® 8 PointSize @ 0.02 D , RGBColor @ 1, 0, 0 D<D ; pl2 = Plot @ ysol @ x D , 8 x, a, b <D ;

Show @ pl1, pl2, PlotRange ® 8 xrange, yrange <D

Out[323]=

0.2 0.4 0.6 0.8 1.0

-1.0 -0.8 -0.6 -0.4 -0.2

Riferimenti

Documenti correlati

GLI ANIMALI MI HANNO INSEGNATO A CONOSCERE LE PERSONE, IL LORO MONDO INTERIORE E I LORO DESIDERI, LE LORO PAURE, LA TRISTEZZA, I SOGNI INFRANTI.. IL BENEFICIO CHE NE STAVO

[r]

rappresentanze in Italia di imprese aventi sede legale in paesi facenti parte dello Spazio Economico Europeo (“Imprese U.E.”) che hanno aderito alla rilevazione e che

L’indice di strutturazione dell’attività fisica è inteso come il rapporto tra iscritti a centri sportivi, palestre e piscine e il totale delle persone che svolgono attività

(b) Nei giorni scolastici (lun-ven) al ritorno effettua deviazione all’ISIS Enrico Mattei (c) All’andata deviata all’ufficio postale di Ladispoli (via Sironi). (d) Al ritorno

9 Konektor na víku nádoby zarovnejte se zajišťovací oblastí na nádržce na vodu a postavte nádobu na hlavní jednotku víkem dolů (obr.. Zatlačte nádobu dolů, aby pevně

Per il resto la norma lascia alla valutazione discrezionale del procuratore generale presso la corte di appello e del procuratore della Repubblica interessato la scelta dei soggetti

Titolare Ordine dei Dottori Commercialisti ed Esperti Contabili - Via Venezia 13 – 70122 – Bari – Telefono 0805214760 email info@odcecbari.it – PEC