Post Reply 
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.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
problems with integration - resolved - 11-28-2014, 05:04 AM
RE: problems with integration - parisse - 11-28-2014, 07:33 AM
RE: problems with integration - resolved - 11-28-2014, 01:26 PM
RE: problems with integration - parisse - 11-28-2014, 02:33 PM
RE: problems with integration - akmon - 11-28-2014, 10:30 PM
RE: problems with integration - resolved - 11-29-2014, 11:42 AM
RE: problems with integration - Gilles - 11-29-2014, 09:00 PM
RE: problems with integration - akmon - 11-29-2014, 01:32 PM
RE: problems with integration - peacecalc - 11-29-2014, 08:12 PM
RE: problems with integration - parisse - 11-30-2014, 07:10 AM
RE: problems with integration - resolved - 11-30-2014, 12:22 PM
RE: problems with integration - akmon - 11-30-2014, 12:28 PM
RE: problems with integration - resolved - 12-01-2014, 06:00 AM
RE: problems with integration - Han - 12-01-2014, 03:45 PM
RE: problems with integration - resolved - 12-06-2014 01:39 PM
RE: problems with integration - Han - 12-06-2014, 03:35 PM
RE: problems with integration - resolved - 12-06-2014, 03:37 PM
RE: problems with integration - Han - 12-06-2014, 03:46 PM
RE: problems with integration - resolved - 12-06-2014, 04:07 PM
RE: problems with integration - resolved - 12-07-2014, 12:07 PM
RE: problems with integration - Han - 12-08-2014, 02:19 AM
RE: problems with integration - Claudio L. - 01-07-2015, 03:48 PM
RE: problems with integration - Han - 12-08-2014, 03:57 PM
RE: problems with integration - resolved - 01-03-2015, 11:45 AM
RE: problems with integration - resolved - 01-06-2015, 01:55 AM
RE: problems with integration - Han - 01-06-2015, 01:09 PM
RE: problems with integration - resolved - 01-07-2015, 03:57 AM
RE: problems with integration - resolved - 01-08-2015, 12:40 AM
RE: problems with integration - Han - 01-07-2015, 05:11 AM
RE: problems with integration - Snorre - 01-07-2015, 08:57 AM
RE: problems with integration - resolved - 01-09-2015, 04:13 AM
RE: problems with integration - parisse - 01-09-2015, 07:21 AM
RE: problems with integration - parisse - 01-09-2015, 12:40 PM
RE: problems with integration - resolved - 01-10-2015, 10:30 AM
RE: problems with integration - rprosperi - 01-10-2015, 01:34 PM
RE: problems with integration - Snorre - 01-10-2015, 02:16 PM
RE: problems with integration - Han - 01-10-2015, 02:19 PM
RE: problems with integration - parisse - 01-10-2015, 03:17 PM
RE: problems with integration - Snorre - 01-10-2015, 03:58 PM
RE: problems with integration - parisse - 01-10-2015, 07:58 PM
RE: problems with integration - jte - 01-12-2015, 06:18 AM



User(s) browsing this thread: 1 Guest(s)