- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In fortran there exists a intrinsic function ASIN for calculating arcsine(x).
But there is one problem, x should be real and less than 1 or complex.
But my problem is I have to calculate arcsin(x) for real number x lager than 1.
How can I solve this?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Isn't arcsin(x) only defined for -1<=x<=1 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In F2008 the following should work:
program main complex :: x, y x = cmplx(2,0) y = asin(x) print *,y end program main
but you'll probably need a v15 compiler for that. The above doesn't build with Version 14.0.3.202.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Zhiyong B. wrote:
But my problem is I have to calculate arcsin(x) for real number x larger than 1. How can I solve this?
No real number y exists for which x = sin(y) > 1. In geometrical terms, no point on a circle falls outside the square that just circumscribes the circle.
You can solve 'this' by reviewing your mathematics books.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you want to keep it real, recall that
sin(a+b*i) = sin(a)*cos(b*i)+cos(a)*sin(b*i)
= sin(a)*cosh(b)+i*cos(a)*sinh(b)
so let a = sign(pi/2,x), b = acosh(abs(x)), then sin(a+b*i) = sign(real(1,kind(x)),x)*abs(x)+i*(0)*(don't care) = x
Thus you can test whether abs(x) > 1 and if so you know asin(x) = cmplx(sign(pi/2,x),acosh(abs(x)),kind(x))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This depends on how x is bunged-up. If it is a rounding error
if(x<-1.0) x=-1.0
if(x>1.0) x=1.0
y=asin(x)
Or if x is accumulation of cyclical use mod
y = asin(mod(x+1.0-TINY(x), 2.0) - 1.0)
The issue with the above is when x is exactly 1.0, you would end up with 1.0-TINY(x)
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mecej4 wrote:
Quote:
Zhiyong B. wrote:But my problem is I have to calculate arcsin(x) for real number x larger than 1. How can I solve this?
No real number y exists for which x = sin(y) > 1. In geometrical terms, no point on a circle falls outside the square that just circumscribes the circle.
You can solve 'this' by reviewing your mathematics books.
Thanks anyway. I have solved this problem. In fact, there exists x=sin(y) >1 with y a complex number.
Here is my code for solution:
complex function arcsin(x) real x complex I = (0.0, 1.0) if (abs(x) >= 1) then arcsin = -I*log(I*x + I*sqrt(x**2 -1)) else arcsin = ASIN(x) end if end function

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page