Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-21 Thread Bernard Lebel
Okay thanks a lot everyone.

Bernard



On 9/20/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Bernard Lebel wrote:
> > Hello,
> >
> > I have this little math problem. I have this formula from wich I get a
> > dot product between two vectors.
> >
> > cos(ß) = A.B / |A|.|B| = -0.0634
> > So this would give me radians, right?
>
> No, it's the cosine of ß, which has no units (a cosine is a ratio of two 
> lengths)
>
> >
> > Then if I use
> >
> > math.degrees( -0.0634 )
> >
> > This gives me a value of -3.6325524211294193.
> >
> > However I have a book in front of me who says I should get a value of
> > 93.635 degrees. m
> >
> > Btw, in the book, the equation is written
> >
> > ß = cos-1(-0.0634) = 93.635, where -1 is actually an exponent. Maybe
> > I'm just interpreting this wrong?
>
> The -1 means inverse. You have cos(ß) = -0.0634 - you want to find the angle 
> whose cosine is -0.0634, i.e. (inverse cosine)(-0.0634). Another name for 
> cos-1 is arccosine. In Python it is math.acos():
>  >>> import math
>  >>> math.acos(-0.0634)
> 1.6342388771557625
>  >>> math.degrees(_)
> 93.634990377223801
>
> Kent
> >
> >
> >
> > Thanks
> > Bernard
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread Terry Carroll
On Tue, 20 Sep 2005, R. Alan Monroe wrote:

> >  >>> math.degrees(_)  <--- in all my time on tutor
>  I have never noticed
>  this underscore trick
>  before


That *is* cool.

I've usually done something like:

 >>> a+ 3*b +(5*ht/9) * 32
 9936254.2

Then use the up-arrow key to get

 >>> a+ 3*b +(5*ht/9) * 32

and edit it toL

 >>> x = a+ 3*b +(5*ht/9) * 32
 >>> foo(x)

The underscore's a nice stepsaver.  And limiting it to the interpreter 
avoids perlish abuse.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread Kent Johnson
John Fouhy wrote:
> On 21/09/05, R. Alan Monroe <[EMAIL PROTECTED]> wrote:
> 
>>> >>> math.degrees(_)  <--- in all my time on tutor
>>
>> I have never noticed
>> this underscore trick
>> before
> 
> 
> I'm not a big fan of it, actually.  It smells of Perl and those opaque
> one-liners that make use of implicit functions implicitely setting
> implicit variables...

I'm actually not much of a fan either - it's too easy to lose what I wanted by 
doing another step, then it's too late. And I usually don't use it on tutor 
because I think it is a bit obscure. This time I wondered if anyone would 
notice :-)

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread Nathan Coulter
John Fouhy wrote:
> On 21/09/05, R. Alan Monroe <[EMAIL PROTECTED]> wrote:
> 
>>> >>> math.degrees(_)  <--- in all my time on tutor
>>
>> I have never noticed
>> this underscore trick
>> before
> 
> 
> I'm not a big fan of it, actually.  It smells of Perl and those opaque
> one-liners that make use of implicit functions implicitely setting
> implicit variables...
> 

It also only works in *interactive* interpreters. -- Poor Yorick
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread John Fouhy
On 21/09/05, R. Alan Monroe <[EMAIL PROTECTED]> wrote:
> >  >>> math.degrees(_)  <--- in all my time on tutor
>  I have never noticed
>  this underscore trick
>  before

I'm not a big fan of it, actually.  It smells of Perl and those opaque
one-liners that make use of implicit functions implicitely setting
implicit variables...

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread R. Alan Monroe
> Bernard Lebel wrote:

>  >>> import math
>  >>> math.acos(-0.0634)
> 1.6342388771557625
>  >>> math.degrees(_)  <--- in all my time on tutor
 I have never noticed
 this underscore trick
 before
> 93.634990377223801

That's quite handy.

Alan

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread Kent Johnson
Bernard Lebel wrote:
> Hello,
> 
> I have this little math problem. I have this formula from wich I get a
> dot product between two vectors.
> 
> cos(ß) = A.B / |A|.|B| = -0.0634
> So this would give me radians, right?

No, it's the cosine of ß, which has no units (a cosine is a ratio of two 
lengths)

> 
> Then if I use
> 
> math.degrees( -0.0634 )
> 
> This gives me a value of -3.6325524211294193.
> 
> However I have a book in front of me who says I should get a value of
> 93.635 degrees. m
> 
> Btw, in the book, the equation is written
> 
> ß = cos-1(-0.0634) = 93.635, where -1 is actually an exponent. Maybe
> I'm just interpreting this wrong?

The -1 means inverse. You have cos(ß) = -0.0634 - you want to find the angle 
whose cosine is -0.0634, i.e. (inverse cosine)(-0.0634). Another name for cos-1 
is arccosine. In Python it is math.acos():
 >>> import math
 >>> math.acos(-0.0634)
1.6342388771557625
 >>> math.degrees(_)
93.634990377223801

Kent
> 
> 
> 
> Thanks
> Bernard
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Maths: getting degrees from radians (or am I wrong?)

2005-09-20 Thread Bernard Lebel
Hello,

I have this little math problem. I have this formula from wich I get a
dot product between two vectors.

cos(ß) = A.B / |A|.|B| = -0.0634
So this would give me radians, right?

Then if I use

math.degrees( -0.0634 )

This gives me a value of -3.6325524211294193.

However I have a book in front of me who says I should get a value of
93.635 degrees. m

Btw, in the book, the equation is written

ß = cos-1(-0.0634) = 93.635, where -1 is actually an exponent. Maybe
I'm just interpreting this wrong?



Thanks
Bernard
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor