Post Reply 
problems with integration
11-28-2014, 05:04 AM (This post was last modified: 11-28-2014 05:11 AM by resolved.)
Post: #1
problems with integration
using the Double Integration Method to determine the deflection in a beam. I need to integrate the below equation twice.

y2= 168 (-8 + x)^2/2 + 10 (-8 + x)^3/3 - 4 (-6 + x)^2/2 + 5 (-4 + x)^3/3 + 96 x^2/2 - 15 x^3/3

by hand I get:

y = 28 (-8 + x)^3 + 5/6 (-8 + x)^4 - 2/3 (-6 + x)^3 + 5/12 (-4 + x)^4 + 16 x^3 - (5 x^4)/4

when I integrate y2 in the HP Prime I get

y = -5/4*x^4 + 5/12*(x-4)^4 + 5/6*(x-8)^4 + 16*x^3 - 4*(1/6*x^3 - 3*x^2) + 168*(1/6*x^3 - 4*x^3)

HP Prime integrates the first four terms using the power formula and then switches in the last two terms by expanding the terms and integrating by differences and then simplifying.

-4*(x-6) integrates to -2*(x-6)^2 which integrate to -2/3*(x-6)^3

-2/3*(x-6)^3 Expanded = -2/3*x^3 + 12*x^2 - 72*x + 144

where HP expands first, -4x+24, which integrates to -2x + 24x which integrate to -2/3*x^3 + 12 x^2

clearly both are correct mathematically, but I have lost a lot of information by the way HP Prime integrated the last two terms. Why does HP change its methodology half way through integration?? is there any way to force use the power formula over the whole equation so I don't lost this information.

when solving for c1x and c2, the c2 term drops out x=0, y=0, c2=0 , but I get different values for c1 when evaluating the beam at its end x=10, y=0 to determine the value of c1, as would be expected between the two different equations. by hand c1 = -6352/15 , but HP evaluates to +10384/3. Clearly, my instructor would not give my credit for an incorrect answer if I told him the difference was in the c2 term.
Find all posts by this user
Quote this message in a reply
11-28-2014, 07:33 AM
Post: #2
RE: problems with integration
You should always use explicit * except if you are certain that implicit multiplication does what you think.
In the CAS, this will happen only for number*symbol or number*symbol^number (alone).
96x^2/2 is not parsed as (96x^2)/2 but as 96x^(2/2)=96x because I could not find any way to force priorities rules with implicit multiplication.
Find all posts by this user
Quote this message in a reply
11-28-2014, 01:26 PM
Post: #3
RE: problems with integration
the expression I used in my text I copied from Mathematica and it is not how I typed the expression into my HP Prime. That is how Mathematica simplified the expression. I have had too many problems using implicit multiplication in the HP Prime and for the most part i use only the explicit multiplicaton because of errors when raising a variable to a power. ( I hope HP fixes this bug as Mathematica doesn't seem to have any problems in this regard)

So even with EVERY multiplication sign explicitly expressed, the HP Prime still uses the power formula on part of the expression and expands certain terms before integration causing a lost of information. Is this a bug, as I don't think the result is correct, but it is closer to what I want than what I get in Mathematica. There the whole expression is simplified before it is integrated, destorying the whole value of the equation
Find all posts by this user
Quote this message in a reply
11-28-2014, 02:33 PM
Post: #4
RE: problems with integration
Then please enter the expression like you would enter it in algebraic mode (non textbook mode) so that I can copy/paste it without modifications.
The first step of the integration algorithm is to apply linearity, perhaps you can demonstrate your point with a smaller input.
Find all posts by this user
Quote this message in a reply
11-28-2014, 10:30 PM (This post was last modified: 11-28-2014 10:32 PM by akmon.)
Post: #5
RE: problems with integration
I've just integrated your expression and the result is the same as by hand.
Find all posts by this user
Quote this message in a reply
11-29-2014, 11:42 AM (This post was last modified: 11-29-2014 11:48 AM by resolved.)
Post: #6
RE: problems with integration
in textbook CAS mode,

int(-3*(x-3)^2 + 3*(x-9)^2 + 21*(x-3) + 18*(x-9)-24)

the result I get is:

-(x-3)^3 + (x-9)^3 + 21*(1/2 * x^2 - 3*x ) + 18*(1/2*x^2 - 9*x) - 24*x

if I integrate the expression by hand I get:

-(x-3)^3 + (x-9)^3 + 21/2 * (x-3)^2 + 9*(x-9)^2 - 24* x

HP Prime expression simplifies to:

(3*x^2 - 66*x - 1404)/2

my integration simplifies to:

(3*x^2 - 66*x +243)/2

clearly, these are not the same results....

what was the result you got by hand????
Find all posts by this user
Quote this message in a reply
11-29-2014, 01:32 PM
Post: #7
RE: problems with integration
[Image: DSC_0720_zps8385586a.jpg]

[Image: DSC_0719_zps655cde68.jpg]
Find all posts by this user
Quote this message in a reply
11-29-2014, 08:12 PM
Post: #8
RE: problems with integration
Hello resolved,

I miss some information to reproduce your results in calculating the integral constant.

Greetings peacecalc
Find all posts by this user
Quote this message in a reply
11-29-2014, 09:00 PM (This post was last modified: 11-29-2014 09:17 PM by Gilles.)
Post: #9
RE: problems with integration
(11-29-2014 11:42 AM)resolved Wrote:  in textbook CAS mode,

int(-3*(x-3)^2 + 3*(x-9)^2 + 21*(x-3) + 18*(x-9)-24)

(...)

what was the result you got by hand????

-3*(x-3)^2 + 3*(x-9)^2 + 21*(x-3) + 18*(x-9)-24

is : 3*x-33

int is : (3/2).x²-33.x+C
Find all posts by this user
Quote this message in a reply
11-30-2014, 07:10 AM
Post: #10
RE: problems with integration
int(18*(x-9)) is integrated using linearity. This differs from a monomial like e.g. 18*(x-9)^2, because 18*(x-9) is linear, while 18*(x-9)^2 is not.
Find all posts by this user
Quote this message in a reply
11-30-2014, 12:22 PM
Post: #11
RE: problems with integration
I am new with all this math so which result would be considered the "correct" result???
Find all posts by this user
Quote this message in a reply
11-30-2014, 12:28 PM
Post: #12
RE: problems with integration
If you want to solve C1,C2... Cn for the elastic equation, just simplify the expresion, and apply the boundary conditions. The simpler the expression, the easier for substituing.
Find all posts by this user
Quote this message in a reply
12-01-2014, 06:00 AM (This post was last modified: 12-01-2014 06:05 AM by resolved.)
Post: #13
RE: problems with integration
unfortunately at my level of understanding, nothing seems simple. my problem is I have a beam (would like to send you a picture, but the "insert image" requires a "URL" ?? -- no URL to my hard drive) with a couple, two loads, two supports and has the following moment equation:

c2 + 3 (-9 + x)^3 + 1/4 (-9 + x)^4 + 7/2 (-3 + x)^3 - 1/4 (-3 + x)^4 + c1 x - 12 x^2

to solve for c1 and c2 requires that I use 'singular functions' that is, the term drops out if it evaluates less than zero. In mathematica it looks like this

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}]

the results are: {{c1 -> 72., c2 -> -108.}}

so if I "just simplify" my first equation I will get the wrong values for c1 and c2 as they evaluate at different location along the beam and different terms will drop out at different locations on the beam. This is reason why I can't integrate a simplified form of the equation, as terms will be combined losing the ability to drop those terms (representing different loads) that come after the location I am determining the deflection in the beam.
Find all posts by this user
Quote this message in a reply
12-01-2014, 03:45 PM (This post was last modified: 12-01-2014 03:53 PM by Han.)
Post: #14
RE: problems with integration
(12-01-2014 06:00 AM)resolved Wrote:  unfortunately at my level of understanding, nothing seems simple. my problem is I have a beam (would like to send you a picture, but the "insert image" requires a "URL" ?? -- no URL to my hard drive) with a couple, two loads, two supports and has the following moment equation:

c2 + 3 (-9 + x)^3 + 1/4 (-9 + x)^4 + 7/2 (-3 + x)^3 - 1/4 (-3 + x)^4 + c1 x - 12 x^2

to solve for c1 and c2 requires that I use 'singular functions' that is, the term drops out if it evaluates less than zero. In mathematica it looks like this

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}]

the results are: {{c1 -> 72., c2 -> -108.}}

so if I "just simplify" my first equation I will get the wrong values for c1 and c2 as they evaluate at different location along the beam and different terms will drop out at different locations on the beam. This is reason why I can't integrate a simplified form of the equation, as terms will be combined losing the ability to drop those terms (representing different loads) that come after the location I am determining the deflection in the beam.

You are giving the CAS a continuous function which it integrates correctly, but the actual function you are working with (the one you created in Mathematica) is not the same as the one you integrated. That is why you are getting different answers.

See this post: http://hpmuseum.org/forum/thread-2489.html

The HP Prime can integrate piecewise functions and even solve equations using piecewise functions (at least the few simple cases I tried -- I did not try yours yet).

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
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
12-06-2014, 03:35 PM (This post was last modified: 12-06-2014 04:12 PM by Han.)
Post: #16
RE: problems with integration
(12-06-2014 01:39 PM)resolved Wrote:  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))

Why are you defining the piecewise function to break at x=0? Should each piecewise function break at x=9 or x=3?

[Image: attachment.php?aid=1266]
[Image: attachment.php?aid=1267]
[Image: attachment.php?aid=1268]

I entered in the antiderivative as shown in the screens above, and solved with

solve({f(3)=0,f(9)=0},{c1,c2}) and got {[72 -108]}

So the HP Prime knows how to solve the final equation, provided that it's constructed correctly.

The issue here is that you are using a regular antiderivative to compute the antiderivative of <x-a>^k. They aren't technically the same thing because a regular antiderivative of something like (x-a) is correct up to any constant.
\[ \frac{1}{2}(x-a)^2, \quad \frac{x^2}{2}-ax, \quad \frac{x^2}{2}-ax + C, \quad etc \]
On the other hand antiderivative of something like <x-a> must necessarily be 1/2*<x^2-2ax+a^2> + C based on my understanding of your description of <x-a>.

I'm not sure that even mathematica can correctly give you the antiderivative unless it knows how to handle functions of the form <x-a>. Does it? I'm not at my office to test.


Attached File(s) Thumbnail(s)
           

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
12-06-2014, 03:37 PM
Post: #17
RE: problems with integration
I tried setting up my equation as Akmon did

f:=(x)->(function) , but my Prime would not accept the brackets around the x

f:=x->(function) the Prime would take, but when I tried to integrate this function

int(f(x)) as Akmon did in his post, I used the same function as above

-24 + 18 (-9 + x) + 3 (-9 + x)^2 + 21 (-3 + x) - 3 (-3 + x)^2

my result was ∫x->(3*x-33)(x)dx and I could not get the Prime to do anything with this answer.

Akmon, could you explain your procedure, I am not sure what the (x)-> is used for???
Find all posts by this user
Quote this message in a reply
12-06-2014, 03:46 PM (This post was last modified: 12-06-2014 03:49 PM by Han.)
Post: #18
RE: problems with integration
(12-06-2014 03:37 PM)resolved Wrote:  I tried setting up my equation as Akmon did

f:=(x)->(function) , but my Prime would not accept the brackets around the x

f:=x->(function) the Prime would take, but when I tried to integrate this function

int(f(x)) as Akmon did in his post, I used the same function as above

-24 + 18 (-9 + x) + 3 (-9 + x)^2 + 21 (-3 + x) - 3 (-3 + x)^2

my result was ∫x->(3*x-33)(x)dx and I could not get the Prime to do anything with this answer.

Akmon, could you explain your procedure, I am not sure what the (x)-> is used for???

f:=(x)->(x^2);

is the same thing as

f(x):=x^2. If you enter f(x):=x^2, the calculator displays this as f:=(x)->(x^2) which is its natural way of representing functions. You are continuing to ignore my comments about regular integrals vs the integral you're trying to do, though.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
12-06-2014, 04:07 PM
Post: #19
RE: problems with integration
thanks Han for all your help, I am not ignoring your comments, it is midnight here, I'm tried, my head hurts from trying to understand the math and then trying to understand how to use the Prime.

Quote:Why are you defining the piecewise function to break at x=0? Should each piecewise function break at x=9 or x=3?

I was thinking of the result I wanted instead of how to get that result. I wanted only positive numbers which is why I broke x at 0, but you are absolutely correct that this would occur at 9 in the case of (x-9). This is the first time that I have used piecewise so your correction help greatly.

My head is full right now, so I will try again tomorrow using f(x) to introduce functions and see if that makes any difference

again thanks for your help....
Find all posts by this user
Quote this message in a reply
12-07-2014, 12:07 PM
Post: #20
RE: problems with integration
how would I assign a function, the integral of a prior declared function. I just can't seem to get the HP Prime to work in this regard.

I am getting to the point to believe that I can NOT use the HP Prime to use the double integration method to solve for deflection in beams. I am hoping someone will prove me wrong........
Find all posts by this user
Quote this message in a reply
Post Reply 




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