Search code examples
functionmathjupyter-notebooklinear-algebradeterminants

SymPy Wronskian function


I have been trying to compute the wronskian using SymPy, and can not figure out how to use the function. I did look at the program itself but I am very new to python. For functions any sinusoidal is okay. I just want to observe how to use SymPy in this way for future reference. Any help would be great! enter image description here

~I listed my imports below

import sympy as sp
from scipy import linalg
import numpy as np
sp.init_printing()  

enter image description here

I don't this that 'var' is the only thing wrong with what I am inputting.


Solution

  • You have to define the var first. You have not defined it. Also the functions should go in a list.

    x = sp.Symbol('x')
    ## Define your var here
    Wronskian_Sol = sp.matrices.dense.wronskian([sp.sin(x), 1-sp.cos(x)**2], var, method="bareiss")
    

    Here is an example in this book "Applied Differntial Equation with Boundary Value Problems" by Vladimir A. Dobrushkin at page 199. I computed a Wronskian for these three functions using Sympy

    • x
    • x*sin(x)
    • x*cons(x)
    import sympy as sp
    x = sp.Symbol('x')
    var = x
    Wronskian_Sol = sp.matrices.dense.wronskian([x, x*sp.cos(x), x*sp.sin(x)], var, method="bareiss")
    print(Wronskian_Sol)
    print(Wronskian_Sol.simplify())
    

    This gives the output. The first is not simplified, the last one is simplified. You can reduce the first one to simplified version easily by taking the common factor x**3 out which leaves (sin(x)**2 + cos(x)**2) ..and this is nothing but 1.

    x**3*sin(x)**2 + x**3*cos(x)**2
    x**3
    

    You can confirm the solution by manually taking the determinant of the derivative matrix.