The Grey Labyrinth is a collection of puzzles, riddles, mind games, paradoxes and other intellectually challenging diversions. Related topics: puzzle games, logic puzzles, lateral thinking puzzles, philosophy, mind benders, brain teasers, word problems, conundrums, 3d puzzles, spatial reasoning, intelligence tests, mathematical diversions, paradoxes, physics problems, reasoning, math, science.

   
The Grey Labyrinth Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    RegisterRegister  
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Samadhi's school help thread
Goto page 1, 2, 3 ... 11, 12, 13  Next
 
Reply to topic    The Grey Labyrinth Forum Index -> Science, Art, and Culture
View previous topic :: View next topic  
Author Message
Samadhi
+1



PostPosted: Sat Feb 18, 2006 7:30 am    Post subject: 1 Reply with quote

I'll ask questions about math every now and then, and I'll post my java assignments for review.

No math questions yet, but I do have a java assignment. I'd just like someone who is familiar with how anal professors can be to critique it given the posted requirements. To wit:
[instructions]
Write your 2nd Java program that reads in three whole numbers and outputs the average of the three numbers.
  • You will use comments on top of your program. The comments will cover the following information:
  1. Programmer’s name (your name in this case)
  2. Program name.
  3. Programming date.
  4. Modification date if any.
  5. Programming language used (Java).
  6. Computer used to compile the program (PC? Mac? Or?)
  7. The purpose of this program.
  8. Any special requirements for the input?
  9. What will be the output?
  10. Variable names and their usages
[/instructions]
I think it's a little silly to put the comments for the variables at the top of the program but ~shrug~
Code:

/**
 Program to give the average of three numbers
 Author: J Kevin Kirby
 Program name: ThreeNumberAverage.java
 Programming date: 2/17/2006
 Programming language: Java
 Compiled on: PC
 User should only enter whole numbers (int) and the output will be a decimal (double)
 Variables are firstNumber, secondNumber, and thirdNumber for the three user inputs and
   averageNumber for the output of the average of the three numbers
*/
import java.util.*;

public class ThreeNumberAverage
{
   public static void main(String[] args)
   {
      int firstNumber;
      int secondNumber;
      int thirdNumber;
      double averageNumber;
      Scanner keyboard = new Scanner(System.in);

      System.out.println(
         "Enter three whole numbers separated by a space:");
      firstNumber = keyboard.nextInt();
      secondNumber = keyboard.nextInt();
      thirdNumber = keyboard.nextInt();
      averageNumber = (firstNumber + secondNumber + thirdNumber);
      averageNumber = averageNumber/3;
      System.out.println("The average of the three numbers is " + averageNumber);

   }
}
Did I miss anything?
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Talzor
Daedalian Member



PostPosted: Sat Feb 18, 2006 10:19 am    Post subject: 2 Reply with quote

For all normal purposes your program looks fine, but heres a few suggestion for those really anal professors:

You could specify the range of the input (-2,147,483,648 to 2,147,483,647). In comparison the range of a long is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

nextInt() throws 3 exceptions:
InputMismatchException - if the next token does not match the Integer regular expression, or is out of range.
NoSuchElementException - if input is exhausted
IllegalStateException - if this scanner is closed.
You can setup a try - catch statement to handle these (read: printout a telling error message).
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
Samadhi
+1



PostPosted: Sat Feb 18, 2006 1:52 pm    Post subject: 3 Reply with quote

Error catching has been specifically avoided as of yet. I'd love to throw it in, but I'd probably get marked off for it.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Samadhi
+1



PostPosted: Sat Feb 18, 2006 1:54 pm    Post subject: 4 Reply with quote

This is a beginner class BTW. I've never messed with java, but I know programming and this should be easy. But I've never messed with a programming professor.....
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Chuck
Daedalian Member



PostPosted: Sat Feb 18, 2006 2:25 pm    Post subject: 5 Reply with quote

Java is supposed to be used to program video games. The program is incorrect unless you have to kill something to see the answer.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Samadhi
+1



PostPosted: Sat Feb 18, 2006 2:33 pm    Post subject: 6 Reply with quote

Give me your address there
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Samadhi
+1



PostPosted: Mon Feb 20, 2006 12:34 pm    Post subject: 7 Reply with quote

Math question 1:
This is from the chapter titled Matrices, Determinants and the Cross Product.

Find the intersection of the planes x + (y - 1) + z = 0 and -x + (y + 1) - z = 0.

Since this is in the above titled chapter I figured it should have something to do with that. Since the line needs to be perpindicular to the normals for both planes, I figured I'd take the cross product of the normals and use that to get the line, but it doesn't work.

Anyone know this one? (it should be in the form of x = at, y = bt, z = ct)
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
mith
Pitbull of Truth



PostPosted: Mon Feb 20, 2006 1:55 pm    Post subject: 8 Reply with quote

That should work (the cross product of the normals is parallel to the line, then find a point on the line). If you want to post your work here, I can look through it.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Samadhi
+1



PostPosted: Mon Feb 20, 2006 2:27 pm    Post subject: 9 Reply with quote

Ok, here's what I had...
Code:

| i  j   k|
| 1  1   1|
|-1  1  -1|


So the cross is (-1-1)i - (-1+1)j + (1+1)k -> -2i + 2k so (x = -2t, y = 0t, z = 2t). And that seems to work....
And looking at the planes graphically they clearly intersect on the zx plane, so I'd reduce it to (x = t, y = 0, z = -t) but that's not the answer in the book. The answer they have is (x= t, y =2t, z = -5t)

Bah!!! stupid book. The even problem before that has (x +2y +z = 0, x -3y -z = 0) which using cross product equals that answer. Consider me annoyed.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Samadhi
+1



PostPosted: Mon Feb 20, 2006 2:33 pm    Post subject: 10 Reply with quote

I guess I should trust my instincts more.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
The Ragin' South Asian
Head Poncho



PostPosted: Mon Feb 20, 2006 2:36 pm    Post subject: 11 Reply with quote

unless your instinct is to not trust your instincts
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
Samadhi
+1



PostPosted: Mon Feb 20, 2006 2:50 pm    Post subject: 12 Reply with quote

Ecstatic Happiness
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
mith
Pitbull of Truth



PostPosted: Mon Feb 20, 2006 3:05 pm    Post subject: 13 Reply with quote

That's not quite correct; t=0 would give (0, 0, 0), which is clearly not on either plane, for example.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ogm*
Guest



PostPosted: Mon Feb 20, 2006 4:19 pm    Post subject: 14 Reply with quote

Just by inspection you can add the equations and get y=0. Subsitute that back in and you get x+z=1. So the answer would be x=t, y=0, z=1-t, I think.
Back to top
Samadhi
+1



PostPosted: Mon Feb 20, 2006 10:40 pm    Post subject: 15 Reply with quote

mith wrote:
That's not quite correct; t=0 would give (0, 0, 0), which is clearly not on either plane, for example.
I'm a little fuzzy on describing lines in R3.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
CzarJ
Hot babe



PostPosted: Tue Feb 21, 2006 5:08 am    Post subject: 16 Reply with quote

You need two things to describe a line in Ranything: a position vector and a direction vector. Call the position vector r0, the direction vector a, and the line r(t), and you have r(t) = r0 + ta. This begs the question: What does that mean? Well, a direction vector is any vector parallel to the line. A position vector is any point on the line (technically any vector with its initial point at the origin and its terminal point on the line, of course, but why bother saying all that?). The former you have; the latter you're missing.
Back to top
View user's profile Send private message Send e-mail AIM Address
Samadhi
+1



PostPosted: Tue Feb 21, 2006 3:38 pm    Post subject: 17 Reply with quote

I see it now. And since a point on that line is (0, 0, 1) I would add the zero and the one to the tx and tz in the formula, but since it's a negative slope, then ogm is exactly correct.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
CzarJ
Hot babe



PostPosted: Tue Feb 21, 2006 3:49 pm    Post subject: 18 Reply with quote

Yessir. I'm glad there's this way, though; I wouldn't want to ogm's way every time =P.
Back to top
View user's profile Send private message Send e-mail AIM Address
Samadhi
+1



PostPosted: Tue Feb 21, 2006 6:05 pm    Post subject: 19 Reply with quote

Here's one that's a symptom of rustiness

If x 1 + kx 2 = c and x 1 + lx 2 = d have the same solution set, show that the equations are identical.

It's rather obvious, but it doesn't discuss it in the book and I'm don't remember the methodology for this kind of thing at all.

I mean I can subtract the second from the first and get kx 2 - lx 2 = c - d......but I don't know what to do with it after that.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
mith
Pitbull of Truth



PostPosted: Tue Feb 21, 2006 6:19 pm    Post subject: 20 Reply with quote

What happens when x 2 is 0?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Samadhi
+1



PostPosted: Tue Feb 21, 2006 6:34 pm    Post subject: 21 Reply with quote

Ah c = d. thanks
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Samadhi
+1



PostPosted: Sun Feb 26, 2006 10:38 pm    Post subject: 22 Reply with quote

I'm missing it on this one. "Prove the identity without evaluating the determinants"

With this text, the vertical lines on the outside mean determinant of the system.

I'm guessing (1 + t) ( 1 - t) has something to do with it but I'm drawing a blank.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Antrax
ESL Student



PostPosted: Mon Feb 27, 2006 8:24 am    Post subject: 23 Reply with quote

To get from left to right, you do three things:
R1 <- R1 - t*R2 (doesn't change determinant)
R1 <- R1 / (1-t^2) (multiplies determinant by 1-t^2
R2 <- R2 - t*R1 (doesn't change determinant)
_________________
After years of disappointment with get rich quick schemes, I know I'm gonna get rich with this scheme. And quick!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Samadhi
+1



PostPosted: Mon Feb 27, 2006 8:06 pm    Post subject: 24 Reply with quote

Cool, thanks. I figured there had to be row adds but just couldn't see it for whatever reason.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Samadhi
+1



PostPosted: Sat Mar 04, 2006 6:37 am    Post subject: 25 Reply with quote

So here's what I thought of mentioned in this thread.

When my teacher mentioned the cross product of vectors he said that it can only be used in R3. Well, that bugged me. I know that the cross happens to be the area of the parallelagram, but the way I really thought of it was a vector that is orthogonal to both inputs. And since in R3 any plane needs two vectors that are non scalar to describe it, the cross product is therefore the normal for the plane. In the books (so far) and by my teacher, using a matrix to calculate the cross has been described only as a pneumonic.

Anyway, I thought, "Ok, getting the normal in R3 uses a 3x3 matrix, would a 4x4 work for R4?" So, I spent a couple of minutes plugging in non parallel vectors and seeing that it worked and then, *ding*. Duh. Of course it works!

What's being done on the typical cross product (R3) is setting up a 3x3 matrix with ones for the top row, the scalar factors for the other two vectors in the rows below that, and then finding the dets for the top row. In any square matrix multiplying the determinants of one row by any other row of the matrix will always equal zero. And that's the definition of a dot product (vector multiply) and when the dot equals zero, the vectors are orthogonal. So, the cross is obviously the normal to the plane because it's vector multiple of any other row equals zero. Which means the dot product is zero and therefore the vectors are orthogonal. This translates to hyperplanes as well.

It wasn't easy explaining it to my prof. I started with the premise that n points with no 3 points colinear are necessary to describe a plane/hyperplane in Rn (n>1 obviously). This equates to n-1 vectors that can not be found by addition/subtraction of any of the other vectors in the set (my description of this is a bit weak). But you have to have the normal to describe any plane and this method desribes it. I'm thinking this has to be important since the differential in Rn where n >2 is a plane tangent to the point.

Anyway, it was fun getting that.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Samadhi
+1



PostPosted: Sat Mar 04, 2006 6:48 am    Post subject: 26 Reply with quote

Holy crap. By the same formulas that make U*(VxW) work for the volume of the parallelpiped, I think that works for the "volume" of a n-parrallelpiped too (using v1Xv2X....vn as the row matrix I said in the last post). I'll have to think about it in the morning (when sober).
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
MatthewV
Daedalian Member :_



PostPosted: Sun Mar 05, 2006 7:03 pm    Post subject: 27 Reply with quote

My calc 3 teacher briefly mentioned something of this sort in class...
Back to top
View user's profile Send private message Send e-mail AIM Address
Bicho the Inhaler
Daedalian Member



PostPosted: Tue Mar 07, 2006 8:43 am    Post subject: 28 Reply with quote

You may know this already (maybe that's what you meant in your post), but:
Code:
| x_1  y_1  z_1 |
| x_2  y_2  z_2 |
| x_3  y_3  z_3 |
is nothing but the volume of the parallelopiped defined by the points (x_k, y_k, z_k) (for k = 1, 2, 3) and the origin. (Actually, it is the "signed" volume in the sense that reflecting the shape through a plane should negate its area. The unsigned area is simply the absolute value.) This generalizes perfectly to higher dimensions. In fact, you can take this as the definition of the determinant, if you want :-)
Back to top
View user's profile Send private message
Samadhi
+1



PostPosted: Tue Mar 07, 2006 9:36 am    Post subject: 29 Reply with quote

Well, yeah I did know that about parrallelpipeds, in fact when shown I thought it was the most beautiful thing I've seen in years. But I didn't know that that works for R4+. That's what I was wondering.

I hadn't taken the time to check the outcome of the formulas, but it holds. I love it.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Samadhi
+1



PostPosted: Thu Mar 09, 2006 8:45 am    Post subject: 30 Reply with quote

Given that you're in n space, and you have n vectors (non scalar multiples), I know how to calculate the angle between any two, but what about the angle between those two and another vector?
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
CzarJ
Hot babe



PostPosted: Thu Mar 09, 2006 8:53 am    Post subject: 31 Reply with quote

I'm not sure I understand the question. To be fair, I spent about 45 minutes today proving the most mundane facts about vectors using the definition (for example, a*0=0 for any scalar a, and -u=(-1)*u), so I'm in the mode where I need everything painstakingly spelled out for me.

edit: my parentheses were in goofy places.


Last edited by CzarJ on Thu Mar 09, 2006 3:36 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail AIM Address
Samadhi
+1



PostPosted: Thu Mar 09, 2006 10:46 am    Post subject: 32 Reply with quote

Seems like we're about the same level actually. I learned that about 2 weeks ago.

I'm having difficulty describing this because there really isn't any well defined terminology for anything above R3. People throw on "hyper" and think they're cool, but that doesn't do it justice.

Basically, I'm trying to say that just like in R3, if you have 3 non-planar vectors, (u, v, & w) if you take u & v or u & w or v & w you can find the area defined by that pair of vectors by multiplying one vector times the other vector times the sine of the angle between them. And you can find the angle by the inverse cosine of (the inner product of the vectors divided by the product of their lengths).

Moving onto the third vector, you can't use the angle between it and either vector, you need to use the angle between it and both to find the appropriate height of the described volume/hyperarea/whatever.

In R3, by a very sweet proof, you can use cross product to find that height, and by further observance the determinant of the 3x3 matrix to find the volume.

That doesn't translate well to R4 or higher.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Samadhi
+1



PostPosted: Thu Mar 09, 2006 10:49 am    Post subject: 33 Reply with quote

Well...it appears to work and all. I just can't prove it.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
CzarJ
Hot babe



PostPosted: Thu Mar 09, 2006 3:39 pm    Post subject: 34 Reply with quote

Are you looking for the angle between the third vector and the plane defined by the first two?
Back to top
View user's profile Send private message Send e-mail AIM Address
Samadhi
+1



PostPosted: Fri Mar 10, 2006 6:51 am    Post subject: 35 Reply with quote

Call it a surface since I'm going for R4+. But yes.
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
CzarJ
Hot babe



PostPosted: Fri Mar 10, 2006 8:04 am    Post subject: 36 Reply with quote

You lost me. =P

In R3, two non-colinear vectors define a plane. To find the angle between the plane and that vector, take the cross product of the two vectors (or any two vectors) in the plane to get the normal, find that angle, and subract from pi/2.

To find the angle between a vector and the subspace defined by three other non-coplanar vectors in R4, there is an analogue of the cross-product which maps uses three vectors instead of two and produces a vector perpendicular to all three. As you might expect, it's:
Code:
| i  j  k  l|
|a1 a2 a3 a4|
|b1 b2 b3 b4|
|c1 c2 c3 c4|


The proof is simple but a pain in the butt, so you'll have to trust that I've done it both on paper and with Mathematica. Anyway, using this, you can use the same tactic.

If you think about it, the two dimensional determinant det(i j/x y) takes the vector (x,y), to (y, -x), which is perpendicular. This led me to conjecture that there is an analog of the cross product in n dimensions which takes n-1 vectors and gives a vector perpendicular to each of them. I've spent the last couple of days pondering this, and trying to come up with the start of a proof, and I've had a couple of neat ideas, but nothing that's really panned out so far.

I have no idea if this is what you were talking about or not, but I think it's cool, so there. =P
Back to top
View user's profile Send private message Send e-mail AIM Address
Samadhi
+1



PostPosted: Fri Mar 10, 2006 8:58 am    Post subject: 37 Reply with quote

See....I'm trying to prove exactly that. So, thanks for nothing. Razz
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Samadhi
+1



PostPosted: Fri Mar 10, 2006 8:59 am    Post subject: 38 Reply with quote

(seriously, read 25 and 26)
_________________
And he lived happily ever after. Except for the dieing at the end and the heartbreak in between.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
kevinatilusa
Daedalian Member



PostPosted: Fri Mar 10, 2006 3:12 pm    Post subject: 39 Reply with quote

As a random side note, there's a slick way of showing that "4 dimensional cross product" really is perpendicular to the vector in question:

If you think about expansion by minors along the first row you can get that
Code:
The dot product of <a1, a2, a3, a4> and | i  j  k  l|
                                        |a1 a2 a3 a4|
                                        |b1 b2 b3 b4|
                                        |c1 c2 c3 c4|       
means exactly the same thing as

Code:
|a1 a2 a3 a4|
|a1 a2 a3 a4|
|b1 b2 b3 b4|   which has 2 equal rows
|c1 c2 c3 c4|
Back to top
View user's profile Send private message
CzarJ
Hot babe



PostPosted: Fri Mar 10, 2006 8:35 pm    Post subject: 40 Reply with quote

Ooh, that is slick. Does that transfer to other dimensions? I'd figure it myself, but I know next to nothing about determinants.
Back to top
View user's profile Send private message Send e-mail AIM Address
Display posts from previous: by   
Reply to topic    The Grey Labyrinth Forum Index -> Science, Art, and Culture All times are GMT
Goto page 1, 2, 3 ... 11, 12, 13  Next
Page 1 of 13

 
Jump to:  
You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Site Design by Wx3