HP Forums
Numerical integration - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Numerical integration (/thread-5635.html)



Numerical integration - alealessietto - 02-03-2016 04:52 PM

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


RE: Numerical integration - DrD - 02-03-2016 04:55 PM

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-


RE: Numerical integration - alealessietto - 02-03-2016 05:03 PM

Thank you for your answer, but I'm sorry, I don't know what is the "template" key, [units C]. Can you help me?


RE: Numerical integration - DrD - 02-03-2016 05:17 PM

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.


RE: Numerical integration - alealessietto - 02-03-2016 05:30 PM

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


RE: Numerical integration - DrD - 02-03-2016 05:38 PM

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-


RE: Numerical integration - alealessietto - 02-03-2016 05:55 PM

Sad hoping someone could help me! I need to solve that problem!


RE: Numerical integration - Arno K - 02-03-2016 06:39 PM

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


RE: Numerical integration - ndzied1 - 02-03-2016 08:32 PM

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).

[attachment=3089]

Then enter a function to integrate into the template.

[attachment=3090]

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.

[attachment=3091]


RE: Numerical integration - retoa - 02-04-2016 10:22 AM

[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.


RE: Numerical integration - ndzied1 - 02-04-2016 11:04 AM

It looks like you are in Textbook mode and I am in RPN mode. Some other settings could affect this as well.


RE: Numerical integration - retoa - 02-04-2016 12:31 PM

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.