IEEE rejected our article after minor revisions because the reviewer did not understand a small issue. Is it likely to succeed if we appeal?

Question: I submitted an article to a certain top IEEE  transaction journal, and after a year and a half of peer review, it was finally rejected. During this period, we got a chance to make minor revision.The paper was then sent to two new reviewers. One of the new reviewers made several rounds of incorrect comments. In the latest revised version, I clearly addressed his error issues. However, he deliberately claimed that he could not understand it and said that my notation was problematic. As a result, the paper was rejected.
Comment: How do you know the reviewer deliberately 'could not understand it'?  In general, as a reviewer, I want to be able to extract the key ideas in the first read.  An important aspect of writing a paper is to write in a manner even a 'non-expert' can walk away with the key ideas.  Similarly, when you write the responses to reviews, you have to explain your reasonings like to a 10 year old.  It is possible that you wrote the paper to be understood by you only.   A reviewer is likely to reject a paper that he/she doesn't understand, just to be on the safe side.
Comment: You are so right, I totally agree. We have answered and explained the reviewer's questions in detail in the current version of the appeal, hoping to get a good result.
Answer: No, it is very unlikely to succeed unless you do major modifications, addressing the concerns of the reviewer(s). Even then, resubmission after rejection may be impossible.
Most important, however is to try to address the reasons why you weren't understood. Was your notation non-standard, for example? And if so, was it completely and clearly explained in the target language.
What you write here seems like two people talking past one another having different backgrounds and/or assumptions. You need to address that if you want success. It isn't up to them (and future readers) to try to understand you if you are insufficiently clear.
Your words "deliberately" and "unreasonably" worry me. Complaining to editors of unfairness or claiming the reviewers are idiots will get you exactly nowhere.
Even for another journal, you may have a lot of work to do. In the long term, high standards are to your benefit as well as that of the world of scholarship.
Comment: Thanks.  The response letter to the reviewer' comments and the revised manuscript have been  sent to the reviewer.  I  believe that I have adequately addressed the concerns raised by  the Reviewer  and made significant improvements to the manuscript.  I will carefully consider what you suggest.
Answer: Do not continue to re-submit to the journal that rejected your paper.  Try another journal.
Comment: @zhangyuan It's your job when writing a paper to explain your method, so when a reviewer doesn't understand it this is seen by the editor (who will have chosen reviewers they expect to be able to understand papers in the same general area) as a fault with the paper, not the reviewer.
Comment: But the reviewers did not understand our method, which can be explained. Regarding the erroneous conclusions he mentioned, we all have theories and experiments to prove that our arguments are correct. We are not happy that such articles are unreasonably rejected. At present, an appeal has been applied, and the journal is processing it, but I don't know the probability of success.
Comment: Thanks.I totally agree with your point of view. We have provided detailed instructions and explanations for what the reviewers did not understand, and hope to get a good result.


total area of intersecting rectangles

Question: What is an algorithm for determining the total area of two rectangles that are intersecting and may be rotated off the coordinate axes?
Comment: related but does not have the rotation possibility requirement: [total area of intersecting rectangles](http://stackoverflow.com/questions/4549544/total-area-of-intersecting-rectangles/4555164#4555164)
Comment: I would like to point out that the currently highest rated answer by Tom Medley, while very interesting, is *not* the easiest approach. The straightforward solution is to use one of the algorithms for [convex polygon intersection](http://stackoverflow.com/a/13105297/145999) (like Sutherland-Hodgman) to find the intersection between both rectangles, then calculate the [area of the intersection](http://www.mathwords.com/a/area_convex_polygon.htm), then calculate the area of the union as Area(rect1) + Area(rect2) - Area(intersection). This is also outlined in the answer by Alexandre C.
Answer: Here's roughly what you need to do, expressed as generally as possible, but covering all possibilities:

Work out the class of intersection. I.e. How many edges does the intersection area have? It could be anything from 0 to 8.
Find all vertices of the intersection. This will be all intersections between the edges of the rectangles, and associated corners of the rectangles themselves. Working this bit out is the most complex/tedious.
Work out the area of the intersection, by dividing it up into triangles if necessary.

Here's all the ways the rectangles can intersect:

Update
I've had some thoughts, and the best way to categorize the intersection is to trace round the perimeter of each rectangle and count the number of times each edge intersects another edge. You'll get a vector, e.g. for a six sided intersection area: {1,1,1,1},{0,1,1,1}, and for 8: {2,2,2,2},{2,2,2,2}. The two special cases you'll need to check for are when one rectangle completely encloses the other and when the edges are in line. You'll need to do careful checks, but this would be the starting point for a function to categorize the intersection.
Comment: There's also the possibility that the intersection could be a 5, 6, 7 or or 8-sided figure.
Comment: Nice diagrams.  That alone deserves a +1.
Comment: Another case: two rectangles of the same size precisely overlapping (the overlapped area is the total area of either rectangle).
Comment: As the rectangles may be tilted, the intersection could be also a triangle
Comment: I've amended my answer, have I missed any cases?
Comment: @jball I'm not prepared to provide a full solution! And you would be able to optimize the calculation of the area once you can categorize it certainly.
Answer: Area(R1 union R2) = Area(R1) + Area(R2) - Area(R1 intersection R2), so you can calculate the area of the intersection to have the area of the union.
Intersections of two rectangles (or two convex polygons) are simple:

They are convex polygons
Their points are characterized as follows: intersection points of any pair of edges, and points of one rectangle which are inside the other.

So it goes like this:

L is an initially empty linked list
R1 has edges e1, e2, e3, e4, R2 has edges f1, f2, f3, f4. Compute intersection points of ei and fj, for all i,j=1,2,3,4. Add them to list L.
For each vertex v of R1, if v is inside R2, add it to L.
For each vertex w of R2, if w is inside R1, add it to L.

The convex hull of points in L is your intersection. As every point in L is on the boundary of the intersection, you can triangulate it and compute its area. Easy:

L = [x0, x1, ... ]
Sort points in L according to the angle of (xi - x0) with respect to an horizontal line passing through x0
First triangle is x0, x1, x2
Second triangle is x0, x2, x3
nth triangle is x0, x(n+1), x(n+2)

The area of a triangle is given by Heron formula:

a, b, c are edge lengths
s = 0.5 * (a + b + c)
area = sqrt(s * (s - a) * (s - b) * (s - c))

but beware of computing s - a, s - b and s - c independantly since you can encounter roundoff error (what if c ~ a and b << a for instance ?)
Comment: Is calculating the intersection of each edge in the first rectangle to every edge in the second rectangle really the best solution?
Comment: @jball: for rectangles, it gives you 16 such tests. For intersecting more complex convex polygons, you may want to use quadtrees or similar to avoid most of the tests. Note however that after a change of variables to put R1 along coordinate axes, these tests are straightforward.
Comment: Thinking about it more, finding the intersection just creates unnecessary calculations. A better method is to find the vertices of the entire union, and then calculate the area of that. It reduces the area calculations from 3 (2 that are trivial) down to 1. And there are better algorithms than triangulation for calculating the area of a polygon.
Comment: Example that handles convex and concave polygons: http://www.mathopenref.com/coordpolygonarea.html
Comment: @jball: Finding the vertices of the union seems as difficult, and less natural than what I wrote, which took me 5 minutes to figure out. And yes, there are better algorithms than triangulation for the area of a convex polygon, this one was on top of my head.
Comment: @jball: the method you link to seems numerically horrible (all those determinants xy - yx are very prone to roundoff error). Moreover, it is exactly computing the area by triangulation, by the same method I use, but instead of Heron's formula, it uses the cross product. Heron's formula is likely to be numerically more accurate, provided that eg. you compute (s - a) by 0.5 * (-a + b + c).
Comment: @jball: and your linked to method does **not** handle non convex polygons.
Comment: @Alexandre C. - First point - rounding errors will not happen (See the [further explanations](http://www.attewode.com/Calculus/AreaMeasurement/area.htm) that are available on the web). Second point, using Heron's requires more code and more processing (finding square roots is expensive). Third point, it **does** handle concave polygons. As a matter of fact it handles all polygons except for crossed polygons. Those will never occur in this situation.
Comment: @Alexandre C. - Just noticed your comment about finding the union - it may seem less natural, but it's more direct to the problem, and no more difficult to write out. Your algorithm above works perfectly simply by changing "inside" to "outside" in *For each vertex v of R1, if v is inside R2, add it to L.* and the symmetrical statement for the vertices of R2.
Comment: @jball: Okay, this is in fact Stokes formula, so it will work for any simply connected "Jordan" polygon (ie. **no holes**, **no self-intersections**). For the numerical accuracy, I still think you expose yourself to roundoff error by computing the area this way. And after reading your comment, finding the union is as natural as finding the intersection.
Comment: @Alexandre C. - yes, it's a special case of Stokes. You can derive the cross product method yourself if you wish to understand why there won't be any roundoff errors but it's well established as a direct (not approximate) method for calculating the area of a polygon.
Comment: @jball: It will have roundoff error when xi and yi are moderate and the total area small (ie. for instance xi, yi ~ 10000 and area ~ 1 or so, you expect to lose 4 figures). You'll cancel a lot of digits when performing the cross products (8 or so in our case), and thus lose more precision than you would lose by other methods.
Comment: @Alexandre C. I'm confused - how are the cross products losing digits?
Comment: @jball: when you substract close numbers, ie. 10000001 - 10000000 = 1, but you have now one significant digit where you had 8 before.
Comment: @Alexandra C. - I see. This doesn't yield a different total result from the other methods though, does it?
Answer: Ok, you have 3 possibilities:
1. Rectangles don't intersect
2. One rectangle is completely contained within the other (or they coincide)
3. The result of intersection is some convex polygon.  You compute the area of a polygon by breaking it into triangles (by drawing segments from the first vertex to every other except for adjacent once).  The you sum up the areas.  You can use Herodot's theorem to calcaulate triangle's area and that's where midlle school geometry comes in.
Comment: Herodot's theorem? Do you mean Heron's formula?
Comment: IVlad, you are missing the point.  If you are more interested in a correct spelling then you should probably dwell on humanitarian forums.
Comment: @Nickolodeon - you can't just sum up the areas, because then you will sum the area of the intersection twice. So you need to subtract the area of the intersections. How do you propose we do that?
Comment: Okay, continue your hand-waving. How can any of us here be a match for someone who can't even spell right and uses advanced stuff like Herodot's theorem to compute triangle areas?
Comment: @belisarius - actually I don't think it can be concave. Of course this answer makes no sense and I downvoted it, but I don't see how the intersection could be concave...
Comment: IVlad, could you provide an example (in terms of some array of points so I'll get a concave polygon)?  Thanx
Comment: IVlad, how about summing up the areas of 2 rectangles and subtract polygonal area from the result, ha?  I know it's tough for those that downvote answers without making one more step furher into thinking.
Comment: jball, that seems to be the only way to go.
Comment: As a matter of fact, fredley proposes a right way to go (I just don't see how angles can be>180!).  You need to start constructive comment on that, jball.  My solution is just more instructive.
Comment: @Nickolodeon What? Your "solution" glosses over how to determine what the intersecting polygon is and provides what looks to be a clumsy method for calculating its area. These are actually the most interesting parts of the problem. It's quite a stretch to say you provided an instructive solution.
Comment: @jball, finding convex polygon of intersections is not hard, at least very bad algorithm is: you can find intersection of 4 * 4 segments and after that find the convex polygon (oh yes by convex hull!!), and calculating area of convex polygon is as easy as google search http://www.mathwords.com/a/area_convex_polygon.htm
Comment: @Saeed not finding an elegant solution for calculating the intersection of the two rectangles is what has prevented me from posting an answer. Your link on calculating the area of the resulting polygon just proves my point to @Nickolodeon about the above answer's area calculation method being unnecessarily awkward and inefficient.

total area of intersecting rectangles


Finding inradius given the heights

Question: I'm given the heights of a triangle. Find the inradius. I know that inradius is area/semiperimeter. But then?
Answer: Let the area of triangle be $T$, the heights $h_a, h_b, h_c$, and $s$ the semi-perimeter. Then:
$$2T = ah_a = bh_b=ch_c$$
$$a = \frac{2T}{h_a},  b = \frac{2T}{h_b}, c = \frac{2T}{h_c} $$
$$a+b+c= 2T(\frac{1}{h_a}+\frac{1}{h_b}+\frac{1}{h_c})$$
$$\frac{s}{T}=\frac{1}{h_a}+\frac{1}{h_b}+\frac{1}{h_c}$$
I hope you get it from here, the sum of the reciprocals of the heights is the reciprocal of the inradius itself. Nice little theorem.
Comment: Wow! That was easy. Thanks for such a simple explanation. I'll accept (check) it, but I would like to wait a few minutes to see if there's any better answer.

Finding inradius given the heights


How to restore System Preferences.app without reinstalling?

Question: My younger brother decided to sudo rm -r /Applications/System\ Preferences.app. Yeah, it was a pretty stupid thing to do.
(In his defense, it's probably my fault for giving him bad habits--whenever I set up new macs, I always forcibly remove iTunes, Chess, and other preinstalled applications that I consider useless.)
He is currently running MacOS Sierra, and aside from the fact that he can't change any settings, his computer appears to be running fine.
I told my brother to redownload the Sierra installer from the Mac App Store, use Pacifist to extract the System Preferences application, and copy it back to his applications folder.
He did so, but the newly-extracted System Preferences app doesn't work. It opens, but displays a blank window with no preference panes to click on. I advised him to do a reinstall, but he doesn't want to.
How can my brother get System Preferences back?
Comment: He has a Time Machine backup, right?
Comment: He needs to reinstall OS X.
Answer: Reinstalling the latest combo updater for Sierra is probably the first thing I'd try. Won't overwrite anything it doesn't need to, but should put back anything that's missing.
https://support.apple.com/kb/DL1918?locale=en_IE


Vector fields as sections of O(2) on P^1(C)

Question: The tangent bundle of $\mathbb{P}^1(\mathbb{C})$ is given by $\mathcal{O}_{\mathbb{P}^1}(2)$. A section of $\mathcal{O}_{\mathbb{P}^1}(2)$ is, say, $x_0^2$, where $[ x_0 : x_1]$ form homogeneous coordinates on $\mathbb{P}^1$. My question is: which vector field is it? Can one draw the vector field, say, by viewing $\mathbb{P}^1$ as $S^2$, or, perhaps, by looking in one open chart?
An answer to my question would either supply a vector field that I can actually draw on $\mathbb{C}$, and would generalize to $\mathbb{P}^1(\mathbb{R})$ so that we can actually draw a vector field on the real line corresponding to (the homogeneous monomial of total degree 2) $x_0^2$, or show that this is not possible (maybe a vector field is not well-defined from homogeneous coordinates). Thanks
Answer: This can be computed on affine coordinates in a way similar to computing global sections of $\mathcal O_{\mathbb P^1}(n)$. Let $x_{1/0}=x_1/x_0$ and $x_{0/1}=x_0/x_1$ be the coordinates on the standard affine open sets $U_i=\{x_i\neq 0\}$. A vector field on $\mathbb A^1_{x_{1/0}}$ takes the form $v=f(x_{1/0})\frac{\partial}{\partial x_{1/0}}$. When we write $v$ in terms of $x_{0/1}=x_{1/0}^{-1}$, the chain rule says:
$$
v= f(x_{0/1}^{-1})\frac{\partial}{\partial (x_{0/1}^{-1})} = f(x_{0/1}^{-1})\frac{1}{\partial (x_{0/1}^{-1})/\partial x_{0/1}} \cdot \frac{\partial}{\partial x_{0/1}} =-x_{0/1}^2 f(x_{0/1}^{-1}) \frac{\partial}{\partial x_{0/1}}.
$$
So in order for $v$ to not have a pole at $[0:1]$, $f(x_{0/1}^{-1})$ can have a pole of order at most $2$, i.e. $f(x_{1/0})$ is a polynomial of degree at most $2$. Therefore, the global sections of the tangent bundle have this basis:
$$
v_0=\frac{\partial}{\partial x_{1/0}} = -x_{0/1}^2 \frac{\partial}{\partial x_{0/1}};x_{1/0}v_0=x_{1/0}\frac{\partial}{\partial x_{1/0}} = -x_{0/1} \frac{\partial}{\partial x_{0/1}};x_{1/0}^2v_0=x_{1/0}^2\frac{\partial}{\partial x_{1/0}} = - \frac{\partial}{\partial x_{0/1}}.
$$
And the tangent bundle is isomorphic to $\mathcal O_{\mathbb P^1}(2)$ by a map that takes:
$$
x_0^2\longmapsto v_0; \quad x_0x_1\longmapsto x_{1/0}v_0; \quad  x_1^2\longmapsto x_{1/0}^2v_0.
$$
Comment: This is beautiful, thank you.


How can I check if a customer is logged in?

Question: I'm new to CC and in my home page I need to display a banner just if a user is logged in. I read the documentation and I think I need to work with customer groups (registered and unregistered), but didn't quite understand how to perform checks on these groups. Anyone who can help me to get closer to a solution?
Answer: When you simply want to check if a customer is logged in or not (if he is logged in that includes that he is in the customer group "registered"), you can access the Customer class and use the method isAuthenticated or alterantively the authenticated property of the Customer object initialized by that class.
For example:
<isif condition="${pdict.customer.authenticated === false}">

Customer in that case can be accsessed in different ways:
As part of a controller call:
req.currentCustomer
or as part of a basket:
currentBasket.customer


How does electrical current have energy? (when electrons move very slowly through circuit)?

Question: How does electrical current have energy? (when electrons move very slowly through circiut )
Answer: In an electrical circuit, an electrical current $I$  in a conductor with resistance $R$ produces an energy per time (as heat) $$W=I V=R I^2$$ This energy corresponds to the energy gained from the electric field by each charge carrier (electron) when traversing the potential difference (voltage) over the resistance $R$ $$I=Q/t=ne/t$$ Thus $$W=neV/t $$
On the other hand, a stationary electric current $I$ produces a magnetic field $B$ around it which has the magnetic field energy density $$u=\frac {B^2}{2\mu_0}$$ The work corresponding to this total magnetic field energy has to be done in order to set up the stationary current. This is related to the phenomenon of self-induction.
Answer: You're right that the electron drift velocity is very low, and given the small mass of the electrons to begin with, it must carry very little kinetic energy. What's more, the time averaged current has to be constant in any steady state circuit, so the kinetic energy content of the electrons flowing is undiminished throughout the circuit.
So, how is energy being delivered from source (eg battery) to sink (eg resistor)? The answer is that the energy is moving through the electromagnetic fields in and around the wires. I've not seen or done a detailed analysis on this point, but my understanding is that if you do you'll find that the Poynting vector field accounts for all of the energy flow in the circuit.


Duck Duck Go SEO

Question: The search engine duck duck go has generated some interest, and there are a few people who use it. I was wondering if if would be worth while to optimize my site to rank better on duck duck go, and if it is worthwhile, if there are any tips for how to rank better on their site.
Comment: Offtopic: I like how scrolling down at duckduckgo populates more search results without having to go to a second page. Google should do that. Takes away the irrelevancy of the second page.
Comment: Interest from who? Not from anyone I know.
Comment: I would suggest that Blekko has gained more interest than DDG...
Answer: I wouldn't even give that search engine a thought. Until they reach a critical mass and can potentially deliver real traffic oit's not worth doing anything special for them.
Anyway, if your site is done properly you will be optimized for every search engine. There shouldn't be a need to do anything for any one search engine.
Comment: I should have been clearer: I was wondering if there were any tips that would help me rank better on duck duck go. However, that's irrelevant, because as you said they don't have enough users to make it worthwhile.
Comment: Looks like it's worth revisiting this answer. Critical mass achieved : )  DuckDuckGo is now at approx 10 million daily queries. See [How DuckDuckGo Rode A Wave Of Post-Snowden Anxiety To Massive Growth](http://www.fastcompany.com/3046943/how-duckduckgo-rode-a-wave-of-post-snowden-anxiety-to-massive-growth).  They aren't anywhere near Google-scale, but it's waaaay up on their 2011 numbers.  All that said, John's point about a properly done site working for every search engine is still valid.
Comment: Whomever downvoted care to explain why?

Duck Duck Go SEO


Determine what Application or Process is making Authentication request

Question: I have a Server that makes authentication requests once a minute using credentials of an Administrator that has left the organization. The account is disabled. I have made the expected sweep of Services to make sure none are running under the Admin credentials in question.  I have searched the registry for a connection between the user account and a Process, but found nothing. What is the best way to narrow down what Process/Application is making the authentication requests using this disabled account? The Server in question is setup as a VMWare Horizon View Connection Broker, which was setup originally by the owner of the now disabled account making the persistent authentication calls. I see the failed requests on the Domain Controller.  I can capture and review the packets via Wire Shark, but there is no Application/Process information there.  How can I connect the Authentication requests to a process?
Comment: Microsoft Network Monitor will show you the process responsible for the traffic.
Comment: NetMon does show the conversation, but I am not seeing a PID or similar way to connect the conversation with a specific process etc.  I have not played with NetMon much at all, and certainly not in a long time.
Answer: We have a few scripts we run on a regular basis to scrape our DCs for account lockouts. The lockout event usually shows the source IP and name of the failed authentication source.
As a follow up the scripts attempt to check the event log of the source for a failed authentication attempt. Doing so yields the process Id and usually the process name which was used to authenticate.
You say you know which host the failed requests are coming from so you should be able to filter the security event log for "Audit Failure" events. Seeing events that occur every minute might lead you more quickly to an event that will give you what you're looking for.
The problem is that sometimes it's a generic process (e.g svchost.exe). This is where the process ID comes in handy. Task manager should be able to show you the service info for a particular process ID. Failing that, procexp certainly will.
Common places to look (including ones you already mentioned) are:

Services
Scheduled Tasks
Terminal sessions (usually symptomised by periodic occurrences)

EDIT:
My answer makes the assumption that failed login event auditing is enabled by default, it is in our environment. enable auditing of account login events


jquery tooltip with dynamic div

Question: I have in my partial view a link. I want the "tooltip" to be shown if user hovers on that link.
So far I've tried several tooltip jquery plugins but they almost all use title element. I want a div to be shown when user hovers on the link. Additionally, all those plugins use element classes and not ids. I want to use Id because on the page I will have about 10 partial views with different content. Obviously when user hovers on a specific link generated in a specific partial view, the appropriate div should be shown.
Can someone please help me
Answer: You can do this with the jQuery qTip2 plugin.
Answer: qTip2 - http://craigsworks.com/projects/qtip2/demos/ - this plugin is the best one and can be customized in many different ways (including your idea).
btw. I would not use the same id for more then one element as this is not recommended. I would use something like data-id="commonName" or add another class like this class="existingClass anotherClass yourClassTooltip" as its a standard.

jquery tooltip with dynamic div


Show infos only to the author in the author.php

Question: I need to be able to show some informations only to the author in his profile viewable in the front end, for istance I need to add a text under the avatar that only the author, if logged in, can see.
This text will inform them that they can change the avatar anytime by adding it in their profile page...
I could also add some more details...
Is there a way to achieve this?
Thanks!
Comment: Nothing at all! I've been searching on Google and here too with no luck. I guess everything is related to author_name, if he/she is logged than I show a text or anything else if another author is logged in but has a different name then the text is hided.
I've no clue...
Comment: Not the name, but rather the ID. Have posted an answer that should hopefully help you get started.
Answer: You can check who the current user is and whether they have the same ID as the user that is being viewed.
global $current_user
wp_get_current_user();

if(the_author_meta('ID') === $current_user->ID) :
    // Add your code here...
endif;

See these Codex pages for more information -

wp_get_current_user()
the_author_meta()
Answer: This one works for me...
    <?php
    global $current_user;

    get_currentuserinfo();
    if (is_user_logged_in() && (current_user_can('edit_others_posts') ||
    $current_user->ID == $post->post_author) ) {my text goes here');
    }
    ?>


Doppler effect of sound in any general direction and speed

Question: In my high school, I have been taught about doppler effect in sound, in which both source and observer are moving in same line. But I was thinking that what if these bodies were moving in any possible direction, or if these bodies path were some curve, function which was dependent on any set variables. Is there any elegant formula for this? How to derive that formula?
Answer: For simplicity, let us assume the observer is at rest, and we will consider two scenarios to see where it comes from. In scenario one, the sound source is moving towards the observer at a speed $v$ and emits sound at a frequency $f$. Thus between every cycle, the source moves a distance $v/f$ and the wavelength gets shortened by this amount to: $\lambda'=\lambda-v/f=\frac{c-v}{f}$. The frequency of the sound heard by the observer is thus:
$$f'=\frac{c}{\lambda'}=f\frac{c}{c-v}$$
Here $c$ is the speed of sound. Now suppose the source is moving directly perpendicular to the observer. In a very small time interval, the distance between the source and the observer is going to be constant and thus the wavelength will not be shifted.
We can now recognize that we can break up any path into two components, one parallel and one perpendicular to the line connecting the observer and the source. We then only have to consider the parallel component of velocity. In general, the doppler effect will be:
$$f'=f\frac{c}{c-v_\parallel}$$


What is a resonance element?

Question: I'm looking at a horn antenna and why its a good addition to a waveguide. I've read that the horn can operate at a wide range of frequencies since it has no resonant element. But I can't find a good description of what a resonant element is in this application.
Comment: "element" here just means a "part". It means no part of the horn is resonant at any particular frequency.
Answer: In this context, a resonant element would be a chunk of the system that possesses a substantial quantity of impedance (either capacitance or inductance), different from that of the system as a whole. So if the horn had a local swelling or constriction somewhere along its length, the impedance of that segment would not match that of the horn inlet or outlet, and reflections would occur.
By the way it is not strictly true that a horn has no resonant elements in it. It has both inductance and capacitance contained in each little element of its length- however, by smoothly tapering the horn the impedance change from the throat to the exit of the horn is made gradual and the horn thereby becomes a transformer which matches the impedance of the waveguide to that of free space.

What is a resonance element?


Rebuild linux raid array?

Question: I'm going to be building a media server soon and I want to know how hard it would be to rebuild an array in the event of an ssd failure. Here's what I'm doing. I'm going to have a 128GB SSD boot drive running Linux and then I'm going to have two 6TB drives in raid 1. In the event the SSD dies and I lose my configuration how hard will it be to rebuild the array? Should I just stay away from the SSD boot drive? I'll be doing a kernel raid with mdadm. Thanks.
Comment: ditch the ssd boot drive; it is of no benefit to a media server.
Answer: The raid configuration is stored on the raid devices themselves. You could take your RAID drives out of that computer and put them into any computer and mdadm would be able to start the RAID off them. Problems start when the metadata on the drives themselves is damaged.
You could include your SSD in the RAID 1, using 128G on the HDDs and write-mostly. You'd still get SSD read performance but HDD write performance off such a RAID. On the upside you'd survive SSD failures.
For full SSD performance, just make backups. (You need them anyway).
Comment: Well I feel stupid. I thought the config was stored on the OS drive. So that answered that.
Comment: The configuration on the OS drive is usually limited to assigining the UUID of the RAID to a specific `/dev/mdX` number. It usually also contains a mail adress to notify you of RAID failures. By itself, it is not sufficient to actually access the RAID data.

Rebuild linux raid array?


What do you call a person who has an interest to be a lecturer or professor?

Question: If someone has interest (means that they are doing something to achieve that) in being an academic, such as a lecturer for a university, if that person is having educational qualifications which are suitable for that lecturer position and if that person has not become a lecturer yet and if his/her profession is something else now, what is the best word to call that person? Can he/she be called as academic enthusiast?
Answer: Someone who has set a goal and is actively working towards it is aspiring to (toward?) said goal.

as·pire (verb) direct one's hopes or ambitions toward achieving something.
"we never thought that we might aspire to those heights"
source Merriam-Webster

While used with a wide range of aspirations, a common use is applied to struggling actors or artists.
Answer: You can use that phrase, though I'd recommend you do that among friends and not on job materials. My answer will address commonly recognized titles within academia.
There is a term I've encountered at conferences for people who are not affiliated with a university but who do academic research: independent scholar. This substitutes for their affiliation, but it also serves as an ad hoc position title. They even have their own organizations, like the National Coalition of Independent Scholars.
While there is not necessarily a sense that independent scholars aspire to be university professors (some do, some don't), it would be preferable to academic enthusiast or aspiring academic in many job-related contexts. University departments are often looking to hire graduate students or post-docs as faculty. The title enthusiast sounds comparatively nonchalant and amateur compared to those positions, and aspiring sounds hopeful but insubstantial. (OK, so you aspire. What are you doing to get there?) At least in the US, Canada, and UK, hiring committees show a strong bias towards people who are currently doing the work they would be hired for in some way. This bias has led to phrases like "publish or perish" to describe the expectation of academic publishing to get or keep a job. Because hiring committees expect current competency and not hopefulness, I recommend avoiding aspirational language in any job materials or portfolios.
In comparison, independent scholar isn't a perfect term, but accompanied with a publication history it would demonstrate that the prospective applicant is serious about their work. Other terms that might be used include prospective faculty (used by several university websites) and faculty candidate (often applied internally by universities to applicants for faculty positions; also used generally as a label for people on the faculty job market). In other words, I recommend picking explanations that signal how you're one step away from the next position.


How to track a scene properly?

Question: I've recorded this scene in 1080p60fps, and I cannot for the life of me get a solve error of below 2. I've got the focal length set to auto, so I'm not sure what's going on. I've done motion tracking in Blender before and it worked out well, but I seem to be getting a bad track.
Comment: This may help: http://blender.stackexchange.com/questions/42329/how-can-i-get-better-results-when-doing-camera-motion-tracking
Answer: I was pretty easily getting a solve error of 0.81, so there's nothing wrong with your footage:

So I bet you don't use your tracking properly. I just use a defined range of frames for the Solve as you can see in my screenshot which has lots of camera perspective shift. Then I used the "Detect Features" function to let Blender automatically track some points and I only erased those with erratic spikes in the Graph editor view. I added a few more markers manually to align the floor and origin as well as the axises. After I let Blender redefine Focal Length and K1 once I already got a pretty decently low Error. In the end it adjusted the Focal length to 32.6210899.
Just follow the great Track, Match, Blend! tutorial to understand the common way of how to achieve a good result.

How to track a scene properly?


normalizing euler angles rotation vector

Question: I need to display the rotation in Euler angles of an object's certain axis.
I am aware that retrieving the rotation of an object in Euler angles gives inconsistent results, some of which can be solved by simply using modulo 360 on the result. however one permutation that unity sometimes does when assigning a vector with the value of "transform.localRotation.eulerAngles" is instead of retrieving the Vector3 "V", it retrieves "(180, 180, 180) - V".
to my understanding, "(180, 180, 180) - V" does not result in the same real world rotation as V, unlike "(180, 180, 180) + V" which does leave the actual rotation unaffected.
what is the explanation for the phenomenon, and what is the best way of normalizing an Euler angles rotation vector assuming I know the desired and feasible value of one of its axes? (for example, to normalize it such that all of it's values are mod 360 and it's Z axis equals 0 assuming it does have a representation in which Z = 0)
Comment: "one permutation that unity sometimes does when ... " - can you quote the source for this?
Answer: I don't know about the first part of the question (it is different enough to be its own question imo) but I can answer your second one.
So, you have these inputs :
Quaternion desiredRotation;
float knownZ;

And you're trying to find Vector3 eulers where eulers.z is approximately knownZ and Quaternion.Euler(eulers) == desiredRotation.
Here's the procedure I would use:

First, determine the up direction rotated by desiredRotation and the up and right direction rotated by a roll of knownZ:
Vector3 upDirEnd = desiredRotation * Vector3.up;

Quaternion rollRotation = Quaternion.Euler(0,0,knownZ);
Vector3 upDirAfterRoll = rollRotation  * Vector3.up;
Vector3 rightDirAfterRoll = rollRotation * Vector3.right;

We know the local up direction after desiredRotation is applied and that the only thing that can adjust the up direction after the roll knownZ is applied is the rotation done by the euler pitch component. So, if we can calculate the angle from upDirAfterRoll to upDirEnd as measured around the rightDirAfterRoll axis...
float determinedX = Vector3.SignedAngle(upDirAfterRoll, upDirEnd, rightDirAfterRoll);
// Normalizing determinedX
determinedX = (determinedX + 360f) % 360f;

...we can determine the x component of eulers!
Then, we do the same with the yaw component of eulers to make the new forward direction line up with the end forward direction:
Vector3 forwardDirEnd = desiredRotation * Vector3.forward;

Quaternion rollAndPitchRotation = Quaternion.Euler(determinedX, 0, knownZ);
Vector3 forwardDirAfterRollAndPitch = rollAndPitchRotation * Vector3.forward;
Vector3 upDirAfterRollAndPitch = upDirEnd; // unnecessary but here for clarity

float determinedY = Vector3.SignedAngle(forwardDirAfterRollAndPitch, forwardDirEnd, upDirAfterRollAndPitch );
// Normalizing determinedY
determinedY = (determinedY + 360f) % 360f;

Vector3 eulers = new Vector3(determinedX, determinedY, knownZ);

To ensure that the given quaternion can be made with the given component, you could check if the axes given to SignedAngle actually can rotate the input vector to the target vector, or you can just compare the calculated eulers and the given quaternion:
Quaternion fromEuler = Quaternion.Euler(eulerAngles);

if (fromEuler==desiredRotation)
{
    // use eulerAngles here
}
else
{
    // component and quaternion incompatible
}

Hopefully that helps.
Answer: I'm not quite sure I understand your question correctly, but the euler angles just represent the angles of 3 rotations applied around the 3 axis in a specific order, right? So why would you normalize it by adding 180 everywhere? You should bring each angle individually into the range 0-360 by modulo-ing them.
Your question seems to imply that you can obtain any orientation by only rotating around two axis instead of three... is that what you are trying to achieve?
Using quaternions could possibly help you, in fact an orientation can be defined with just 4 scalar values: an axis and an angle
Comment: it's not me who is adding 180 everywhere. since a mapping from Quaternions to Euler angles isn't injective, Unity may give different Euler angle vectors for the same quaternion, I am looking for a way to overcome that.
Comment: maybe this helps? https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Quaternion_to_Euler_Angles_Conversion


how to play a sound file using php script only

Question: please tell me how to play a sound file(.wav) using php script. I need to get the values from DB and Depending upon the values i should play a sound file. thanks in advance.iam using linux operating system.
Comment: Where do you want the sound to play? Do you want it to play client-side, in the browser, or are you writing scripts to execute interactively server-side?
Comment: It wouldn't be possible to play an audio file using /pure/ PHP on neither the client nor server side anyway.
Answer: PHP is only a processing language, it cannot play audio for the user,
It can display HTML/Javascript code that will play the wav sound though.
Answer: You need to embed player in HTML, if you have to do it dynamically using PHP, do something like this...
$myAudioFile = "myAudiofile.wav";
echo '<EMBED SRC="'.$myAudioFile.'" HIDDEN="TRUE" AUTOSTART="TRUE"></EMBED>';

Update:
As per the new HTML5 standard we can use the built-in audio player
$myAudioFile = "myAudiofile.wav";
echo '<audio autoplay="true" style="display:none;">
         <source src="'.$myAudioFile.'" type="audio/wav">
      </audio>';

Answer: And on Ubuntu Linux install something like play
sudo apt install sox

(from https://askubuntu.com/a/920542/355766)
Then in php
exec('/usr/bin/play /path/to/audio.wav');

Answer: On Windows we can use powershell:
exec('powershell -c (New-Object Media.SoundPlayer "C:\Windows\Media\notify.wav").PlaySync();');


Lock layers on layers panel

Question: Is there any way to lock layers in QGIS to prevent them from being accidentally deleted like you can in Illustrator or CAD?
Answer: Project / Properties / Data sources and then you can fine-tune per layer the rules you want to "protect" your project.
Comment: Perfect thankyou. I have to say it would be easier if a padlock symbol was applied next to the "eye" icon on each layer. Also calling it "required" isn't what would call logical.

Lock layers on layers panel


Appending data to the existing database

Question: I've got a quick question , that would be great if anyone can help me with this problem:
I have 2 SQL 2012 databases A & B , they are both Identical same tables and same structures as well.
Data is inserted into DB A and on regular schedule I need the data to be inserted into DB B automatically and APPENDS to the existing data in DB B,after that, data in DB A gonna deleted and the whole process starts over again with new records.I couldn't preform this action using any methods of replication because once the data is deleted from DB A same thing gonna happen in DB B.
On the other hand these data contains FK pointing to other tables in the database so if the first problem solves and it starts APPENDING data to the existing data on DB B all these FK should be updated with new values in DB B.
Do you guys have any solution using SQL itself or any other tools?
Comment: Are these databases on the same server or separate ones?
Answer: You can use Transactional Replication, but you have to exclude the DELETEs. Just replicate INSERTs and UPDATEs.
Here's a related article.
Answer: We had a similar issue. I created procedure spExportAuditLog to resolve this issue. It can be run as often as desired, for us, to export data to database B from A--which is on a different server.
The biggest concern for us was borging production database A by performing too much I/O on it all at once. So we chunked the records a batch at a time and used waitfor delay '000:00:10' to pause this process to allow other activity to occur.
Also, we absolutely wanted a complete rollback should any issues occur. Hope this helps you roll your own. Also, I detest cursors so I created my own while/end loop instead.
We absolutely did NOT want the hassle of replication. Hope this helps you roll your own!
<code>Create proc [dbo].[spExportAuditLog]
as
set nocount on
declare @errorvar int,@max int, @min int, @watermark int, @batch int, @beforecounter int, @aftercounter int, @AuditCounter int, @NewAuditCounter int, @errortext varchar(255)
select @beforecounter=0
select @aftercounter=0
select @NewAuditCounter = count(*) from newaudit.dbo.auditlog
print 'NewAudit AuditLog Count Before'
print @NewAuditCounter
print 'Audit AuditLog Count Before'
select @AuditCounter=count(*) from [<your linked server here>].audit.dbo.auditlog
print @AuditCounter
select top 1 @max=ID from newaudit.dbo.auditlog where  datediff( minute, datestamp,getdate()) <= 1440 order by ID
select @min=min(ID) from newaudit.dbo.auditlog

Set XACT_ABORT on
select @batch =100000
select @watermark=@min
while (@watermark <=@max)
begin
        begin transaction
        insert into [<your linked server here>].audit.dbo.auditlog(X1, X2, X3, X4, X5, X6, X7, X8, X9)
        select X1, X2, X3, X4, X5, X6, X7, X8, X9
                     from newaudit.dbo.auditlog where X1 between @watermark and @watermark+@batch and X1<= @max order by id
                     if @@ERROR <> 0 select @errorvar=@errorvar+1
        delete from newaudit.dbo.auditlog where X1between @watermark and @watermark+@batch and X1<= @max
        if @@ERROR <> 0 select @errorvar=@errorvar+1
        if @errorvar > 0
        begin
            select @errortext= 'ROLLBACK!! Problem with error IDs between:' + CONVERT(varchar(50), @watermark) + ' and ' +CONVERT(varchar(50), @watermark+@batch)
            print @errorText
            rollback
            select @errorvar=0
        end
        else commit
        select @watermark = @watermark+@batch +1
        waitfor delay '000:00:10'
end
select @NewAuditCounter = count(*) from newaudit.dbo.auditlog
print 'NewAudit AuditLog  Count After'
print @NewAuditCounter
print 'Audit AuditLog Count After'
select @AuditCounter=count(*) from [<your linked server here>].audit.dbo.auditlog
print @AuditCounter
</code>

Appending data to the existing database


If every five point subset of a metric space can be isometrically embedded in the plane then is it possible for the metric space also?

Question: Let $X$ be a metric space with at least $5$ points such that any five point subset of $X$ can be isometrically embedded in $\mathbb R^2$ , then is it true that $X$ can also be isometrically embedded in $\mathbb R^2$ ?
Comment: I know nothing about this, could you explain a little why you might expect this to be true?
Comment: @David C. Ulrich : You had written a long and involved answer , I thought of reading it today , but I see you have deleted it , was there some serious error in it ?
Comment: @Jose27 : Well , the five in the question I just arbitrarily chose , I know that the answer to the question is in negative if we wanted the real line instead of the plane ; but in plane I could get no where with it , so I asked
Comment: The answer was simply wrong, as @achillehui pointed out. Yesterday I didn't see how to salvage it, this morning I believe I see how to fix it. Having screwed up once I'm going to check things carefully before posting the fixed version - stay tuned. (I "proved" something about embedding in $\Bbb R^n$, by induction. My version of the case $n=1$ was wrong, but having been given the correct version for $n=1$ I believe the induction is ok, although there's one new lemma needed.)
Comment: Btw yes, $5$ is the right number for $\Bbb R^2$.
Comment: Answer undeleted.
Answer: "Embeddings" below are isometric; $(X,d)$ is a metric space.
In fact $X$ can be embedded in $\Bbb R^n$ if and only if every subset of $X$ containing no more than $n+3$ points can be embedded in $\Bbb R^n$. Thanks to @achillehui for noticing that the first version of this post was wrong, for stating the correct version of the result, and for telling us it's due to Menger (Untersuchungen über allgemeine Metrik, Mathematische Annalen, 100:75–163, 192) way back in 1928. Edit I've finally seen how to give an example showing that $n+3$ is best possible. See the bonus section at the bottom.
The proof is by induction on $n$. You may notice that the structure of the proof for $n=1$ is identical to the structure of the induction step. In fact the case $n=1$ could be derived by induction from the case $n=0$. That might involve some head-scratching; it seems best just to give the case $n=1$ separately.
In the case $n=1$ various plausible but not quite trivial lemmas can be replaced by the following triviality: If $X$ can be embedded in $\Bbb R$, $a,b$ are two distinct points of $X$, $x,y$ are two distinct points of $\Bbb R$, and $|x-y|=d(a,b)$, then there is exactly one embedding $f:X\to\Bbb R$ with $f(a)=x$ and $f(b)=y$. (For existence, replace the given embedding $g$ by $\pm g+c$. For uniqueness, note that if $|f(a)-t|=|f(a)-s|$ and $t\ne s$ then $f(a)=(s+t)/2$, and  similarly for $f(b)$.)
Theorem 1. $X$ can be embedded in $\Bbb R$ if and only if any four points of $X$ can be embedded in $\Bbb R$.
Proof: For the less trivial direction: We may assume $X$ has more than one point. Choose $p,q\in X$ and define $f(p)=0$, $f(q)=d(p,q)$.
Suppose $r\in X$, $r\ne p,q$. The hypothesis and the comment above (with $\{p,q,r\}$ in place of $X$) shows that there is a unique embedding $g$ of $p,q,r$ with $g(p)=f(p)$ and $g(q)=f(q)$. Define $f(r)=g(r)$.
We have defined $f:X\to\Bbb R$ such that $|f(r)-f(p)|=d(r,p)$ and $|f(r)-f(q)|=d(r,q)$ for every $r$. We are done if we can show that $|f(r)-f(s)|=d(r,s)$ for $r,s\notin\{p,q\}$. As above there is a unique embedding $g$ of $p,q,r,s$ in $\Bbb R$ with $g(p)=f(p)$ and $g(q)=f(q)$. Uniqeness of the embedding of $p,q,r$ shows that $g(r)=f(r)$. Similarly $g(s)=f(s)$, so $|f(r)-f(s)|=|g(r)-g(s)|=d(r,s)$. QED.
The case $n>1$ requires a few preliminaries.
Lemma 0. Suppose $x_1,\dots,x_N,y_1,\dots,y_N\in\Bbb R^n$ and $|x_j-x_k|=|y_j-y_k|$ for all $j,k$. Then there is an isometry $f:\Bbb R^n\to\Bbb R^n$ with $f(x_j)=y_j$.
Proof: Let $v_j=x_j-x_0$, $w_j=y_j-y_0$. We have $|v_j|=|w_j|$ and $|v_j-v_k|=|w_j-w_k|$. The parallelogram law shows that $|v_j+v_k|=|w_j+w_k|$, so that $v_j\cdot v_k=w_j\cdot w_k$ by polarization. Hence $$\left|\sum t_jv_j\right|=\left|\sum t_jw_j\right|.$$In particular $\sum t_jv_j=0$ if and only if $\sum t_jw_j=0$, so that there exists a linear map $T:span(v_j)\to span(w_j)$ with $$T\left(\sum t_jv_j\right)=\sum t_jw_j.$$Now $T$ is evidently an isometry; extend $T$ to an orthogonal map from $\Bbb R^n$ to itself by mapping the orthogonal complement of $span(v_j)$ to the orthogonal complement of $span(w_j)$. QED.
Definition We say $F\subset\Bbb R^n$ is coplanar if there exist $c\in\Bbb R$ and $v\in\Bbb R^n$ with $v\ne0$ such that $x\cdot v=c$ for every $x\in F$.
Lemma 1. Suppose $x_1,\dots,x_N\in\Bbb R^{n}$ and $\{x_1,\dots,x_N\}$ are not coplanar. If $|x_j-y|=|x_j-z|$ for all $j$ then $y=z$.
Proof: Saying $|x_j-y|=|x_j-z|$ is the same as $(x_j-\frac{y+z}{2})\cdot(z-y)=0$; if $y\ne z$ this says that $x_1,\dots,x_N$ are coplanar. QED.
Lemma 2. Suppose $F\subset\Bbb R^n$ is not coplanar. Then $F$ has a non-coplanar subset containing exactly $n+1$ points.
Proof: Fix $x_0\in F$. The set $\{x-x_0:x\in F\}$ spans $\Bbb R^n$, so it must contain a basis. QED.
Theorem 2. $X$ can be embedded in $\Bbb R^n$ if and only if every subset of $X$ containing no more than $n+3$ points can be embedded in $\Bbb R^n$.
Proof: The proof is by induction on $n$. The case $n=1$ is exactly Theorem 1 above. Suppose then that the theorem holds for embeddings into $\Bbb R^n$, and suppose that every subset of $X$ containing no more than $n+4$ points can be embedded in $\Bbb R^{n+1}$.
We want to show that $X$ can be embedded in $\Bbb R^{n+1}$, so we may assume that $X$ cannot be embedded in $\Bbb R^n$. By induction there exists $S \subset X$, with $|S|\le n+3$, such that $S$ cannot be embedded in $\Bbb R^n$. By hypothesis there exists an embedding $f:S\to\Bbb R^{n+1}$. Since $S$ cannot be embedded in $\Bbb R^n$, the image $f(S)$ cannot be coplanar. Applying Lemma 2 we see this: There exist $p_1,\dots,p_{n+2}\in X$ and an embedding $f$ of $p_1,\dots,p_{n+2}$ in $\Bbb R^{n+1}$ such that if we set $x_j=f(p_j)$ then $x_1,\dots,x_{n+2}$ are not coplanar.
Suppose that $q\ne p_1,\dots,p_{n+2}$. The hypothesis and Lemma 1 show that there is exactly one $x\in\Bbb R^{n+1}$ with $|x-x_j|=d(q,p_j)$ for all $j$; define $f(q)=x$.
We have defined $f:X\to\Bbb R^{n+1}$. To show that $f$ is an isometry it is enough to show that if $r,q\ne p_1,\dots p_{n+2}$ then $|f(r)-f(q)|=d(r,q)$. The hypothesis shows that there is an embedding $g:\{r,q,p_1,\dots,p_{n+2}\}\to\Bbb R^{n+1}$, and now Lemma 0 shows that there exists such a $g$ with $g(p_j)=f(p_j)$. Now Lemma 1 shows that $g(r)=f(r)$ and $g(q)=f(q)$, so that $|f(r)-f(q)|=|g(r)-g(q)|=d(r,q)$. QED

Bonus In fact $n+3$ is best possible.
In the first version of this answer I "proved" Theorem 2 with $2n+1$ in place of $n+3$. The induction was ok, more or less the same as above; the problem was that I'd "proved", largely on the basis of wishful thinking, that Theorem 1 was true with $3$ in place of $4$. Thanks again to @achillehui for pointing out that was wrong.
I think the simplest way to show that $4$ is best possible for $n=1$ is this: Let $X$ consist of the four points $(0,0),(0,1),(1,0),(1,1)$, with the $\ell^1$ metric (that is, $d(x,y)=|x_1-y_1|+|x_2-y_2|$). It's easy to see that any $3$-point subset of $X$ embeds in $\Bbb R$, and that $X$ itself does not.
That example actually generalizes to $n\ge1$, but when it's presented that way it's not so clear how. I'm going to give a fairly careful description of an example showing that $5$ is best possible for $n=2$. I claim that it is clear that the example below generalizes to show that $n+3$ is best possible for $n\ge2$, and I leave as an unimportant exercise to show how the example for $n=1$ above is actually the same construction as what I give for $n=2$, if you look at it right.
Let $a_1,a_2,a_3$ be the vertices of an equilateral triangle in the plane. Let $c$ be the center of that triangle. Let $X=\{a_1,a_2,a_3,c,c'\}$, where $c'$ is something else. Define a metric on $X$: First, define the distance between any two points of $\{a_1,a_2,a_3,c\}$ to be the euclidean distance as points in the plane. Define $$d(c',a_j)=d(c,a_j)$$and set $$d(c,c')=2h,$$where $h$ is the perpendicular distance from $c$ to one of the sides of our triangle. No need to scratch your head over the triangle inequality, that will follow when we show that any $4$-point subset of $X$ can be embedded in the plane.
If we remove $c'$ from $X$ what remains is a subset of the plane. If we remove $c$ we can set $f(c')=c$ to embed the remaining four points.
Suppose we remove $a_3$. Map each of the points $a_1,a_2,c$ to itself. Map $c'$ to the point on the other side of the segment $[a_1,a_2]$, so we get a rhombus with diagonals $[a_1,a_2]$ and $[c,f(c')]$.
So any four points of $X$ can be embedded in the plane. But $X$ itself does not embed in the plane; if this is not clear it can be proved from Lemma 1 and Lemma 0 using arguments as above.
So $5$ is best possible for $n=2$. And I assert again that the same construction shows that $n+3$ is best possible for $n\ge2$; if anyone wants to write a formal description go for it. (For $n=3$ we start with the vertices and center of a regular tetrahedron and add a sort of duplicate of the center point...)
Comment: @achillehui Finally saw how to show $n+3$ is best possible; thought you might be interested. Thanks again...
Comment: nice, it is good to see a proof that $n+3$ is best possible.
Comment: @DavidC.Ullrich : Sorry to bother you after such a long time but I cannot understand the preliminary remarks before Theorem 1 , about the existence-uniqueness of $f$ ; could you please elaborate how do you construct such an $f$ and why it is unique ?
Comment: @user228169 I can try to be a little more explicit, but I fear much of what I write is going to be just repeating what I wrote. If the following does not do it for you try to be more explicit about exactly what steps you don't follow. In that paragraph we are given an embedding $g:X\to\Bbb R$. We are given $a,b\in X$ and $x,y\in\Bbb R$ with $|x-y|=d((a,b)$. Now since $|x-y|=|g(a)-g(b)|$ it's possible to choose $\pm$ and $c$ so that if we set $f=\pm g+c$ then $f(a)=\pm g(a)+c=x$ and $f(b)=\pm g(b)+c=y$. (Consider two cases, depending on whether $y-x$ and $g(b)-g(a)$ have the same sign.) [...]
Comment: @user228169 That gives existence of an embedding $f$ with thhe stated property. For uniqueness: Suppose $f$ and $f'$ are embeddings with the stated property. Suppose $c\in X$. Then $|f(c)-x|=|f'(c)-x|$ and $|f(c)-y|=|f'(c)-y|$. if $f(c)\ne f'(c)$ this would imply that $x=(f(c)-f'(c))/2$ and $y=(f(c)-f'(c))/2$, so $x=y$, contradiction.


How does sklearn random forest use features in the form of 1D/2D array instead of a single value during splitting at a node?

Question: For the training of random forest model in sklearn, I understand that for features of a single value, a threshold for splitting the data is determined by minimizing the Gini impurity or maximizing information gain. However, how does the split happen when the given feature is an array of values (e.g. an image with calculated edges, etc.). Is it just calculating a thresholding value for each element of that array (i.e., each pixel)? Or are there any considerations of the relationships between different elements across the array like it is with convolutional neural networks?
Answer: With RandomForest as it exists in scikit-learn, and practically all other implementations, there is no way to input structured data - be it 1D sequences or 2D matrices. All data must be transformed into a set of feature columns before passing to fit()/predict(). And the RandomForest method is unaware of any relation between these feature columns.
This typically means that to perform well on images or sequences, feature engineering must be performed in a previous step of the pipeline, to extract meaningful features that the classifier can work with.


What is a good metric for comparing a single value to a distribution?

Question: I'd like to compare single values from one distribution to another distribution, effectively transforming the second distribution in such way, that its values reflect both datasets simultaneously, i.e. the values of the second distribution correspond to some sort of normalized difference between the initial values and the first distribution. I thought about using z-score or one sample effect size (Cohen's D) for this task, but I'm unsure if these approaches are justified.
Answer: The z-score could help you understand how far away a data point in one distribution is from the mean of that distribution, in terms of standard deviations. This can be useful for comparing individual data points across distributions and assessing the significance of the difference.
Cohen's d, on the other hand, provides a standardized measure of the effect size between two distributions. It indicates the difference between the means of the distributions in terms of standard deviations. It's particularly useful for quantifying the magnitude of the difference between two distributions.
If your goal is to transform the second distribution to reflect a normalized difference between the initial values and the first distribution, using Cohen's d might be more appropriate. This is because Cohen's d specifically focuses on the difference between means, and it will give you an effect size that can help you understand the practical significance of the difference.Keep in mind that both z-score and Cohen's d have their limitations
Before deciding which approach to use, consider the characteristics of your data.
Comment: Yes, Cohen's D focuses on the difference between means, but if you're comparing a value to a distribution, then you only have mean value of the first distribution. What would be an assumption here - to treat a single value from the second distribution as mean of that distribution?
Comment: When comparing a single value to a distribution, assuming that the single value represents the mean of the second distribution could be a reasonable approximation for the purpose of calculating Cohen's d. Imagine you have a single value and a group of values (a distribution). If you want to compare the single value to the group, you can sort of pretend that the single value is the "average" of that group. This can help you calculate Cohen's d, a measurement that tells you how different the single value is from the group.


Changing background color of AxTOCControl

Question: I'm having trouble finding a way to change the background color of the AxTOCControl.
Is there a way to do this?
I'm using ArcGIS Engine 10 C# and VS2010.
Answer: Nope, we could not find a way to do it. See my thread How to set background color in TOC? on the ESRI forum.

Update: We could not find a way to
  change the color of the TOC. So we
  change the background of the swatch
  instead. We did that by looping
  through layers casting to ILagendInfo
  and updating the bitmap in the
  IPictureMarkerSymbol, converting all
  pixels with background color to gray
  making the white symbols to show up.

Might be a good Idea to vote on this ArcGIS Engine Idea
Answer: my guess is the first child hwnd under the main AxTocControl's hwnd is the treeview itself (you may want to try the top level one as well). You can use the following (unchecked) code to change a treeview's background color
<code>[DllImport("user32.dll")]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
static int TV_FIRST = 0x1100;
static int TVM_SETBKCOLOR = (TV_FIRST + 29);

private void ChangeBGColor(IntPtr tv_hwnd, Color color)
{
    int c = System.Drawing.ColorTranslator.ToWin32(color);
    SendMessage(tv_hwnd, TVM_SETBKCOLOR, IntPtr.Zero, new IntPtr(c));
}
</code>


How to display Grouped product without using image and other details..?

Question: I have one Bazaar store to develop in Magento. I have created grouped product, with simple product. As per requirement I want to display only Product name and list of product(Which I added in grouped product), Other details like image,and tags,etc don't want to display. For this What things I need to do. Which file I need to override or need to create a new module or need to implement any other technique. Please suggest me what way I follow.
Answer: If you are talking about the main product page view (not the list view, i.e. category or search) then you need to look at the catalog/product/view.phtml template file.
Here you can customise how the product is displayed and if you need to test for a grouped product you can use
if($_product->getTypeId() == 'grouped')

And then customise how you want to display the grouped product.
i.e.
<?php if($_product->getTypeId() == 'grouped'): ?>
    //grouped product data
<?php else: ?>
    //other product data
<?php endif; ?>

You will also need to customise the child html in catalog/product/view/type/grouped.phtml for the simple products of the grouped products in a similar way.
Comment: Please can you explain me more..Because I saw view.phtml file. If I comment out long description. I think it might be reflected on simple product. So how should I customize I am not getting an idea.
Comment: yes, so for product data you don't want to show for grouped products you need to test for a grouped product and then modify the html as you wish. I have updated my answer.
Comment: Please can you provide me one sample code with few content on Grouped product..?
Comment: This way I successfully remove the description and other details .Now only image is remains. How should I remove it.
Comment: Look in view.phtml where the image html is rendered and do the same product check.
Comment: Ok let me check..
Comment: Thanks a lot paj for your instant reply..so I can solve it immediately..


Was ist der Unterschied zwischen gestalten und bilden?

Question: Können Sie einige Beispiel geben? Liegt der Unterschied bei der Bedeutung oder der Benutzung?
Answer: The difference of these 2 expressions is as well in their meaning as in their use: first you have to form (bilden -> build) something or someone  before you can arrange or transform it -> (aus)gestalten.
Both terms have the meaning of shaping and forming but Bildung is often used as synonym  of education and schooling, while Gestalten as noun e.g. is the titel of a subject for working (textiles Gestalten, bildnerisches Gestalten (drawing), technisches Gestalten. these are all new terms for the ancient subject "Werken".)
Bilden is developed from an inner image (Bild),  gestalten is the active process of arranging or giving a shape to an existing, exterior objects group or things.
Look up also: Bildung / Gestaltung, Ausbildung / Ausgestaltung.
comparing the derivated nouns combined  with the prefix Aus- the difference becomes clearer:
Ausbildung:
training, instruction, education, training, drill, development, training,
 formation, growth, formation, development, design, construction
Ausgestaltung:
development, arrangement, organization, decoration


What influence has the distance of the moon on the height of the tides?

Question: As the Moon recedes from the Earth, are the tides getting taller or shorter? If the Moon is, someday, twice as far from the Earth, how many high tides will be there be each day?
Answer: Just imagine there would be no moon at all. Obviously there would be no tides due to the moon. As Dr. Chuck pointed out in the comments, there would still be tides due to the sun, but the tidal forces of the Sun are only about 46% of the moons tidal forces (taken from german Wikipedia about Tides: https://de.wikipedia.org/wiki/Gezeiten).
So the farer the moon is, the smaller the tides get.
The question about the number of tides is a bit trickier:
If the moon is twice as far away from earth, the gravitational force between earth and moon is only $\frac{1}{4}$ of todays. Assuming the moon is still in a circular orbit around earth, its centrifugal force therefore might also be only $\frac{1}{4}$ of todays, and since $F_c \propto \omega^2$ its angular velocity $\omega$ might only be half the speed than today.
If we assume conservation of angular momentum $\vec{L}=\vec{r}\times\vec{p}$ instead, its velocity $v\propto p$ has to be only half of todays value. And since $\omega = \frac{v}{r}$ this would mean that its angular velocity is reduced by a factor of 4. However this would not result in a circular orbit and if you do the calculations for an elliptic orbit, you probably end up with the same factor of 2 as before (just guessing here...).
As others pointed out in theirs answers and dmckee in the comments, both will only have a minor effect on the number of tides. Moon orbits earth roughtly once a month while the earth rotates once a day. Since the moon orbits in the same direction as earth rotates, it actually slows down the speed of tides. So a slower rotating moon would actually result in more tides each day, but the effect would be minor.
Comment: If there were no moon, there would still be tides (albeit smaller) due to the sun.  It is the relative positions of the moon and sun that cause the so called spring tides (when moon and sun are aligned) and neap tides (when they are at right angles).
Comment: The timing of the tides is mostly down to the Earth's rotation. Moving the moon out would barely affect their frequency (which is currently a shade less than twice a day, and would then be a slightly smaller shade less than twice a day).
Comment: True, i`ve edited my answer to make it correct. Still kept the calculation, even if its answer is not that important anymore.
Answer: The number of tides stays just about the same, as the earth turns under the tidal bulges.  On a water earth we would have two tides per day.  Local landforms impact that greatly, varying from place to place.  The tidal force is the difference of the moon's gravity on the near and far sides of the earth.  It falls off as $\frac 1{r^3}$, so the if the moon were twice as far away the lunar tides would be (about) $\frac 18$ as tall.  The solar tides would become the dominant ones, so the total height would not decrease nearly that much.
Answer: The tides will get smaller as the moon moves away having less gravitational effect. As long as there are tides there will be two per day because this is based on the Earths rotation not the moons distance. As the Earth spins the tides rise on the side facing the moon and the opposite side because of gravity. Its these tidal forces along with the Earths spin that's causing the moon to recede.


Ruby on Windows using Ruby irb, and how to set up RoR

Question: I started playing around with Ruby on Windows. I downloaded Ruby and started it with the command line with Ruby.
I typed in irb to the command prompt and it changed to the irb command prompt.
Then I started trying out commands like 1 => 1; and other things, but I got no output. I just go the next prompt. What ta heck am I doing with that? :)
What should I do to make sure I have RoR set up and start creating applications?
Thanks and sorry for the generally confused question.
Comment: are you certain that what you're typing into irb isn't expecting a closing quote?  What you've described sounds like you've typed an unterminated string.
Answer: Although I prefer using Ruby on Rails on a Mac, I have a soft place in my heart for Windows, so I set RoR up on my Windows machine a while back. But be forewarned, you may be setting yourself up for some heartache and pain. In addition to errors and badness, Ruby runs much slower on Windows. I would highly recommend setting up a dual boot or virtual machine with Linux and then putting Rails on your Linux OS instead of trying to set it up on Windows. You can use Windows Virtual PC or something similar if you want to go the virtual machine route.
But, if you still want to stick with Windows, I think one of the easiest ways to get everything installed is to use Wayne Seguin's RailsInstaller. Along these lines, I used Agile Web Development With Rails to help me learn the process of getting Rails set up and to build my first app. Great book.
Hope this helps.
Answer: In irb you can tell if your current line is unterminated doesn't start with >.
irb(main):001:0> "I'm gonna wait
irb(main):002:0" to finish this string"    # The string isn't terminated
=> "I'm gonna wait\nto finish this string"
irb(main):003:0>

But more interestingly in irb it would seem that a semi-colon(;) it won't terminate the line. Since semi-colons(;) inRuby aren't necessary and are just meant to be statement separators. irb won't actually run your statements until you end one without a semi-colon. Also 1 => 1 isn't a valid Ruby statement.
irb(main):001:0> string = ""
  => ""
irb(main):002:0> string << "I'm gonna run this line\n";
irb(main):003:0* string << "Plus this line\n"
  => "I'm gonna run this line\nPlus this line\n"
irb(main):004:0> string << "Semi-colons are not cool in Ruby"
  => "I'm gonna run this line\nPlus this line\nSemi-colons are not cool in Ruby"
irb(main):005:0>

So your problem should be solved by NEVER using semi-colons in Ruby
Also all these examples were run on Windows 7 using Powershell
PS C:\Users\Justin> ruby -v
ruby 1.9.3p0 (2011-10-30) [i386-mingw32]

As Aaron mentioned the best way to get started is probably RailsInstaller. I haven't used it personally, but it looks like it does pretty much everything for you.
I use RubyInstaller and set up my Rails environment myself. RailsInstaller does all that for you.


Weaknesses of a Lich?

Question: What weaknesses does a lich have? I've found a lot about their abilities and strengths, but not their weaknesses.
Answer: In general, they have few specific weaknesses beyond those all undead share. Specific liches can of course have unusual weaknesses.
Since this is for 2e, I recommend looking at Van Richten's Guide to the Lich. It is designed specifically for Ravenloft, but it is generally compatible with almost any of the 2e settings. It goes into background on liches and lays out a number of variations which a DM can use for making custom liches, including unique weaknesses that a particular lich may have.
Of particular note, it suggests that many liches may need to periodically perform elaborate rituals to continue to maintain themselves. Those rituals can be exploited by patient lich hunters because the requirements of the ritual often force the lich to venture forth from their lairs to either acquire substances needed for the ritual itself or to be in the right place at the right time to perform the ritual. In short, they provide an opportunity for adventurers to ambush the lich at a time when the lich is away from its base of power.
Comment: @Relic: Perhaps you could ask in a separate question what general weaknesses undead have in 2e.
Comment: No, I fixed a typo. I think the general undead vulnerabilities are both well known and beyond the scope of my answer. The more specific vulnerabilities in the book are a menu of options for a GM to choose from so they both don't directly answer the question as asked and I'm not too inclined to pull out my book and list the entire menu. Hopefully what I provided helped or someone more inclined to present the list will add it.
Comment: I already looked at the guide. I also feel your answer isn't complete unless you actually list the weaknesses you mention. common for undead and the lich specific since they both apply.
Comment: TimothyAWiseman you still haven't actually listed the undead weaknesses
Answer: The whole process is more about preparation rather than finding a weakness.
A Lich doesn't really have any weaknesses which is part of why they're so terrifying to fight/encounter. If it's something the party stumbled on, they should run, go prepare and then come back. It really comes down to how your party plays it out.
You have to consider what a Lich is: an undead magic user. So it's weaknesses will be related to the defense of it's magic attacks. Silencing and physical attacks are probably best. An issue when fighting a Lich is they sometimes have magic resistance the older they are. In playing, we've had success by using certain magical items (wand of Rock to mud, wand of light for attack/ Rings of protection, spell turning for defense - but remember a ring of spell turning does nothing for area effect spells ie: disintegration).
In one fight, we won because a character (out of desperation) grabbed the Lich and the others just pounded it. By grabbing the Lich and pinning it down, it loses it's ability to cast somantic spells, but you still have to worry about anything verbal or material.
Resources: 2nd Edition players handbook, 2nd Edition DMs guide, Red Wizards - #3 in the Harpers series, or more importantly the *Erevis Cale trilogy.
*The Erevis Cale trilogy illustrates the true power of a Lich, but this one in particular was a master of magic and psionics.
Comment: Would be lovely if you provided the corresponding sources :)
Comment: Resources: 2nd Edition players handbook, 2nd Edition DMs guide, Red Wizards - #3 in the Harpers series, or more importantly the *Erevis Cale trilogy.

*The Erevis Cale trilogy illustrates the true power of a Lich, but this one in particular was a master of magic and psionics.

Weaknesses of a Lich?


Can't change Startup Applications Preferences "Could not save /home/USER/.config/autostart/sideportrait.sh.desktop file"

Question: I'm new to Linux (Ubuntu 20.04 LTS) and I'm having troubles with my monitor setup. Assume for the rest of this post that when I write USER I mean the username I chose during installation (my username is my real name, so...).
I installed the proprietary nVidia driver I needed, and so far seems fine (the games I've tried work), except that my dual monitor setup doesn't save between boots. I have one in landscape in the center, and one in portrait mode to my right.
On startup, Ubuntu thinks my right monitor is landscape, so my mouse moves down instead of right, and all my windows are sideways. I used nVidia X Server Settings to change the settings and it would work but not save between boots. I've tried 'Save to X Configuration File' in two places, /etc/X11/xorg.conf and /etc/X11/Xsession.d/xorg.conf, and neither allow the monitor settings to persist after reboot. I always end up with my right monitor thinking it should be in landscape mode.
I also tried to apply the nVidia settings, then go and change something in Ubuntu's Settings->Display then apply that, and then save to xconfig in NVidia, but it didn't work and I got another problem instead.
The problem I got is the same problem as this user on reddit here, including my monitors looking like theirs did in the screenshots they provide, where their portrait-monitor wasn't used and their main monitor was extra stretched. I followed the directions in the comment chosen as the solution (used arandr to save a .sh, then added it to the Startup preferences), and it works just fine getting my monitors to display correctly, but it also doesn't persist between startups.
Because it's easier than messing with nVidia settings every time, I now just load the .sh file in arandr when I boot up.
Next reboot, I opened Startup Applications Preferences and the new entry I'd added to save my monitor settings wasn't there at all.
So I tried following the directions of the answer on this post here (sudo chown -R [username]:[username] ~/.config and gnome-session-properties; I replaced [username]:[username] with USER:USER because that's what I assumed it meant). I actually tried the second solution first, and it didn't make a difference, so I tried doing the first command and the second but instead of gnome-session-properties I tried sudo gnome-session-properties and then rebooted. Same problem as before - settings didn't change, side monitor thinks it's landscape.
Through some testing I found that if I open Startup Applications Preferences through the menu or the command gnome-session-properties the added command isn't there, but if I open the program through sudo gnome-session-properties the startup command I added is there. Why is that, and how do I get it to actually do something?
Also, when I open Startup Applications Preferences from terminal with just gnome-session-properties and add the desired setting, the terminal gives me:

** (gnome-session-properties:3523): WARNING **: 20:40:59.259: Could not save /home/USER/.config/autostart/sideportrait.sh.desktop file

Despite giving this warning, the startup program looks like it's there before I close it, but when I reopen it, the added setting is gone.
I looked at my files and found that in .config there isn't a folder called autostart - it's a text file, and in the text file the only thing is some stuff about Discord (which also doesn't actually run on startup), despite there being three things in Startup Applications Preferences that are always there - I just don't see them in the autostart file. What's going on here? I've got hidden files visible according to the Files settings, but I don't see an autostart folder.
How do I fix this? I'll run the arandr file every time I reboot if I have to, but I'd rather not.
Answer: I experienced the same issue and found that owner of ~/.config/autostart is root. Thus sudo chown $USER:$USER ~/.config/autostart resolved this problem.


How to get a response to refund request to last.fm?

Question: December 13, 2012, last.fm announced that they would be discontinuing their radio service in several countries on January 15, 2013, and that customers could request a subscription refund. I did so the very same day, because the radio service is 90% of the reason for buying it (the other being the event announcements). On January 16 the last.fm client could no longer play their radio, and I have still not heard a single word from them. Has anyone had more luck with this, and perhaps any tips to get through to them?
Comment: Same for me here. I just started a thread on the assistance forum : http://www.lastfm.fr/forum/85169/_/2200628
Answer: I started a thread on the assistance forum on 26th January.
The answer from a LastFm team member was:

Next week, I believe.

So I guess people will get refund in February.
Answer: After following the advice in @RenaudDumont's thread I posted the following support request:

Username: [removed] Last payment: 19. Sep 2012 Paid for: 12 months'
  subscription [removed] Transaction ID: [removed]
What is the status of my refund? I requested it on 13 December 2012
  and I never heard anything back.

Anybody else having this problem should probably do the same. I wonder how many thousand they've effectively swindled so far...


Can I make a postgreSQL redistributable?

Question: I dont know about open source, I read some licenses but I want to know about your experiences about it, my goal is write my software and make a redistributable with postgreSQL, can I do it without pay any fee? I read something about MySQL, that you need pay a fee if you make a redistributable of this in your software release.
Comment: Are you just distributing an application that *uses* PostgreSQL, or are you *bundling* PostgreSQL with your application?  Which PostgreSQL client library / driver are you using?
Comment: my software uses PostgreSQL and I want to bundling it with my installer, my software is writed in C# and I use ADO.NET
Comment: Npgsql from http://npgsql.projects.postgresql.org/
Answer: I am not a lawyer, and this does not constitute legal advice.
PostgreSQL, including the Npgsql driver you are using, is licensed under the terms of the PostgreSQL license.  The primary clause of the license is:

Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.

Bundling PostgreSQL and the driver with your software is fine.  The license is very similar to the MIT license, which boils down to "do whatever you want, just include a copy of the license text and don't misrepresent ownership or omit the copyright notices."
This is one of the primary reasons I prefer PostgreSQL over MySQL for new development; the official MySQL client libraries are licensed under the GPL, which means you need to purchase a commercial license to distribute proprietary code that uses those libraries.
Comment: The paraphrase of the license Tom Lane, one of the core developers often uses is "Do what you want with it, just don't sue us."
Answer: We are using postgreSQL in an app we are developing, and we couldn't see any costs involved for deploying the app with postgreSQL. I think we even emailed them to make sure. So my answer would be that no, there are no costs involved.


Why were old games programmed in assembly when higher level languages existed?

Question: I noticed that most if not all Nes / Atari, etc games were coded in assembly, however at that time, C, COBOL, and FORTRAN existed which I would think would make it easier to code right? So then why did they choose assembly over these available higher level languages?
Comment: We still program chunks of many games in assembly -- or more typically, by using C++ compiler intrinsics that look like functions, but actually compile into single hardware opcodes. The reason, then and now, is performance.
Answer: Those games had 8-bit CPU chips and microscopic memories, like, 2kB. This answer would take up over half the RAM.
Compiled code was out of the question.  Even on 8-bit CPU's with "large" memories, like "64K" (whee!) compiled code was difficult to use; it was not routinely seen until 16-bit microprocessors appeared.
Also, the only potentially useful language was C and it had not yet taken over the world. There were few if any C compilers for 8-bit micros at that time.
But C wouldn't have helped that much. Those games had horribly cheap hacks in them that pretty much required timing-specific instruction loops ... e.g., a sprite's Y-coordinate might depend on WHEN (in the video scan) its control register was written. (Shudder...)
Now there was a nice interpreted-bytecode language around that time or perhaps a little bit later: UCSD Pascal running on the UCSD P-System. Although I'm not a big Pascal fan, it was way ahead of everything else for those early processors. It wouldn't fit on a game or run fast enough for game play, though.
Comment: "640K ought to be enough for anybody." - Bill Gates. Done.
Comment: Ah! The good(?) old days...  *::stares off into the distance::*
Comment: Also, compilers sucked compared to modern gcc/clang because writing an *optimizing* compiler is *hard*.  (And it needs a lot of memory and time to run, so a good optimizing compiler for Z80 or whatever can't run on a Z80.)  It used to be a *lot* easier to beat a C compiler with hand-written asm, compare to now where it's still possible on a small scale (for certain loops: [Why is this C++ code faster than my hand-written assembly for testing the Collatz conjecture?](https://stackoverflow.com/a/40355466)) but totally impractical to beat the compiler for large-scale constant-propagation.
Answer: Performance, performance, performance. Games have always been all about getting the most out of the hardware. Even the best C, COBOL or FORTRAN compilers today can't compete with skillfully crafted assembly code.
As DigitalRoss has pointed out, there were also severe memory constraints, and assembly was the only tool that allowed for the fine grained control needed.
The same thing sort of applies today, although the old-days' assembler has been more or less replaced with C++. Even though programming languages such as Python exist (that are very easy to use), the low-level programming languages are still preferred for the most demanding applications.
Comment: @btilly: Back in the day, we modified the output from the Fortran compiler to hand optimize performance critical sections.  Fortran was required by the contract but didn't meet the performance requirements.
Comment: @btilly: That is only because there are very, very few people today who bother acquiring the necessary knowledge to do that. It is not worth it anymore.
Comment: There are very, very few people today who can actually beat C, COBOL or FORTRAN compilers.
Comment: @btilly: Compilers back then *sucked* compared to modern optimizing compilers.  They were *much* easier to beat with hand-written asm.  e.g. [Why do C to Z80 compilers produce poor code?](https://retrocomputing.stackexchange.com/q/6095).  (Z80 was a particularly poor compiler target, as well as old compilers sucking.)  Modern optimizing compilers are the product of millions of dev hours of effort, and wouldn't run in the cramped memory of an old system anyway.  [Why are there so few C compilers?](https://softwareengineering.stackexchange.com/a/273711)
Comment: @PeterCordes Not only that, but also modern hardware is a much more complex optimization target.
Comment: @btilly: only if you consider auto-vectorization.  x86-64 is a pretty nice compiler target, having 15 (mostly) orthogonal integer registers + a stack pointer.  Pointers fit in a single register, and any register can be a base and/or index in an addressing mode (major diff from Z80, or 8086 segments).  Powerful out-of-order execution capabilities make instruction-scheduling / ordering mostly unimportant even though implementations are highly pipelined superscalar.  Intel/AMD design CPUs to be good at plowing through compiler-generated code, even when it's less optimal than hand-written.
Comment: @btilly: Sandybridge-family has less weird stuff than P6-family, e.g. no more register-read stalls so compilers don't have to worry about reading too many "cold" registers in a loop.  (Although gcc still likes to increment a register before reading it as a pointer, probably a heuristic left over from tuning for P6...  I don't think compilers ever did really model the pipeline in enough detail to know when they'd get register-read stalls, and clang still creates partial-register stalls for P6-family.)  Pipelined in-order CPUs like some ARM are a tricky compiler target, though.
Comment: @PeterCordes You probably know this a lot better than I do.  My last memory of the complications had to do with register-read stalls...
Comment: @btilly: yeah, Intel has steadily made their architectures easier compiler targets, removing more and more tricky stalls.  Modern x86 has even fewer "glass jaws".  Skylake even made page-split loads nearly as cheap as cache-line splits (~10 cycle penalty, down from ~100), so auto-vectorizing over maybe-unaligned data, or coalescing stores/loads of adjacent data, is less risky.  AMD's Ryzen is pretty robust, too, AFAIK, with basically no weird scheduling rules.  (uop caches help a lot).  Low power silvermont and Xeon Phi (knight's landing) have some stuff to avoid; multi-uop isns stall decode.
Answer:
"make it easier to code right"

Didn't matter.
High performance, minimal memory use was essential.
Easy to code was irrelevant.
Remember, early games had microscopic amounts of memory on very, very slow processors with no actual devices.  Stuff was connected -- essentially -- directly to the CPU chip.
Answer: Compilers back then were not as good as the compilers we have now.  Therefore many people felt, rightly or wrongly, that they could out optimize the compiler.
Comment: fortunately most of those who can are writing the compilers. :D
Answer: I would assume there were a much larger percentage of programmers that both knew assembler and wouldn't think twice about programming in assembler.  And even into the IBM-PC and AT days folks that never really programmed anything but assembler were still around and could easily program circles around the C and Pascal programmers.
Pascal, and C were wonderful (for desktop computers) once they got a foothold and you could afford a compiler, you were happy to just be programming in some new language and had never heard of an optimizer, you just assumed the high level language turned into the machine code the same way with every compiler.  You still easily fit your programs on a 5.25" floppy.  And had plenty of that 640K to spare.
I think we need to bring back or have more 4K programming contests.  Write a game for the GBA or NDS but the binary, data, code, everything, cannot be larger than 4K.  Or perhaps re-invent the gameplay of asteroids, rocks, ship, bad guys, missles, don't worry about the video pixels because, first it wasn't, and second that was handled by a second processor (well hardware state machine), just generate the vector drawing commands.  There are free 6502 C compilers out there now, and p-code based pascal compilers that it would be easy to run the output on the 6502, and see if you can get the frame rate up to real time at 1.5mhz or whatever it was running.  And fit in the prom.  I think the exercise will answer your question.  OR...just make a runtime p-code interpreter and see if that fits. (standardpascal.org, look for the p5 compiler).
A handful of Kbytes is like a thousand lines of code or less.  There just wasn't that much to the program, and assembler isn't difficult at all, certainly not on a 6502 or other similar systems.  You didn't have caches and mmus and virtualization and multi core, at least not the headaches we have today.  You had the freedom to chose whatever resister you wanted, each subroutine could use its own custom calling convention, you didn't throw away huge quantities of instructions juggling registers or stack or memory just so you could call functions in a standard way. You had but one interrupt and used it to time poll/manage the hardware (video updates, evenly timed polling of buttons and other user input, polling the quarter slot detector even while the game is being played).
Asteroids looks to be roughly 3000 lines of assembler.  With the efficiency of the compilers now or then I would say you would need to write the whole game in about 500 lines of C code to beat that, pascal using p-code I will give you 100 lines of code, okay 200 (not p-code but optimized for the target I will give you more lines than C).
The Atari VCS (a.k.a 2600) didn't even have memory for a framebuffer for the video.  The program had to generate the pixels just in time as well as perform all the game tasks. Sure, not a lot of pixels, but think about the programming task and the limited size and speed of the rom.  For something like that you start getting into how many instructions per pixel, and we are talking a small number.  High level compiled code is going to run in fits and spurts and not going to be smooth enough to guarantee the timing.
If you have the chance you should disassemble some of those old game roms, very educational, the instruction sequences were often very elegant.  Optimized compiled high level code has cool tricks but it just isn't the same.
Supposedly better languages and compilers don't automatically make you better, faster, more efficient or reliable.  Just like a fancy car doesn't make someone a better driver.
Answer: At the time they were developed, higher level languages were not available or did not perform well for the platforms on which they had to run.
Answer: Memory and speed have always been critical for games.  My brother-in-law has a system that far outstrips the PC I run my virtual servers on, as well as desktop.  He complains about the refresh rates on games.  Assembly code can offer ability to optimize code not necessarily available from an old compiler.  Modern optimizing compilers can do optimizations which make the resulting code faster than hand coded.
The old games relied heavily on CPU speed for timing.  They are deadly to run on modern CPUs which run several times faster.  One of the delay methods was to run a loop which incremented or decremented a counter a certain number of times.  (These may get optimized out by a compiler.)
Answer: Although limited memory and limited speed were definitely an issue for Atari 2600 games, the main problem with a high-level language was a lack of control over timing. Just about every aspect of the system that involved timing had to be handled by the software including things like vertical blanking that typically you'd expect the hardware to do for you.
The more changes you made in position, color or data in a scan line the more critical the timing would become. In some cases you had to perform a write to a register a specific number of CPU cycles after the start of the line. If you were 1 CPU cycle early or 1 CPU cycle late the result would be incorrect.
Such timing precision just isn't practical using a high-level language.


How to write my project contribution in graduate application essay?

Question: I am applying for PhD position in the USA. In the application, I have to write a essay on my research experience. Its not a SOP, rather how I worked there, why, findings, what were my contributions, techniques I learned etc.
I have few publications and some of them were entirely done by me. My supervisor guided and when the manuscript was written, it was checked by other post docs or professors and that how their name is also in my paper.
My question is how to write it in the essay?
Answer: Simply describe the nature of each project and a title, perhaps the title of a publication if possible. and note that the work was done as part of coursework. The implication will be that the work is yours and also that there was some feedback on it.
If the others are co-authors you can describe your work/role as "principal investigator", but make sure that the others agree with that characterization.
Comment: That is fine. Just tell it like it is.
Comment: Actually none of them were done as a part of coursework, I work as a research assistant. All of them where independent work. I asked the graduate coordinator who suggested to write my research experiences like an abstract of a research article.


Using IPAD's as controllers for a Unity game

Question: We are making a Multiplayer game using Unity. The actual game would be run from a PC projected on a screen and the players would be using their respective Ipad as a controller to play the game. I am not sure how difficult this would be to achieve inside Unity but I am assuming that all the game data inside Unity would need to be fed and retrieved from some kind of a server. How would this be possible with Unity because each Ipad would have a separate Unity build and also a separate build for the PC from where the actual game would be running.
Answer: Since Unity can publish games to iOS, this would be just like making any other client server application. The easiest would be to have the iPads all connected to the same network as the host PC, but you could easily utilize the Master Server tools provided with Unity to get everyone connected.
You'd likely use RPCs for most of your communications. As long as the PC build and iOS build defined the same RPCs (which they would if you don't change your code between builds), you wouldn't have a problem with them communicating.
As for how much game data you transfer between the clients and server, it will depend almost entirely on your game and how you've designed it.
Comment: As a side note, I think you'll have a hard time using iPads as controllers if the player is supposed to be looking at the projected screen. A touch screen does not make a very good controller, unless the controls are very simple.
Comment: Well, assuming the control scheme involves buttons on the touchscreen. I once imagined using iPads as steering wheels for a driving game on PC.
Comment: True, using the accelerometers would make for an easy control scheme.
Comment: thanks a lot. Yes using Ipads as controller is not intuitive but this is just a backup plan for us in case our original idea doesn't work. Also our design is very simple in terms of gameplay which is why we think Ipad would be ideal.