download
raw
2.99 kB
Module file not meant for execution.
--- Running Galerkin (Least Squares) Example ---
...evaluating matrix...
(0,0)
(0,1)
(0,2)
(1,1)
(1,2)
(2,2)
A:
Matrix([[1, 1/2, 1/3], [1/2, 1/3, 1/4], [1/3, 1/4, 1/5]])
b:
Matrix([[sqrt(pi)*erf(1)/2], [1/2 - exp(-1)/2], [-exp(-1)/2 + sqrt(pi)*erf(1)/4]])
coeff: [-18 + 3*exp(-1) + 12*sqrt(pi)*erf(1), -63*sqrt(pi)*erf(1) - 6*exp(-1) + 96, -90 + 60*sqrt(pi)*erf(1)]
approximation: x**2*(-90 + 60*sqrt(pi)*erf(1)) + x*(-63*sqrt(pi)*erf(1) - 6*exp(-1) + 96) - 18 + 3*exp(-1) + 12*sqrt(pi)*erf(1)
Galerkin coefficients: [-18 + 3*exp(-1) + 12*sqrt(pi)*erf(1), -63*sqrt(pi)*erf(1) - 6*exp(-1) + 96, -90 + 60*sqrt(pi)*erf(1)]
Galerkin approximation: x**2*(-90 + 60*sqrt(pi)*erf(1)) + x*(-63*sqrt(pi)*erf(1) - 6*exp(-1) + 96) - 18 + 3*exp(-1) + 12*sqrt(pi)*erf(1)
f: exp(-x**2)
u: x**2*(-90 + 60*sqrt(pi)*erf(1)) + x*(-63*sqrt(pi)*erf(1) - 6*exp(-1) + 96) - 18 + 3*exp(-1) + 12*sqrt(pi)*erf(1)
--- Galerkin Example Finished ---
--- Running Interpolation Example ---
...evaluating matrix...
(0,0)
(0,1)
(0,2)
(1,0)
(1,1)
(1,2)
(2,0)
(2,1)
(2,2)
A:
Matrix([[1, 0, 0], [1, 0.500000000000000, 0.250000000000000], [1, 1, 1]])
b:
Matrix([[1.00000000000000], [6.12323399573677e-17], [-1.00000000000000]])
coeff: [1.00000000000000, -2.00000000000000, -4.44089209850063e-16]
approximation: -4.44089209850063e-16*x**2 - 2.0*x + 1.0
Interpolation coefficients: [1.00000000000000, -2.00000000000000, -4.44089209850063e-16]
Interpolation approximation: -4.44089209850063e-16*x**2 - 2.0*x + 1.0
f: cos(pi*x)
u: -4.44089209850063e-16*x**2 - 2.0*x + 1.0
--- Interpolation Example Finished ---
--- Running Regression Example ---
(...evaluating matrix...)
B:
[[10. 5. ]
[ 5. 3.51851852]]
d:
[5.67128182 2.83564091]
coeff: [0.56712818 0. ]
approximation: 0.567128181961771
Regression coefficients: [0.56712818 0. ]
Regression approximation: 0.567128181961771
f: sin(pi*x)
u: 0.567128181961771
Traceback (most recent call last):
File "/root/finite_difference/src/approx/approx1D.py", line 413, in <module>
comparison_plot(
File "/root/finite_difference/src/approx/approx1D.py", line 324, in comparison_plot
plt.plot(xcoor, approx, '-')
File "/dolfinx-env/lib/python3.12/site-packages/matplotlib/pyplot.py", line 3838, in plot
return gca().plot(
^^^^^^^^^^^
File "/dolfinx-env/lib/python3.12/site-packages/matplotlib/axes/_axes.py", line 1777, in plot
lines = [*self._get_lines(self, *args, data=data, **kwargs)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/dolfinx-env/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 297, in __call__
yield from self._plot_args(
^^^^^^^^^^^^^^^^
File "/dolfinx-env/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 494, in _plot_args
raise ValueError(f"x and y must have same first dimension, but "
ValueError: x and y must have same first dimension, but have shapes (601,) and (1,)

Xet Storage Details

Size:
2.99 kB
·
Xet hash:
1011fe653922acffc643dd41e4b8e0dab75091f8715c204ee84d92693b334b7b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.