[Tutor] question about expressing mathematical equations
dyoo at hkn.eecs.berkeley.edu
Sat Feb 5 07:52:33 CET 2005
On Fri, 4 Feb 2005, alieks lao wrote:
> Once again i have a question concerning something from the tutorial im
> being tortured by.
> x.y= \ x (dot)y(dot)
> /__ i
> How would i express this in python.
> If the above doesn't make any sense to ya'll.
> It's at the bottom of this page>>>
[Note to author Michael Williams: we found a wacky typography bug on the
HTML rendering of the link above. I'm CCing you to make sure you know
Ah, ok, I see it: you're talking about exercise 3.10?
The guide there is using linear algebra notation: it is defining the dot
product between two vectors 'x' and 'y'. I think you're misreading the
diagram: it's more like this:
x dot y= \ x * y
/__ i i
(The period at the end of the equation is really meant to be just a
typographic period. *grin*)
As a concrete example, if we were taking the dot product between two
sequences 'x' and 'y':
x = (3, 1, 4, 1, 5)
y = (2, 7, 1, 8, 2)
then we'd be calculating, in effect:
(x * y +
x * y +
x * y +
x * y +
x * y)
--> ( 3 * 2 +
1 * 7 +
4 * 1 +
1 * 8 +
5 * 2 )
--> ( 6 + 7 + 4 + 8 + 10 )
Numeric Python comes with an dot() function built in:
so if you're dealing strictly with Numeric arrays, you don't need to do
any work to 'dot' two arrays together. *grin*
... Oh, that's not good! Warning: It looks like the typography of
Exercise 3.10 in the HTML is screwed up. The problem as written in the
HTML is nonsensical. Look at the PDF instead. You'll see that the
question will make more sense in the PDF here:
The GIF images in the HTML has some strange offset error that I don't
understand, but img22.gif and img23.gif are in the wrong places on the
HTML page. I'll CC the author to see if that can get fixed.
I notice that you're learning from the "Handbook of the Physics Computing
Course". There are other tutorials in:
that you may find more approachable if you want less math.
Good luck to you!
More information about the Tutor