problems with integration
|
12-06-2014, 01:39 PM
(This post was last modified: 12-06-2014 02:57 PM by resolved.)
Post: #15
|
|||
|
|||
RE: problems with integration
I tried on my HP Prime:
int(max(0,x-3)), the result ∫max(0,x-3)dx one can NOT integrate such a function with the command Max in the integral, so that option is out. I tried integrating with piecewise in the integral I get "Warning: piecewise indefinite integration does not return a continuous antiderivative" Enter again and I get each term integrated separately. for example I assigned y2 the following function y2:=-24+18*piecewise(x-9 if x>0, 0 if x<=0) + 3*(piecewise((x-9)^2 if x>0, 0 if x<=0)) + 21*piecewise((x-3) if x>0, 0 if x<=0) - 3*(piecewise((x-3)^2 if x>0, 0 if x<=0)) five terms; integrate y2 twice; y1:=int(y2,x) y:=int(y1,x) y = 21*piecewise(1/2*(1/3*x^3 - 3*x^2) if x>0, 0 if x<=0) + 18* piecewise(1/2*(1/3*x^3 -9*x^2) if x>0, 0 if x<=0) - 3*piecewise(1/12*(x-3)^4 if x>0, 0 if x<-0) + 3*piecewise(1/12*(x-9)^4 if x>0, 0 if x<=0) - 12*x^2 I can NOT use subst() inside of solve(), so substitute for x separately then solve for c1 and c2. when x=3 y=0 and when x=9 y=0 subst(y,x=3) = -621 subst(y,x=9) = -5670 solve({0=-621+3*c1+c2, 0=-5670+9*c1+c2},{c1,c2}) the result {(1683/2 , -3807/2)} whereas if integrate by hand and enter the data into y y = 3*(piecewise( (-9 + x) if x>0, 0 if x<=0))^3 + 1/4*(piecewise( (-9 + x) if x>0, 0 if x<=0 ))^4 + 7/2*(piecewise( (-3 + x) if x>0, 0 if x<=0))^3 - 1/4* (piecewise( (-3 + x) if x>0, 0 if x<=0))^4 - 12 x^2 subst(y,x=3) = -432 subst(y,x=9) = -540 solve({0=-432+3*c1+c2, 0=-540+9*c1+c2},{c1,c2}) the result {(18, 378)} which is a bit disappointing as Mathematica gives me the values c1=72 and c2=-108 ycc[x_] := 3 Max[0, (-9 + x)]^3 + 1/4 Max[0, (-9 + x)]^4 + 7/2 Max[0, (-3 + x)]^3 - 1/4 Max[0, (-3 + x)]^4 - 12 x^2 + c1 x + c2 NSolve[{0 == ycc[x] /. x -> 3, 0 == ycc[x] /. x -> 9}, {c1, c2}] {{c1 -> 72., c2 -> -108.}} I don't know which is the "correct" answer - HP Prime seems to have a problem in that it integrates (x-3) differently from (x-3)^2 which causes a loss of information, but solving the hand integrated function for the values of c1 and c2 using piecewise gave me different results then what I got in Mathematica, which leads me to wonder if piecewise has its own problems. the answer I got in Mathematica using the double integration method was confirmed by using the the moment diagram by parts method, so I am more likely to believe Mathematica's results are correct. after posting I realized that I made a mistake in square the terms inside piecewise and y2 should have been entered as y2:=-24+18*piecewise(x-9 if x>0, 0 if x<=0) + 3*(piecewise((x-9) if x>0, 0 if x<=0))^2 + 21*piecewise((x-3) if x>0, 0 if x<=0) - 3*(piecewise((x-3) if x>0, 0 if x<=0))^2 after integrating twice and solving for c1 and c2, I get the values {(1683/2 , -2997/2)} so I am still frustrated as there is no confirmation with HP Prime after posting I decided to try max with the hand integrated equation y4:= 3*max(0,x-9)^3 + 1/4*max(0,x-9)^4 +7/2*max(0,x-3)^3 -1/4*max(0,x-3)^4 - 12*x^2 subst(y4,x=3) = -108 subst(y4,x=9) = -540 solve({0=-108+3*c1+c2, 0=-540+9*c1+c2},{c1,c2}) and I get the result {(72, -108)} which confirms with Mathematica, so there seems to be a problem with piecewise in this application. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 5 Guest(s)