```python
import numpy as np  

def f(x):
    return np.sqrt(x + 2)

```


```python
x = np.array([-2, -1, 0, 2, 4, 6])  # Creando el vector de valores de x
y = f(x)
y

```




    array([0.        , 1.        , 1.41421356, 2.        , 2.44948974,
           2.82842712])




```python
import pandas as pd

tabla = pd.DataFrame( list(zip(x, y)), columns=['x', 'f(x)'] )
tabla

```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>x</th>
      <th>f(x)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>-2</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>1</th>
      <td>-1</td>
      <td>1.000000</td>
    </tr>
    <tr>
      <th>2</th>
      <td>0</td>
      <td>1.414214</td>
    </tr>
    <tr>
      <th>3</th>
      <td>2</td>
      <td>2.000000</td>
    </tr>
    <tr>
      <th>4</th>
      <td>4</td>
      <td>2.449490</td>
    </tr>
    <tr>
      <th>5</th>
      <td>6</td>
      <td>2.828427</td>
    </tr>
  </tbody>
</table>
</div>




```python
%matplotlib inline

import matplotlib.pyplot as plt

def move_spines():
    """Esta funcion divide pone al eje y en el valor 
    0 de x para dividir claramente los valores positivos y
    negativos."""
    fix, ax = plt.subplots()
    for spine in ["left", "bottom"]:
        ax.spines[spine].set_position("zero")
    
    for spine in ["right", "top"]:
        ax.spines[spine].set_color("none")
    
    return ax

x = np.linspace(-2, 6, num=30)

ax = move_spines()
ax.grid()
ax.plot(x, f(x))
plt.title(r"Grafico de $f(x)=\sqrt{x + 2}$")
plt.ylabel('f(x)')
plt.xlabel('x')
plt.show()
```


```python

def f(x):
    return x**2 - x + 2

x = np.array([1, 1.5, 1.9, 1.95, 1.99, 1.999, 2.001, 2.05, 2.1, 2.2, 2.5, 3 ])
y = f(x)
tabla = pd.DataFrame(list(zip(x, y)), columns=['x', 'f(x)'])
tabla
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>x</th>
      <th>f(x)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>1.000</td>
      <td>2.000000</td>
    </tr>
    <tr>
      <th>1</th>
      <td>1.500</td>
      <td>2.750000</td>
    </tr>
    <tr>
      <th>2</th>
      <td>1.900</td>
      <td>3.710000</td>
    </tr>
    <tr>
      <th>3</th>
      <td>1.950</td>
      <td>3.852500</td>
    </tr>
    <tr>
      <th>4</th>
      <td>1.990</td>
      <td>3.970100</td>
    </tr>
    <tr>
      <th>5</th>
      <td>1.999</td>
      <td>3.997001</td>
    </tr>
    <tr>
      <th>6</th>
      <td>2.001</td>
      <td>4.003001</td>
    </tr>
    <tr>
      <th>7</th>
      <td>2.050</td>
      <td>4.152500</td>
    </tr>
    <tr>
      <th>8</th>
      <td>2.100</td>
      <td>4.310000</td>
    </tr>
    <tr>
      <th>9</th>
      <td>2.200</td>
      <td>4.640000</td>
    </tr>
    <tr>
      <th>10</th>
      <td>2.500</td>
      <td>5.750000</td>
    </tr>
    <tr>
      <th>11</th>
      <td>3.000</td>
      <td>8.000000</td>
    </tr>
  </tbody>
</table>
</div>




```python
x = np.linspace(-2, 4, num=30)

ax = move_spines()
ax.grid()
ax.plot(x, f(x))
ax.scatter(2, 4, label="limite cuando x tiende a 2", color='r')
plt.legend()
plt.title(r"Grafico de $f(x)=x^2 -x + 2$")
plt.ylabel('f(x)')
plt.xlabel('x')
plt.show()
```


```python

from sympy.interactive import printing
from sympy import Limit, limit, Symbol, S

# imprimir con notación matemática.
printing.init_printing(use_latex='mathjax') 

x = Symbol('x') # Creando el simbolo x.
Limit(x**2 - x + 2, x, 2) # Creando el objeto Limit
```




$\displaystyle \lim_{x \to 2^+}\left(x^{2} - x + 2\right)$




```python

# Resolviendo el Limite con el metodo doit()
Limit(x**2 - x + 2, x, 2).doit()
```




$\displaystyle 4$




```python

# La funcion limit nos da directamente el resultado
limit(x**2 - x + 2, x, 2)
```




$\displaystyle 4$




```python

Limit(1/x, x, S.Infinity).doit()
```




$\displaystyle 0$




```python

from sympy import Derivative, diff, simplify

fx = (2*x + 1)*(x**3 + 2)
dx = Derivative(fx, x).doit()
dx
```




$\displaystyle 2 x^{3} + 3 x^{2} \left(2 x + 1\right) + 4$




```python
simplify(dx)
```




$\displaystyle 8 x^{3} + 3 x^{2} + 4$




```python

# Derivada de segundo orden con el 3er argumento.
Derivative(fx, x, 2).doit()
```




$\displaystyle 6 x \left(4 x + 1\right)$




```python

# Calculando derivada de (3x +1) / (2x)
fx = (3*x + 1) / (2*x)
dx = Derivative(fx, x).doit()
simplify(dx)
```




$\displaystyle - \frac{1}{2 x^{2}}$




```python
simplify(diff(fx, x))
```




$\displaystyle - \frac{1}{2 x^{2}}$




```python
diff(fx, x).subs(x, 1)
```




$\displaystyle - \frac{1}{2}$




```python
from sympy import Integral, integrate

fx = x**3 - 6*x
dx = Integral(fx, x).doit()
dx
```




$\displaystyle \frac{x^{4}}{4} - 3 x^{2}$




```python
integrate(fx, x)
```




$\displaystyle \frac{x^{4}}{4} - 3 x^{2}$




```python
Integral(fx, (x, 0, 3)).doit()
```




$\displaystyle - \frac{27}{4}$




```python
diff(integrate(fx))
```




$\displaystyle x^{3} - 6 x$




```python
integrate(diff(fx))
```




$\displaystyle x^{3} - 6 x$




```python

```

fb7c99e37ba14ff6c2b060f0b7147a0b0a30f2a9
ipynb
Jupyter Notebook
funcion.ipynb
Darwing99/python-calculo
c9367c92285db9656379ee375ba91632138ed3ba
Apache-2.0
funcion.ipynb
Darwing99/python-calculo
c9367c92285db9656379ee375ba91632138ed3ba
Apache-2.0
funcion.ipynb
Darwing99/python-calculo
c9367c92285db9656379ee375ba91632138ed3ba
Apache-2.0
Qwen/Qwen-72B
1. YES
2. YES