"asin" function is always solving between 0 and pi/2 of interval. Why?

I am encounering a problem when using asin function. function is solving the problem always between 0 and pi/2. why?
a=0.5;
x=[0.0 0.5 0.75 1.250 2.5 5.0 7.5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]./100-0.5 ;
y=[0.0 0.394 0.475 0.594 0.795 1.090 1.322 1.518 1.828 2.066 2.245 2.375 2.459 2.498 2.487 2.420 2.290 2.106 1.881 1.623 1.339 1.038 0.729 0.430 0.165 0.0];
X=[x flip(x)]
Y=[y flip(y)];
for k=1:numel(X)
p(k) = 1-((X(k)./(2*a)).^2)-(Y(k)./(2*a)).^2;
sin2the(k) = (p(k)+sqrt(p(k).^2+(Y(k)./a)^2));
sinthe(k) = sqrt(sin2the(k)./2);
theta(k) = asin(sinthe(k));
psi(k) = asinh(Y(k)./(2.*a.*sinthe(k)));
end
plot(theta,psi)
graphic of psi againts theta must be like in picture

 Accepted Answer

Most likelly because of the arguments you give it.
From the documentation:
  • For real values of X in the interval [-1, 1], asin(X) returns values in the interval [-π/2, π/2].
Illustrated here —
a=0.5;
x=[0.0 0.5 0.75 1.250 2.5 5.0 7.5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]./100-0.5 ;
y=[0.0 0.394 0.475 0.594 0.795 1.090 1.322 1.518 1.828 2.066 2.245 2.375 2.459 2.498 2.487 2.420 2.290 2.106 1.881 1.623 1.339 1.038 0.729 0.430 0.165 0.0];
X=[x flip(x)]
X = 1×52
-0.5000 -0.4950 -0.4925 -0.4875 -0.4750 -0.4500 -0.4250 -0.4000 -0.3500 -0.3000 -0.2500 -0.2000 -0.1500 -0.1000 -0.0500 0 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500 0.4000 0.4500 0.5000 0.5000 0.4500 0.4000 0.3500
Y=[y flip(y)];
for k=1:numel(X)
p(k) = 1-((X(k)./(2*a)).^2)-(Y(k)./(2*a)).^2;
sin2the(k) = (p(k)+sqrt(p(k).^2+(Y(k)./a)^2));
sinthe(k) = sqrt(sin2the(k)./2);
theta(k) = asin(sinthe(k));
psi(k) = asinh(Y(k)./(2.*a.*sinthe(k)));
end
plot(theta,psi)
asinarg = [min(sinthe) max(sinthe)]
asinarg = 1×2
0.8660 1.0000
asinv = asin(asinarg)
asinv = 1×2
1.0472 1.5708
asinext = asin([-1 1])
asinext = 1×2
-1.5708 1.5708
.

6 Comments

NOw I fixed the X and Y coordinate. But problem is same. Can ı fix this problem
a=0.5;
x=[0.0 0.5 0.75 1.250 2.5 5.0 7.5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]./100-0.5 ;
y=[0.0 0.394 0.475 0.594 0.795 1.090 1.322 1.518 1.828 2.066 2.245 2.375 2.459 2.498 2.487 2.420 2.290 2.106 1.881 1.623 1.339 1.038 0.729 0.430 0.165 0.0];
X=[x flip(x)]
Y=[y -flip(y)];
for k=1:numel(X)
p(k) = 1-((X(k)./(2*a)).^2)-(Y(k)./(2*a)).^2;
sin2the(k) = (p(k)+sqrt(p(k).^2+(Y(k)./a)^2));
sinthe(k) = sqrt(sin2the(k)./2);
theta(k) = asin(sinthe(k));
psi(k) = asinh(Y(k)./(2.*a.*sin(theta(k))))
end
plot(theta,psi)
hold on
plot(X,Y)
hold off
Please describe the problem.
It seems to work correctly.
a=0.5;
x=[0.0 0.5 0.75 1.250 2.5 5.0 7.5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100]./100-0.5 ;
y=[0.0 0.394 0.475 0.594 0.795 1.090 1.322 1.518 1.828 2.066 2.245 2.375 2.459 2.498 2.487 2.420 2.290 2.106 1.881 1.623 1.339 1.038 0.729 0.430 0.165 0.0];
X=[x flip(x)];
Y=[y -flip(y)];
for k=1:numel(X)
p(k) = 1-((X(k)./(2*a)).^2)-(Y(k)./(2*a)).^2;
sin2the(k) = (p(k)+sqrt(p(k).^2+(Y(k)./a)^2));
sinthe(k) = sqrt(sin2the(k)./2);
theta(k) = asin(sinthe(k));
psi(k) = asinh(Y(k)./(2.*a.*sin(theta(k))));
end
plot(theta,psi)
hold on
plot(X,Y)
hold off
.
ı am trying to solve equation with theta value. But theta value must b in interval of 0 - 2*pi, here answer of theta is in isinterval of 0 to pi/2. because of that plot of psi against theta is wrong , not like the picture above ı shared.
Maybe you could tell us the equation you are trying to solve for theta.
Is it true that "asinh" (inverse hyperbolic sine) is used in the calculation of psi ?
@Torsten Thank you!
I am now confused. I have no idea what the actual problem is.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!