Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Python the Voigt Profile

  1. Apr 2, 2015 #1
    I very new to python and this might look relatively easy to some of you. I need to write a code so that

    [tex] H(a,u) = \frac{a}{\pi} \int_{-\infty}^{\infty} \frac{e^{-y^2}}{a^2+(u-y)^2}dy [/tex]

    it plots the above function for different values of the a parameter, so that ultimately i will have a graph of 3 or more function of the form [itex]H(a_1,u)[/itex], [itex]H(a_2,u)[/itex], [itex]H(a_3,u)[/itex] as functions of u. Can anyone provide a code ?
     
  2. jcsd
  3. Apr 2, 2015 #2

    Mark44

    Staff: Mentor

    The key is
    We're not going to do this for you. We'll be happy to help you out on it, but you need to show us what you've tried.
     
  4. Apr 3, 2015 #3
    import numpy as np
    import pylab as pl
    from math import exp
    from scipy.integrate import quad

    def voigt( u , a ):

    def integrand( y ):

    return exp(-y**2)/( a**2 + ( u - y )**2 )

    return quad( integrand ,-np.inf , np.inf )


    x = np.linspace(-100 , 100 )

    Func = voigt( x , 0.1 )

    pl.plot( x , Func )

    pl.show()

    This is as far as i got before i posted...
     
  5. Apr 3, 2015 #4
    Teach a man to fish he eats for a lifetime. Here's some important tools to breaking it down. I suck at calculus so I use this to calculate integrals.
    http://integrals.wolfram.com/index.jsp
    You would enter it in the Wolfram language, where x^y means x to the power of y, remember your parenthesis. Then take the output, and code it in the python language...its the same except x**y = x to the power of y.
     
  6. Apr 6, 2015 #5
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Python the Voigt Profile
  1. Error on Python (Replies: 9)

  2. Chess with Python (Replies: 2)

  3. Is Python the future? (Replies: 10)

  4. Python installation (Replies: 10)

Loading...