I think integrating piecewise where the variable appears in the conditions in a non-trivial way may require implementing some new algorithm. See https://code.google.com/p/sympy/issues/detail?id=2128 and https://code.google.com/p/sympy/issues/detail?id=3801.
Aaron Meurer On Mon, Nov 11, 2013 at 11:17 AM, George Gerber <[email protected]> wrote: > Good day, > My ultimate goal is to solve for the coefficient of a piecewise function > that is integrated. > Example: > > from sympy import solve, symbols, Piecewise > x, C1 = symbols('x C1') > strain = C1*x > # Linear strain distribution assumption > stress = Piecewise((strain**2,strain>0),(strain**3,strain>1)) # > Stress-stain relationship of material > Force = stress.integrate((x,-1,1)) > # Force = integral of stress over an area > sol = solve([Force-1],[C1]) > # Find the strain distribution which will balance the specified force > > Is this possible or is this too advanced for sympy (even in near future)? > > Best regards, > George > > > On Monday, 11 November 2013 06:58:04 UTC+2, George Gerber wrote: >> >> Good day, >> >> The integration of a piecewise function below results in a single numeric >> number, instead of producing a piecewise equation containing the symbols >> 'C1', 'C2' and 'C3'. >> Is this a bug? >> >> Best regards, >> George >> >> ~~~~~~~~~~~~~~~~~~~~~~~~ >> >> from sympy import symbols, Piecewise >> x,y,C1,C2,C3 = symbols('x y C1 C2 C3') >> >> W = 1.0 >> L = 1.0 >> A1 = 1.0 >> A2 = 1.0 >> sigma_max = 1.0 >> strain0 = 1.0 >> >> strain = C1*x+C2*y+C3 >> >> sigma = >> 1e6*Piecewise((0,strain>0),(A1*strain**2+A2*strain,strain>strain0),(sigma_max,True)) >> F_c = sigma.integrate((x,-W/2,W/2),(y,-L/2,L/2)) >> >> >> print 'F_c',F_c >> ~~~~~~~~~Result is:~~~~~~~~~~~~~ >> F_c 500000.000000000 >> > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
