# HG changeset patch # User Angelica Echavarria-Gregory # Date 1226355651 18000 # Node ID 80e7a79d74d398ac99323fd100c56063f2bbedce # Parent d66dc8f1f1077acc5776284d9fbbcc4c9871fb01 The function to PLEASE MERGE WITH ALL OF SYMPY FOR IT TO WORK ALONG WITH OTHER INTEGRALS; # Please, let's implement this function, we need Sympy to, for example, recognize when he find this expresion next to a different expression and be able to solve all together:
# Thanks Stephan who came up with the idea of converting the poly into a Gaussian Integral. diff -r d66dc8f1f107 -r 80e7a79d74d3 sympy/integrals/integrals.py --- a/sympy/integrals/integrals.py Fri Oct 24 19:09:04 2008 +0200 +++ b/sympy/integrals/integrals.py Mon Nov 10 17:20:51 2008 -0500 @@ -376,4 +376,28 @@ if isinstance(integral, Integral): return integral.doit() else: - return integral + return integral + + +# The function to PLEASE MERGE WITH ALL OF SYMPY FOR IT TO WORK ALONG WITH OTHER INTEGRALS; +# Please, let's implement this function, we need Sympy to, for example, recognize when he find this expresion next to a different expression and be able to solve all together: + +# Thanks Stephan who came up with the idea of converting the poly into a Gaussian Integral. + +import sympy +from sympy import Symbol, integrate, sqrt, simplify, exp, erf, pprint + +def GaussIntegral(expr,param,lowerbound,upperbound,z=Symbol('z')): + """Finds the definite integral of exp(second order polynomial) expression trough transforming into Gaussian Integral""" + exponent = expr.args[0] + coeff = exponent.as_poly(param).coeffs + t1 = sqrt(coeff[0])*param + t2 = coeff[1]*param/(2*t1) + square = t1+t2 + remainder = simplify(exponent-square**2) + jacobn = 1/square.diff(param) + result = integrate(exp(-z**2),z).subs(z,square)*jacobn*exp(remainder) + result + A=(result.subs(param,upperbound).evalf())-(result.subs(param,lowerbound).evalf()) + return pprint(A) + --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patches@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en -~----------~----~----~----~------~----~------~--~---