Wikipedia:Reference desk/Archives/Mathematics/2008 January 22

From Wikipedia, the free encyclopedia
Mathematics desk
< January 21 << Dec | January | Feb >> Current desk >
Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


January 22[edit]

Bra-ket notation in LaTeX[edit]

\left and \right are great, and work just as I expect for and . But when I put them together in a bracket, I'm at a loss what to do. Using an unadorned | gives me . Logically there should be something like \middle or \center, but the first doesn't exist and the second does something totally different. How do I tell LaTeX to automatically adjust the middle line to the correct size? —Keenan Pepper 04:17, 22 January 2008 (UTC)[reply]

Do it manually with \bigm|, \Bigm|, \biggm|, or \Biggm| (whichever gives you the correct size). —Bkell (talk) 04:30, 22 January 2008 (UTC)[reply]
Note that that's \bigm followed by a vertical line, not \bigml. Same for the others. —Bkell (talk) 04:31, 22 January 2008 (UTC)[reply]
Unfortunately, it looks like Wikipedia's LaTeX renderer doesn't know \bigm and friends, so you have to leave off the m and just use \big or \Bigg or whatever: . —Bkell (talk) 04:34, 22 January 2008 (UTC)[reply]
For non-wikipedia use, \vphantom is useful for making sure heights are done correctly.
\newcommand{\braket}[2]{\left\langle{#1}\vphantom{#2}\right|\left.\vphantom{#1}{#2}\right\rangle}
Used like \braket{\frac{tall}{side}}{wide~side}
The short style file braket.sty can also be used, then the syntax is \Braket{\frac{tall}{side}|wide~side} JackSchmidt (talk) 06:08, 22 January 2008 (UTC)[reply]
This \vphantom trick has a couple of shortcomings: It renders both halves twice (this can be solved with some clever box manipulation), and it doesn't get the spacing quite right around the middle bar. —Bkell (talk) 08:50, 22 January 2008 (UTC)[reply]

I just found out that my LaTeX distribution (TeX Live for Ubuntu) does have \middle and it works exactly as I expect! So, since these other solutions are unacceptable (the first doesn't actually do anything automatically, and the second sounds like a horrible kludge), my new question is: Why doesn't Wikipedia's TeX engine have this irreplaceable command \middle, and when is it going to get it? —Keenan Pepper 13:37, 22 January 2008 (UTC)[reply]

The \middle that you have probably works in a similar but more complicated way as the "kludge" above, just behind the scenes. ;-) As for why Wikipedia's TeX engine doesn't have it, I don't know; there are other useful things that it doesn't do (like \textstyle). You can file a bug report if you like, and see if anyone picks it up. —Bkell (talk) 15:14, 22 January 2008 (UTC)[reply]
The trick that Mathematica uses for similar notations is to write \left\langle\left.foo\right|bar\right\rangle. This sizes the vertical bar based on "foo"; you can of course move the fake "." delimiter to the right end if "bar" is (expected to be) bigger. --Tardis (talk) 17:31, 23 January 2008 (UTC)[reply]
One time I needed a LaTeX command, put it on the talk page (leaving it a compile error) and it was there a few days later. No idea how it happened. I could guess someone came along, noticed the compile error and bumped it along to the right spot where the command was added. Pdbailey (talk) 20:24, 25 January 2008 (UTC)[reply]

can this diff eq be solved?[edit]

Does anyone have any suggestions on how to solve this non-linear second-order differential equation: where a and b are positive constants, and y is a function of x. Thanks. --131.215.166.106 (talk) 04:20, 22 January 2008 (UTC)[reply]

Any constant will work, y=c. Black Carrot (talk) 08:31, 22 January 2008 (UTC)[reply]
I'm trying to solve for when a=0, and I don't think it can be done in elementary functions. I have that y' = ce^(-b/2y^2) (please check), and the List_of_integrals_of_exponential_functions doesn't have anything good to say about that. Black Carrot (talk) 08:52, 22 January 2008 (UTC)[reply]
When b=0, it's linear. y=cx^(a+1)+d, for constants c and d. Black Carrot (talk) 08:56, 22 January 2008 (UTC)[reply]
Hey, I found another case. y=(a+2)/(bx). Black Carrot (talk) 09:35, 22 January 2008 (UTC)[reply]
y=2/(bx+c) is good when a=0. Black Carrot (talk) 10:05, 22 January 2008 (UTC)[reply]
I got my earlier formula for when a=0 wrong. It wouldn't be y' = ce^(-b/2y^2), it'd be y' = (-b/2)y^2+c, which is a lot easier to solve. Still hard, but easier. If you want to solve it yourself, it'll help to know trigonometric integrals, partial fractions, and separation of variables. Black Carrot (talk) 04:52, 23 January 2008 (UTC)[reply]
You might find this helpful: [1] Black Carrot (talk) 05:03, 23 January 2008 (UTC)[reply]
y' = f(y) is solved by x = ∫ dy / f(y).  --Lambiam 08:49, 23 January 2008 (UTC)[reply]

Finding a definite integral[edit]

It's the night before my calculus final and I'm about to go to bed, but I'm just really bugged by this problem from a past final that I have no idea how to do:

0π/6 sec 2θ tan θ dθ

I know how to take definite integrals of polynomials and indefinite integrals of trigonometric functions, but this! We never learned this ... could anyone please show me at least how to set it up? Thanks so much in advance. —Preceding unsigned comment added by 70.19.20.251 (talk) 04:37, 22 January 2008 (UTC)[reply]


Could you do if it were indefinite?72.219.143.150 (talk) 04:40, 22 January 2008 (UTC)[reply]

Yes, but when you're trying to evaluate a definite integral, other stuff comes into play, like a, b, ∆x, and ci, and I don't know how to "integrate" all that (terrible pun) with taking the antiderivative of trigonometric functions ... —Preceding unsigned comment added by 70.19.20.251 (talk) 04:44, 22 January 2008 (UTC)[reply]

Well, yes, but if you know the antiderivative of the function it is a small step to definite integration...I guess what I'm asking is if the disconnect is just evaluating it. Do you know the antiderivative of the function? Show me that. (oops, forgot to ask---is the tangent's argument 2θ as well? Try a u-substitution. 72.219.143.150 (talk) 04:49, 22 January 2008 (UTC)[reply]

  • Is the problem or actually ? The latter would make more sense on an exam (at least, one I would write :P) and is easier to solve (i.e., it's ). Requiring the knowledge of some identity to rewrite in terms of a function of seems not so fun, I would think. Could you clarify this please? --Kinu t/c 04:51, 22 January 2008 (UTC)[reply]

Er, oops. Kinu, you got it. Lapse in my identities. I think the secant should be squared for this integration to be plausible on an exam.72.219.143.150 (talk) 04:53, 22 January 2008 (UTC)[reply]

Yes, I know that the antiderivative of sec x tan x is sec x, so the disconnect is indeed just computing it. And yes, it's sec 2θ tan 2θ, my mistake. Unfortunately, we haven't learned how to use u-substitution in integration ... —Preceding unsigned comment added by 70.19.20.251 (talk) 04:54, 22 January 2008 (UTC)[reply]

(after making a silly mistake) Hm, the arguments are going to present a problem if you can't do u-subs. Your antiderivative is sec(2θ)/2. You'd plug the limits of integration into it and solve it like you would a polynomial expression, ending up with the value sec(/3)/2-sec(0)/2. Since I forget how to parse math stuff, you can calculate those values.72.219.143.150 (talk) 05:07, 22 January 2008 (UTC)[reply]

If it helps, we have an entire article on U-substitution. Black Carrot (talk) 08:01, 22 January 2008 (UTC)[reply]
Consider this, if you know how to find the antiderivative (indefinite integral) then you should be able to evaluate a definite integral. Just find the antiderivative like it was an indefinite integral, (be sure to back substitute if you used a u-substitution to get your antiderivative) then if we call the antiderivative F, find F(b)-F(a) (that result comes from the Fundamental theorem of calculus read the "Second part" in that article) (b is the upper bound and a is the lower bound of the original integral.) A math-wiki (talk) 09:30, 22 January 2008 (UTC)[reply]
I get the impression that 70.19.20.251's class ran out of time for the semester before they got around to the fundamental theorem. (Look at all the recent questions that involve evaluating definite integrals the hard way, using a Riemann sum directly.) In that case, one would hope that the teacher won't put such complicated trig integrals on the exam. The past year's test could have more advanced material just because the class went faster that time. --tcsetattr (talk / contribs) 09:38, 22 January 2008 (UTC)[reply]

Tetrahedron in Sphere[edit]

What is the largest volume of a tetrahedron that can be inscribed in a sphere? I can do it with a triangle and a circle, but I don't know where to begin when in 3 dimensions. Give me a hint. :) HYENASTE 05:39, 22 January 2008 (UTC)[reply]

Consider a tetrahedron of fixed size and therefore known volume, and determine the volume of the circumscribed sphere. For reasons of symmetry, the centre of that sphere is the centre of the tetrahedron, which is its centroid. From that you can determine the radius of the sphere.  --Lambiam 06:33, 22 January 2008 (UTC)[reply]
I think you're making the assumption that the tetrahedron of largest volume is regular, which does seem like it should be true; how do you show this? —Bkell (talk) 06:37, 22 January 2008 (UTC)[reply]
I could give a sloppy argument that I find convincing. Take a sphere of the chosen size and inscribe any tetrahedron in it. Choose one face of the tetrahedron as the base, oriented as low as possible and horizontal. If the apex is below the base now, the volume can be made at least as big by moving it to a similar position above the base. From there, letting the apex roam freely, the volume is maximized uniquely when the apex is at the very top of the sphere. In other words, if on the tetrahedron you've chosen there's a face where the associated apex is not at the top of the sphere from its frame of reference, that tetrahedron has less volume than some other tetrahedron. The only tetrahedron where each apex is at the top from the point of view of its base, is the regular one. Black Carrot (talk) 07:47, 22 January 2008 (UTC)[reply]
A similar argument, building up from the two-dimensional case: having chosen a base, maximize its area. That would be an equilateral triangle, as can be proven. The only tetrahedron with all equilateral triangles for faces is the regular one. Black Carrot (talk) 07:52, 22 January 2008 (UTC)[reply]

Inverse color[edit]

How do I calculate the inverse color for a color? i.e. if I'm given a color, I want the color best suited for the background color, i.e. most readable.

I have seen many many online inverse color tools that simply assume it's the 256 complement (if I am using that term correctly), so (to use decimal), 10's inverse is 245. But of course then you get the color #808080 (i.e. 128 128 128), and the inverse is not correct at all.

Does anyone have a better formula? I'm thinking perhaps the color such that new minus old color has the maximum absolute magnitude. Any ideas? Ariel. (talk) 10:48, 22 January 2008 (UTC)[reply]

I'm not sure how exactly you're calculating the inverse, but you want to be breaking the colour down into its red green and blue components. For a given colour , your inverse will be . Readro (talk) 11:21, 22 January 2008 (UTC)[reply]
The answer depends on definition of 'inverse' , that is what color model you use. It's quite safe to assume that black and white should be 'inverse' to each other. But what do you mean by inverse of, say, bright yellow? Should it be dark brown (light–dark inversion, i.e. lightness inversion in HSL color space) or rather intense blue (RGB inversion, proposed by Readro above)? --CiaPan (talk) 12:30, 22 January 2008 (UTC)[reply]
If what you're after is a color which is as different as possible from the given color, then yes, you want each of the RGB components to have the maximum distance between them. This will always be a color with RGB components of 0 or 255. So for (192, 140, 60), for example, the most distant color will be (0, 0, 255). Of course, I am assuming here that in terms of perception, the components are completely unrelated and 128 is midway between 0 and 255. Also, this will not be bijective - the same color will be the "inverse" of many colors. If you want a bijection which guarantees that the colors will be quite different, you can take each RGB component and add 128 modulo 256. -- Meni Rosenfeld (talk) 12:39, 22 January 2008 (UTC)[reply]
Readro's inversion, and 128 modulo 256 both don't handle gray - they produce gray as the result. Meni's idea - is I guess, for each component - if it's greater than 127 make it 0, if it's less or equal, make it 255. I think that should work. CiaPan: you ask which type of inversion - I would answer: both. Because otherwise you don't handle gray (the opposite color to gray is still gray), so you need lightness change, but light yellow on dark yellow is also hard to read, so you also want a color inversion. Would Meni's idea do that? Ariel. (talk) 13:30, 22 January 2008 (UTC)[reply]
Ok, now I understand (I hope). :) Well, yes, Meni's idea is best for you: it will give most contrast color possible, approximately inversing the hue of a given color and choosing its maximum or minimum value. For example for yellow and similar colors you'll get intense blue; for any bright gray color, including white, you'll get black; for all very dark colors you'll get white, an so on. --CiaPan (talk) 13:41, 22 January 2008 (UTC)[reply]
[ec] Adding 128 modulo 256 does handle gray - it produces black or white for the result (for dark grey it will give light grey, which works but is perhaps suboptimal). My other suggestion will turn light yellow to light blue and dark yellow to white. -- Meni Rosenfeld (talk) 13:56, 22 January 2008 (UTC)[reply]
Sorry, I miss-understood what you wrote (misread the modulo). I tried it - it handles some colors better then others. It doesn't produce the opposite color (from a color wheel) for all colors like this color for example, on the other hand this seems OK. The other method you posted works nicely, except cyan is not a very easy color to read. Ariel. (talk) 15:38, 22 January 2008 (UTC)[reply]
You've asked two completely different questions here. A perceptually "opposite" color is not generally a good background color for maximum readability. The most-distant-in-RGB strategy will get you cyan on red, which is a terrible combination for readability even though these are perceptually very different colors. The add-128-modulo-256 strategy will give you such horrors as red on grey. In these cases cyan on black and red on white would have been far better. You should also take into account that you may have colorblind users, and what looks good to you may be unreadable to some of them. I think your best bet is to use a black background for all bright colors and a white background for all dark colors. To judge the brightness of an RGB color you could use the sRGB formula in the Luminance (relative) article. If it isn't obvious by now, your question really belongs on the science desk; human color perception is complicated and weird, and there's no simple mathematical answer to the questions of what looks most different or best. -- BenRG (talk) 15:24, 22 January 2008 (UTC)[reply]
The color is actually the background color, and I just want something readable for the text label on top of the color (the color blind person would read that - I think contrasting colors and brightness simultaneously should be readable to a color blind person, just changing the color would not be). I tried making all the text either black or white, it worked for many colors, but not for all of them. The ones that were mid-way in luminosity were hard to read. So far the most-distant method worked best, but some colors look terrible, as you mentioned. There has to be a better way - your cyan on red are both full luminosity colors, I want to also invert the luminosity. So solid red should become black (the cyan at 0 darkness). (Well, I think I want that - I don't really know what I want :) Ariel. (talk) 15:49, 22 January 2008 (UTC)[reply]
Can you give examples of colours for which neither a white nor a black label worked well?  --Lambiam 18:02, 22 January 2008 (UTC)[reply]
For example: this color in white and this one and in white. I mean it's not terrible, but a color instead of black or white would be better. Ariel. (talk) 15:47, 23 January 2008 (UTC)[reply]
Hmm... what color would you prefer on them? At a glance, I can't think of any color that would obviously look more readable on those backgrounds than black or white (which do about equally well, as one might expect on a medium-brightness background). —Ilmari Karonen (talk) 02:49, 25 January 2008 (UTC)[reply]
Note that properly converting RGB colors to grayscale isn't quite as simple as just adding the components together. In fact, the precise conversion formula will depend on the specific RGB color space used, but a quick and dirty rule is to weigh the red channel by 30%, the green by 60% and the blue by 10%. Thus, to pick the maximally contrasting color from the set {black, white}, given the background color (r, g, b) ∈ [0,1]3, one might use the formula:
Ilmari Karonen (talk) 04:31, 23 January 2008 (UTC)[reply]
I particular, the rule I give above produces, for extremal backgrounds choices, black on green, yellow, cyan and white, and white on black, red, blue and magenta. Simply using the unweighted mean would yield the opposite choice on green and magenta, which I think you'll agree would not look optimal. —Ilmari Karonen (talk) 04:38, 23 January 2008 (UTC)[reply]
You could also perhaps experiment with lowering the threshold a bit, say from 5 to 4.5, since the human eye seems to be somewhat more comfortable with black on a dark background than with white on a bright one. But the 50% threshold ought to work well enough. —Ilmari Karonen (talk) 04:48, 23 January 2008 (UTC)[reply]

Is the Ariel asking about complimentary colors as in art and design? Complimentary are the exact opposite of each other and shows the best contrast. It is based on RYB not RGB. 2 complimentary colored paints when mixed will always be black. See http://www.faceters.com/askjeff/answer52.shtml NYCDA (talk) 23:58, 22 January 2008 (UTC)[reply]

Two complimentary colors, as it says in the article you linked, usually mix to a muddy brownish color. Black and white have to be produced separately, essentially as two more primary colors. Black Carrot (talk) 04:16, 23 January 2008 (UTC)[reply]
That would be Complementary colors. AndrewWTaylor (talk) —Preceding comment was added at 08:45, 23 January 2008 (UTC)[reply]
I know what they are, I was asking how to calculate them. And if they are a good choice. Ariel. (talk) 15:47, 23 January 2008 (UTC)[reply]

(See above for 2 colors that didn't work great with black or white.) All the ideas posted worked pretty well, but I think it can be better. I like the most distant color rule, but I'd like to remove cyan, magenta, and yellow from the options, since those colors aren't the easiest to read. Any ideas? Ariel. (talk) 15:54, 23 January 2008 (UTC)[reply]

Mathmatically the opposite of "all" is "some", not "none". Opposite of gray is white or black depending on your prespective. You might be better of if you add 128 to the component if the value is less then 128, substract 128 if the value is greater then 128. For 128 itself, you can set it to 0 or 255. Using this rule, you get
sample sample sample sample

NYCDA (talk) 19:11, 23 January 2008 (UTC)[reply]

Alot of people seem to be trying to invert colour mathematically. What is needed here is to invert for the eye. Itensity is not equally effected by the colours. Intensity is generally: (0.299*r) + (0.587*g) + (0.114*b). Opposite intensity = (0.368*r) + (0.080*g) + (0.552*b). So for grey of 128,128,128, the opposite is 47 (0.368*128), 10 (0.080*128), 70(0.552*128), you then invert that to get 208, 245, 185. For gray 32,32,32 the opposite colour is 12,3,17 -> 243,252,238. For red (255,0,0), the opposite itensity is 94,0,0 -> 161,255,255. Opposite of blue (0,0,255) is 0,0,140 -> 255,255,115. Opposite of dark green (0,128,0) is 0,10,0 -> 255,254,255. This is the TRUE opposite. The value I use (0.386,0.080,0.552) are beacuse of the sensitivity of the eye, we see green the most and blue the poorest. Samples: Grey Grey Blue Blue Darkgreen Darkgeen Red Red D.Yellow D.Yellow Green Green I think you will find that no matter what colour you put in, you will get the most pleasing 'opposite' colour for human vision. Note that there is another set of values for computer screens. With these values red and green will be to bright. I know that these are the values for print (newspapers etc) but for computer screens I don't know. I think the green 0.08 is alot higher.--155.144.251.120 (talk) 01:10, 24 January 2008 (UTC)[reply]

How did you calculate the opposite factors? I can see that they add to .666 but why is that what you choose? Also the Luminance (relative) has different factors. That article has very different numbers, and different from Ilmari's 30/60/10 rule as well. Edit: found it, the Luma (video) has your numbers. Ariel. (talk) 01:41, 24 January 2008 (UTC)[reply]
Never mind, I just figured it out. The sums each add to 1. Two set of them add to 2, and 2/6=.666. Ariel. (talk) 01:43, 24 January 2008 (UTC)[reply]
I take back my never mind - for the values in the Luminance (relative) what do I do for .7152? Take the absolute? I tried that, but the new factors: 0.4541, 0.0485, 0.5945 don't add up to 1 anymore. Ariel. (talk) 01:55, 24 January 2008 (UTC)[reply]
This inverse doesn't seem right. For white you get Light green, and I think you should get black. Ariel. (talk) 02:04, 24 January 2008 (UTC)[reply]
Some of 155's observations are good, but his method for inverting is completely bogus. For the color (186, 236, 164), the inverse he proposes is the color itself. -- Meni Rosenfeld (talk) 23:11, 24 January 2008 (UTC)[reply]
Perhaps we need to look at this from a different angle, there are two things that seem to really matter to our eye, pigment and luminosity. So if we describe the standard RGB values in terms of these two. Thing of it like this, the pigment is the actual color, (direction of a vector onto the color wheel) and luminosity is the intensity of this pigment (length of said vector). There's also the issue of the grey scale, which could be thought of as a z-component of that vector which gives it depth. To avoid the issue of grey on grey, one could argue that the length of the vector should always be maximized to get the resulting color to be as different as possible from the first color. A math-wiki (talk) 07:43, 24 January 2008 (UTC)[reply]
After some further thought, I'll clarify my describtion a bit. On the XY plane, the direction the vector takes is the pigment (coloration), the length on the planes describes the intensity of the pigmentation, and the change in height over the length of vector is the luminosity with the brightest white being the highest positive value allowed, and the darkest black the lowest negative value allowed. A math-wiki (talk) 07:53, 24 January 2008 (UTC)[reply]
You might want to try somethjing like just inverting (red = 255 - red) then factor by the weighting of the lumanance: r = r/1.567889620, g = g/0.466070096; b=b/4.616805170; This takes care of greys because they go to greens:

blackblackwhitewhitegreygreydgreydgreylgreylgreyredredlredlredgreengreenlgreenlgreenbluebluelbluelblueyellowyellowlyellowlyellowindegoindegolindegolindegovioletvioletlvioletlviolet--Dacium (talk) 00:24, 25 January 2008 (UTC)[reply]

I don't know how you guys end up with these oddities. With your system, what will be the result if the original has 0 green? -- Meni Rosenfeld (talk) 12:07, 25 January 2008 (UTC)[reply]
A-math wiki, there are three parameters for the type of system you describe, chrominance (what you call pigment), luminance, and (the one you missed) saturation. A fully saturated colour is, for instance, bright red and a de-saturated colour is, for instance pink. ie, desaturating adds white. In any abstract representation of colour there must be (at least) three parameters, at least when we are describing human vision. SpinningSpark 18:37, 27 January 2008 (UTC)[reply]
A-math wiki's description sounds a lot like HSL and HSV... - SigmaEpsilonΣΕ