```python
import numpy as np  #Importa libreria numerica 
import sympy as sym #simbolica
import matplotlib.pyplot as plt #importa matplotlib solo pyplot
import matplotlib.image as mpimg 
from sympy.plotting import plot  #para plotear 2 variables
from sympy.plotting import plot3d  # para 3
from sympy.plotting import plot3d_parametric_surface
from IPython.display import Image 
import ipympl  #Para importar gestor de imagenes 
sym.init_printing() #activa a jupyter para mostrar simbolicamente el output

%matplotlib inline
```


```python
Image(filename='LAB1_2.png',width=300)
```


```python
Vin, Vo, V3, V2 = sym.symbols('V_{in}, V_o, V_+, V_-')
V2=V3
Ir1, Ir2, Ir3, Ir4 = sym.symbols('I_{R1}, I_{R2},I_{R3},I_{R4}')
R1, R2, R3, R4, RL = sym.symbols('R1, R2, R3, R4, R_{L}')

Irl = sym.Function('I_{R_L}')(Vin,RL) #Defino viarible simbolica Irl como una funcion de Vin y RL 
sym.pprint(Irl)

#SUM(I) en nodo 3 (+) es CERO => 
eq_Irl = sym.Eq(Irl,Ir1+Ir3)
sym.pprint(eq_Irl)

```

    I_{R_L}(V_{in}, R_{L})
    I_{R_L}(V_{in}, R_{L}) = I_{R1} + I_{R3}



```python
#La corriente en Ir1 es: (Vo-V+)/R1 = Irl - Ir3
# Ir3 = (Vin - V+)/R3
Ir1 = (Vo-V3)/R1
Ir3= (Vin - V3)/R3
eq_Irl = sym.Eq(Irl,Ir1+Ir3)
sym.pprint(eq_Irl)
res=sym.solve(eq_Irl,(Vo-V3))
eq_Vo3=sym.Eq(Vo-V3,sym.expand(res[0]))
sym.pprint(eq_Vo3)
```

                             -V₊ + V_{in}   -V₊ + Vₒ
    I_{R_L}(V_{in}, R_{L}) = ──────────── + ────────
                                  R₃           R₁   
                                           R₁⋅V₊   R₁⋅V_{in}
    -V₊ + Vₒ = R₁⋅I_{R_L}(V_{in}, R_{L}) + ───── - ─────────
                                             R₃        R₃   



```python
#SUM(I) en nodo 2 (-) es CERO =>
eq_Ir2 = sym.Eq(Ir2,Ir4)
sym.pprint(eq_Ir2)
Ir2 = (Vo-V3)/R2
Ir4= (V2)/R4
eq_Ir2 = sym.Eq(Ir2,Ir4)
sym.pprint(eq_Ir2)
res2=sym.solve(eq_Ir2,(Vo-V3))
eq_Vo3_=sym.Eq(Vo-V3,sym.expand(res2[0]))
sym.pprint(eq_Vo3_)
```

    I_{R2} = I_{R4}
    -V₊ + Vₒ   V₊
    ──────── = ──
       R₂      R₄
               R₂⋅V₊
    -V₊ + Vₒ = ─────
                 R₄ 



```python
#Remplazando 
eq_=sym.Eq(eq_Vo3.rhs-eq_Vo3_.rhs)
sym.pprint(eq_)
```

                                R₁⋅V₊   R₁⋅V_{in}   R₂⋅V₊    
    R₁⋅I_{R_L}(V_{in}, R_{L}) + ───── - ───────── - ───── = 0
                                  R₃        R₃        R₄     



```python
# Irl = V+/RL => V+=Irl*RL
# R1 = 100Ω; R2 = 10KΩ; R3 = 1KΩ y R4 = 100KΩ
res=sym.solve([eq_.subs({V3:Irl/RL,(R2/R4):(R1/R3)})],Irl)
sym.pprint(res)
```

    ⎧                        V_{in}⎫
    ⎨I_{R_L}(V_{in}, R_{L}): ──────⎬
    ⎩                          R₃  ⎭



```python
Vo= sym.Function('Vo')(Vin,RL) #Defino viarible simbolica Vo como una funcion de Vin y RL 
Irl= sym.Symbol('I_{RL}')
sym.pprint(Vo)
sym.pprint(eq_Vo3) #De esa ecuacion se remplaza V+= RL * Irl
sym.pprint(sym.Eq(V3,RL*Irl))
```

    Vo(V_{in}, R_{L})
                                           R₁⋅V₊   R₁⋅V_{in}
    -V₊ + Vₒ = R₁⋅I_{R_L}(V_{in}, R_{L}) + ───── - ─────────
                                             R₃        R₃   
    V₊ = I_{RL}⋅R_{L}



```python
eq_Vo=sym.Eq(Vo,Irl*(RL+R1+RL*R1/R3)-Vin*(R1/R3))
sym.pprint(eq_Vo)
#REMPLAZO DEL RESULTADO Irl(V1,RL)
sym.pprint(sym.simplify((eq_Vo.subs(Irl,(Vin/R3)))))
```

                               ⎛     R₁⋅R_{L}        ⎞   R₁⋅V_{in}
    Vo(V_{in}, R_{L}) = I_{RL}⋅⎜R₁ + ──────── + R_{L}⎟ - ─────────
                               ⎝        R₃           ⎠       R₃   
                        R_{L}⋅V_{in}⋅(R₁ + R₃)
    Vo(V_{in}, R_{L}) = ──────────────────────
                                   2          
                                 R₃           



```python
#RL MAX como VoMAX=10v
#R1 = 100Ω; R2 = 10KΩ; R3 = 1KΩ y R4 = 100KΩ
Vo = sym.Symbol('Vo')
RLM=sym.Function('R_{L_{MAX}}')(Vin)
eq_RLM=sym.Eq(RLM,Vo/(Vin*(R3+R1)/R3**2))
sym.pprint(eq_RLM)
sym.pprint(eq_RLM.subs({Vo:10,R1:100,R2:10e3,R3:1e3,R4:100e3}))
```

                                 2        
                               R₃ ⋅Vo     
    R_{L_{MAX}}(V_{in}) = ────────────────
                          V_{in}⋅(R₁ + R₃)
                          9090.90909090909
    R_{L_{MAX}}(V_{in}) = ────────────────
                               V_{in}     



```python

```

d75574b77024ca6ea2ffeca249126017230ab368
ipynb
Jupyter Notebook
python/1/LAB1_EJ_2.ipynb
WayraLHD/SRA21
1b0447bf925678b8065c28b2767906d1daff2023
Apache-2.0
2021-09-29T16:38:53.000Z
2021-09-29T16:38:53.000Z
python/1/LAB1_EJ_2.ipynb
WayraLHD/SRA21
1b0447bf925678b8065c28b2767906d1daff2023
Apache-2.0
2021-08-10T08:24:57.000Z
2021-08-10T08:24:57.000Z
python/1/LAB1_EJ_2.ipynb
WayraLHD/SRA21
1b0447bf925678b8065c28b2767906d1daff2023
Apache-2.0
Qwen/Qwen-72B
1. YES
2. YES