Promblem with integration
03-16-2016, 02:14 PM
Post: #1
 Annaguseva Junior Member Posts: 2 Joined: Mar 2016
Promblem with integration
In CAS, cannot integrate sin(x^2) or any other trigonometric function that involves x^(number): int(sin(x^2),x,0,8) Calculator gives out "integrate(...)" instead of answer. What's wrong?

Attached File(s) Thumbnail(s)

03-16-2016, 05:28 PM
Post: #2
 toshk Member Posts: 188 Joined: Feb 2015
RE: Promblem with integration
(03-16-2016 02:14 PM)Annaguseva Wrote:  In CAS, cannot integrate sin(x^2) or any other trigonometric function that involves x^(number): int(sin(x^2),x,0,8) Calculator gives out "integrate(...)" instead of answer. What's wrong?

in Home environment you find the answer , doesn't work in CAS but just press SHIFT>>ENTER to get the answer, some of the nifty tricks!!! Temperament Prime

03-16-2016, 06:34 PM (This post was last modified: 03-16-2016 07:22 PM by Tim Wessman.)
Post: #3
 Tim Wessman Senior Member Posts: 2,225 Joined: Dec 2013
RE: Promblem with integration
Since there is no exact closed form answer here (not without using some stuff not supported in any calculator), it returns the input unevaluated. Two ways to get a numeric approximation.

1. Press SHIFT-ENTER (to run approx( ) on your last input)
2. Put a "." in one of your limits. int(sin(x^2),0.,8) <-- note the 0. and not just 0

Both of those will immediately evaluate a decimal result.

The reason it works in HOME as stated already is that the X variable is an approximate valued number. Hence, it is just like putting the "0." in the second option as it triggers the approximate numerical calculation.

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
03-16-2016, 07:03 PM
Post: #4
 Annaguseva Junior Member Posts: 2 Joined: Mar 2016
RE: Promblem with integration
Thank You!
03-16-2016, 07:49 PM (This post was last modified: 03-16-2016 08:29 PM by toshk.)
Post: #5
 toshk Member Posts: 188 Joined: Feb 2015
RE: Promblem with integration
(03-16-2016 06:34 PM)Tim Wessman Wrote:  Since there is no exact closed form answer here (not without using some stuff not supported in any calculator), it returns the input unevaluated. Two ways to get a numeric approximation.

1. Press SHIFT-ENTER (to run approx( ) on your last input)
2. Put a "." in one of your limits. int(sin(x^2),0.,8) <-- note the 0. and not just 0

Both of those will immediately evaluate a decimal result.

The reason it works in HOME as stated already is that the X variable is an approximate valued number. Hence, it is just like putting the "0." in the second option as it triggers the approximate numerical calculation.

there is a close form to these integrations (Mathematically) but not for someone who just want numerical answer directly.

give a little push to Prime, and one can find the close form..or they shd be implemented into Prime if there is a need...
http://www.wolframalpha.com/input/?i=int...9,x,0,8%29

03-16-2016, 10:07 PM (This post was last modified: 03-17-2016 01:30 AM by Anders.)
Post: #6
 Anders Member Posts: 102 Joined: May 2014
RE: Promblem with integration
The closed form for int(sin(x^2)x,0,x) is the Fresnel integral S(x) function or just S(x).

S(x) is a variation of the Gauss error function (erf = int(e^-x^2)) and the imaginary error function (erfi = int(e^x^2)) that can be formulated in terms of erf(x) and erfi(x) with some complex math. However, S(x) is not supported on any handheld calculator that I am aware of. Given the limited flash memory on the Prime (or any calculator for that matter), I am not sure this is a top candidate to make it into the Prime's flash memory in some future release - there are many more important functions not yet implemented that have higher utility value. But if there is space then, sure go ahead. But implement erfi(x) first then S(C) and also the Fresnel integral C(x) function which is = int(cos(x^2)x,0,x).
03-17-2016, 06:54 AM
Post: #7
 parisse Senior Member Posts: 1,090 Joined: Dec 2013
RE: Promblem with integration
If you add more special functions, then of course you can compute more antiderivatives symbolically, but this requires more work than just adding a table lookup for sin/cos(x^2), because you must also integrate expressions that can be reduced to these forms. This is an endless quest and I'm not convinced it is really usefull. My programming time is finite, I have to make choices, Fresnel integrals are not on the top list.
03-17-2016, 05:36 PM
Post: #8
 Wes Loewer Member Posts: 227 Joined: Jan 2014
RE: Promblem with integration
(03-16-2016 10:07 PM)Anders Wrote:  The closed form for int(sin(x^2)x,0,x) is the Fresnel integral S(x) function or just S(x).

Since S(x) is itself defined as an integral, I would not have considered it a "closed form" solution. I realize that "closed" does not have a hard & fast definition, so that's just my opinion.

You may or may not find this helpful: https://en.wikipedia.org/wiki/Closed-form_expression
03-17-2016, 11:09 PM (This post was last modified: 03-18-2016 02:17 AM by Anders.)
Post: #9
 Anders Member Posts: 102 Joined: May 2014
RE: Promblem with integration
Yes I used the "closed form" much more loosely defined than Wiki. I was thinking to express the result using named standard functions like erf, erfc, gamma... (these particular once are already implemented in Prime but are nonetheless not in closed form per Wiki).

Anyway, I took another pass at this integration...

You could express int(sin(x^2)x,0,x) only in terms of erf(x) (avoiding erfi(x), S(x) and C(x) altogether). After some complex math you get:

int(sin(x^2),x,0,x) =
(1+i)*√(pi/32)*( erf( (1+i)/√(2) * x) - i*erf( (1-i)/√(2) * x) )

So int(sin(x^2)x,0,8) =
(1+i)*√(pi/32)*( erf( (1+i)/√(2) * 8.0) - i*erf( (1-i)/√(2) * 8.0))
should come out as 0.601721644935

Not sure if it's enough closed form though.
03-18-2016, 01:25 PM
Post: #10
 parisse Senior Member Posts: 1,090 Joined: Dec 2013
RE: Promblem with integration
Seems to plot, the imaginary part cancels nicely. I'll have a look...
03-18-2016, 05:26 PM
Post: #11
 Anders Member Posts: 102 Joined: May 2014
RE: Promblem with integration
parisse,
That would be great!

To complete the picture with cos(x^2), using Euler and variable substitution you can do a similar complex math calculation and derive int(cos(^2)x,0,x) in terms of erf(x) symmetrically as:

int(cos(x^2),x,0,x) =
(1-i)*√(pi/32)*( erf( (1+i)/√(2) * x) + i*erf( (1-i)/√(2) * x) )

It turns out that the signs in front of the two i's are swapped otherwise the same. Very nice actually.

03-19-2016, 11:46 AM
Post: #12
 parisse Senior Member Posts: 1,090 Joined: Dec 2013
RE: Promblem with integration
http://www-fourier.ujf-grenoble.fr/%7epa...sin(x^2))&
This will only work for finite boundaries in definite integration.
10-29-2017, 06:52 PM (This post was last modified: 10-30-2017 09:15 AM by salvomic.)
Post: #13
 salvomic Senior Member Posts: 1,366 Joined: Jan 2015
RE: Promblem with integration
(03-16-2016 10:07 PM)Anders Wrote:  The closed form for int(sin(x^2)x,0,x) is the Fresnel integral S(x) function or just S(x).

S(x) is a variation of the Gauss error function (erf = int(e^-x^2)) and the imaginary error function (erfi = int(e^x^2)) that can be formulated in terms of erf(x) and erfi(x) with some complex math. However, S(x) is not supported on any handheld calculator that I am aware of. Given the limited flash memory on the Prime (or any calculator for that matter), I am not sure this is a top candidate to make it into the Prime's flash memory in some future release - there are many more important functions not yet implemented that have higher utility value. But if there is space then, sure go ahead. But implement erfi(x) first then S(C) and also the Fresnel integral C(x) function which is = int(cos(x^2)x,0,x).

(03-17-2016 06:54 AM)parisse Wrote:  If you add more special functions, then of course you can compute more antiderivatives symbolically, but this requires more work than just adding a table lookup for sin/cos(x^2), because you must also integrate expressions that can be reduced to these forms. This is an endless quest and I'm not convinced it is really usefull. My programming time is finite, I have to make choices, Fresnel integrals are not on the top list.

I apologise if I reopen this post, but after a bit of time I wonder if there are some developments or thoughts about the implementation of Fresnel integrals S(x) and C(x) and erfi() in CAS (in the Prime) or if there is already any custom program (or App) to handle them simply and friendly.
Thank you!

Salvo

EDIT: could it be so simple? There are warnings with the below code, therefore I'm wondering...

Code:
#cas erfi(x):= return -i*erf(i*x) #end
***
Code:
EXPORT Fresnel_S(x) // Fresnel integral S(x) BEGIN local t; RETURN int(SIN(t^2),t,0,x); END; EXPORT Fresnel_Sn(x) // Fresnel integral S(x) normalized π/2 BEGIN local t; RETURN int(SIN((π/2)*t^2),t,0,x); END; EXPORT Fresnel_C(x) // Fresnel integral C(x) BEGIN local t; RETURN int(COS(t^2),t,0,x); END; EXPORT Fresnel_Cn(x) // Fresnel integral C(x) normalized π/2 BEGIN local t; RETURN int(COS((π/2)*t^2),t,0,x); END;
(above Fresnel integral S(x) and C(x) with and without normalisation with π/2 factor, following some authors...)

∫aL√0mic (IT9CLU), HP Prime 50g 41CX 71b 42s 12C 15C - DM42 WP34s :: Prime Soft. Lib
 « Next Oldest | Next Newest »

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