<jupyter_start><jupyter_text>Short intro- The *SciPy* **framework** builds on top of the *low-level NumPy* for multidimensional arrays,- and provides a large number of *higher-level* **scientific algorithms**. Some of the topics that *SciPy* covers are:- Special functions (```scipy.special```)- Integration (```scipy.integrate```)- Optimization (```scipy.optimize```)- Interpolation (```scipy.interpolate```)- Fourier Transforms (```scipy.fftpack```)- Signal Processing (```scipy.signal```)- Linear Algebra (```scipy.linalg```)- Sparse Eigenvalue Problems (```scipy.sparse```)- Statistics (```scipy.stats```)- Multi-dimensional image processing (```scipy.ndimage```)- File IO (```scipy.io```)<jupyter_code># Different kinds of import 
#   fetch all        --  from scipy import *     -- for REAL??
#   part of          --  from scipy.linag as la  --  hmm, reasonable 
#   part of part of  --  from scipy.special import jn, yn 
from scipy import *  # use this can reduce a lot of work (for me)<jupyter_output><empty_output><jupyter_text>Special Functions - *I have no idea what the* ```special functions``` *mean*.- Here's a wiki [link](https://zh.wikipedia.org/wiki/%E8%B4%9D%E5%A1%9E%E5%B0%94%E5%87%BD%E6%95%B0)<jupyter_code>from scipy.special import jn, yn, jn_zeros, yn_zeros
n = 0
x = 0.0 

print(
    "J_{:d}({:f}) = {:f}".format(n, x, jn(n, x))
)

x = 1.0 

print(
    "J_{:d}({:f}) = {:f}".format(n, x, jn(n, x))
)
x = linspace(0, 10, 100)

fig, ax = plt.subplots()

for n in range(4):
    ax.plot(x, jn(n, x), label=f"$J_{n}(x)$")
    
ax.legend()
n = 0
m = 4 

jn_zeros(n, m)<jupyter_output><empty_output><jupyter_text>Integration> It was called (numerical) ***quadrature*** as well.<jupyter_code>from scipy.integrate import quad, dblquad, tplquad<jupyter_output><empty_output><jupyter_text>- 0x01 - basic usage<jupyter_code>def f(x):
    return x 

x_lower = 0 
x_upper = 1 


val, abs_err = quad(f, x_lower, x_upper)

val
abs_err<jupyter_output><empty_output><jupyter_text>- 0x02 - wtf usage<jupyter_code>def integrand(x, n):
    """
    Bessel function of first kind and order n.
    """
    return jn(n, x)  # :(

x_lower = 0
x_upper = 1 


val, abs_err = quad(integrand, x_lower, x_upper, args=(3,))

val
abs_err<jupyter_output><empty_output><jupyter_text>- 0x03 - simple func<jupyter_code>val, abs_err = quad(lambda x: exp(-x ** 2), -Inf, Inf)  # use 'Inf' as integral limits (is fine)

val
abs_err 

# what's this for??
analytical = sqrt(pi)
analytical<jupyter_output><empty_output><jupyter_text>- 0x04 - higher-dimen integration<jupyter_code>def integrand(x, y):
    return exp(-x**2 - y**2)

x_lower, x_upper = (0, 10)
y_lower, y_upper = (0, 10)

val, abs_err = dblquad(
    integrand, 
    x_lower,
    x_upper,
    lambda x: y_lower, 
    lambda x: y_upper,
)


val
abs_err<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1674929178470255, 'fraction_numerical': 0.02018413597733711, 'mean_word_length': 4.380952380952381, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 30, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '544132', 'license': 'Unlicense', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1119, 'n_words': 276, 'path': 'sci_py_lecture_scipy.ipynb', 'repo_name': 'codingEzio/code_py_datasci_libraries', 'size': '2824'}