Second order derivatives of implicit functions - SymPy

Viewed 32

I need to solve this problem - details below.

Below is my Jupyter notebook exported to Python code.

I have this problem.

I have no idea how to call SymPy's idiff to find the
mixed second order derivative (that is the (d^2)z/dxdy).

https://calculus.subwiki.org/wiki/Second-order_mixed_partial_derivative

#!/usr/bin/env python
# coding: utf-8

# ### Differentiating an implicit function using SymPy

# In[1]:


import sympy as sp


# In[2]:


sp.__version__


# In[3]:


sp.init_printing(use_latex='mathjax')  # use pretty mathjax output


# In[4]:


sp.var('x y z')

### We define some implicit function z = f(x,y) 
### via the following equation F(x,y,z) = 0 
### which is the same as the equation 
### cos^2(x) + cos^2(y) + cos^2(z) = 1

F = (sp.cos(x))**2 + (sp.cos(y))**2 + (sp.cos(z))**2 - 1

### OK, our goal now is to find the second order 
### partial derivatives of z=f(x,y) w.r.t. 
### 1) x,x
### 2) x,y
### 3) y,y

### How do we do this?!
### Seems 1) and 3) are doable but 2) is not doable.


# #### So now we are looking to find these 
# #### second order partial derivatives:  
# #### $d^2z / dx^2$, $d^2z / dy^2$, $d^2z / dxdy$
# #### How do we do it?! 

# In[5]:


f1 = sp.idiff( F, z, x )
f1


# In[6]:


f2 = sp.idiff( F, z, y )
f2


# In[7]:


sp.simplify(sp.idiff( F, z, x, 2 ))


# In[8]:


sp.simplify(sp.idiff( F, z, y, 2 ))


# In[ ]:
0 Answers
Related