Where did JSBach study composing? Was he an autodidact?

Question: We know that Bach comes from a family of musicians.
But who was his teacher in composition?. Who did he study with? Or was he self-taught?
Comment: Have you already read the encyclopedia overview stuff? https://de.wikipedia.org/wiki/Johann_Sebastian_Bach
Comment: yes I have,  that's why I posted this question.
Comment: @AlbrechtHügli can you please clarify, what exactly remains unclear after reading that?
Comment: To me there's nothing unclear. But I ask this question because it won't be known to everybody ...
Comment: This is actually a very similar question ... but there was no hint to it when I asked mine. I will poste my answer here and later copy it there. Then we can delete this duplicate if necessary ...
Answer: A few things to note regarding the other answer and C.P.E. Bach's obituary:
First, CPE Bach and a number of Bach's students and admirers (including Forkel, Kirnberger, etc.) basically had an agenda in expanding J.S. Bach's reputation after his death.  JSB was not primarily known as a composer during his lifetime, but his students and sons wanted him to be remembered.  There is thus undoubtedly a bit of exaggeration in some of the early biographies, as noted by later biographers.
Second, I think before adopting terms like "autodidact" and assuming JSB had no training in "composition," but only training in organ, we should be a bit more clear about what training in "composition" and in "organ" constituted at that time.  A skilled organist, like JSB's brother Johann Christoph (who studied with Pachelbel) would likely have a knowledge of music theory and musical structure on par with at least what someone with an undergraduate degree in composition would have today.  To be an effective organist around 1700 in this part of Germany would require complex knowledge of musical improvisation.  Organists were expected to fill out figured bass when accompanying an ensemble, sometimes completely extemporize accompaniments, and often produce original fantasias and even fugues on subjects from hymn tunes just in the course of an average Sunday church service, to serve as preludes, interludes, etc.
All of this requires a detailed knowledge of musical structure and the basics of putting together music (i.e., what we'd now likely call "composition"), even if it was mostly taught as patterns at the keyboard to fill out various chord progressions, create effective transitions, utilize imitation in melodic subjects, etc.
So when CPEB reports that JSB received only lessons to be an organist from his older brother Johann Christoph, we may assume that there was a lot more going on there than simply reading scores and manual/pedal technique (as we often think of in modern classical keyboard performers).  Also, the organ is an instrument that naturally teaches one some principles of orchestration, as one learns how to use various combinations of stops, how to combine manuals and pedals, etc. to create an effective texture.  If JSB's brother was at all an effective organist (which we should assume, based on his education from Pachelbel and his position), he could have easily passed on a lot of knowledge in "organ lessons" that today we'd likely consider to be closer to "composition."
There's a lot more analysis possible when we begin to look at the little bits we can glean from JSB's biography.  JSB's father, Ambrosius, was not known as a composer.  But Ambrosius's cousin, another Johann Christoph Bach, was a noted composer at the church where Ambrosius worked.  Johann Christoph was lated cited by JSB and JSB's students with reverence for his compositions.  JSB was therefore exposed at an early age to competent relatives who were composers, and it's likely there was at least some influence there.  (Note that JSB himself taught at least a half-dozen of his various Bach family relations in composition aside from his sons.  The Bach family was so well-known as musicians and composers by around 1700 that the word "Bach" in that part of Germany was almost a synonym for "musician."
 Older members of the family teacher younger ones in various aspects of music was just assumed to be normal.)
We don't have other details of JSB's musical training, but he clearly was brought up among a family of incredibly skilled musicians and composers.  He was trained in organ at least by his brother, and an organist's skills at this time would have prepared him for a lot of tasks that we would now call "composition."
Lastly, we should note that there were definitely strong characteristics to JSB's personality.  Some have characterized him as an impossible and argumentative perfectionist (who got himself in trouble on a number of occasions and even thrown into prison when he attempted to leave a position); others as a more generous teacher.  But what's clear is that JSB was a perfectionist.  He did not tolerate incompetence.
And he was orphaned at a rather young age, which led to his time living with his elder brother.  Although some scholars view the stories where young JSB fought against his elder brother to copy compositions by moonlight (because money was tight, and Johann Christoph apparently thought it a waste) as apocryphal, perhaps there's some nugget of truth there.  It's very clear that JSB had very high standards for what constituted a competent keyboardist.  This is a man who valued his ability to improvise fugues so strongly that when the King of Prussia embarrassed him by asking him to compose a 6-voice fugue on a difficult subject on the spot, JSB turned around and improvised a 3-voice fugue, then a 6-voice fugue on a different subject, and then sent the King an extended set of the most insane contrapuntal variations, canons, and other musical whimsies on the King's theme just to prove his competence when he wasn't able to fulfill the King's request on the spot.
JSB thought a keyboard player should have such improvisatory skills, and he was one of the last to possess them, as fuguing gradually went out of fashion and improvising in the Galante style and other modern styles became more in fashion for JSB's sons.
To JSB, a competent organist could do a lot of things that only someone with at least an undergraduate degree in music composition or music theory might be able to do today (and in fact, probably couldn't do to JSB's standard).  So when CPE Bach says his father only learned to be an "organist" from his brother, it's likely that JSB learned a lot.  And maybe, given the stories about the copying of manuscripts by moonlight, JSB did hold a grudge and didn't want to give too much credit to his inferior older brother.  He certainly didn't want to give his older brother credit for teaching him to become a composer.
After all, his older brother Johann Christoph may have been a skilled organist, but there's no evidence he ever produced musical compositions.  So yes, JSB was likely on his own in developing the more advanced compositional skills.  But JSB may have come to that prepared by interactions with his family members with a huge amount of music theoretical and practical improvisatory background that made it easier for him to learn to compose.
Just as a final note: we also know JSB was well-known in his lifetime as an expert on organ repair, maintenance, etc.  Where did he acquire such skills?  It's reasonable to assume he probably picked some significant background up from his father's cousin Johann Christoph (a skilled organist) and his elder brother Johann Chrisoph (also an organist) in the course of regular maintenance of organs when he was a child.  We don't assume he was a complete "autodidact" in organ building too, as he came from a family where knowledge about organs was common, and he was constantly around this stuff as a child.  Similarly, there's no reason to suppose he didn't pick up significant background on the skills to be a composer when growing up in these circumstances.  This doesn't take away anything from JSB's accomplishments or his own learning -- just noting that he didn't start from "nothing" and in fact likely started with more knowledge than students we'd call "trained composers" often start with today.
Comment: This is a very careful and critical research and a good summary. I'd like to add this link where the author seems to doubt about the glorification of the obituary's chief author e.g. the 2 points: the death year of JS elder brother and the  "myth" of the moonlight copies all over 6 months: https://pdfs.semanticscholar.org/08e2/742ffcca8f10d86bf7e271cc3c78d1d85556.pdf
Answer: Actually this was question meant as a Q/A, as I knew Bach arranged a lot of music by other composers like e.g. Vivaldi, but I didn't know that he considered himself as an autodidact.
And I thought this might be interesting for all of you.
So the  intent of this question was to point out that Bach was autodidact and learned composing by studying, copying and transcription of works by other composers:

Bach studied the works of different composers from childhood, learning from them through listening, reading, transcribing, editing and imitating the music as well as taking over compositional means, forms and genera.

http://www.radioswissclassic.ch/de/musikdatenbank/musiker/107887047d79b32dcca8b1718cfa3fe30e7ad/biography

Music creation
Bach - a self-taught composer
Bach's son Carl Philipp Emanuel Bach testifies that Bach considered himself a self-taught composer.  There was no guaranteed composition lessons.  The instruction with his brother in Ohrdruf "may well have reproached an organist, and so on.  nothing else "(C. Ph. E. Bach 1775).  Even to Bach's stay at Buxtehude, which lasts several months, there is no evidence that he had received composition lessons on this occasion.  Forkel reports Bach's statement: "I must have been diligent;  whoever is so diligent, will be able to do so well. "
"The soulful has made his own taste by his own additives.  [...] His own contemplation has made him pure in his youth. [...] He has learned the arrangement of the orchestra through the performance of very many [...] starry music, without the systematic study of phonology. "

C. Ph. E. Bach: obituary, 1754 [12]
https://de.wikipedia.org/wiki/Johann_Sebastian_Bach
Answer: No.  The term autodidact -- as a distinction from someone who'd earned a diploma -- didn't become well known until two hundred years after Bach died.
Even in German.
If Bach considered himself such, so did half the populace.


Meaning of "Conceptual point of view"

Question: Now and then, I here this:

From the conceptual point of view ...

However, I still can't get its meaning. I think it is somehow related to the way to think about a particular subject, but I'm not sure.
What does it mean?
Answer: Looking at is in an abstract way, without dealing with the details.
From a conceptual point of view the Golden Gate bridge is a simple machine.
From a conceptual point of view climbing a mountain is easy: you just have to put one foot after the next until you reach the top.  In reality it can be quite challenging to climb mountains as you have to worry about frost bit and altitude sickness and a myriad of of other problems from blisters to avalanches.
See: conceptually1
Comment: Hi, thanks for the reply. Can you elaborate a little more on looking at it in an abstract way ?
Answer: In general, there are two major ways to analyze or consider a particular subject: factually and conceptually. To fully comprehend the meaning of "conceptual point of view" as it is often used in English, it is important to understand this contrast.
A factual point of view is one that perceives characteristics that can be directly analyzed, measured, and observed. As an example:

Nuclear fission is a remarkable discovery in science. Since the development of the atomic theory in the early 19th century, scientists have been fascinated by the vast amounts of energy contained within a tiny atom. Indeed, one nuclear fission event releases approximately 200 million electron volts, and from it we have seen such wonders as the clean, efficient energy produced by nuclear reactors, to the destructive power of nuclear weapons.

By contrast, a conceptual point of view is one that perceives characteristics that cannot be truly observed, and instead only exist as concepts.

Nuclear fission involves the splitting of an atom. Atoms are held together tightly by the electromagnetic and the strong force--the two strongest forces in the known universe. Breaking such a strong bond is very difficult, but likewise the yield is staggering. Modern atomic theory is a very diverse study which involves many concepts from differential equations, positive feedback, chain reactions, and graph theory. As a concept and theory, nuclear fission is one of man's crowning intellectual achievements.

Do you see the difference? The first example focuses on the observed effects and applications of the phenomenon. Whereas the second example discusses the concepts and theory behind it.
So in general, when describing something from a "conceptual point of view", it's a good idea to stick with qualitative properties (i.e. qualities).
Answer: also known as the notional view here
I hear it a lot in meetings with high level managers...

Meaning of "Conceptual point of view"


Running xinc on OpenBSD's Apache Server

Question: Has anyone been able to get xinc to run correctly under OpenBSD's chrooted default Apache? I'd like to keep our development server running fully chrooted just like our Production server so that we make sure our code runs just fine chrooted.
Answer: Have you posted the issue on the Xinc bug tracker? Xinc itself should run fine as it runs both as a daemon and as a web app. As you alluded to, the issue may be that the daemon is not running in a chroot'ed environment where as the web interface is, leading to either side not grabbing the files.
Answer: @dragonmantank
In Xinc's case, I hope you used PEAR to install it.
pear list-files xinc/Xinc

This should do it, and show you where your Xinc install put its files. So even though Xinc is "just" one big PHP script, it's still spread out into rc scripts and all those other things which are necessary to make an application run. I'm sure you don't need to add all paths listed there, but probably some in order to make it run.
Aside from Xinc itself, I think it also needs phpUnit and a bunch of other PEAR libs to run, so what I'd propose is this:
pear config-get php_dir

And then you need to add that path (like Henrik suggested) to the chroot environment.
Answer: Having never used xinc myself, I can only hint as to how I usually get to chrooting apps.
First step would be to gather information on everything the app needs to run; this I usually accomplish by running systrace(1) and ldd(1) to find out what is needed to run the software.
Go through the output of
systrace -A -d. <app>
ldd <app>

and make sure that everything the app touches and needs (quite a lot of apps touch stuff it doesn't actually need) is available in the chroot environment. You might need to tweak configs and environment variables a bit. Also, if there is an option to have the app log to syslog, I usually do that and create a syslog socket (see the -a option of syslogd(8)) in order to decrease the places the app needs write access to.
What I just described is a generic way to make just about any program run in a chroot environment (however, if you need to import half the userland and some suid commands, you might want to just not do chroot :). For apps running under Apache (I'm sure you're aware that the OpenBSD httpd(8) is slightly different) you have the option (once the program has started; any dynamic libraries still needs to be present in the jail) of using apache to access the files, allowing  the use of httpd.conf to import resources in the chroot environment without actually copying them.
Also useful (if slightly outdated) is this link, outlining some gotchas in chrooted PHP on OpenBSD.
Answer:
First step would be to gather information on everything the app needs to run; this I usually accomplish by running systrace(1) and ldd(1) to find out what is needed to run the software.

I'll give this a try. The big issue I've found with xinc is that while it is a PHP application, it wants to know application installation paths (yet it still spreads stuff into other folders) and runs some PHP scripts in daemon mode (those scripts being the hardest to get running). So, for example, I told it to install to /var/www/xinc and then made a symlink of
/var/www/var/www/xinc -> /var/www/xinc
and it partially worked. I got the GUI to come up bit it refused to recognize any projects that I had set up. I think the biggest problem is that part of it is running a chroot and the other half is running outside.
If all else fails I'm going to just have to build something as we program inside chrooted environments since our production is chrooted. We've run into issues where we code outside of a chroot and then have to back track to find what we need to make it work inside a chroot.

Running xinc on OpenBSD's Apache Server


Router benefits in 2018 compared to a L3 Switch

Question: What are the benefits nowadays to use a Router instead of a L3 Switch ?
Comment: You may wait a little longer before accept an answer, in case a better one appear.
Comment: Related: https://networkengineering.stackexchange.com/questions/25643/advantage-of-layer-3-switch-over-router?rq=1
Comment: It is a foundational issue regarding the design/engineering of the platform. In general, L3 switches are designed as switches first, with added L3 capabilities. Routers are designed as routers first and may provide some switching capability.
Answer: It usually comes down to options and resources, where routers have more of each. Routers often have the ability to have different types of interfaces that are not available on switches. They also typically have more resources (RAM, processor, etc.). Routers also usually have a hardware assist for NAT, which is actually resource intensive, and most switches do not NAT. Also, routers usually have an option to run a firewall that many switches do not because firewalls are resource intensive.
In general, you use layer-3 switches as LAN routers, and use a router for WAN connections.
Comment: I would add that "Layer 3 switch" vs "Router" is much more of a marketing term distinction than one concerning an objectively comparable set of technical features. A "layer 3 switch" will typically implement IP routing functionality (i.e. be an IP router) and may or may not have any routing-related additional features like specific upper-layer protocol relays or proxies, dynamic routing protocol implementations, access control functionality, multicast routing support, IPv6 Teredo gateways or IPSEC tunnel endpoints - you name it.
Comment: It's also an issue of *what kind* of resources. L3 switches are likely to have a much larger backplane and L2/L3 forwarding capacity at the cost of less resources for processing above that layer.


Using random forest to select important variables & then putting into logistic regression?

Question: I was wondering does it make sense to use random forest to select most important variables then put into logistic regression for prediction? I think that it might not make sense because what's important for random forest might not be important for logistic regression?
Answer: There are many factors which are underlying the 'importaces' of featues obtained from random forest.
For instance, features with more number of categories (unique values if its a numerical feature) would be more likely to get find splits; making it more important feature.
Having all features with same number of categories is not a common scenario.
So, even though the features identified are likey to be the best predictors (in logistic regressions etc.), one need to take the inherent biases in the randome forest algorithm into consideration while utilizing the 'important' features. Therefore whether it would make sense to use the important features from random forest model into logistic regression would depend on if any and how much the importances are biased.
Source for the information and further useful details on the biases in estimation of feature importances by random forest algorithm: Bias in random forest variable importance measures: Illustrations, sources and a solution Bias in random forest variable importance measures: Illustrations, sources and a solution
Answer: There is not any single good answer to this question as this thing depends on many factors and one of them is the data. As per my experience, I prefer not to remove features as even little information can be very useful.
Answer: The Boruta algorithm uses random forests to select relevant features. There are Python Github and R package implementations.


Duplicate entry: com/google/firebase/FirebaseApiNotAvailableException.class

Question: I have an Android project built with React-Native and employing Google Play Services (analytics, cloud messaging, ads). I'm not explicitly using Firebase anywhere.
Tried upgrading the Play Services from 8.4.0 => 9.2.0. Also upgraded the GPS classpath.
buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:3.0.0'

...
dependencies {
    compile 'com.google.android.gms:play-services-analytics:9.2.1'
    compile 'com.google.android.gms:play-services-ads:9.2.1'
    compile 'com.google.android.gms:play-services-base:9.2.1'
    compile 'com.google.android.gms:play-services-gcm:9.2.1'

Notice that I'm not explicitly depending on Firebase anywhere.
Ever since the upgrade I'm getting the following Gradle build error:

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/firebase/FirebaseApiNotAvailableException.class

I know that Firebase comes bundled within the Google Play Services (since 9.0), so I figured something else is compiling and linking with an older version.
So looking at the dependency insight (gradle -q dependencyInsight --configuration compile --dependency firebase) I've noticed that firebase-common 9.0.0 is being added on top of 9.2.1:

But I can't for the life of me find out what causes this.
Answer: Well - the culprit is React-Native.
The hint was this obscure line that appears on the Gradle console:

google-services plugin could not detect any version for
  com.google.android.gms or com.google.firebase, default version: 9.0.0
  will be used.

The fix? Force the RN library project to link with the correct Firebase version, by adding the following line to its build.gradle:
compile 'com.google.firebase:firebase-core:9.2.1'

And thus:

As a side-note, this issue has triggered me to look deeper into gradle dependency management. I've written an extensive post about resolving common dependency issues.
Comment: i had a different issue, but this answer did the trick :)

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zza.class
Comment: I had the same problem, but when I added firebase-core version 10.0.1, I was getting: `com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zze.class`
Rolling the version back to 9.2.1 fixed it. Thank you for your post!
Answer: The problem is that you use both the plugins in the build.gradle file
so remove the one Google Play Services plugin, like
apply plugin: 'com.google.gms.google-services'

and
compile 'com.google.android.gms:play-services:11.0.2'

So remove both of one library and then add
packagingOptions {
    exclude 'META-INF/NOTICE' // It is not include NOTICE file
    exclude 'META-INF/LICENSE' // It is not include LICENSE file
}

Answer: In my case, I was using this in app/build.gradle:
compile 'com.google.android.gms:play-services-location:9.8.0'
compile 'com.google.android.gms:play-services-maps:9.8.0'

The error when I was trying to generate a Signed APK was:
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/firebase/FirebaseApiNotAvailableException.class

I modified app/build.gradle by removing the two lines I mentioned above and using this instead:
compile 'com.google.android.gms:play-services:9.8.0'

Of course "play-services" is the full bundle and not an optimized way to do this. It would be best to specify the specific services that are required (read Does "play-services:9.8.0" include "play-services-location:9.8.0"?), but for now it fixes the error in my case.
Answer: java.util.zip.ZipException: duplicate entry: com/google/firebase/iid/zzb.class
follow this its work .remove your current google play service dependency and go to file in android Studio select module setting and the select dependency tab now click on + icon and select lib dependency after that search your play service in studio and add it


How to find the the relationship between different numbers

Question: Assuming i have 4 numbers a,b,c and d, my question is how can i find the right set(s) of operands a,b,c,d and operators which gives a specific result d, for example to find the right expression containing the operands 1,2,3 and 4 which evaluate to 24, a possible solution would be: 1*2*3*4 = 24 or 2*3*4/1 = 24, is there a tool/method to do this?.
Answer: I doubt it. There are these riddles where e.g. you only use the digit 4 and certain operator and try to create all possible numbers. Some are rather tricky, while others are easy but it does not seem like an algorithm can be found to do that.
Of course, that's not a proof but I'm not sure a proof would be easy.
You could e.g. see though, that it's difficult to construct $\pi$ with natural numbers, as $\pi$ is transcendental. So you will need more than just the standard operators.
Comment: Yeah i don't think too that such an algorithm exists, but trying differrent combinaison isn't that hard for a computer.
Comment: Sure, we could do some coding but a program is just an algorithm that a computer can understand. As I've explained, numbers as $\pi$ need more than standard operators. That'd already be a problem.
Answer: I personal didn't get your question well
you need four numbers $A$ $B$ $C$ $D$, which on a particular operations gives a result $d$,
Find all possible expression by which the variables $A$, $B$, $C$, and $D$ can be manipulated by an operation to give the same result $d$.
If there was no repetition of any of the variable, we would not be able to get anything new
$1×2×3×4 = 24$ and $(2×3×4) \div 1 = 24$.
$1$, $2$, $3$and $4$ Worked without repetition because one of the the variable there was equal to $1$, multiplying and dividing by $1$ is same.
so there must be repetition of this variables if-not, we wouldn't get anything.
Now let's first assume the product of all the variables was $d$
$$
A × B × C × D = d
$$
finding another operation by which we can manipulate $A$ $B$ $C$ $D$ depends on the actual value of these variables..
If we were forced to to repeat a variable, then
$$
\cdot A \cdot B \cdot C \cdot D \lt d
$$
because introducing other maths operation like $+$ $-$ and $÷$, would lesser its value
Now without repetition there are infinite ways to make up these, just by mixing and repeating the numbers


Network App Restriction

Question: I recently bought a japanese cellphone (Fujitsu F-06e NX). It came with some really cool apps but most of them have limited functionality due to network work restrictions (Phone must be on docomo ntt network). I was wonder if there was a way to bypass this restriction. Thanks :)
Answer: Install Orbot Proxy by Tor. You will have to root the phone if your apps don't have their own proxy settings. Tor is a very good anonymizing network; in fact, Stack Exchange has their own website for it: StackExchange
You can also configure a VPN and connect your phone to that, via Settings or by downloading a VPN app. You can subscribe to a private VPN server (small monthly fee), you can create your own VPN server, either with OpenVPN software or Windows 7 VPN wizard, or, if privacy doesn't matter, you can connect to a free, public VPN server.
Other than those two methods, options get very difficult from here. There's no reason the above VPN method shouldn't work, unless your device doesn't support it. Still, try a VPN app (This one seems to be legit and has pretty good reviews).
Sometimes VPN's are blocked as well (think massive corporations), although it is almost impossible to completely block one. Try hosting your own VPN server, in the situation where they have a targeted block-list.
Also, in the event that if your device rejects everything you install on it, one would have to modify the .APK's of the apps themselves to target a custom VPN or proxy server. Programming knowledge is a requirement. This would all be to avoid rooting.
I think that is the entire list. Good luck
Comment: As this is a new phone and I dont have any experience rooting could there be alternative method where I dont have to root?
Comment: Well, Orbot works without root, as long as you can configure proxy settings inside your apps (such as within Firefox mobile, to bypass all websites). I'll update my answer with other methods as well.
Comment: Thanks Aaron, but how do one configure that Tor Orbot? I have absolutely no idea how to go about it.

Network App Restriction


Mean Value Theorem Inequalities

Question: I have recently learned the Mean Value Theorem and have been trying to do a few proofs using it. The first question I approached says use the Mean Value Theorem to prove that $\sqrt{1+h}$$<$$ 1 +$ $h\over 2$ for all $h > 0$. My attempt goes like this:
Let $h > 0$ and $f(x)$ = $\sqrt{1+x}$. Now, by the Mean Value Theorem, there must exist t $\in (0,h)$ such that $f'(t) =$ $f(h) - f(0) \over h - 0$. This means that $f(h) =$ $f'(t)(h-0) + f(0)$ = $h \over 2\sqrt{1 + t}$ $+ 1 $. Thus, $h \over 2\sqrt{1 + t}$ $<$ $1 +$ $h\over 2$. Is my approach to this problem correct? Are there any improvements that should be made to the proof? Also, another problem asks for $n \geq 1$ and $0 \leq y \leq x$ show that n$y^{n-1}$$(x - y)$$\leq$$x^n$ $-$ $y^n$$\leq$$nx^{n-1}$$(x - y)$ My main problem with this is that it is a function of two variables, so I am not sure how to assign the function which I take the derivative of. Any hints would be much appreciated.
Answer: For the second problem :
Take $f(x)=x^n$ so $f'(x)=nx^{n-1}$ .
The inequality is now equivalent with :
$$f'(y) \leq \frac{f(x)-f(y)}{x-y} \leq f'(x)$$
From the mean value theorem there is some $a \in (y,x)$ such that :
$$\frac{f(x)-f(y)}{x-y}=f'(a)$$
The inequality is now equivalent with :
$$f'(y)<f'(a)<f'(y)$$ but because $f'$ is increasing this is equivalent with :
$$y<a<x$$ which is true because $a \in (y,x)$ .
Comment: Thank you very much! After reading this answer the problem is very clear to me

Mean Value Theorem Inequalities


Direct3D vector output?

Question: Is there any means to interpret Direct3D output as a series of vectors instead of a raster image? I am hoping I could use such a feature to generate a PDF file containing the rendered Direct3D output. Am I being too optimistic?
Answer: Well there is noting specifically stopping you from interpreting the input data as vectors.  It is, however, fundamentally a rasteriser.  Pixel shaders entirely stop making sense the moment you convert to vector data.
Still you know what your transforms are and you know what the vertex data is so you could output it as vector data in whatever format you want ...

Direct3D vector output?


How does Firefox encrypt passwords without selecting Master Password?

Question: I know that the file logins.json contains all my encrypted passwords in Firefox browser. How does Firefox encrypt these passwords if I don't use the 'Master Password' option? Does this mean key3.db file is used also if I didn't select Master Password?
Answer: When the profile is initialized, a blank password (an empty string) is used. You can find the code for this in toolkit/components/passwordmgr/crypto-SDR.js on line 64:
if (token.needsUserInit) {
  this.log("Initializing key3.db with default blank password.");
  token.initPassword("");
}

Additionally, based on the import method in toolkit/components/passwordmgr/LoginImport.jsm on line 68, the encrypted passwords are imported into logins.json from key3.db without modification. Therefore, they will be using the same default password.
Comment: @Ant Most users do not use Firefox's "master password" feature to protect their stored passwords, so they would be at risk if their password file could be stolen. It is a trade-off between convenience and security.
Comment: @Ant On Windows, Chrome encrypts the passwords with Windows DPAPI, which can be decrypted by any program running as the Windows user, unless the user's logon password is forcibly reset.
Comment: @Hila: I guess Firefox doesn't optimize for the empty-password case by having extra code to skip the encrypting.  As the code shows, they turn the empty string into a crypto key (somehow, doesn't matter how).  There's no choice of key that will produce ciphertext = plaintext.  All that matters is that the empty string produces the same key every time, just like any other string produces the same key every time.
Comment: @Hila The reason they appear encrypted (as Peter points out) is that the default blank string still acts as an encryption key in their algorithm. This obfuscates the passwords which provides a small amount of protection, especially on shared computers.
Comment: @AustinHartzheim But when I try to decrypt this password using 3DES with this default blank string I didn't get my password...
Answer: AFAIK Firefox does not encrypt passwords unless you set a master password; instead it uses BASE64 to encode the data. That protects you from seeing the passwords when opening files with an editor, but it's trivial to get the original secrets.
Unfortunately Mozilla is not very open regarding the algorithms in use when a master password is set: You'll have to find out from the sources, I'm afarid.
Comment: You claim something completely different from the current answer. Did it change? Do you have a link that verifies your claim? Because to my knowledge, it is indeed encrypted as the currently top voted answer says, not (only) base64 encoded. You are also making claims that they hide it, and while the info is not super easy to find, it's also not exactly as if they have anything to hide in an open source product... (Also, your German autocorrect is leaking ;-) "ist", "zu")
Comment: I must admit that I haven't re-checked the "no master password" case in the last ten years ;-)


limit the access to uploaded files

Question: I have some files that I want to be accessible only to registered users. So I have uploded them to a page set as private. Is this sufficient to prevent unregistered users to download them? I have made a simple test and it seems to me that the answer is: yes, it suffices, but maybe I forget something...
Answer: If people can guess the file download urls then they will still be able to get to them (e.g. if someone who has access shares the download urls out).
To get around that kind of problem you typically need to set up a file handler script that will grab them from a protected directory that prohibits direct content downloading and serve them up.
That being said, what you are doing is generally good enough unless it is vitally important that people not be able to find and download things.
Comment: The test I've made is the following. I've copied the url to the document, and pasted it into the address bar of another browser window where I was not authenticated. And I received the message: Something is going wrong. Bad address, or perhaps you try to access to a private document. So, I suppose that guessing the file download url can't help to circumvent the protection...
Comment: Good to hear. You should be fine then.

limit the access to uploaded files


Do elves have surnames?

Question: Do elves have surnames/family name? For instance what is the surname or famous elves like Galadriel, Arwen, Legolas, ...
Comment: Think about this a little deeper - if I remember correctly only hobbits have surnames!
Comment: Related question perhaps but not already answered. The answer Why do only Hobbits use a combination of first- and lastname? is interesting but doesn't answer to this question.
Answer: Just like modern humans, the various peoples of Middle-Earth all have different naming conventions. In fact the only people in Middle Earth to have family names analogous to the common (but not universal) modern format of Firstname Lastname are the Hobbits of The Shire (Bilbo Baggins, Peregrin Took) and presumably also of Bree (the Underhills) and the Men of Bree (Barliman Butterman).
So, NO, none of the Elves (Galadriel, Arwen or Legolas) had "family names" as we understand them. However, they did have second names and epithets that were often used in the same FirstName LastName format as the usual modern usage of Surnames.
The naming tradition of the Valinorian Elves - such as Galadriel and the elves of The Silmarillion, the essë, gave an Elf three different names at various times of the lives.

Essi: chosen by the father and often based on the father's own name or derived from old legends. Given at or near birth. Galadriel's father-name was Artanis meaning "Noble Woman" in Noldolin Quenya. Maedhros's father-name was Nelyafinwë (literally Finwë the Third).
Amilessë: chosen by the mother and often prophetic in nature. Given sometimes at or near birth but often bestowed years later. Galadriel's mother-name was Nerwen meaning "Man-Maiden" in Noldolin Quenya (referring to her height and bold character). Maedhros's mother-name was Maitimo (the "Well-Shaped One" was known to be good-looking)
Epessë: often acquired by an Elf as an honorific later in life. Galadriel's epessë was Alatáriel meaning "Maiden Crowned with Radiant Garland" in Telerin Quenya, given to her by Celeborn, her husband. Maedhros's epessë was Russandol ("Copper-Top" - he was a rare red-headed elf).

When these Valinorian elves made their way to Middle-Earth, where Sindarin was the common elven tongue, they adopted Sindarinized versions of their names. So Alatáriel became Galadriel and Maitimo / Russandol became Maedhros.
Both Maedhros and Galadriel, like most other elves in the era of the Silmarillion are referred to with those single names only, without their names being doubled in the FN LN format anywhere in the canon, though Maedhros was sometimes called "Maedhros the Tall".
On the other hand, one of the exceptions was Galadriel's brother Finrod. He was known as Finrod Felagund - the former part being the Sindarized version of his father-name and the latter part being the Sindarized version of an epessë given to him by Dwarves - Felakgundu meaning "Hewer of Caves".
We do not know if Arwen was her father-name or mother-name, or if the later day elves in Rivendell even still followed this tradition at the time of her birth, but she does have an epessë, Undomiel and she was often referred formally as Arwen Undomiel. As such the name Undomiel serves as part of a double name in the format of FirstName LastName, but is not a true surname since it is unique to her and does not refer to the family.
Legolas had no ancestry from the Valinorian Elves and we do not have much information on the naming customs of the Sindar and the Silvan elves, among whose numbers Legolas would be counted. He is almost always referred to as Legolas, in the singular, except for the one time when Gandalf calls him Legolas Greenleaf, which again serves as adequate example of FirstName LastName format. However, "Greenleaf" is simply the literal English translation of "Legolas", so again, it cannot be counted as a true surname.
Comment: Legolas is also referred to (in the movie, at least, I don't recall if he's called this in the book) as Legolas Thranduilion, which just means, "Legolas, son of Thranduil". This is a similar construction that eventually gave us surnames like Robertson, Johnson, Fredrickson, etc.
Comment: There is also a character in The Silmarillion named Legolas Greenleaf, from Gondolin

Do elves have surnames?


How do I set a custom post type Category after import using wp_set_post_terms

Question: I'm importing Events from a Salesforce Event Manager into WordPress, specifically into the The Events Calendar.  The Events Calendar creates a CPT called Events.  It also has its own Categories, which have the taxonomy name of "tribe_events_cat".
Everytime a user updates an event in Salesforce they are updated in WordPress through an object-sync plugin.  However, I can't set the Category through object-sync since the category is a taxonomy, not a property of the Event object.
I tried the following code but it is not working.  The save_post hook is definitely firing its callback function everytime I update an Event, but the category is not being set.  In this example code, I'm just trying to set any updated event to 'Retreat', which is an Event Category that I've set up.
add_action( 'save_post_tribe_events', 'fix_event_category', 1, 1);
function fix_event_category($post_id) {
    $category = array(get_cat_ID('Retreat'));
    $taxonomy = 'tribe_events_cat';
    wp_set_post_terms($post_id, $category, $taxonomy);
}

Answer: The answer is don't use wp_set_post_terms, use wp_set_object_terms instead.  wp_set_post_terms only works with the built-in post object.


DLP vs end-to-end messengers

Question: I am interested in how DLP systems work. I have noticed that developers of DLP say that the software can see messenger traffic including end-to-end solutions. I understand MITM, certificate change, but in the case of end-to-end, how does it work? There is encryption between two devices, the third device cannot see it, isn't that correct? It must decrypt for analyzing traffic.
Comment: Hi and welcome. I removed the second question because it is unrelated to the first and is completely dependent on the software you use. For example, I have used DLP solutions that do not take screenshots (that does not sound like DLP to me, actually).
Comment: Can you link to something saying that a DLP package can see end-to-end encrypted messages?
Comment: They can probably see the traffic, but can't interpret it. I have seen DLP solutions look for weird spikes based on ML and than flag that as a possible data exfiltration, but obviously they have no way of seeing what kind of data was exfiltrated.
Comment: @schroeder, hi. I will try to find related articles, but they in russian. About screenshots - i think the biggest part do that, foe example, i detected it in wireshark, remote server sends me command SCREENSHOT, my pc send answer with encrypted data. Admin has confirmed that dlp make screenshots. For example, you can search searchinfrom dlp solution
Comment: @RaimondsLiepiņš, sound reasonable, but for example, well known that skype is fully watched by dlp systems, in last time i read similar info about telegram and viber desktop.
Answer: It will depend on the specific implementation of the specific product and the specific message traffic.
Data Loss Prevention tools tend to work in one of two ways: they sit on the network and look at logs, read emails, read file shares; or they are installed as a desktop agent which, the vendors assert, has full access to every keystroke, window, file and memory object.  DLP vendors, IMHO, like to assert much.  The network DLP products may require that the end user organisation tags data of interest.  The product then uses its magic unicorn to identify all those documents with that tag.  The agent-based products will know what files are being touched and can therefore assign a risk weighting to actions and hence report on them via the dashboards that they seem to love.
To read a message then could be as simple as the keystrokes being captured, could be the window being asked to report on its contents, it could be that the tool has the message certs and it implements a MITM as you say.  It could be as simple as reading the message store from the message server.
Regulated institutions such as financial service trading floors may have a requirement to monitor and record all instant messages being used. Many years ago I implemented IMLogic which was an IM compliance tool used by an investment bank as their traders used all the IM clients to have personal calls with external parties. They had a client that intercepted messages and sent them to the server for storage: nothing particularly clever.
The DLP products can only report on what they know: I expect that it would be possible to write your own chat client that they could not inspect if you had full end-to-end encryption.
The only way to be absolutely sure about how a specific vendor monitors a specific chat channel is to ask them.
Comment: Unfortunately, vendors do not demonstrate their tech details( but thanks, sounds reasonable.
Comment: @askkeratone I get called by vendors constantly who want to do a demo.  If you can persuade them that you work for a company that might buy their prioduct then they may give you a webex with a sales engineer. The sales engineer will explain how the tool works.  Failing that, go to Infosec and ask them there, if you can bear the sales pitch that will come with it.

DLP vs end-to-end messengers


Can I setup something on my raspberry pi so that a prgram I have is always running?

Question: I have tried adding it to the rc.local file but sometimes the program will launch on boot but won't stay open. Is there a way to have so when the program stops running that it gets relaunched?
Comment: creating a *service* in `systemd` is good for this sort of thing
Comment: would this work with two python programs I am running or does it need to be something else?
Comment: yes, this would work
Answer: try using systemd, the following is a simple service config, runs as user pi, will restart on failure (to a point, if it always fails immediately, systemd will not try to restart the process continually)
You'd create a file in /etc/systemd/system - perhaps call it something like myservice.service ... the .service is important
[Unit]
Description=Your Service
After=network.target

[Service]
User=pi
Group=pi
Type=simple
ExecStart=/home/pi/yourprogram.py
Restart=on-failure

[Install]
WantedBy=multi-user.target

In this example, the service wont start until after network.target is active - which, for my case was essential, as the above is based on a service I have running that requires network availability
Go through systemd documentation for the many possibilities regarding waiting for particular targets you can use for Before, After and WantedBy, and Wants ... all sorts of configurations that allow you to control precisely when your service will run
Then to "install" and "start" the service
systemctl enable myservice.service
systemctl start myservice.service

you can stop the service at any time
systemctl stop myservice.service

and to disable it completely (i.e. so it wont start on reboot)
systemctl disable myservice.service

At which point you could delete the myservice.service file you created earlier
This is an extremely basic example, but that is as much as you need to create a service that meets your requirement that it restarts if it fails
Comment: Is there a way to have it run as a sudo or root user? I need to run it usually as "sudo python datalogger.py".
Comment: I tried this and it didn't work. The program has an output and its not even running once.
Comment: oh, you need output to the terminal? rc.local would fail as often as this solution in that case
Comment: Its not output to terminal that I need, the program outputs to a csv file in my user folder. I know its not a permissions issue because it worked when I launch it manually.
Comment: then it may be a "current folder" issue - set the current folder as required in the code, or use  full paths not relative ones
Answer: There are pre-done ways that I am sure someone will suggest, but if you like to do it on your own do this. I have no idea what language you wrote your program in, so this wont be specific, but general Idea
at the start of your program, have it look for a specific file
~/.myPIDfile
in this file there will (maybe) be a pid. If there is one, check if that process is still running, if it is, then exit.
if its not rewrite the file with your current pid.
Now the program can be started as often as you want, but if there is already one running, it will just exit.
then add
* * * * * /path/to/your/program >> /path/to/log/file 2>&1

to your cron job with
crontab -e

This will start the program every minute, but again your program is now smart enough to know if there is already one running, so you will only have a single instance running. If there is a crash, in the next minute cron will start it up again.
Edit: so in python, i grabbed this from here
def findProcess( processId ):
    ps= subprocess.Popen("ps -ef | grep "+processId+"| grep -v grep", shell=True, stdout=subprocess.PIPE)
    output = ps.stdout.read()
    ps.stdout.close()
    ps.wait()
    return output

If the PID is running, this will return a string, and I think if its not running it will return None.
So a function to check the PID might work like this:
def checkPID:
        try:
                f=open("/path/to/pidFile","r")
        except:
                #no pid file, good to continue
                return True
        pid=f.read()
        status=findProcess(pid)
        if status is None:
                #no line from grep, not running
                return True
        if len(status)<3:
                #very short string, maybe a newline, but no process info=not running
                return True
        f.close()
        f=open("/path/to/pidFile","w")
        f.write(str(os.getpid()))
        f.close()
        return False

and at the start of your program you would do:
if checkPID:
        exit()

~
Comment: It's written in Python.
Comment: Tired this and the program would only run its loop once and stop. But if I run it in terminal as sudo python myprogram.py it runs without issue.
Comment: make the program executable, chmod +x /path/to/program    add '#!/usr/bin/env python' to the top of your program.    Does your program need to be sudo'ed?


Do I have to apply more force than gravity to lift my leg above the ground?

Question: How much force do I do apply when I lift my leg above the ground? The same amount as gravity does on my leg (mg)? Or MORE than it (greater than mg)? If the displacement from the ground to my lifted leg is h meters, then what's the work done? mgh or more than mgh? Basically I wanna know if I have to apply more force or do more work than gravity to lift my leg up.
Comment: But the actual force exerted by your muscle might be 5 ... 10 times larger than the weight you bear, due to the mechanical disadvantage inherent in your skeletal system. See https://courses.lumenlearning.com/physics/chapter/9-6-forces-and-torques-in-muscles-and-joints/ for example.
Comment: Actually since the leg is pivoted about the hip joint the force to move it is less than $m g$ (assuming the total mass of the leg is $m$).
Comment: Obviously more than what simple Newtonian physics would suggest, else you would reach absurd conclusions that you could hold a heavy weight above your head indefinitely since there is no change in energy or net work being done.
Comment: You are mixing a question which is clearly about an ideal situation, and a very messy real-world scenario. Which are you asking about? One important factor is, that the ground, the shoe and the foot are all compressed when at rest in the initial situation. Even a minuscule amount of upward lift will allow these "springs" to uncompres a bit, and allow your leg to raise a bit: micrometers, millimeters, even centimeters if you have soft ground and thick soles. Does that fit the scope of your question, or is this more of a "spherical cow in vacuum" kind of scenario?
Comment: @g.kertesz - I was talking about the equipollent force upwards on the foot. Essentially the force required to produce the same torque about the joint as the muscles do.
Comment: @JAlex -- it was just a general remark from me, since OP did not even tell which force he is interested in specifically.
Answer: Because your leg began at rest, moved for a time $\Delta t$ and ended at rest, the average force it felt was
$$ \langle F \rangle = \frac{\Delta p}{\Delta t} = 0 $$
meaning on average your force was equal and opposite to gravity.
However, when you accelerated upward you acted with more force than gravity, and when you decelerated it, you acted with less force.
Comment: @wizzwizz4 I suspect internal resistance in the leg (muscles, joints and tendons) is a lot larger than air resistance. Not that that changes the validity of your comment.
Comment: You're neglecting air resistance, etc..; in fact, more average force will have to be applied because of this. (However, it's not very much extra force.)
Comment: Also something not to forget about in computations is gravitational pull of distant galaxies on the knee that assist knee in overcoming the gravitational pull of the Earth by attracting it in its direction.
Comment: @wha7ever - The galaxies are also pulling the Earth. What matters is the tidal effect. That's the reason so that lifting your leg is easier when the Moon is high on the sky.
Comment: Guys, the art of physics is to know to which accuracy your model holds. Wanting to be more precise using galactic tidal forces is OK, but this information won't add anything because of the errors coming from way stronger forces like radiation pressure from the sun at day time and thermal fluctuations in air pressure (quite ironic they're "strong"). When adding really small magnitude effects, you should check if you forget any other affects with the same magnitude or bigger. Lets agree that Arthur's comment is on spot and wizzwizz4 also adds a good first approximation and settle it there? :)
Answer: Remember Newton's laws. If you only exert exactly the same force as gravity, then you are balancing out gravity, resulting in no initiation of motion (this is Newton's 1st law):
$$\sum F=F_\text{lift}-mg=0\qquad \text{ when }F_\text{lift}=mg.$$
In order to accelerate your leg upwards you must thus exert a larger force than gravity (this is Newton's 2nd law):
$$\sum F=F_\text{lift}-mg=ma\qquad \text{ when }F_\text{lift}>mg.$$
The work you have to do to lift the leg to a height $h$ is the gravitational potential energy needed $U_g$ and the kinetic energy supplied $K$:
$$W=U_g+K=mgh+\frac12 mv^2.$$
If you move your leg up and then keep it there, then its kinetic energy is zero (you keep it there at rest). Only then is the work equal to just $mgh$. Meaning, if this is the end situation, then you only have to do work equal to the work done by gravity when the leg falls back down later on.
Now, with all this being said, keep in mind that this is all an idealized description.

Firstly, lifting your leg is not a clear-cut process such as lifting a box because you have parts of your limbs such as the thigh that are only lifted partly.
Secondly, be aware that the work $W$ mentioned above is only the work done on the lifted object. It is not the work done by the body. Your body is generally inefficient and might spend a lot of energy just to produce the force that lifts your leg. All this behind-the-scenes energy usage and waste is not included in the above calculation of work.
Comment: "...resulting in no motion" Did you mean no acceleration? Doesn't N1 say an object at rest or in moving at constant velocity remains at rest or moving at constant velocity unless acted upon by net force?
Comment: Your welcome  +1
Comment: @BobD Sure, I was merely assuming that the leg starts from rest - and thus stays at rest if the upwards force equals the downwards force.
Comment: Understand. Don't mean to make a big deal out of it. I was just concerned with associating N1 with no motion without the qualification. Especially since once motion is initiated, the forces can balance and constant motion occur. May I suggest replacing "no motion" with "no initiation of motion". Bob
Comment: @BobD Good suggestion, done.
Answer: Yes, if you apply same force as gravity then your leg would be at rest as the two forces will be cancelling eachother. Now if you have to move the leg upward you need to give your leg a motion from resting position. Now to give a body at rest any motion you need to apply force. Hence, yes you need to apply more force.                                           M×a=F-Mg[F is force applied by you, M is mass of your leg, a is acceleration of your leg as a result of extra force applied by you].
Answer: TL; DR The question is poorly defined: it is based on a simplified model of a leg, which is not really applicable.
Indeed, Newtonian physics deals with point-like objects or, at best, a collection of such objects connected by links (aka solid body in the case of rigid links).
Foot as a point-like object
In the first case we can consider foot as a point-like object, and then the forces need to balance themselves to raise the foot with a constant speed. There are some caveats, related to the fact that the foot, if initially at rest, needs to be first accelerated to make it moving and then need to be stopped, so that the force is not constant in time. But, once it is raised, the forces balance each other (from the point of view of Newtonian mechanics).
Leg as series of sticks and joints
The OP speaks about a leg, which cannot be considered as a point-like object, but rather a series of rigid parts connected by joints. One can develop mechanical model of different level of complexity: starting with simple foot-ankle-hip model and moving on to model them mechanically, as, e.g., in the figure below (taken from the first result that came up in Google).

In this case we will have many forces and torques, as well as several parts of the leg with different masses, so the question needs to be refined.
Leg as elastic objects
Now, the parts of the leg are not really rigid, but rather elastic - that is they get deformed when the leg moves. This is particularly the case of the muscles, which play a prominent role in the movement. We thus need to involve elasticity theory, which goes somewhat beyond the Newtonian mechanics (although largely based on it), and deals with continuous stresses rather than forces.
Contraction of muscles
Energy needs to be supplied to make the muscles contract, and needs to be continuously supplied to keep them contracted. This implies largely thermodynamic treatment, far away from simple Newtonian balance of forces. Yet, in terms of work it tells us that we need to spend energy even when the leg is not moving (aka "do more work than gravity").
Chemistry and biology
The above levels of description have not gone beyond physics, which however would be necessary, if we were to describe the motion on the cellular and molecular levels.
Answer: The general, "ideal" answer in Newtonian physics is as follows. I'll consider downward forces (and Earth's acceleration g) as negative quantities, and upward forces as positives.
The first thing to repeat and emphasize:
No net forces act on unaccelerated objects.
An object suspended in gravity experiences the gravitational force $F_{grav} = m*g$ (m being their mass and g being Earth's acceleration, $9.81 m/s^2$). Because it is suspended and is not accelerated, no net force is acting on it: There must be something holding it up (the ground, a muscle etc.) by exerting on it the exact opposite of the gravitational force. We can call this suspending force $F_{susp}$. Mathematically, the statement "no force is acting on them" means "when we add all the forces up, the result is 0: $F_{susp} + F_{grav} = 0$. The forces acting on the leg cancel each other out, they have the same magnitude but opposite signs. Another way to express this equilibrium is $F_{susp} = -F_{grav}$. Same force, opposite direction.
$F_{susp}$ is the "effective force" the body exerts on the leg, ignoring levers, joints etc. which may yield a higher or lower force to be "applied" by muscles, tendons etc., as seen from the point of view of the actor. Think of a pulley. But the force on the object opposing the gravitational pull is always $-F_{grav}$ because no net forces are acting on an unaccelerated object, including one at rest. Here you can think of a pulley again, this time from the perspective of the hanging object.
Now let's consider the phases involved in lifting the leg.

Acceleration phase: In order to accelerate something against gravity — and accleration is obviously necessary if you want to put it into motion — you must not only apply $F_{susp}$ but a bit more, some additional $F_{up}$. Because $F_{susp}$ is exactly canceled out by gravitation, $F_{up}$ is a net force which accelerates the object upward; as an equation we would add up all acting forces and find that the net residue is exactly $F_{up}$: $F_{susp} + F_{grav} + F_{up} = F_{up}$ (instead of 0).
Coast phase: This delta only has to be applied for a short moment until the leg is moving. After that moment, to keep it moving at a steady pace, we have to make sure no net forces act on it, so it is again simply $F_{susp}$ again which is exactly canceled out. No acceleration, no net force.
Deceleration phase: Versus the end of its relocation the object slows down in order to come to rest (to rest, at least, relative to your position on Earth's surface which is following a literally convoluted trajectory through space — but I digress ;-) ). During this slowing-down phase, which is physically an acceleration like any other, a net force $F_{down}$ must act on it in the same direction as gravity. This is achieved by lowering the suspending force by this small amount so that gravity can get the upper hand. $F_{down}$ is similar to $F_{up}$, just in the opposite direction. Because the object is accelerated, adding all acting forces up results in a residual net force: $F_{grav} + (F_{susp} + F_{down}) = F_{down}$ (instead of 0). (Because $F_{down}$ is facing downward it is negative; adding it to the upward facing $F_{susp}$ decreases the resulting upward force.) After that slowing-down period the leg comes to rest again, and at rest the acting forces are simply $m*g$ in both directions, again canceling each other out.

This discussion of the idealized physics misses a few issues that play a large role in real life. Obviously, the body works with significant friction: Tendons run through sheets, tissue is deformed, fluids are pressed through vessels when the thigh bends and muscles contract etc. etc. Most of the time we move we are not lifting or net-accelerating anything (when we move an object from A to B we accelerate it and then brake it, but we are not able to recuperate the kinetic energy but instead need to exert more energy to stop the movement until it is at rest again): We are simply creating heat. The mechanical work you perform to lift the leg is much higher than the gain in potential energy of the lifted mass.
More energy spent while moving something the same distance means that the forces applied were larger, which is one real-life answer to your question.
Another issue is that holding limbs in a position that is not the equilibrium is actually quite energy-consuming, even if none of that is transformed into kinetic or potential energy: It is all going to waste, i.e., heat. Keeping muscles contracted requires cell activity which accelerates their metabolism: Sugar and oxygen must be transported there, breathing and heart rate accelerate etc. It is exhausting.
Forces and energy to overcome friction and to fuel the peculiarities of our body are not considered in the ideal Newtonian mechanics considerations above. This is by design: One of the biggest modern-era physics achievements was to divide the chaotic muddle we see when we take in the real world into superimposed subsystems which could be described separately. In a way Newtonian physics is a regression from the Aristotelian concept that every movement needs a mover, a continuing cause. Rejecting this is the core of Newtonian physics: Motion change needs a mover; steady motion as such doesn't. This is an astonishing abstraction, the achievement of a genius thinker, because this literally never happens in macroscopic reality. On Earth nothing ever continues moving without some mover. Unpropelled, everything comes to a stop rather quickly. In cosmological time even celestial objects moving through vacuum experience friction through tidal forces, become tidally locked etc.
Newton enabled us to think of friction as an effect separate from the basic mechanical laws. It could be seen as an impurity, a contamination: In machines and transportation, let alone school room physics, we try to minimize it because it is annoying, less deterministic and comparatively hard to compute.
But friction is not a side effect, an impurity best ignored: Heat losses are systematically described by thermodynamics which became a central part of cosmology in the 20th century. Aristotle was right, after all: Nothing, literally nothing macroscopic moves or changes without friction, without increasing entropy, without being propelled, without a mover. The concept of ever-increasing entropy is a fundamental and far-reaching concept with the same rank as evolution in biology. The simple principle is that unlikely random events don't occur that often.
Newtonian physics is only a subsystem, but a brilliantly carved out, beautiful one.
Answer: Firstly laying out my physics/math assumptions

no friction

only moving the leg vertically (as if you are lifting a bag)

constant gravity, $g$

force on leg, $F$, only varies with time

for $t<0$ the ground provides the force to stop movement

therefore we can limit movement to 1 dimension, $x$
and from newtons second equation we get $a(t)=-mg+F(t)$
Now we want to have the leg to start from rest and finish at rest, if it doesn't finish at rest then you haven't finish lifting it.
If $F(t)$ is a constant (either greater than $mg$ or less than $mg$) then we won't get this behaviour, it will either not start moving ($F=mg$) or not stop ($F\neq mg$).
But if we have a slightly more complicated expression for the force, for example
where $t_0$ is chosen so that the leg stops at the right height (which i'm going to call $L$).
$$F(t)=\begin{cases}
      2mg & 0\leq t<\frac{t_0}{2}\\
       0& \frac{t_0}{2}\leq t\leq t_0 \\
      mg & t_0\leq t
   \end{cases}$$
ie lifting the leg with twice the force of gravity for the first half then letting gravity slow it to a stop for the last half, then providing a constant force to match gravity so that it stays there. (a point of note is that the average force
is $mg$)
hence the acceleration is
$$a(t)=\begin{cases}
      +mg & 0\leq t<\frac{t_0}{2}\\
       -mg & \frac{t_0}{2}\leq t\leq t_0 \\
      0 & t_0\leq t
   \end{cases}$$
from this we can find the velocity, by either integrating or recognising that these are the same conditions as newtons equations of motion so would follow the same behaviour
$$v(t)=\begin{cases}
      +mgt & 0\leq t<\frac{t_0}{2}\\
       -mg(t- \frac{t_0}{2})& \frac{t_0}{2}\leq t\leq t_0 \\
      0 & t_0\leq t
   \end{cases}$$
and then the height
$$x(t)=\begin{cases}
      +mgt^2 & 0\leq t<\frac{t_0}{2}\\
       -mg(t- \frac{t_0}{2})t+L& \frac{t_0}{2}\leq t\leq t_0 \\
      L & t_0\leq t
   \end{cases}$$
A point to mention is that this isn't the only function that would fit the conditions, there would be an infinite number of possible force functions. But they would still have an average force of $mg$.
hopefully that helps
Answer: Here's a general way to look at it:
For starters assume you have all your weight on one leg, so the other leg is hovering very slightly above the ground. If we didn't assume this we would have to account for the weight shifting from one leg to the other and this would complicate the story ever so slightly. At this point you are still stationary so the force on your standing leg is exactly $mg$. During the lifting of your leg your center of mass moves a little bit upward. Unless rotations are involved you can treat objects like they are point masses located at their center of mass. So for example to calculate the work that was done you can calculate the height of the center of mass before you lift your leg and the height after and use the difference to calculate $\Delta W=mg\Delta h$. The energy expended will generally be a bit higher because your muscles lose energy due to friction.
To look at the force that is exerted on the ground let's look at the height of your center of mass and we will assume there is a period of constant acceleration, a period of constant velocity and a period of constant deceleration. The velocity and acceleration graphs will look something like this:

The acceleration graph is the result of the total force on your body, which is given by
$$F_\text{total}=F_\text{leg}+F_\text{gravity}$$
If you ponder a bit about how the signs should be you can conclude that

during the initial constant acceleration $F_\text{leg}>mg$,
during the phase of constant velocity $F_\text{leg}=mg$,
during the last phase of constant deceleration $F_\text{leg}<mg$.

The graph that I showed above is ofcourse not how a real world graph will look like but it should give you a vague idea of what is happening.
Answer: Well ,in theory, yes. Your leg weighs a certain amount, let's say 30 pounds, but when you lift your leg, there is some friction that will always resist, such as the air that you displace being relocated, and the slight amount of friction in your leg joint and sinews rubbing together and such. So you do apply more force, but it is a such a small amount, that it is hardly noticeable. It is so small, that it does not matter for any practical reason. I hope this answers your question.
Answer: To suspend 1kg of mass at the earth's surface requires 96 watts of energy.  This can be done by building an electronic circuit that suspends a mass, and computing the power requirements.  Many physicists believe that no work is required to hold a mass in a gravitational field, which is false.  Try holding a 100 lb mass over your head for an hour, and then tell me...that...lol ed
Comment: Read this: https://physics.stackexchange.com/q/1984/305718
Comment: work, in physics, is **defined** as force times distance (or for variable forces, it is the path integral of the force). So if an object doesn't move then no work is required. Also there is a $1kg$ mass that has be suspended in Paris for over 100 years and it required no power to suspend it.


What is the diffrence between window 2008 server 32bits and 64 bits editions when I want to deploy an image?

Question: I want to deploy a windows 2008 32 bit image but I want to know that what is different between 32bit and 64 bit when I want to build the 32bit image.
Answer: There is no difference beacause IF YOU DEPLOY A 32 bit image YOU CAN NOT BUILD A 64 bit image. That simple.
That said, deploying 32 bit images these days is negligent. Go 64 bit - 64 bit operating systems can see all your memory (32 bit is limited to MAXIMUM 4 GB, most likely about 3.5), and 64 bit can run 32 bit programs.
Answer: Deployment is the same whether the image is 64 bit or 32 bit.  You can deploy the images from the same deployment server.


How to keep Glasses on when Breastfeeding/Feeding

Question: When my partner is feeding the baby, her glasses slip down because she's looking down at the baby, and she has both hands full, so she can't push them up. I'm happy to push them back on when I'm there, but I was wondering if there was any advice from bespectacled mothers on how to handle this problem.
Comment: With experience, she will/should be able to breastfeed practically hands-free. In fact, she'll be able to manage to eat, cook, type, etc. -- all while breastfeeding.
Comment: @Swati but, by the time that experience arrives, the babies learn to grab things... such as one's glasses. B-)
Comment: Croakies? http://croakies.com/
Comment: Any reason not to wear her contact lenses?
Comment: Doesn't have any. Doesn't wear them generally.
Answer: I know this hardly seems like an answer at all, but better fitting glasses are probably your best option. Mom likely doesn't even need new glasses, but maybe just an adjustment for a better fit around the ears.
Good luck!
Answer: I bought some small braiding rubber bands (which you can find in the "ethnic hair" section of any pharmacy next to hair relaxer) and wrapped a couple around the ends of my wife's glasses like this.  She says they stay up now.
This type of rubber band is good because it doesn't fall apart after a few months and doesn't grab at hair the way a regular rubber band does.
Comment: You're right, it's unclear.  I do mean wrapping them around just the ends, not making a poor-man's croakie.
Comment: You're just wrapping them around the end of the ear pieces? That's a great idea.


High frequency noise on PCB

Question: I have been asked to continue an unfinished project using Sigfox ATA8520 transceiver and Arduino DUE board. There are some LEDs and buttons on the board which I think are used for selecting different modes on the board. When I turn the board on, I see that the LEDs are driven through transistors that randomly turn on without touching the board. These LEDs do not glow quite dim but bright enough to see in a well lit room. What could be causing it and how can I fix it?
Comment: Sounds to me like pull down resistors are not connected
Comment: SMPS are worst offenders then line noise on wires that may be suppressed with filters and RF cap to earth gnd.
Answer: There could a few reasons why traces that carry high frequency often run into noise issues. Points below come from personal experience and what I learnt troubleshooting high frequency noise on boards.

You need decoupling capacitors close the power supply preferably tantalum.
Noise usually occurs because of parasitic capacitance or inductance building up in the circuit. Reasons for this could be length of traces that carry high frequency signals. These signals induce voltage onto neighboring traces thereby generating noise which for a beginner would be almost impossible to troubleshoot.
When using high frequencies, linear power supplies must be used such as a battery pack or even bench power supplies that are linear.
Use pull-down resistors (at base/gate of transistor/MOSFET) when switching semiconductors are used such as transistors, MOSFETS, etc.
You need to be careful of how ground planes are connected. Usually it is recommended to run high frequency transceivers and digital logic of microcontrollers of separate power supplies or at least separate ground places to mitigate as much high frequency noise as possible.
Proper shielding of high frequency components from low frequency components would be a useful technique to avoid issues you are facing.
Comment: Thanks for your answer, I have been asked to design a new board and your recommendations will be very helpful.

High frequency noise on PCB


How to add more toppings to frozen pizza?

Question: I generally buy frozen Pizza Margherita in store for making a quick lunch if I am running out of time. However, I don't really like the taste of the baked Pizza because it is just Tomato and Cheese. I am a vegetarian and I would like to add toppings but when? Should I directly add veggies on frozen pizza and put it in the oven or let the frozen pizza bake for a few minutes and then add the toppings ? Suggestions are most welcome.
Answer: The method I've used to add toppings to frozen pizza is- use frozen toppings. For example, green peppers are in my opinion a great addition to pizza. I usually keep frozen green peppers and other pizza-worthy vegetables for use with many things, and frozen pizza is one of them. This way, I simply add the toppings to the pizza before baking and viola! Easy, simple, and much more tasty frozen pizzas.
Answer: I do this quite frequently, as well as making my own pizzas. Most pizzas will cook in approximately 20 minutes, so it is absolutely fine to put any of your favourite toppings on right from the start of cooking. It may be beneficial for some foods which are more likely to char (such as broccoli or thinly sliced ham) to be either dipped in water first or covered with a little cheese to insulate them against the heat and stop them from drying out.
Comment: You might find the onion nicer if you fry it first, then add it to the pizza near the end of the cooking time. It also has the added benefit of driving the water out - raw onions are one of the main offenders for soggy pizza.
Comment: Ditto this exactly. I add toppings (sliced raw onion / mushroom / bell pepper / broccoli / asparagus..., shredded or sliced meats) and then some extra cheese. Bake for the normal amount of time and it's fine. The only thing you have to be careful of is not adding too many "wet" vegetables as these can make the middle of the pizza end up a bit soggy.
Comment: I love caramelised onions on a pizza! Especially if a tiny bit of sugar and a healthy glug of balsamic vinegar are added shortly before the end of frying!
Answer: One of the best toppings for a pizza is egg, just don't put it on at the start. Let the pizza cook for about 12 minutes then crack the egg on top and place back in for another 6-8 minutes. This should leave the egg runny, but if you don't want it like this then just leave for a little longer.
Onions and peppers are good toppings as well and they can go on right from the start.
Comment: I have spent a lot of time with my friend the pizza and I have somehow never considered eggs as a potential topping. Thanks for that!
Answer: For vegetarian options, it depends on what you want to add.  Pickled jalapeño slices go right on top before you bake it, and they add just the right amount of zing to a bland pizza (cut them in half or even quarters if you're timid).  Spinach or kale can be washed, chopped, and added right on top, too, before the bake. Unless you slice green peppers or onions quite thin, microwave them for 45 sec. before you put them on. (Red peppers cook faster.) Fresh mushrooms sound fantastic, but raw ones will make a frozen pizza soggy, so do stir-fry them first for 1-2 min. in oil or butter and then add them before the bake. Fresh tomatoes should go on after the bake, unless they are anemic winter or strip-mined tomatoes, in which case, you should dice them, press the extra juice out, and scatter them before the bake in a wide circe, avoiding the middle. Olives can go on either before or after.  As my dad says, dress up frozen pizza? I dress it up in a tuxedo!
Answer: Roasted veggies yesterday. I'll reheat them before topping the frozen pizza, then use the regular cooking time.
Answer: My granddaughter will only eat
cheese pizza with mushrooms and black olives so I thinly slice the mushrooms and olives and spread them out over the frozen pizza. Then on the other half, I thinly slice red onion and separate into rings and scatter on that half, along with pepperoni. I think sprinkle a little garlic powder and black pepper over the entire pizza, then scatter a thin layer of mozzarella all over. I bake at 425 for 20-22 minutes, rotating the pan at 10 minutes and it's never soggy and the crust is crisp and the cheese bubbly and slightly brown. I cool for a couple of minutes, then slice and serve
Answer: Chop up lunch meats , leftover fully cooked chicken or hamburger, Kroger has a frozen bag of peppers and onions diced and your very simple plain pizza just became something from the heyday of pizza when flavors were in incredible.add it all at the beginning cook at 400 for roughly twenty minutes.


Given a signal that is not bandlimited, how do you properly take the FFT?

Question: I assume that the Nyquist theorem doesn't apply, at least not in the standard sense, for a non-bandlimited signal. In my case, I sample the signal (in the time domain) above the Nyquist rate and then take the FFT up to the Nyquist frequency. How should I take into account the fact that my signal isn't bandlimited?
Comment: If the signal is not bandlimited, how do you sample it above the Nyquist rate? That's a contradiction.
Comment: @MBaz. Assume physics does not apply and you can sample continuously in time :)
Comment: @user253751. Yup. Too bad everything we have besides pure math is finite.
Comment: You have to bandlimit the continuous-time signal first.  Then sample the signal properly.  Then FFT.
Comment: Your assumption is simply incorrect.  Nyquist always applies.  It either tells you what the band limiting should be, or what the effects will be if you're not band limited.
Comment: @MadPhysicist then you have an FT, not a DFT or FFT, right?
Answer: In the real world, there is always some amount of aliasing, because no real signal is actually bandlimited.
In many cases, the signal spectrum tends to zero relatively quickly as the frequency increases. With a proper selection of sampling frequency, aliasing (and the corresponding distortion) can be kept within acceptable levels.
In other cases, the signal's spectrum rolloff to zero is very slow -- an example would be trying to sample white noise. Directly sampling the signal at any practical sampling rate results in unacceptable aliasing. What one does is to filter the signal first, and then sample. This results in information loss, but at least the frequency band of interest was properly sampled.
To directly answer your question (corroborating what Dan said): if you're not in one of these two scenarios, the signal is not properly sampled: the samples do not correspond to the signal and it is essentially impossible to perform any useful signal analysis using them.
Comment: The problem with the 1Hz sine is when you try to re-generate the continuous-time signal from its samples: the interpolation will fail at the start and end of the signal. Regarding distortion, the fact that this distortion is acceptable in many cases is what makes DSP useful in the first place. In a well-designed system aliasing **is** an irrelevant technicality. It was not clear from the OP's question whether the aliasing in their system is irrelevant or significant.
Comment: @OverLordGoldDragon You are reading things in my post that I didn't say. Also: the sampling theorem (what the original question is about) is all about reconstruction from the samples. And: most signals of interest tend to zero both as $|t| \rightarrow \infty$ and $|f| \rightarrow \infty$.
Comment: I don't understand why such aliasing isn't treated as an irrelevant technicality. A signal can be perfectly 1Hz over a finite duration, and if we sample it over that duration, then we have a perfect 1Hz sine, without distortions that are implied by aliasing. Just because "finite = infinite bw for continuous FT" doesn't mean "all real world signals are distorted", as such descriptions imply. Isn't it better to reserve the word for when we have actual uncertainty for peak frequency over a finite duration?
Comment: @MBaz +1 Thank you very much. Could you please elaborate on how to determine the proper sampling in either of the two cases you mentioned, as well as how to determine what the filter should be? Signal processing is quite new to me.
Comment: To add on to my previous comment, I guess the distinction between the two cases is somewhat arbitrary, and in the case #2, you probably apply a low-pass filter or something like that. Is that correct? But why do you sample afterward? I thought the signal was already sampled in the time domain, you take the FT, and then apply the filter to the output. Could you sample first and then apply the filter? Sorry for being dense, but I don't have a signal processing background.
Comment: @user2 I recommend picking up Richard Lyon's book on DSP, it's excellent and approachable. To your questions: it's not that the distinction is arbitrary; rather, it depends on the requirements of your design, regarding how much aliasing is tolerable, what sampling rates are available, etcetera. Finally, indeed a low-pass filter is used to match the bandwidth of the analog, continuous-time signal to the sampling rate of your analog-to-digital converter. Filtering must happen before sampling; otherwise aliasing will occur and can't be fixed. Search for "anti alias filtering".
Comment: That's not a problem with sampling or the signal, that's a limitation of just one of possible postprocessing tools. Sinc interpolation isn't the only continuous reconstruction method, nor is it necessarily the best, nor do we _need_ a continuous reconstruction in the first place. "Fourier bandlimited" requires infinite sampling rate from big bang to heat death, which is a useless criterion and makes the use of Fourier transform in this way useless, like saying $x^2 = -1$ can't be solved. It also makes your point on energy rolloff irrelevant, as finite signals never roll off in CFT.
Answer: If your signal is not band-limited prior to sampling, then without any further information (such as a copy of the signal sampled at a time offset, which could synthesize a higher sampling rate), irreversible "damage" is done to the waveform via aliasing: each sample contains energy from all Nyquist zones and the FFT will properly reflect this result.  It is simply a many to one mapping so nothing further can be done without other information. An analogy is x+ y = 5; we know the sum but without a second formula we cannot distinguish x from y —- so in this case without other information about the signal we cannot know what Nyquist zone in the continuous time domain the signal originated. "Other information" can be what filtering was used or other copies of the waveform with different sampling that was done concurrently (or repeatably sampled if we know other details of the waveform such as ergodicity and stationarity). In most cases we are sampling the waveform to determine its characteristics but noting that there are situations where other information can be used. This last point can be more confusing so should not distract from understanding the aliasing mechanism when sampling signals and understanding the need for band selection filtering prior to sampling.
The bottom line to avoid aliasing is that the signal must be band-limited to be within one Nyquist zone prior to sampling (including the possibility of bandpass filtering higher Nyquist zones when the analog input bandwidth of the ADC allows for bandpass sampling).
The same condition exists when decimating or resampling the signal- prior to down-sampling, the higher sampled waveform must first be band-limited to be within one Nyquist zone for the lower sampling rate.
Answer: In real life (as opposed to mathematical fictions) there is always noise (thermal and quantum at the limit), measurement errors, finite durations of operation, finite precision data types and arithmetic, etc., among other limitations, creating a noise floor.
So in practice, one considers a signal to be band limited if all the spectrum above the band limit frequency is thought to be below the desired or assumed noise floor.  Or considers the portion of the spectrum above the band limit frequency to be noise contributing to the measurement and computational noise floor.
So you take your FFT by taking an FFT.  But your FFT result becomes fuzzy by up to the maximum of that floor, or is fuzzy by about some statistic of that noise floor, due to the aliasing of that above bandlimit frequency noise into the spectrum (FFT result bins) of interest.
Answer: The FFT is an efficient computational algorithm implementing the DFT (discrete Fourier transform) performing an orthogonal transform on a finite discrete data set.  There is no way to "improperly" take it.  It is nonsensical to talk about "bandlimited" "signals" in connection with an FFT; for example, it is employed as an integral part in very large multiplication algorithms that have nothing whatsoever to do with band-limited signals but rely on it for diagonalisation of circulant matrices.
What is covered by the Nyquist theorem is discrete-time equispaced sampling.  FFT is a red herring other than that "band-limited" tends to be defined in terms of the continuous time-unlimited Fourier transform which is somewhat related to the DFT but is an analytical rather than computational tool.
Certain approximations of Fourier transform related information, like the overlapped windowed short-time Fourier transform, give some useful interpretations of relevant signal characteristics.
But there is no way to handwave your problem around those interpretations in general terms: how useful readings of those computational readings are depends on the kind of task you are trying to address, and bandlimitations and/or aliasing are artifacts in connection with your sampling process and are not really affecting the validity of the subsequent analysis of the data other than by the GIGO principle (garbage-in, garbage-out).


Change tab size of "cat" command

Question: When I am in vim I can change the tab size with the following command:
:set ts=4

Is it possible to set tab size for cat command output too?
Answer: The first command here emulates the formatting you see in vim.  It intelligently expands tabs to the equivalent number of spaces, based on a tab-STOP (ts) setting of every 4 columns.
printf "ab\tcd\tde\n" |expand -t4

Output
ab  cd  de

To keep the tabs as tabs and have the tab STOP positions set to every 4th column, then you must change the way the environment works with a tab-char (just as vim does with the :set ts=4 command)
For example, in the terminal, you can set the tab STOP to 4 with this command;
tabs 4; printf "ab\tcd\tde\n"

Output
ab  cd  de

Comment: good to know (1). `expand` (from coreutils package) and `tabs` (from ncurses package) command, (2). and the meaning of ts is [**T**]ab [**S**]top
Answer: Just use the following code:
tabs -n

Where n is the number of spaces you want tabs to correspond too.
In order to not having to do this every time you start the shell, just edit your .bash_profile in ~/ and add the above line to the end of the file.
For further info about the tabs command, refer to:
man tabs

Comment: Just beware that permanently changing your default tabs width might screw up other commands (for example `ls` out put may look not properly aligned).
Comment: Aliasing `ls` to `ls -T 0` helps with the `ls` output
Answer: There's no notion of tabs or tab stops in cat; the program just funnels the inputs to the output and treats tabs like any other character.  If the output device happens to be a terminal, tabs will be handled according to whatever behavior the terminal is configured to provide.
Systems implementing POSIX.1 have a command called tabs(1) that will adjust the terminal's concept of how tabs should be displayed.  Depending on a particular tab layout is not considered a good idea, as someone may send your file to some other device such as a printer that won't do what you intended.
When you adjust ts in vim (or plain vi), all you're doing is adjusting how the editor interprets tab characters when displayed.  It has no bearing on what ends up in the file.
Comment: Thanks for explanation. How is the printer configured to treat tabs?
Comment: Most printers treat them the same way as most terminals do by default:  the left margin and every eight characters afterward.
Answer: Based on the above answers and examples, it would seem that the actual command the OP wanted is...
cat somefile | expand -t4
This works for me on Red Hat 6.4.
Answer: To expand on the already given answers, expand can also take a list of tab stop positions. This is useful if the content lengths of the varlious columns varies a lot.
I came over this requirement today when I wanted to make the output of openssl ciphers more readable:
$ openssl ciphers -v 'HIGH'|tr -s ' ' '\t'|expand -t31,41,57,70,90
ECDHE-RSA-AES256-GCM-SHA384    TLSv1.2   Kx=ECDH         Au=RSA       Enc=AESGCM(256)     Mac=AEAD
ECDHE-ECDSA-AES256-GCM-SHA384  TLSv1.2   Kx=ECDH         Au=ECDSA     Enc=AESGCM(256)     Mac=AEAD
ECDHE-RSA-AES256-SHA384        TLSv1.2   Kx=ECDH         Au=RSA       Enc=AES(256)        Mac=SHA384
ECDHE-ECDSA-AES256-SHA384      TLSv1.2   Kx=ECDH         Au=ECDSA     Enc=AES(256)        Mac=SHA384
...
ECDH-ECDSA-AES128-SHA          SSLv3     Kx=ECDH/ECDSA   Au=ECDH      Enc=AES(128)        Mac=SHA1
AES128-GCM-SHA256              TLSv1.2   Kx=RSA          Au=RSA       Enc=AESGCM(128)     Mac=AEAD
AES128-SHA256                  TLSv1.2   Kx=RSA          Au=RSA       Enc=AES(128)        Mac=SHA256
AES128-SHA                     SSLv3     Kx=RSA          Au=RSA       Enc=AES(128)        Mac=SHA1

CAMELLIA128-SHA                SSLv3     Kx=RSA          Au=RSA       Enc=Camellia(128)   Mac=SHA1
PSK-AES128-CBC-SHA             SSLv3     Kx=PSK          Au=PSK       Enc=AES(128)        Mac=SHA1

Using only expand -t31 would blow up the width of the output from around 100 characters to more than 160 characters.
Comment: An easier way to do that is to use `column`: `openssl ciphers -v 'HIGH' | column -t`
Answer: For X terminal emulators (eg. $TERM is xterm, st, etc.):
$ tabs -N

For virtual consoles (no X Server, only text console where $TERM is linux, etc.):
$ setterm --tegtabs N

Where N is an integer number of spaces to be used for TAB.
Sed way insead of tr which translates SET1 to SET2 of characters in 1:1 'proportions':
$ sed 's/\t/    /g' FILENAME
           ^^^^^
        spaces here

Answer: Many terminals support setting variable tab stops.  Those that are vt100, linux and or support the EMCA-48 standard do,
most terms on linux support setting tab size: xterm and family (uxterm, urxvt) xfce4-terminal, luit, Terminal, SecureTTY, among others.
So wrote a script a few years back to set my tabs at login to every 2 spaces -- used to use 4, then 3 for a short bit, and now at 2....
So now, if I 'cat' a file, tabs in the file will expand to my terminal's setting.
If I got through vim or more, they do their own tab expansion, but alot of utils use tabs.
Will include the script here for reference, and or personal use:
#!/bin/bash  -u
#console_codes(4) man page... vt100/2 et && EMCA-48 standard
# (c) la walsh (2013) -- free to use and modify for personal use.
#                     -- optionally licenced under Gnu v3 license.

# v0.0.3    - try to reduce tabcols to minimal set to reproduce.
# v0.0.2    - set tabs for full terminal width (try to get term width)

shopt -s expand_aliases extglob
alias my=declare
alias int='my -i'       array='my -a' intArray='my -ia'   string=my

my _Pt=$(type -t P)
[[ $_Pt && $_Pt == function ]] && unset -f P
alias P=printf
unset _Pt

P -v clrallts  "\x1b[3g"    #Clear All TabStops
P -v hts       "\033H"      #Horizontal TabStop
P -v cpr       "\x1b[6n"    #Current Position Report

getcols() {                 # try to read terminal width
  local sttyout="$(stty size </dev/tty)"
  int default_cols=80
  if [[ -n ${COLUMNS:-""} && $COLUMNS =~ ^[0-9]+$ ]]; then
    default_cols=$COLUMNS; fi
  [[ -z ${sttyout:-""} ]] && { echo $default_cols; return 0; }
  int cols="${sttyout#*\ }"
  echo -n $[cols<2?default_cols:cols]
  return 0
}

getpos () {
  string ans    wanted=${1:-xy}
  int attempt=0 max_attempt=1   # in case of rare failure case
                                # use 'attempt' value as additional
                                # time to wait for response
  while : ; do
    ( ( P "\x1b[6n" >/dev/tty) & 2>/dev/null )
    read  -sd R -r -t $[2 + attempt] ans </dev/tty;
    ans=${ans:2};
    int x=0-1 y=0-1
    if ! x="${ans#*;}" y="${ans%;*}" 2>/dev/null  ||
      ((x==-1||y==-1)); then
      ((attempt+=1 < max_attempt)) && continue
    fi
  break; done
  string out=""
  [[ $wanted =~ x ]] && out="$x"
  [[ $wanted =~ y ]] && out="${out:+$x }$y"
  [[ $out ]] && echo -n "$out"
}

declare -ia tabs

get_tabs () {
  P "\r"
  tabs=()
  int pos=0 oldpos=0-1
  while ((oldpos!=pos));do
    ((pos)) && tabs+=($pos)
    oldpos=pos
    P "\t"
    pos=$(getpos x)
  done
  P "\r"
  return 0
}

# Note: this func uses ability to _read_ tabstops as _proxy_ for setting them
# (i.e. it makes no sense to be able to read them if you can't set them)

test_tabset_ability () {
  string prompt="tty_tab:"
  int newcol=${#prompt}+1
  P "\r$prompt"
  int mycol=$(getpos x)
  ((mycol && mycol==newcol)) && return 0    ## return OK

  { P " Term tabset ability not detected mycol=${mycol:-''},"
    P " promptlen=$newcol)\n"; } >&2
  exit -1
}

do_help_n_display_curtabs () {
  P " <n>   - set tab stop to N\r"
  intArray diffs;
  int last=1  cur i
  string eol=""
  get_tabs && {
    for ((i=0; i<${#tabs[@]}; ++i)); do
      cur=${tabs[i]}
      diffs[i]=cur-last
      last=cur
    done
    intArray reverse_tabs_set=()
    int prevtab=0-1
    for ((i=${#diffs[@]}-2; i>0; --i)); do
      int thistab=${diffs[i]}
      if ((thistab!= prevtab)) ;then
        reverse_tabs_set+=($thistab)
        prevtab=thistab
      fi
    done
    P "current value: tty_tab "
      for ((i=${#reverse_tabs_set[@]}-1; i>=0; --i)); do
        P "%d " "${reverse_tabs_set[i]}"; done
    P "\r";
  }
  get_tabs  && {
    P "(from 1, tabs skip to column: "
    P "%s " "${tabs[@]}"
    P "\r\n"
  }
}

set_tabs () {
  int max_col=${1:=0-80}
  int tabstop=${2:-?"need a param for tabstop"}
  int tab=$tabstop        pos=0
  string str=""
  P $clrallts               ## reset old tabs
  while ((++pos<cols)) ;do  ## move across screen setting tabs
    str+=" "
    ((pos%tab)) || str+="$hts"
  done
  P "\r$str\r"
}

int cols=$(getcols)

test_tabset_ability         ## exits if no ability

if (($#==0)) ; then
  do_help_n_display_curtabs
  exit 1
else
  set_tabs "$cols" "$@"
fi

# vim: ts=2 sw=2

Hope it helps...
Answer: According to the manpage, cat can not do it on its own. But you can e.g. run the output from cat through tr filter to replace the tabs with any number of spaces you wish:
cat somefile | tr '\t' '  '

will replace the tab character with two spaces.
Update: as pointed out in the comments to this post, this actually does not work. Nevertheless, I'm keeping the answer as an example of how not to do it.
Comment: It's actually replacing `'\t'` with only one space, no matter how many spaces are in between the second pair of quotes `'      '`
Comment: `tr` doesn't work that way..  each **byte** of arg 1 is substituted by each corresponding **byte** of arg 2..... Therefore `printf '\t' |tr '\t' 'ळ'`  prints out a single byte whose hex value is `\xE0` .. which is the first byte of the three UTF-8 encoded bytes which make up the character `ळ` (whose Unicode CodePoint value is U+0933)
Comment: Ah, of course. Thanks for catching my silly mistake!

Change tab size of "cat" command