http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746
MATLAB Central Newsreader  Combination of variables with a constraint
Feed for thread: Combination of variables with a constraint
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Wed, 04 Apr 2012 18:08:11 +0000
Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872330
Leyo Joseph
Hello,<br>
<br>
In the following equation, "a" and "alpha" are variables.<br>
sqrt((a*sin(aplha))^2+(1a*cos(alpha)^2)=0.25<br>
Many combinations of "a" and "aplha" are solutions to the above equations.<br>
For example a=0.9835 and aplha 0.2531 is a solution.<br>
How to find all of the combinations of "a" and "alpha" that are solution to the above equations.<br>
Thanks,

Wed, 04 Apr 2012 18:51:18 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872349
Sargondjani
I would not rely on numerical methods to get 'all' results. Using calculus is probably a better idea. <br>
<br>
However, making a 3D plot might help to give you some idea of the shape of the solution (within in a certain range of a and alpha).

Wed, 04 Apr 2012 19:27:12 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872367
Roger Stafford
"Leyo Joseph" wrote in message <jli2mb$5b6$1@newscl01ah.mathworks.com>...<br>
> Hello,<br>
> <br>
> In the following equation, "a" and "alpha" are variables.<br>
> sqrt((a*sin(aplha))^2+(1a*cos(alpha)^2)=0.25<br>
> Many combinations of "a" and "aplha" are solutions to the above equations.<br>
> For example a=0.9835 and aplha 0.2531 is a solution.<br>
> How to find all of the combinations of "a" and "alpha" that are solution to the above equations.<br>
> Thanks,<br>
       <br>
I think you mean<br>
<br>
sqrt((a*sin(alpha))^2+(1a*cos(alpha))^2)=0.25<br>
<br>
Your expression is missing one right parenthesis.<br>
<br>
As you surely are aware, there are infinitely many combinations of 'a' and 'alpha' that will satisfy that equation. However, it might help to give explicit solutions of each of these variables in terms of the other. That way you can see the necessary restrictions that are placed on each variable.<br>
<br>
cos(alpha) = a/2+(15/32)/a<br>
<br>
a = cos(alpha) +or sqrt(cos(alpha)^215/16)<br>
<br>
As you can see, alpha will necessarily be restricted by the requirement that cos(alpha)^2 >= 15/16 for real solutions. Also 'a' will have to lie between 3/4 and 5/4 or between 5/4 and 3/4.<br>
<br>
Nevertheless that leaves infinitely many solutions possible. Just do an ordinary plot of a/2+15/(32*a) against a to see where the curve falls between 1 and +1, remembering that infinitely many alpha's will give the same cosine value and you will get a feeling for the possible "combinations".<br>
<br>
Roger Stafford

Thu, 05 Apr 2012 00:22:37 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872391
Leyo Joseph
Thanks Roger. Your explanation is clear. But don't know how to convert this idea to a plot...<br>
Leyo Joseph<br>
<br>
<br>
<br>
<br>
<br>
<br>
"Roger Stafford" wrote in message <jli7ag$otd$1@newscl01ah.mathworks.com>...<br>
> "Leyo Joseph" wrote in message <jli2mb$5b6$1@newscl01ah.mathworks.com>...<br>
> > Hello,<br>
> > <br>
> > In the following equation, "a" and "alpha" are variables.<br>
> > sqrt((a*sin(aplha))^2+(1a*cos(alpha)^2)=0.25<br>
> > Many combinations of "a" and "aplha" are solutions to the above equations.<br>
> > For example a=0.9835 and aplha 0.2531 is a solution.<br>
> > How to find all of the combinations of "a" and "alpha" that are solution to the above equations.<br>
> > Thanks,<br>
>        <br>
> I think you mean<br>
> <br>
> sqrt((a*sin(alpha))^2+(1a*cos(alpha))^2)=0.25<br>
> <br>
> Your expression is missing one right parenthesis.<br>
> <br>
> As you surely are aware, there are infinitely many combinations of 'a' and 'alpha' that will satisfy that equation. However, it might help to give explicit solutions of each of these variables in terms of the other. That way you can see the necessary restrictions that are placed on each variable.<br>
> <br>
> cos(alpha) = a/2+(15/32)/a<br>
> <br>
> a = cos(alpha) +or sqrt(cos(alpha)^215/16)<br>
> <br>
> As you can see, alpha will necessarily be restricted by the requirement that cos(alpha)^2 >= 15/16 for real solutions. Also 'a' will have to lie between 3/4 and 5/4 or between 5/4 and 3/4.<br>
> <br>
> Nevertheless that leaves infinitely many solutions possible. Just do an ordinary plot of a/2+15/(32*a) against a to see where the curve falls between 1 and +1, remembering that infinitely many alpha's will give the same cosine value and you will get a feeling for the possible "combinations".<br>
> <br>
> Roger Stafford

Thu, 05 Apr 2012 05:18:19 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872407
Roger Stafford
"Leyo Joseph" wrote in message <jliokd$sg2$1@newscl01ah.mathworks.com>...<br>
> Thanks Roger. Your explanation is clear. But don't know how to convert this idea to a plot...<br>
> Leyo Joseph<br>
> <br>
> <br>
> <br>
> <br>
> <br>
> <br>
> "Roger Stafford" wrote in message <jli7ag$otd$1@newscl01ah.mathworks.com>...<br>
> > "Leyo Joseph" wrote in message <jli2mb$5b6$1@newscl01ah.mathworks.com>...<br>
> > > Hello,<br>
> > > <br>
> > > In the following equation, "a" and "alpha" are variables.<br>
> > > sqrt((a*sin(aplha))^2+(1a*cos(alpha)^2)=0.25<br>
> > > Many combinations of "a" and "aplha" are solutions to the above equations.<br>
> > > For example a=0.9835 and aplha 0.2531 is a solution.<br>
> > > How to find all of the combinations of "a" and "alpha" that are solution to the above equations.<br>
> > > Thanks,<br>
> >        <br>
> > I think you mean<br>
> > <br>
> > sqrt((a*sin(alpha))^2+(1a*cos(alpha))^2)=0.25<br>
> > <br>
> > Your expression is missing one right parenthesis.<br>
> > <br>
> > As you surely are aware, there are infinitely many combinations of 'a' and 'alpha' that will satisfy that equation. However, it might help to give explicit solutions of each of these variables in terms of the other. That way you can see the necessary restrictions that are placed on each variable.<br>
> > <br>
> > cos(alpha) = a/2+(15/32)/a<br>
> > <br>
> > a = cos(alpha) +or sqrt(cos(alpha)^215/16)<br>
> > <br>
> > As you can see, alpha will necessarily be restricted by the requirement that cos(alpha)^2 >= 15/16 for real solutions. Also 'a' will have to lie between 3/4 and 5/4 or between 5/4 and 3/4.<br>
> > <br>
> > Nevertheless that leaves infinitely many solutions possible. Just do an ordinary plot of a/2+15/(32*a) against a to see where the curve falls between 1 and +1, remembering that infinitely many alpha's will give the same cosine value and you will get a feeling for the possible "combinations".<br>
> > <br>
> > Roger Stafford<br>
         <br>
You could use the formula<br>
<br>
alpha = acos((a^2+15/16)/(2*a))<br>
<br>
as a varies from 3/4 to 5/4, but it gives only half of a certain eggshaped contour. Also the accuracy is poor near the values of a = 3/4 and a = 5/4. I much prefer a parametric approach.<br>
<br>
Suppose we let a = 1+1/4*cos(t) where t is a parameter which we invent. If t varies from 0 to 2*pi, then a will start at 5/4, decrease to 3/4, and then move back up to 5/4. If we handle things right with the parameter t we can cause alpha to follow one path as a decreases and another path as it increases back again, thereby producing an entire continuous contour.<br>
<br>
Substitute 1+1/4*cos(t) for a in cos(alpha) = (a^2+15/16)/(2*a) and we get<br>
<br>
cos(alpha) = 1sin(t)^2/(32*a)<br>
<br>
Then we can write<br>
<br>
sin(alpha)^2 = 1  cos(alpha)^2<br>
= (64*a*sin(t)^2sin(t)^4)/(32^2*a^2)<br>
<br>
We can write the square root of this as:<br>
<br>
sin(alpha) = sin(t)/(32*a)*sqrt(64*asin(t)^2)<br>
<br>
With the sin(t) factor removed from inside the square root in this manner this enables us to trace an entire eggshaped contour, since alpha will be negative when sin(t) is negative.<br>
<br>
The matlab code to give n points would be;<br>
<br>
t = linspace(0,2*pi,n);<br>
a = 1+1/4*cos(t);<br>
calpha = (a.^2+15/16)./(2*a); % This is cos(alpha)<br>
salpha = sin(t)./(32*a).*sqrt(64*asin(t).^2); % This is sin(alpha)<br>
alpha = atan2(salpha,calpha); % This gives alpha accurately<br>
plot(a,alpha)<br>
<br>
You can check directly that a and alpha will satisfy your original equation (to within roundoff errors.)<br>
<br>
You can get another separate eggshaped contour solution if you make the following changes in the above code:<br>
<br>
a = 1+1/4*cos(t)<br>
salpha = sin(t)/(32*a)*sqrt(64*asin(t)^2)<br>
alpha = mod(atan2(salpha,calpha),*2*pi)<br>
<br>
Furthermore if you add or subtract any multiple of 2*pi to the alpha of either of these contours, you will have another solution. Doing so would then characterize all possible solutions to your equation  two infinite stacks of alternating eggshaped contours.<br>
<br>
I'm afraid my explanations above have been rather brief. I hope it is understandable.<br>
<br>
Roger Stafford

Thu, 05 Apr 2012 05:23:18 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872409
Sargondjani
look up the help on 'plot'. the most simple way to plot is just: plot(x,y) (where the vectors x & y have to be of same length)<br>
<br>
he suggested a plot of "a/2+15/(32*a) against a". to get that plot, using 'a' between 3/4 and 5/4 (as he suggested):<br>
<br>
a=0.75:0.005:1.25; %creates a row vector of x values<br>
cos_alpha=a/2+15/(32*a); %gives you the values that cos(alpha) have to be<br>
plot(a,cos_alpha) %makes the plot<br>
<br>
i dont know the range of cos_alpha but you might want to fix the axis of the plot so it only plots values of cos_alpha between 1.25 and +1.25 (look this up in the help, im sure there is a good example on how to do this)

Thu, 05 Apr 2012 13:55:17 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872464
Leyo Joseph
"Roger Stafford" wrote in message <jlj9ur$q9m$1@newscl01ah.mathworks.com>...<br>
> "Leyo Joseph" wrote in message <jliokd$sg2$1@newscl01ah.mathworks.com>...<br>
> > Thanks Roger. Your explanation is clear. But don't know how to convert this idea to a plot...<br>
> > Leyo Joseph<br>
> > <br>
> > <br>
> > <br>
> > <br>
> > <br>
> > <br>
> > "Roger Stafford" wrote in message <jli7ag$otd$1@newscl01ah.mathworks.com>...<br>
> > > "Leyo Joseph" wrote in message <jli2mb$5b6$1@newscl01ah.mathworks.com>...<br>
> > > > Hello,<br>
> > > > <br>
> > > > In the following equation, "a" and "alpha" are variables.<br>
> > > > sqrt((a*sin(aplha))^2+(1a*cos(alpha)^2)=0.25<br>
> > > > Many combinations of "a" and "aplha" are solutions to the above equations.<br>
> > > > For example a=0.9835 and aplha 0.2531 is a solution.<br>
> > > > How to find all of the combinations of "a" and "alpha" that are solution to the above equations.<br>
> > > > Thanks,<br>
> > >        <br>
> > > I think you mean<br>
> > > <br>
> > > sqrt((a*sin(alpha))^2+(1a*cos(alpha))^2)=0.25<br>
> > > <br>
> > > Your expression is missing one right parenthesis.<br>
> > > <br>
> > > As you surely are aware, there are infinitely many combinations of 'a' and 'alpha' that will satisfy that equation. However, it might help to give explicit solutions of each of these variables in terms of the other. That way you can see the necessary restrictions that are placed on each variable.<br>
> > > <br>
> > > cos(alpha) = a/2+(15/32)/a<br>
> > > <br>
> > > a = cos(alpha) +or sqrt(cos(alpha)^215/16)<br>
> > > <br>
> > > As you can see, alpha will necessarily be restricted by the requirement that cos(alpha)^2 >= 15/16 for real solutions. Also 'a' will have to lie between 3/4 and 5/4 or between 5/4 and 3/4.<br>
> > > <br>
> > > Nevertheless that leaves infinitely many solutions possible. Just do an ordinary plot of a/2+15/(32*a) against a to see where the curve falls between 1 and +1, remembering that infinitely many alpha's will give the same cosine value and you will get a feeling for the possible "combinations".<br>
> > > <br>
> > > Roger Stafford<br>
>          <br>
> You could use the formula<br>
> <br>
> alpha = acos((a^2+15/16)/(2*a))<br>
> <br>
> as a varies from 3/4 to 5/4, but it gives only half of a certain eggshaped contour. Also the accuracy is poor near the values of a = 3/4 and a = 5/4. I much prefer a parametric approach.<br>
> <br>
> Suppose we let a = 1+1/4*cos(t) where t is a parameter which we invent. If t varies from 0 to 2*pi, then a will start at 5/4, decrease to 3/4, and then move back up to 5/4. If we handle things right with the parameter t we can cause alpha to follow one path as a decreases and another path as it increases back again, thereby producing an entire continuous contour.<br>
> <br>
> Substitute 1+1/4*cos(t) for a in cos(alpha) = (a^2+15/16)/(2*a) and we get<br>
> <br>
> cos(alpha) = 1sin(t)^2/(32*a)<br>
> <br>
> Then we can write<br>
> <br>
> sin(alpha)^2 = 1  cos(alpha)^2<br>
> = (64*a*sin(t)^2sin(t)^4)/(32^2*a^2)<br>
> <br>
> We can write the square root of this as:<br>
> <br>
> sin(alpha) = sin(t)/(32*a)*sqrt(64*asin(t)^2)<br>
> <br>
> With the sin(t) factor removed from inside the square root in this manner this enables us to trace an entire eggshaped contour, since alpha will be negative when sin(t) is negative.<br>
> <br>
> The matlab code to give n points would be;<br>
> <br>
> t = linspace(0,2*pi,n);<br>
> a = 1+1/4*cos(t);<br>
> calpha = (a.^2+15/16)./(2*a); % This is cos(alpha)<br>
> salpha = sin(t)./(32*a).*sqrt(64*asin(t).^2); % This is sin(alpha)<br>
> alpha = atan2(salpha,calpha); % This gives alpha accurately<br>
> plot(a,alpha)<br>
> <br>
> You can check directly that a and alpha will satisfy your original equation (to within roundoff errors.)<br>
> <br>
> You can get another separate eggshaped contour solution if you make the following changes in the above code:<br>
> <br>
> a = 1+1/4*cos(t)<br>
> salpha = sin(t)/(32*a)*sqrt(64*asin(t)^2)<br>
> alpha = mod(atan2(salpha,calpha),*2*pi)<br>
> <br>
> Furthermore if you add or subtract any multiple of 2*pi to the alpha of either of these contours, you will have another solution. Doing so would then characterize all possible solutions to your equation  two infinite stacks of alternating eggshaped contours.<br>
> <br>
> I'm afraid my explanations above have been rather brief. I hope it is understandable.<br>
> <br>
> Roger Stafford<br>
<br>
Hello,<br>
<br>
Thanks a lot...this is amazing. I copied the code and it working fine. One more question on this. The original definition of the equation is sqrt((a*sin(alpha))^2+(1a*cos(alpha))^2)=0.25<br>
Instaed of 0.25 on the right side, is it possible to make it a variable and plot it . Like for 0.2, 0.25, 0.3 and 0.35?<br>
Thanks,

Thu, 05 Apr 2012 14:47:12 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872475
Sargondjani
yes you can. you would have to redo all the alggebra substituting C instead of 0.25.<br>
Then you can make a vector for all values of C, say:<br>
<br>
C=[0.1:0.05:0.25];<br>
<br>
You should store a and alpha in matrices. I am assuming a and alpha are column vectors now (so you need to change some things if they are row vectors).<br>
<br>
then you can loop over the values of C:<br>
<br>
for iC=1:length(C);<br>
%put the program that you had before here, but substitute 'a' with 'a(:,iC)' <br>
%everywhere, and the same for 'alpha', this should become 'alpha(:,iC)'<br>
%and replace C with C(ic)<br>
plot(a(:,iC),alpha(:,iC));<br>
hold all;<br>
end;<br>
legend('0.01', '0.15','0.2',0.25); % there's certainly a nicer way to do this with num2str<br>
hold off;<br>
<br>
this should work, but note that it will overwrite the calpha and salpha values in every iteration

Thu, 05 Apr 2012 16:09:17 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872488
Leyo Joseph
"Sargondjani" wrote in message <jlkb9g$q66$1@newscl01ah.mathworks.com>...<br>
> yes you can. you would have to redo all the alggebra substituting C instead of 0.25.<br>
> Then you can make a vector for all values of C, say:<br>
> <br>
> C=[0.1:0.05:0.25];<br>
> <br>
> You should store a and alpha in matrices. I am assuming a and alpha are column vectors now (so you need to change some things if they are row vectors).<br>
> <br>
> then you can loop over the values of C:<br>
> <br>
> for iC=1:length(C);<br>
> %put the program that you had before here, but substitute 'a' with 'a(:,iC)' <br>
> %everywhere, and the same for 'alpha', this should become 'alpha(:,iC)'<br>
> %and replace C with C(ic)<br>
> plot(a(:,iC),alpha(:,iC));<br>
> hold all;<br>
> end;<br>
> legend('0.01', '0.15','0.2',0.25); % there's certainly a nicer way to do this with num2str<br>
> hold off;<br>
> <br>
> this should work, but note that it will overwrite the calpha and salpha values in every iteration<br>
<br>
Hello,<br>
Is this correct ==><br>
C=[0.1:0.05:0.25];<br>
<br>
<br>
n=1000;<br>
t = linspace(0,2*pi,n);<br>
for iC=1:length(C);<br>
<br>
a(:,iC) = 1+1/4*cos(t);<br>
calpha = (a(:,iC).^2+15/16)./(2*a(:,iC)); % This is cos(alpha)<br>
salpha = sin(t)./(32*a(:,iC)).*sqrt(64*a(:,iC)sin(t).^2); % This is sin(alpha)<br>
alpha = atan2(salpha,calpha); % This gives alpha accurately<br>
<br>
<br>
plot(a(:,iC),alpha(:,iC));<br>
hold all;<br>
end;<br>
grid<br>
This is giving me dimension mismatch error. Also, I am not very clear how this is going to work. For example, a=1+cos(t)/4 is drvied under the assumption of 0.25. So this should be different for 0.2?. Similar is the case with calpha and salpha. Please let me know.

Thu, 05 Apr 2012 16:44:12 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872494
Sargondjani
first about the error: if you have a dimension mismatch you should give the commands:<br>
size(var_name) for all the variables in the line where you get the error, then you will see which variables dont have the correct dimension...<br>
<br>
but that is not your first concern now. That is the thing about the C vs. 0.25. As I wrote, you have to redo all the algebra substituting 0.25 with C. So instead of these formulas:<br>
<br>
cos(alpha) = a/2+(15/32)/a<br>
<br>
a = cos(alpha) +or sqrt(cos(alpha)^215/16)<br>
<br>
you should get expressions with C in it. Maybe the other poster is willing to do this for you, but i recommend you do the derivations of the formulas yourself so you actually learn something... <br>
<br>
...then you have to rewrite you programming with the C's in it and then it should work. try first without the forloop, then with the forloop. you might still get the dimension mismatch but let's see by that time. i mean, you will better understand what you are doing by that time as well...

Thu, 05 Apr 2012 17:07:17 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872496
Roger Stafford
"Leyo Joseph" wrote in message <jlk885$dmv$1@newscl01ah.mathworks.com>...<br>
> Instaed of 0.25 on the right side, is it possible to make it a variable and plot it . Like for 0.2, 0.25, 0.3 and 0.35?<br>
            <br>
For general k in the equation <br>
<br>
sqrt((a.*sin(alpha)).^2+(1a.*cos(alpha)).^2) = k<br>
<br>
you can do this:<br>
<br>
n = 1000;<br>
k = rand;<br>
t = linspace(0,2*pi,n);<br>
a = 1+k*cos(t);<br>
calpha = (a.^2+1k^2)./(2*a); % This is cos(alpha)<br>
salpha = k^2.*sin(t)./(2*a).*sqrt(4*a/k^2sin(t).^2); % This is sin(alpha)<br>
alpha = atan2(salpha,calpha); % This gives alpha accurately<br>
plot(a,alpha)<br>
<br>
or for negative a's this:<br>
<br>
n = 1000;<br>
k = rand;<br>
t = linspace(0,2*pi,n);<br>
a = 1+k*cos(t);<br>
calpha = (a.^2+1k^2)./(2*a); % This is cos(alpha)<br>
salpha = k^2.*sin(t)./(2*a).*sqrt(4*a/k^2sin(t).^2); % This is sin(alpha)<br>
alpha = mod(atan2(salpha,calpha),2*pi); % This gives alpha accurately<br>
plot(a,alpha)<br>
<br>
Remember, there infinitely many versions of each of these contours that can be obtained by adding or subtracting multiples of 2*pi to alpha.<br>
<br>
Note: I have assumed here that k < 1. This code has troubles with k > 1 but I haven't had time to see how it could be fixed in such cases. Maybe you can work that out, Leyo.<br>
<br>
Roger Stafford

Thu, 05 Apr 2012 17:43:26 +0000
Re: Combination of variables with a constraint
http://www.mathworks.com/matlabcentral/newsreader/view_thread/318746#872500
Leyo Joseph
"Roger Stafford" wrote in message <jlkjg5$oc$1@newscl01ah.mathworks.com>...<br>
> "Leyo Joseph" wrote in message <jlk885$dmv$1@newscl01ah.mathworks.com>...<br>
> > Instaed of 0.25 on the right side, is it possible to make it a variable and plot it . Like for 0.2, 0.25, 0.3 and 0.35?<br>
>             <br>
> For general k in the equation <br>
> <br>
> sqrt((a.*sin(alpha)).^2+(1a.*cos(alpha)).^2) = k<br>
> <br>
> you can do this:<br>
> <br>
> n = 1000;<br>
> k = rand;<br>
> t = linspace(0,2*pi,n);<br>
> a = 1+k*cos(t);<br>
> calpha = (a.^2+1k^2)./(2*a); % This is cos(alpha)<br>
> salpha = k^2.*sin(t)./(2*a).*sqrt(4*a/k^2sin(t).^2); % This is sin(alpha)<br>
> alpha = atan2(salpha,calpha); % This gives alpha accurately<br>
> plot(a,alpha)<br>
> <br>
> or for negative a's this:<br>
> <br>
> n = 1000;<br>
> k = rand;<br>
> t = linspace(0,2*pi,n);<br>
> a = 1+k*cos(t);<br>
> calpha = (a.^2+1k^2)./(2*a); % This is cos(alpha)<br>
> salpha = k^2.*sin(t)./(2*a).*sqrt(4*a/k^2sin(t).^2); % This is sin(alpha)<br>
> alpha = mod(atan2(salpha,calpha),2*pi); % This gives alpha accurately<br>
> plot(a,alpha)<br>
> <br>
> Remember, there infinitely many versions of each of these contours that can be obtained by adding or subtracting multiples of 2*pi to alpha.<br>
> <br>
> Note: I have assumed here that k < 1. This code has troubles with k > 1 but I haven't had time to see how it could be fixed in such cases. Maybe you can work that out, Leyo.<br>
> <br>
> Roger Stafford<br>
<br>
Thanks ...<br>
Yes my values are for k<1. <br>
I could figure out the derivation of " a " and "calpha". Still trying to figure out the drivation of "salpha" . I think I should be able to do if spend some more time. Thanks a lot for your help. I learned a lot from this exercise.