Post Reply 
Numerical integration
02-03-2016, 04:52 PM
Post: #1
Numerical integration
Hi, I'm new on this forum. Sorry for my english, but I'm italian and I don't speak english very well. However, I study chemical engineering. I've bought HP PRIME and now I have a problem. How can I resolve a numerical integration??
Thank you for your help
Alessio
Find all posts by this user
Quote this message in a reply
02-03-2016, 04:55 PM
Post: #2
RE: Numerical integration
Hi.

It takes awhile to get used to where things are, and what they do, but have you discovered the "template" key, [units C]? That may be helpful for you.

-Dale-
Find all posts by this user
Quote this message in a reply
02-03-2016, 05:03 PM
Post: #3
RE: Numerical integration
Thank you for your answer, but I'm sorry, I don't know what is the "template" key, [units C]. Can you help me?
Find all posts by this user
Quote this message in a reply
02-03-2016, 05:17 PM (This post was last modified: 02-03-2016 05:18 PM by DrD.)
Post: #4
RE: Numerical integration
That is the alpha key C. Just to the right of the Toolbox key. I think it is described on page 13 of the user guide, which you may be able to bring up via the emulator: Help | User Guide. It's called the Math Template Key.
Find all posts by this user
Quote this message in a reply
02-03-2016, 05:30 PM
Post: #5
RE: Numerical integration
Umh, You mean the symbol of defined integration? I use that symbol when I have to solve a definite integral between two values.
However I meant: can you resolve numerical integral with HP Prime? For example it is possible to solve nonlinear equations in a numerical way with fsolve.
For numerical integration I mean: https://en.wikipedia.org/wiki/Numerical_integration
Find all posts by this user
Quote this message in a reply
02-03-2016, 05:38 PM
Post: #6
RE: Numerical integration
I guess, I didn't understand. You might try the forum search feature, with "non linear equations" in the entry field. This topic has been discussed previously, and (I think) there have been some related firmware changes, so make sure you have the latest updates. That's about all I can offer, good luck!

-Dale-
Find all posts by this user
Quote this message in a reply
02-03-2016, 05:55 PM
Post: #7
RE: Numerical integration
Sad hoping someone could help me! I need to solve that problem!
Find all posts by this user
Quote this message in a reply
02-03-2016, 06:39 PM
Post: #8
RE: Numerical integration
Perhaps you mean something like:
Code:

#cas
simpsonint(g,a,b,n):=
BEGIN
local l,l1;
IF even(n) THEN
IF (type(g)==DOM_SYMBOLIC  OR type(g)== DOM_FUNC)
  THEN 
   l:=MAKELIST(X,X,a,b,(b-a)/n);
     IF type(g)==DOM_SYMBOLIC THEN
     g:=unapply(g,x);
     END;
   l:=apply(g,l);
   l1:=MAKELIST(even(X)+1,X,1,n+1);
 return (2*DOT(l,l1)-g(a)-g(b))*(b-a)/(3*n);
   ELSE return ("f must be symbolic or function!");
  END;
 // return 0;
ELSE return "n must be even!";
END;

END;
#end


#cas
trapezregel(g,a,b,n):=
BEGIN
local l;
IF (type(g)==DOM_SYMBOLIC  OR type(g)== DOM_FUNC)
  THEN 
   l:=MAKELIST(X,X,a,b,(b-a)/n);
     IF type(g)==DOM_SYMBOLIC THEN
     g:=unapply(g,x);
     END;
   l:=apply(g,l);
   return (2*ΣLIST(l)-g(a)-g(b))*(b-a)/(2*n);
   ELSE return ("f must be symbolic or function!");
  END;
END;
#end


#cas
rightsum(g,a,b,n):=
BEGIN
local l;
IF (type(g)==DOM_SYMBOLIC  OR type(g)== DOM_FUNC)
  THEN 
   l:=MAKELIST(X,X,a,b,(b-a)/n);
     IF type(g)==DOM_SYMBOLIC THEN
     g:=unapply(g,x);
     END;
   l:=apply(g,l);
   return (ΣLIST(l)-g(a))*(b-a)/n;
   ELSE return ("f must be symbolic or function!");
  END;
END;
#end

#cas
leftsum(g,a,b,n):=
BEGIN
local l;
IF (type(g)==DOM_SYMBOLIC  OR type(g)== DOM_FUNC)
  THEN 
   l:=MAKELIST(X,X,a,b,(b-a)/n);
     IF type(g)==DOM_SYMBOLIC THEN
     g:=unapply(g,x);
     END;
   l:=apply(g,l);
   return (ΣLIST(l)-g(b))*(b-a)/n;
   ELSE return ("f must be symbolic or function!");
  END;
END;
#end

EXPORT NumericIntegr()
BEGIN
local a,N,f,b;
N:=12; a:=1;b:=3;
f:='X^2';
   if input(
     {{f,[8],{20,70,0}},
     {a,[0],{20,30,1}},
     {b,[0],{20,30,2}},
     {N,[0],{20,30,3}}},
     
     "Enter Data",
     {"f(X)=", "a= ", "b= ","N= "
      },
     {
       "Enter the function, upper case X!",
       "Enter the starting point",
       "Enter the endpoint",
       "Enter the amount of intervals"
      
     },
     {f,a,b,N}
   )
then
f:=lower(string(f));
PRINT();
PRINT("Simpsonsumme:   "+simpsonint(f,a,b,N));
PRINT("Trapezsumme:    "+trapezregel(f,a,b,N));
PRINT("Rechtecklinks:  "+leftsum(f,a,b,N));
PRINT("Rechteckrechts: "+rightsum(f,a,b,N));
return 
end;
END;
but I did not implement an adaptive method.
Arno
Find all posts by this user
Quote this message in a reply
02-03-2016, 08:32 PM
Post: #9
RE: Numerical integration
Maybe this will help.

First make sure you are in Home mode (1). Then press the template key (2). Then select the integration template from the touch screen (3).

   

Then enter a function to integrate into the template.

   

At this point, I usually hit Enter to make a copy of the equation (1). The press Shift/Eval (2/3) to numerically evaluate the integral.

   
Find all posts by this user
Quote this message in a reply
02-04-2016, 10:22 AM (This post was last modified: 02-04-2016 10:25 AM by retoa.)
Post: #10
RE: Numerical integration
[attachment=3093]If you work in home you will find directly the numerical result (using capital letters) without the need of "eval"
The precision depends on the settings, I have floating 3.

Se lavori in modalità home (usando variabili maiuscole) invece che in CAS ottieni direttamente il risultato numerico, senza dover utilizzare il tasto "eval".
La precisione del risultato dipende dalle impostazioni, io ho impostato floating 3.


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
02-04-2016, 11:04 AM
Post: #11
RE: Numerical integration
It looks like you are in Textbook mode and I am in RPN mode. Some other settings could affect this as well.
Find all posts by this user
Quote this message in a reply
02-04-2016, 12:31 PM
Post: #12
RE: Numerical integration
You are right, I didn't notice you were in RPN mode.
In RPN I have to press the "eval" key to see the numeric result.
Find all posts by this user
Quote this message in a reply
Post Reply 




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