Interpolatingfunction : Borra Resolvedor Diferencial Numérico Resolvedor Diferencial Numérico

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

In[42]:= Clear[y]; NDSolve[y '[x] + x y[x] ⩵ x && y[0] ⩵ 1, y[x], {x, 0, 7}]

borra resolvedor diferencial numérico


sol = NDSolve[y '[x] + x y[x] ⩵ x && y[0] ⩵ 1, y[x], {x, 0, 7}][[1, 1, 2]]
resolvedor diferencial numérico

Domain: {{0., 7.}}


Out[42]= y[x] → InterpolatingFunction [x]
Output: scalar

Domain: {{0., 7.}}


Out[43]= InterpolatingFunction [x]
Output: scalar

In[44]:= Plot[Evaluate[sol], {x, 0, 7}]


repr⋯ evalúa

2.0

1.5

Out[44]= 1.0

0.5

1 2 3 4 5 6 7

In[45]:=

NIntegrate[sol, {x, 0, 7}]


integra numéricamente

Out[45]= 7.

In[46]:=

Derivative[1][sol][1.4]
derivada

Domain: {{0., 7.}}


Out[46]= InterpolatingFunction [x]′ [1.4]
Output: scalar

In[47]:= Clear[sol];
borra

In[48]:= sol[x_] := NDSolvey '[t] + t y[t] ⩵ t2 && y[0] ⩵ 1, y[t], {t, 0, 7}[[1, 1, 2]] //. t → x;
resolvedor diferencial numérico

In[49]:= sol[2.6]
Out[49]= 2.15694
2 lab1.nb

In[50]:= sol '[3]


Out[50]= 1.14617

In[51]:= sol ''[1.8]


Out[51]= 0.690219

In[52]:= NIntegrate[sol[x], {x, 0, 7}]


integra numéricamente

Out[52]= 23.1828

In[53]:= Plot[Evaluate[sol[x]], {x, 0, 7}]


repr⋯ evalúa
7

4
Out[53]=
3

1 2 3 4 5 6 7

In[54]:=

tabla = Table[{x, sol[x]}, {x, 0, 7, 0.5}]


tabla

Out[54]= {{0., 1.}, {0.5, 0.922153}, {1., 0.881752}, {1.5, 1.07252}, {2., 1.49535},
{2.5, 2.04206}, {3., 2.61794}, {3.5, 3.18254}, {4., 3.72994}, {4.5, 4.26453},
{5., 4.79076}, {5.5, 5.31144}, {6., 5.82825}, {6.5, 6.34222}, {7., 6.85403}}
lab1.nb 3

In[55]:=

TableForm[Join[{{x, y[x]}}, tabla], TableAlignments → Center]


forma de ta⋯ junta alineamientos de tabla centro
Out[55]//TableForm=
x y[x]
0. 1.
0.5 0.922153
1. 0.881752
1.5 1.07252
2. 1.49535
2.5 2.04206
3. 2.61794
3.5 3.18254
4. 3.72994
4.5 4.26453
5. 4.79076
5.5 5.31144
6. 5.82825
6.5 6.34222
7. 6.85403

In[56]:=

Clear[y]; DSolvey '[t] + t y[t] ⩵ t2 && y[0] ⩵ 1, y[t], t //. t → x


borra resolvedor diferencial

y[x] → 1 ⅇ- 2 2 π Erfi x  
x 2 x2
Out[56]= 2+2ⅇ2 x-
2 2

In[57]:= Clear[sol, f];


borra

In[58]:= sol[x_] := NDSolvey '[t] + t y[t] ⩵ t2 && y[0] ⩵ 1, y[t], {t, 0, 7}[[1, 1, 2]] //. t → x;
resolvedor diferencial numérico
1 x2 x2 x
f[x_] := ⅇ- 2 2+2ⅇ2 x- 2 π Erfi  ;
2 2 imaginaria
función error

Plot[Evaluate[{sol[x], f[x]}], {x, 0, 7}, PlotStyle → {Red, {Dashed, Green, Thick}}]


repr⋯ evalúa estilo de repre⋯ rojo rayado verde grueso

4
Out[60]=
3

1 2 3 4 5 6 7
4 lab1.nb

In[26]:= Clear[sol, f];


borra

In[61]:=

sol[x_] := NDSolvey '[t] + t y[t] ⩵ t2 && y[0] ⩵ 1, y[t], {t, 0, 7}[[1, 1, 2]] //. t → x;
resolvedor diferencial numérico
1 x2 x2 x
f[x_] := ⅇ- 2 2+2ⅇ2 x- 2 π Erfi  ;
2 2 imaginaria
función error

In[65]:= diferencias = Table[{x, Abs[sol[x] - f[x]]}, {x, 0, 7, 0.5}]


tabla valor absoluto
TableForm[Join[{{x, Abs[y[x] - approx[x]] // TraditionalForm}}, diferencias],
forma de ta⋯ junta valor absoluto forma tradicional
TableAlignments → Center]
alineamientos de tabla centro

Out[65]= {0., 0.}, 0.5, 3.15006 × 10-8 , 1., 1.39841 × 10-7 , 1.5, 2.00052 × 10-7 ,
2., 6.43578 × 10-8 , 2.5, 1.75849 × 10-7 , 3., 1.5172 × 10-7 , 3.5, 2.6258 × 10-8 ,
4., 8.87974 × 10-10 , 4.5, 3.01777 × 10-9 , 5., 1.8997 × 10-9 , 5.5, 2.81096 × 10-9 ,
6., 2.51513 × 10-9 , 6.5, 1.49341 × 10-8 , 7., 5.58532 × 10-9 
Out[66]//TableForm=
x y(x) - approx(x)
0. 0.
0.5 3.15006 × 10-8
1. 1.39841 × 10-7
1.5 2.00052 × 10-7
2. 6.43578 × 10-8
2.5 1.75849 × 10-7
3. 1.5172 × 10-7
3.5 2.6258 × 10-8
4. 8.87974 × 10-10
4.5 3.01777 × 10-9
5. 1.8997 × 10-9
5.5 2.81096 × 10-9
6. 2.51513 × 10-9
6.5 1.49341 × 10-8
7. 5.58532 × 10-9

You might also like