<a href="https://colab.research.google.com/github/tony2020edx/brew/blob/master/FOAM_Assignment_5.ipynb" target="_parent"></a>

# Simplification and Evaluation of mathematical expressions using Sympy

**Question 1**

\begin{align}
\frac{2x^{12}}{5y^{10}}
\end{align}

Solve for (a) $x = 2$ , $y = 2$  (b) Case 2 : $x = 1$ , $y = 1$ 



**Evaluating the expression using Sympy**


```python
from sympy import*

x = Symbol('x')
y = Symbol('y')

expression = "(2*x**12)/(5*y**10)"

simplified_expression = simplify(expression)
print("The simplified expression is {}". format(simplified_expression))

evaluated_result_a = simplified_expression.subs({x:2, y:2}) 
evaluated_result_b = simplified_expression.subs({x:1, y:1}) 

print("The Evaluated result for (a) is: {}".format(evaluated_result_a))
print("The Evaluated result for (b) is: {}".format(evaluated_result_b))
```

    The simplified expression is 2*x**12/(5*y**10)
    The Evaluated result for (a) is: 8/5
    The Evaluated result for (b) is: 2/5


**Question 2**

\begin{align}35
\left (\frac{4x}{5}\right)
\end{align}

Solve for (a) $x = 1$ and (b) $x = 5$


```python
from sympy import*

x = Symbol('x')

expression = "35*(4*x)/5"

simplified_expression = simplify(expression)
print("The simplified expression is {}". format(simplified_expression))

evaluated_result_a = simplified_expression.subs({x:1})
evaluated_result_b = simplified_expression.subs({x:5})


print("The Evaluated result for (a) is: {}".format(evaluated_result_a))
print("The Evaluated result for (b) is: {}".format(evaluated_result_b))

```

    The simplified expression is 28*x
    The Evaluated result for (a) is: 28
    The Evaluated result for (b) is: 140


**Question 3**

\begin{align}24
\left(\frac{y}{6}+ \frac{3}{8} \right)
\end{align}

Solve for (a) $y = 2$ and (b) $y = 1$


```python
from sympy import*

y = Symbol('y')

expression = "24*((y/6)+(3/8))"
simplified_expression = simplify(expression)

print("The simplified expression is {}". format(simplified_expression))

evaluated_result_a = simplified_expression.subs({y:2})
evaluated_result_b = simplified_expression.subs({y:1})


print("The Evaluated result for (a) is: {}".format(evaluated_result_a))
print("The Evaluated result for (b) is: {}".format(evaluated_result_b))


```

    The simplified expression is 4*y + 9
    The Evaluated result for (a) is: 17
    The Evaluated result for (b) is: 13


**Question 4**

Calculate the pressure P of the gas using Van der Waal’s Equation for real gas

\begin{align}P =
\left(\frac{RT}{V-b} - \frac{a}{V^2}\right)
\end{align}


1. Average attraction between particles (a) = 1.360
2. volume excluded by a mole of particles (b) = 0.03186
3. Universal Gas constant (R) = 8.31
4. Volume of gas(V) = 5
5. Temperature(T) = 275



```python
from sympy import*

a = Symbol('a')
b = Symbol('b')
R = Symbol('R')
V = Symbol('V')
T = Symbol('T')

expression = "(((R*T)/(V-b))-(a/V**2))"
simplified_expression = simplify(expression)
print("The simplified expression is: {}". format(simplified_expression))

evaluated_result = simplified_expression.subs({a:1.360, b:0.03186, R:8.31, V:5, T:275})
print("The solution of Van der Waal’s Equation for real gas under the given conditions is: {}".format(evaluated_result))
```

    The simplified expression is: (R*T*V**2 - a*(V - b))/(V**2*(V - b))
    The solution of Van der Waal’s Equation for real gas under the given conditions is: 459.926598925151


597454d3cf2591304dab110aef64ec82d322eda8
ipynb
Jupyter Notebook
FOAM_Assignment_5.ipynb
tony2020edx/brew
15528d11d99795a1ccfded08964b24c0ac6e1d48
BSD-2-Clause
FOAM_Assignment_5.ipynb
tony2020edx/brew
15528d11d99795a1ccfded08964b24c0ac6e1d48
BSD-2-Clause
FOAM_Assignment_5.ipynb
tony2020edx/brew
15528d11d99795a1ccfded08964b24c0ac6e1d48
BSD-2-Clause
Qwen/Qwen-72B
1. YES
2. YES