Post Reply 
problems with integration
12-08-2014, 02:19 AM (This post was last modified: 12-08-2014 03:58 PM by Han.)
Post: #21
RE: problems with integration
(12-07-2014 12:07 PM)resolved Wrote:  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.

To create a function, use one of the syntaxes below:

1. f(x):=a*x^2+b*x+c; // creates a function \( f(x) = ax^2+bx+c\)

OR

2. f:=(x)->(a*x^2+b*x+c); // creates a function \( f(x)=ax^2+bx+c \)

Please note that f is now a CAS function, and f(x) is the evaluation of the CAS function f at an input value of x. Thus the result of f(x) is a CAS expression (not to be confused with the mathematical function of the same syntax). When you integrate using int(expr, var), the expr argument is a CAS expression. We must keep those concepts straight.

To create a function that is the integral of a previously defined function:

1a. int(f(x),x);
1b. g(x):= tap the screen and copy the result

OR (for a single command)

2. g:=unapply(int(f(x),x), x);

Now typing g(x) will give the result: 1/3*a*x^3+1/2*b*x^2+c*x.

The unapply(expr, var) will evaluate the expression expr and then create a function (with dummy variable var). In the CAS world, something like g(x):=int(f(x),x) is not well-defined due to ambiguity in the substitution priority. It's obvious to a human what is likely the intended result, but not to a computer program.

Quote: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........

You can, so long as you understand that the typical integral (the one implemented in the HP Prime and pretty much any CAS) is _NOT_ the same as the integral operator used on \(n\)-th order ramp functions and similar discontinuous functions (D.F.) commonly used in beam problems. For \( n\ge 0 \) and \( x_0 \le a \),
\[ \int_{x_0}^x (t-a)^n\ dt = \frac{1}{n+1}(x-a)^{n+1} -\frac{1}{n+1}(x_0-a)^{n+1}\]
whereas
\[ \int_{x_0}^x \langle t-a\rangle^n\ dt = \frac{1}{n} \langle x-a \rangle^{n+1} \]


The HP properly handles ramp functions of order \( n\ge 2\) defined as a piecewise function since its integration algorithm resembles the reverse of the chain rule which coincides with the your D.F. integration. (You will also get the warning about integrating piecewise functions.) It's the ramp function and other D.F. whose exponent is less than 2 that will not integrate as you want because the CAS uses the "regular" integrals and not the ones relevant to D.F. So there are a few ways about doing the double integration technique.

1. Use piecewise functions for all ramp functions of order \( n\ge 2\) and leave out the lower-order ramp functions to do by hand. Then just add them in after your double integral.

OR

2. You can implement the following program that will return the proper "antiderivative" of a D.F.

Code:
#cas
MINT(a,n,d):=
BEGIN
// d-th order integral of <x-a>^n  

  local t,f,j,c,m;
  t:=n+d;
  c:=1;
  m:=max(n+1,1);
  f(x):=0;

// do not allow d<0 or n<-1 (need to add doublet)
  if d<0 OR n<-1 then return f; end;

  if t==-1 then
    f:=unapply(piecewise(x<a-ɛ/2,0,a-ɛ/2<x AND x<=a+ɛ/2,1/ɛ,x>a+ɛ/2,0),x);
    return f;
  end;

  if t==0 then
    f:=unapply(piecewise(x<a,0,x>=a,1),x);
    return f;
  end;

  if t>0 then
    if d>0 then
      for j from m to t do
        c:=c*1/j;
      end;
    end;
    f:=unapply(piecewise(x<a,0,x>=a,c*(x-a)^t),x);
    return f;
  end;

  return f;
END;
#end

MINT(a,n,d) computes the \(d\)-th antiderivative of \( \langle x-a \rangle^n \). For example, MINT(3,1,2) is equivalent
\[ \int \int \langle x-3 \rangle\ dx\ dx = \int \frac{1}{2} \langle x-3 \rangle^2\ dx
= \frac{1}{6} \langle x-3\rangle^3 \]
except the result from MINT(3,1,2) is a CAS function equivalent to
\[ (x) \rightarrow \left(\frac{1}{6} \langle x-3 \rangle^3 \right) \]

You can use \( d=0 \) if you don't want to integrate and just want the \(n\)-th order ramp function. I didn't implement the doublet function. I'll leave that as an exercise to the reader. (It can be defined as a 5-piece piecewise function. The three non-zero components are just lines.)

Solving:
\[ y'' = -24 + 18 \langle -9 + x\rangle + 3 \langle -9 + x\rangle^2 + 21 \langle -3 + x\rangle - 3 \langle -3 + x\rangle ^2 \]

f(x):=-24; // in general, this is the non D.F. component; note the functional notation
y1:=unapply( int(f(x),x)+c1 , x) + 18*MINT(9,1,1) + 3*MINT(9,2,1) + 21*MINT(3,1,1) -3*MINT(3,2,1);
y0:=unapply( int(y1(x),x)+c2 , x); // here regular integration is ok since we no longer have ramp functions of order 1 or lower
solve({y0(3)=0,y0(9)=0},{c1,c2});

OR

f(x):=-24;
y:=unapply(int(int(f(x),x)+c1,x)+c2,x) + 18*MINT(9,1,2) + 3*MINT(9,2,2) + 21*MINT(3,1,2) -3*MINT(3,2,2);
solve({y(3)=0,y(9)=0},{c1,c2});


Basically, use the HP Prime's int() function to handle the non-D.F. portion (including the constants c1 and c2. As for the D.F. part, use the MINT() program. If you plan to work with doublet functions and D.F.'s of more negative powers \( n < -2\) you will need to adjust the code for MINT() to handle those cases. It's really just a "shortcut" to some simple integrals which you can easily do by hand with piecewise functions anyway.

Lastly, by having the results be functions, you can then use "substitution" in the solve command by simply evaluating the functions and setting the result equal to zero: y(3)=0 for example.

EDIT: There are probably other ways to do this.

Graph 3D | QPI | SolveSys
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)