Is it possible to point to array of named ranges with INDEX reference form?

Question: I'm keeping data in several equally sized arrays saved as named ranges Arr1, Arr2, Arr3 etc. I want to look up things from any these arrays with INDEX or CHOOSE wrapped inside another INDEX e.g. by going INDEX(INDEX((Arr1;Arr2;Arr3);;MATCH...);2;2)
As my list of arrays grows large and I need to apply my INDEX/CHOOSE-MATCH many places, I'd like to avoid repetition and store the names of my named ranges in another array or table, let's call it Arr_list.
Is it possible to substitute the reference part, i.e. '(Arr1;Arr2;Arr3)' of an INDEX formula with a call to the Arr_list array?
Answer: Wrap the INDEX(Arr_list) in INDIRECT - then the outermost INDEX understands the result of INDEX(ARr_list) refers to a named range.
An example:
=INDEX(INDIRECT(INDEX(ArrayList,2)),2)

Comment: Thank you for the elegant answer. I've implemented it and it works like a charm and dramatically shortens my formula \(^_^)/
Comment: Also, my greatest apologies for taking so long to reply and test your solution! I really appreciate your help.
Answer: A way to do this without the INDIRECT function(which is volatile, and may slow down workbook with large ranges) is to make your Arr_List into one array using the colon Range operator, or the comma union operator.
I show an example of it below with the Master named ranges themselves as named ranges.

You may form a Union like so:
=Name,Age,Sales,Gender OR
=name:Age:Sales:Gender
The comma/Union way is referenced with the 2nd form of INDEX which takes a reference, and then gets the area as parameter like:
=INDEX(Master2, 2, 1, 4) to get Gender.
The Colon/Range way is referenced by the 1st form of Index:
=INDEX(Master, 2, 4)
Comment: Thanks for this solution also. I'm thrilled to see various ways to resolve my problem. I can confirm this also worked for me but I went with BigBen's solution in this case. My apologies for not replying earlier,  :-)


Exportar tabela do DB em formato csv com colunas separadas por ponto e vírgula

Question: Já consigo exportar em CSV, mas as colunas estão vindo separadas por vírgula, como fazer para virem separadas por ponto e vírgula?

Meu código:

<?php
      //export.php
 if(isset($_POST["export"]))
 {
      $connect = mysqli_connect("localhost", "root", "", "simrede");
      header('Content-Type: text/csv; charset=utf-8');
      header('Content-Disposition: attachment; filename=Cadastro_Alunos-Simrede.csv');
      $output = fopen("php://output", "w");
      fputcsv($output, array('lastname', 'firstname', 'department', 'institution', 'username',  'email', 'city', 'course1', 'password'),';');
      $query = "SELECT * from cs_alunos ORDER BY institution";
      $result = mysqli_query($connect, $query);
      while($row = mysqli_fetch_assoc($result))
      {
           fputcsv($output, $row);
      }
      fclose($output);
 }
 ?>

Answer: Seguindo a própria documentação, basta adicinar a flag string $delimiter = "," alterando para ";"
$out = fopen('php://output', 'w');
fputcsv($out, array('this','is some', 'csv "stuff", you know.'),';');
fclose($out);

Comment: Obrigado @IsraelZebulon ! Bem simples, vou dar uma lida na documentação.
Comment: não funcionou adequadamente, apenas o cabeçalho vem com ponto e vírgula
Comment: tem de adicionar em while também pra fucionar


Not able to pass data from view to Controller via url

Question: I am new to CodeIgniter and trying to pass data from view to controller, and then access it. I have looked for various solutions but none of them worked for me. Can you please help in letting me know where am I wrong?
the URL helper is loaded automatically, and I don't understand what else to do.
view.php
 ...
<a href="<?php echo base_url().'product/'.$id; ?>
...

Controller.php

class Product extends CI_Controller{

    public function __construct()
    {
        parent::__construct();
    }

    public function index($id){

       $id = $this->uri->segment(2);
        echo "hello";
          echo $id;
    }

}

the expected result is to print Hello but instead it shows 404 Page not found.
Please help. Thanks in advance.
Comment: just remove $id = $this->uri->segment(2);
Answer: I got the solution to the answer.
<a href="<?php echo base_url().'index/product/'.$id; ?>

prints the correct output. It is so because i did the url_routing in my site. Thanks for the help by the way.


PCI compatible recipe?

Question: I've struggled to find a really straight answer that makes me super comfortable to this question after searching SE, PCI basics, drupal.org, AWS resources, and reading the Drupal PCI Compliance White Paper.
I think I am just looking for some confirmation or denial from folks who have set up eCommerce environments before. Perhaps this is because I am overthinking it (I really don't want to expose a small business to unnecessary liability), and perhaps because environments are all different so it's difficult to say.
I'd like to be sure to create a PCI compatible environment using Drupal Commerce with an onsite payment gateway (Authorize.net). In our MOU it will be up to the site owner to ultimately write down their business processes and take the SAQ (recommended, as they should qualify for level 4 from Visa/Mastercard) to say they are PCI compliant, but since I am building the site out I would like to make sure they don't have any trouble with that piece of it.
As long as we are...

Hosted in a PCI compliant environment (AWS EC2 in this example)
Have firewall properly configured
Serving all relevant (but ideally all) pages over SSL
Use good passwords, no users are shared
All security updates are made for Drupal and modules promptly

Is that a recipe for a PCI compatible environment? Have I forgotten any pieces?
My second but related question is - Does using Drupal Commerce with Authorize.net (onsite processing) mean the business should use:

SAQ-A (Card-not-present merchants: all payment processing functions fully outsourced, no electronic cardholder data storage)

or

SAQ-EP (E-commerce merchants re-directing to a third-party, PCI compliant service provider for payment processing, no electronic cardholder data storage)

I know Drupal Commerce provides the 'no cardholder data storage' by design, but i'm very unclear on the definition difference between 'all payment processing functions fully outsourced' and 'merchants re-directing to a third-party compliant service provider for processing'.
Thanks for your thoughts!
Comment: You may want to consult with Commerce Guys for a definitive answer and authority on this.
Comment: Thanks Kevin! Yes, I will drop them a line - hopefully they're able to throw some advice my way, or at least with any good resources that exist which I haven't found. We won't have the project budget for an official consult if we take this on so i'm still hoping for a community conversation here - barring that I suppose we will go with our best guess and just be super careful about it.
Answer: Disclaimer: Keep in mind I am neither a lawyer nor a PCI QSA.
After doing more research - I'm convinced that using Drupal Commerce with authorize.net AIM (which is the method used by the authorize module that comes with the commerce kickstart profile) should land you directly into SAQ-D in almost all cases (do not pass go, do not collect $200).
This means you need all the things above plus much more management and policy on your end (or your clients end). It wouldn't be feasible for a small company without a huge budget for a custom project.
Here is the best/most robust explanation i've found of which SAQ to use in one place.
To reduce the scope of the CDE using Authorize.net, one would need to integrate with SIM (offsite form generation) to use SAQ-A, or DPM (direct post) to use SAQ-EP. This assumes you can say yes to the entire list of qualifications i.e. only take payment online, no POS etc. The latter option offers more customization but is more work.
This module looks like it will allow you to do so with Drupal Commerce, but I have done no testing or verification.
Looks like smaller budget clients should be briefed on PCI (always) and plan to use the off-site methods such as Authorize.net SIM or Paypal WPS where the form is generated by the CC processing organization's servers, and never touches your environment. This way your environment should be out of scope with proper configuration.
Here is a (albeit pretty old) thread from authorize.net development forum that has some general and scalable config insights I found very useful.
Here is another (1 year old) white paper that sets forth a framework for PCI compliance on AWS in general. Some of these pieces are not applicable to just a Drupal Commerce server, but still interesting and good.
Any more thoughts still welcome.
Comment: Correct, Authorize.net is D, credit card numbers pass through the Drupal server (though they aren't stored). They've just created an Accept.js library to help with this (lowering the requirements to A-EP), but no Drupal module implements it yet.

PCI compatible recipe?


Definite integral of the cube root of $x \ln (x)$

Question: I was trying to solve the 2016 CSE question paper for Math Optional
$$I = \int_{0}^1 \left (x\log \left (\frac{1}{x}\right)\right)^{\frac{1}{3}} dx$$
In my attempt to find $I$, I tried to substitute
$$t = \log \left (\frac{1}{x}\right) \\\ dt = \frac{x}{-x^2}$$
Even tried taking
$$t = x\log \left (\frac{1}{x}\right)$$
and then tried by parts. But I am unable to make headway. Any idea what might work? How can I tackle these types of problems?
Answer: Hint: Set $u = \ln \frac{1}{x}$.
Assuming my scratchwork is correct, I think you should end up with something like $$\int_0^{\infty} \sqrt[3]{u} e^{-\frac{4}{3} u} du.$$
Then make the substitution $\widetilde{u} : = \frac{4}{3} u$ and the result comes out nicely.
Spoiler: Answer is $$\left( \frac{3}{4} \right)^{\frac{4}{3}} \frac{\Gamma(1/3)}{3},$$ where $\Gamma$ denotes the gamma-function.
Comment: I reached that point, but I could not proceed past that.
Comment: Happy to include more, but you should be able to get the answer from here. Please accept answer when you feel it is appropriate.
Comment: Oh thanks, I did not know the integral definition of the gamma function. https://en.wikipedia.org/wiki/Gamma_function
Answer: Hint = Let $x=e^{-u}$ while keeping the Gamma function in mind.
Answer: Take $x = e^{-3t/4}$
Then $\log\frac{1}{x} = 3t/4$
And $t$ varies from $0$ to $\infty$
Substitute these values in question
You'll get the answer in gamma function
Comment: Welcome to Mathematics Stack Exchange! Take the short [tour](https://math.stackexchange.com/tour) to see how how to get the most from your time here. For typesetting equations we use [MathJax](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference).


Assign variable and change property in same line

Question: I have a question on typescript:
I have an interface like following:
interface MyInterface {
  option1?: string;
  option2?: string;
  // more options
}

In another file, I would instantiate an instance of it:
const defaultVar: MyInterface {
  option1: 'defaultValue1',
  option2: 'defaultValue2'
}

Is there any way, to assign the default value to another variable and set specifics to some options? I am not even sure of the notation. Could maybe be:
const specificVar: MyInterface = defaultVar {
  option2: 'specificValue'
}

I want to define a bunch of constants, that all derive from a common default, and only adopt necessary values.
Thanks,
Benjamin
Answer: You can use the object spread operator:
interface MyInterface {
    option1?: string;
    option2?: string;
    // more options
}

const defaultVar: MyInterface = {
    option1: 'defaultValue1',
    option2: 'defaultValue2'
}

const specificVar: MyInterface = {
    ...defaultVar,
    option2: 'specificValue'
}

The code above creates a new object and assigns all properties of defaultVar to specificVar. We can also add extra properties that override properties in the new object.
Comment: Great, exactly what I have been looking for!


Graph with different colors for the same line

Question: Suppose I have the following array:
array = np.random.rand(5,3).flatten()
array

array([0.19274605, 0.46876174, 0.26670674, 0.55353007, 0.47098491,
       0.41225302, 0.99921434, 0.43489851, 0.93929395, 0.85369836,
       0.31313385, 0.41672712, 0.762171  , 0.06592526, 0.23157575])

These are the plotted data (with pyplot.plot()):

Now, I need the line to have a different color depending on the value, for example, I need that for values between 0.2 and 0.4 the line is red, orange for values between 0.4 and 0.6 and blue for values between 0.8 and 1.
How can I do it? I need a solution that does not involve separating the array itself into several subarrays according the ranges and graphing them with the different colors.
NOTE: I've seen a lot of examples of multicolored lines but along the x axis, I need it but for the y axis.
Thanks.
Comment: Why don't you need a solution that splits the array?
Answer: Don't have enough reputation to make a comment. But I think you are looking for this. The link is from the official Matplotlib documentation and is using derivative to represent the line color at different points.
Comment: I've seen a lot of examples of multicolored lines but along the x axis, I need it but for the y axis. Thanks for your answer.
Comment: It could also work on y-axis. Refer to the documentation of [LineCollection](https://matplotlib.org/3.1.1/api/collections_api.html#matplotlib.collections.LineCollection) with an [example](https://stackoverflow.com/questions/35372993/python-matplotlib-multicolor-line).


Global php view for conditional profile image

Question: I have tried to configure a view for a user listing.
In this view only few fields from the user entity will be shown. In the user entity I have a boolean variable. If the boolean variable is TRUE ("1") the real profile image should be shown, otherwise the default image for all users should be shown.
In order to implement it I have added a views field of type Global: PHP.  In the field's code I wrote:
$file = file_load($row->picture);
if(isset($row->field_primum) ) {
if($row->field_primum == "1") {
print theme('image', array('path' => $file->uri));
else ($row->field_primum == "2") {
print();
}
}
}

However it runs only on the first user and not for all users in the display. Do you have any idea why?
Thanks
zanet
Answer: It's possibly the result of syntax errors.
This is where you can see the benefits of well formatted code.
If you format your code like this it becomes more obvious that you have errors in your code (I assume $row->picture actually is a file ID):
$file = file_load($row->picture);
if (isset($row->field_primum)) {
  if ($row->field_primum == "1") {
    print theme('image', array('path' => $file->uri));
    else ($row->field_primum == "2") {
      print();
    }
  }
}

Problems I can see now are:

There you can see that the else actually has no if statement because it is inside the second if statement.
The else also shouldn't have the condition. If it needs the condition then use elseif.
You mention that the field you are using is a boolean field, in which case the values will be 0 & 1, not 1 & 2.
The second print statement should be printing a string so the string should be wrapped in quotes.
You are incorrectly using the a tag to print an image. You should use an img tag for images and an a tag for links.

I would think it should be more like this:
if (isset($row->field_primum)) {
  if ($row->field_primum) {
    $file = file_load($row->picture);
    print theme('image', array('path' => $file->uri));
  }
  else {
    print('');
  }
}

Note that I also moved the file_load() call inside the if statements because there is no need to load it if you aren't using it.


Positive semi-definiteness of a matrix implying certain structure

Question: I have the following (real) matrix which I need to be positive semi-definite,
$P = \begin{bmatrix} P_1 & -\frac{1}{2}(P_1+P_2)\\-\frac{1}{2}(P_1+P_2) & P_2\end{bmatrix} \succeq 0$.
I think this is only the case when, $P_1 = P_2 \succeq 0$, but I couldn't find a way to prove this. I was therefore wondering if this is even the case and if so how to prove this.
Answer: Indeed your claim is correct.
The characteristic polynomial of the matrix is:
$$\lambda^2-(P_1+P_2)\lambda-\frac{1}{4}(P_1-P_2)^2,$$
so that the eigenvalues are:
$$
\lambda_\pm=\frac{P_1+P_2\pm\sqrt{2(P_1^2+P_2^2)}}{2}.
$$
To ensure that both eigenvalues are non-negative it should hold:
$$
P_1+P_2\ge0;\quad (P_1+P_2)^2\ge 2(P_1^2+P_2^2)\Rightarrow 0\ge (P_1-P_2)^2.
$$
The last inequality can however hold only if $P_1=P_2$.
Comment: I forgot to mention that P1 and P2 are symmetric matrices of an arbitrary size, so not necessarily scalar. Will it still hold in that case?
Comment: @Patbott 0f course the proof is valid only for numbers, not for matrices. You should reformulate the question. Probably the best way is to write a new one.


CSRF protection with Symfony

Question: I'm unable to find Symfony documentation to activate CSRF protection in existent forms (with no protection).
I've set the csrf_protection with a token and so on, but forms are failing and I guess something is needed to work correctly.
Answer: Check that:

There's an entry for it in settings.yml
The CSRF token is rendered with the form in the template
CSRF token is not disabled inside the form class (or its parents)

... that should work.
Answer: try rendering it manually in the template, it should be on by default. {{ form_widget(formName._token) }}
if this doesnt work try adding it to the form method setDefaultOptions
$resolver->setDefaults([
        'csrf_protection' => true
    ]);

CSRF protection with Symfony


Binomial distribution probability (forming an equality)

Question: The probability that Sally will play football in any week is 0.29. Sally
does not play football more than once in any week. The probability that
Sally play football at least once in a period of $n$ weeks is greater
than 0.98. Find the smallest possible value of $n$.
While working out (using a tree diagram) I ended up with the inequality
$1 - (0.71)^{n} > 0.98$
But the answer says $1 - (0.71)^{n} < 0.98$
I'm not sure if I understand the question at all; any
help would be greatly appreciated.
Answer: Your approach is correct.
The probability that Sally does not play football in a given week is $1 - 0.29 = 0.71$.  Therefore, the probability that she does not play football in a period of $n$ weeks is $0.71^n$.  The probability that she does play football at least once in a period of $n$ weeks is therefore $1 - 0.71^n$. Since we wish to find the smallest value of $n$ such that the probability that Sally plays football at least once in $n$ weeks is greater than $0.98$, we require that
$$1 - 0.71^n > 0.98$$
as you found.
Let's solve the inequality to verify that your approach is correct.
\begin{align*}
1 - 0.71^n & > 0.98\\
0.02 & > 0.71^n\\
\log_e 0.02 & > n\log_e 0.71
\end{align*}
Since $0.71 < 1$, $\log_e 0.71 < 0$.  Hence, when we divide both sides of the inequality by $\log_e 0.71$, the direction of the inequality reverses, giving
\begin{align*}
\frac{\log_e 0.02}{\log_e 0.71} & < n\\
11.42228817 & < n
\end{align*}
Since we want the smallest number of weeks for which the probability that Sally plays football at least once is greater than $0.98$,
\begin{align*}
\lceil 11.42228817 \rceil & = n\\
12 & = n
\end{align*}
Comment: Thank you very much for clarifying this.


Delete de registros duplicados

Question: Tenho uma base onde os existem registros no o número identificador duplicado, em alguns cenários a data do registro mais novo se difere da do antigo, porém o número e o mesmo (Tenho que apagar o registro com a data menor) em outros casos as datas e números do identificador são iguais (Tenho que manter apenas um registro). Estou usando os dados abaixo, mas não estão sendo apagado os registros duplicados.
Deletes:
1 - Se eu uso esse apaga todos os registros.
DELETE RES1 FROM REGISTRO AS RES1, REGISTRO AS RES2 WHERE RES1.HR_TRA <= RES2.HR_TRA AND RES1.NUMERO = RES2.NUMERO
AND RES1.DT_DATA <= RES2.DT_DATA;

2 - Caso use esse, matem registros duplicados.
DELETE RES1 FROM REGISTRO AS RES1, REGISTRO AS RES2 WHERE RES1.HR_TRA < RES2.HR_TRA AND RES1.NUMERO = RES2.NUMERO
AND RES1.DT_DATA <= RES2.DT_DATA;

Criação e população da base:
-- CRIANDO BASE DE TESTE REGISTROS DUPLICADOS

CREATE DATABASE TESTE;
USE TESTE;
CREATE TABLE REGISTRO
(
ID INT PRIMARY KEY AUTO_INCREMENT,
NUMERO INT(10),
NOME VARCHAR(20),
VALOR INT(10),
DATA_ATU DATETIME,
HR_TRA TIME,
DT_DATA DATE
);

INSERT INTO REGISTRO (NUMERO, NOME, VALOR, DATA_ATU, HR_TRA, DT_DATA) VALUES ('2','TESTE', '200', '2020/02/04 17:06:06', '17:06:06', '2020/02/04');
INSERT INTO REGISTRO (NUMERO, NOME, VALOR, DATA_ATU, HR_TRA, DT_DATA) VALUES ('2','TESTE', '200', '2020/02/04 17:06:06', '17:06:06', '2020/02/04');
INSERT INTO REGISTRO (NUMERO, NOME, VALOR, DATA_ATU, HR_TRA, DT_DATA) VALUES ('2','TESTE', '200', '2020/02/04 16:06:06', '16:06:06', '2020/02/04');
INSERT INTO REGISTRO (NUMERO, NOME, VALOR, DATA_ATU, HR_TRA, DT_DATA) VALUES ('2','TESTE', '200', '2020/02/04 15:06:06', '15:06:06', '2020/02/04');
INSERT INTO REGISTRO (NUMERO, NOME, VALOR, DATA_ATU, HR_TRA, DT_DATA) VALUES ('2','TESTE', '200', '2020/02/04 15:06:06', '15:06:06', '2020/02/04');
INSERT INTO REGISTRO (NUMERO, NOME, VALOR, DATA_ATU, HR_TRA, DT_DATA) VALUES ('1','TESTE', '200', '2020/02/04 15:06:06', '15:06:06', '2020/02/04');
INSERT INTO REGISTRO (NUMERO, NOME, VALOR, DATA_ATU, HR_TRA, DT_DATA) VALUES ('3','TESTE', '200', '2020/02/04 15:06:06', '15:06:06', '2020/02/04');

Comment: Qual seria o resultado esperado?
Comment: Acredito que tenha entendido o que vc precisa, você precisara de apoio de um cursor do mysql ou de uma linguagem para fazer um laço nos registros duplicados. Apenas com o comando delete não sei se da para fazer o que precisa.
Comment: Creio que também deve funcionar, obrigado!!!
Answer: Este comando parece fazer o que você quer:
delete res1 from REGISTRO res1
inner join REGISTRO res2
where res1.numero = res2.numero and
   (res1.dt_data < res2.dt_data or
        (res1.dt_data = res2.dt_data and
         res1.id < res2.id)
    );

O truque foi usar a coluna "id" além da coluna "dt_data". Quando duas linhas tiverem a mesma data, então escolhemos o id menor para apagar.
Comment: Pronto, marcado como certo!
Comment: Efetuei o teste aqui, super funcionou. Obrigado!!
Comment: Blz, não esqueça de marcar a resposta como a correta, que me rende uns pontinhos :D

Delete de registros duplicados


Python Executable including multiple libraries

Question: I am relatively new to Python and have developed an application for myself that I would like to make an executable. It uses multiple external libraries such as Pyqt5, sqlite3, and openpyxl.  I am using pyinstaller to create the .exe - the installer fails with a message "nomodulefound xml.parser.expat" i've tried a few ways to include it in my package but to no avail.
here is a replicable py example:
from decimal import Decimal
import openpyxl  # xl libraries
wb = openpyxl.load_workbook(r'C:\Users\jmstr\OneDrive\Documents\finproxlc.xlsx')
myint = Decimal("27")
print("hello")

any ideas?
Here is my pyinstaller cmd: pyinstaller C:\Users\usr1\IdeaProjects\GUIProjects\finpro.py -p C:\Users\usr1\venv\Lib\site-packages\openpyxl --hidden-import openpyxl --additional-hooks-dir C:\Users\usr1\venv\Lib\site-packages\openpyxl --collect-all xml.parsers.expat
Output of the pyinstall:
['C:\Users\usr1\IdeaProjects\GUIProjects', 'C:\Users\usr1\venv\Lib\site-packages\openpyxl'] Traceback (most recent call last): File "c:\users\usr1\appdata\local\programs\python\python39\lib\runpy.py", line 197, in run_module_as_main return run_code(code, main_globals, None, File "c:\users\usr1\appdata\local\programs\python\python39\lib\runpy.py", line 87, in run_code exec(code, run_globals) File "C:\Users\usr1\AppData\Local\Programs\Python\Python39\Scripts\pyinstaller.exe_main.py", line 7, in  File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller_main.py", line 194, in console_script_run run() File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller_main.py", line 180, in run run_build(pyi_config, spec_file, **vars(args)) File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller_main.py", line 61, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\building\build_main.py", line 977, in main build(specfile, distpath, workpath, clean_build) File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\building\build_main.py", line 899, in build exec(code, spec_namespace) File "C:\Users\usr1\finpro.spec", line 14, in  a = Analysis( File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\building\build_main.py", line 379, in init self.hookspath += discover_hook_directories() File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\isolated_parent.py", line 404, in wrapped return call(function, *args, **kwargs) File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\isolated_parent.py", line 373, in call return isolated.call(function, *args, **kwargs) File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\isolated_parent.py", line 311, in call raise RuntimeError(f"Child process call to {function.name}() failed with:\n" + output) RuntimeError: Child process call to discover_hook_directories() failed with: File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\isolated_child.py", line 63, in run_next_command output = function(*args, **kwargs) File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\building\build_main.py", line 107, in discover_hook_directories import pkg_resources File "c:\users\usr1\appdata\local\programs\python\python39\lib\site-packages\pkg_resources_init_.py", line 35, in  import plistlib File "c:\users\usr1\appdata\local\programs\python\python39\lib\plistlib.py", line 61, in  from xml.parsers.expat import ParserCreate ModuleNotFoundError: No module named 'xml.parsers'
Comment: createa  a [mre].
Answer: Seems like the installion of openpyxl was specific to my IDE (intelliJ) and i could not figure out how to change the spec file to get it to pick up but running this command resolved the issue:
python -m pip install openpyxl


How discontinuous can the limit function be?

Question: While I was reading an article on Wikipedia which deals with pointwise convergence of a sequence of functions I asked myself how bad can the limit function be? When I say bad  I mean how discontinuous it can be?
So I have these two questions:
1) Does there exist a sequence of continuous functions $f_n$ defined on the closed (or, if you like you can take open) interval $[a,b]$ (which has finite length) which converges pointwise to the limit function $f$ such that the limit function $f$ has infinite number of discontinuities?
2) Does there exist a sequence of continuous functions $f_n$ defined on the closed (or, if you like you can take open) interval $[a,b]$ (which has finite length) which converges pointwise to the limit function $f$ such that the limit function $f$ has infinite number of discontinuities and for every two points $c\in [a,b]$, $d\in [a,b]$ in which $f$ is continuous there exist point $e\in [c,d]$ in which $f$ is discontinuous?
I stumbled upon Egorov´s theorem which says, roughly, that pointwise convergence on some set implies uniform convergence on some smaller set and I know that uniform convergence on some set implies continuity of the limit function on that set but I do not know can these two questions be resolved only with Egorov´s theorem or with some of its modifications, so if someone can help me or point me in the right direction that would be nice.
Comment: You might find the [Baire-Osgood theorem](https://proofwiki.org/wiki/Baire-Osgood_Theorem) interesting. (Disclaimer: I wrote up the first version of the page at ProofWiki.)  You might also find [this question/example](http://math.stackexchange.com/questions/102482/how-badly-can-dinis-theorem-fail-if-the-p-w-limit-isnt-continuous) interesting.
Comment: Pretty sure that if you consider the usual construction of the Cantor set and think about the indicator functions of each stage in the construction, you'll find an example of misbehavior 1). Sure, the indicator functions of the intermediate stages aren't continuous, but I'm sure you can "perturb" them a tiny bit to make them everywhere continuous.
Answer: The following is a standard application of Baire Category Theorem:
Set of continuity points of point wise limit of continuous functions from a
Baire Space to a metric space is dense $G_\delta$ and hence can not be countable.
Another result is  the following:
Any monotone function on a compact interval is a pointwise limit of continuous functions.
Such a function can have countably infinite set of discontinuities. For example in $[0,1]$ consider the distribution function of the measure that gives probability $1/2^n$ to $r_n$ where $(r_n)$ is any enumeration of rational numbers in $[0,1]$. The set of discontinuity points of this function is $\mathbb{Q}\cap[0,1]$.
Answer: The answer to 1 is yes. Here is a (kinda cheesy) construction. We want to replicate the behavior of $x^k$ infinitely many times near $x=1$. We start by working on the real line for convenience. Let $n$ be a natural. On each interval $[n,n+1],$ we build a piece $g_{n,k}(x)$ so on the first half of the interval it decreases linearly from $1$ to $0$. On the second half, it increases as $\left(2(x-n+1/2)\right)^k$. Note each $g_{n,k}$ is continuous. And they agree on their shared boundaries. So pasting all of the $g_{n,k}$ together gives us a continuous function $g_k$ on the positive reals.
Now we scale down to $[0,1)$ by a continuous function, namely $h(x)=\frac{x}{x+1}$. Note $h$ is bijective with a continuous inverse. Now $f_k = h g_k h^{-1}$ should have the desired behavior. Continuous functions pass through limits, for for a fixed $x\in [0,1)$, convergence of $f_k(x)$ is equivalent to convergence of $g_k(x)$. So that works.
Next, we want to check that there are infinitely many discontinuities. We designed the $g_k$ to have this behavior so that whenever $h^{-1}(x)$ is an integer, we have a discontinuity in the limit infinitely often near $x=1$, as desired.
Answer: You can quite easily construct a concrete example exhibiting behaviour "2)":
We will construct a sequence of functions whose graphs consist of spikes converging pointwise to Thomae's function
$f_1$ will have a single spike of width $4^{-1}$ around $\tfrac12$ and height $\tfrac12$.
$f_2$ starts as $f_1$ except we narrow its spike to $4^{-2}$ and then we add two spikes of the same width at $\tfrac13$ and $\tfrac23$ each of height $\tfrac13$.
For $f_3$ we again narrow the spikes to $4^{-3}$ and then we add spikes at $\tfrac14$ and $\tfrac34$ of height $\tfrac14$.
Of course writing this out in full detail is mindnumbling crazy and boring, and obviously also missing the point.
What should hopefully be clear is that the $f_n$ will form a sequence converging pointwise to Thomae's function showing that you indeed can have functions as discontinuous as you desired.
But this is nowhere near as bad as possible. You can have limit functions which are discontinuous on a set of measure $1$, though it must still be comeagre per the Baire–Osgood theorem (see my comment below the question for links)


Roomshare - avoiding the worst choice

Question: I'm moving in a new shared house with two other people. There are three bedrooms in the house and we will draw numbers from a hat for the rooms.
All agree that room one is better than room two and room two is better than room three.
I would be happy with either room one or room two.
Would I be better off to draw from the hat first, draw second or draw third, a once-off decision that is made up-front?
Is there a more general strategy for when to draw a room from the hat, given $n$ rooms, with room $i$ better than room $j$, for $1 \le i < j \le n$, with any of the first $k$ rooms being acceptable?
Comment: The question becomes a lot more interesting if you put a goat behind one of the 3 doors.
Comment: It may be better to not draw from a hat, but rather agree on a difference in price to make it fair. http://www.spliddit.org/apps/rent gives you envy-free and efficient solutions to this problem.
Answer: If there's no decision-making involved, but everyone is simply assigned the room they pick out of the hat (which we assume is uniformly random), then the order doesn't matter. By symmetry, you have a 2/3 chance of ending up with a room you like no matter what. You can double-check this by enumerating the possible orders that the rooms are drawn from the hat:
<code>1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
</code>
Each room appears in each position exactly twice, so the probability that room $i$ is picked by the person in position $j$ is always $\tfrac13$.

Roomshare - avoiding the worst choice


Tailwind CSS doesn't create classes when rebuilding

Question: I installed tailwindcss via scoop and created a new project.
Then i ran via CLI tailwindcss init and edited tailwind.config.cjs:
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
      "./*.{html}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

I created input.css:
@tailwind base;
@tailwind components;
@tailwind utilites;

Then created output.css and started the next command:
tailwindcss -i ./assets/css/input.css -o ./assets/css/output.css --watch
Every time i edit html.css tailwind css start rebuilding but doens't create the classes i wrote in html file.
How con i solve this?
Thank you
I tried to see some answers here on stackoverflow and but i didn't find any solution to my problem.
Comment: for who see this: import each tailwind layer like this : "@import "taliwndcss/base". It will work
Answer: My content section was wrong in the tailwind.config.js file.
One thing I did was change " to ' (I don't think this was the issue but I did change this).
The other thing was to make sure the locations for my files were correct. For example I have an index.html file inside my public folder so this is located at './public/index.html' and then my other files were in a folder, './public/pages/**/*/.{html,js}' but you can also do '././public/pages/**/*/js' if you just need js files.


How to return boolean with math expression comparison in Views

Question: I want to output a boolean value like this:
if some field value (e.g. [comment_count]) > x (my constant, e.g. 5) = 1, else 0
without installing Views PHP (or other modules) or having to create a field.
I tried with the Views field "Global: math expression" but that won't support comparisons.
Is there a math expression or another simple way to do this within my view?
PS: I thought I could use floor(logX([comment_count]) but logX() seems not supported: it always returns 0. Custom base logarithm is among PHP math functions but not present in Views? :(
Answer: Easiest method is to either use hook views view pre render out a preprocess function.


How to solve this kind of recurrence relation in closed form? $F(n) = aF(n-1) + bF(n-2) + cF(n-3) + dF(n-4)$

Question: How to solve this   recurrence relation in closed form? $$F(n) = aF(n-1) + bF(n-2) + cF(n-3) + dF(n-4)$$
I know how to solve recurrence relations for less than four calls by solving the characteristic polynomial. But are there other ways so that i don't have to solve the 4 degree characteristic polynomial to solve this recurrence relation?
Comment: so i just have to solve the polynomial equation ?
Comment: You can solve it numerically, that gives some information, certainly. Depends upon what you hope to learn from the information.
Comment: hmmm.  yeah thanks :-)
Comment: @znabil: Will Jagy is lying ;-). There is always a way of solving recurrence relations using backward iteration. However only in few cases(for example in the case when the coefficients are time independent) the resulting sums can be brought into closed form.
Answer: One of the ways of solving such recurrences is backward iteration. Fix the value of $n\ge 1$. Note that the solution will be a sum of product of quantities $a$, $b$, $c$ and $d$ followed by $F_\xi$ where $\xi=0,\cdots,3$. Note that each $a$ diminishes the time index $n$ by unity, each $b$ diminishes it by a two, each $c$ by three and finally each $d$ by a four. Let us denote the number of $b$'s , $c$'s and $d$'s in a sequence as $P$, $q$ and $r$ respectively and let the time index run backwards from the left to the right. Luckily the coefficients do not depend on the time index so all what we need to count the number of strictly ordered sequences of length $P+q+r-1$ (note that the last $d$ quantity in the sequence is replaced by $F_{\xi+1}$) bounded from the below by unity and from the above by $n-\xi-P-2 q-3 r-1$. Therefore we have:
\begin{equation}
F_{n+2} = \sum\limits_{r=0}^n \sum\limits_{q=0}^n \sum\limits_{P=0}^n 1_{n-\xi \ge 2P + 3 q+ 4 r}\frac{(P+q+r)!}{P! q! r!} \binom{n-\xi-P-2 q-3r-1}{P+q+r-1} a^{n-\xi-2 P-3 q-4 r} b^P c^q d^r \cdot F_{\xi+1}
\end{equation}
for $\xi=1$ only. In this way we have obtained one ''mode'',i.e. one solution. The other three linearly independent solutions can be obtained using similar reasoning except that certain boundary conditions have to be taken into account. We will complete this later on.


Analytic function vanishes in an open unit disk. Show it vanishes identically.

Question: $f$ is an analytic function that vanishes in a unit disk which is a subset of domain $D$. Show that it vanishes all over $D$.
This was one of our quiz questions and I think we need to assume that $D$ is connected for it to be true. I couldn't find counterexample.
Comment: Probably a "domain" is defined to be an open and connected set.
Comment: That's what I was also wondering. I also think it should be open and connected.
Comment: If $D$ is an open set which has a connected component which is disjoint to the unit disk then you can simply define $f$ to be $1$ on that component and $0$ everywhere else.
Comment: It's more generally true that if $z_n$ is a convergent sequence of points in $D$ whose limit is also in $D$, and if $f(z_n)$ is constant for all $n$, then $f$ is constant on $D$.
Answer: You can write the domain $D$ as a disjoint union of two open sets:
$$U = \{z_0 \in D : f^{(k)}(z_0) = 0 \text{ for all } k\ge 0\}$$
and
$$V = \{z_0 \in D : f^{(k)}(z_0) \ne 0 \text{ for some } k\ge 0\}.$$
One of them is nonempty. Since $D$ is connected, the other must be empty.
The openness of $U$ is slightly subtle, hinging upon the fact that for any $z_0 \in D$, there is an open disk $B_r(z_0)$ with $r>0$ on which
$$f(z) = \sum_{k=0}^\infty \frac{f^{(k)}(z_0)}{k!} (z-z_0)^k.$$
Comment: I wrote at the bottom of my answer that it's subtle and gave a hint. Basically, if all derivatives vanish at $z_0$, then since analytic functions have power series representations at each point which are valid on an open set (given by the formula I gave), the function is identically zero in a neighborhood $W$ of $z_0$, and thus all derivatives of $f$ vanish at all points in $W$ as well.
Comment: $V$ is open but why $U$ is open?
Answer: Typically, a domain is open and arcwise connected. There is a theorem of Weierstass that says that if a function is analytic in a domain, and there is a sequence of points with at least one limit point in $D,$ take any sequence of distinct points in the disk converging to the center of the disk here, and $f$ takes value $0$ at each term of the sequence, which your sequence does since it vanishes on the entire disk, then $f$ is identically $0$ on the domain.
I always found this theorem pleasing. As a reference, you can find it in Hille, "Analytic Function Theory, Theorem 8.1.3 (I'm using the fourth printing of the first edition since I'm ancient. The text has been expropriated by Springer in its Graduate Texts series. In my index, the theorem is sourced under Zeros, frequency of.) I hope this helps.


Basefield 'string' shown as select list widget in entity form

Question: I've got a custom entity ('content_sharing') and defined one of the fields as $fields['entity_definition'] = BaseFieldDefinition::create('string').... The create-form I'm showing the user is loaded with an empty entity via a controller like so:
    $contentSharing = $this->entityTypeManager()
      ->getStorage('content_sharing')
      ->create([]);
    $form = $this->entityTypeManager()
      ->getFormObject('content_sharing', 'custom_mode')
      ->setEntity($contentSharing);
    $output['form'] = $this->formBuilder()->getForm($form);
    ...

What I need now is to present the user a select-list of possible strings (options) that are dynamically pre-populated everytime the form is loaded. The only FieldWidget for string fields is a textfield. I tried to come up with my own custom FieldWidget similar to this
 * @FieldWidget(
 *   id = "string_select_list",
 *   module = "content_sharing",
 *   label = @Translation("Select list for strings"),
 *   field_types = {
 *     "string"
 *   },
 *  multiple_values = FALSE
 * )
 */

class StringSelectList extends OptionsWidgetBase {

However, this resulted in an error and I  noticed that this needs to have options defined which I cannot (don't know how to) provide for my string basefield.
I could of cource just add a dummy form-element select list that provides the values for my entity field, but I wanted to use the entityform as it is without any further custom elements.
Possible with a custom widget or any other solutions?
Answer: Create a list_string base field and use as widget OptionsSelectWidget.
$fields['entity_definition'] = BaseFieldDefinition::create('list_string')
  ->setLabel(t('Entity Definition'))
  ->setSettings([
    'allowed_values' => [
      'value1' => 'Value 1',
      'value2' => 'Value 2',
    ],
  ])
  ->setDisplayOptions('form', [
    'type' => 'options_select',
  ])

To update the options dynamically add a callback to the base field settings allowed_values_function, see How do I programmatically update the allowed values of a list field?
Comment: I thought about that too, but was hesitant because of having to update the allowed values every time. I'll give that a try.
Comment: I guess that passing an argument other than `FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity` is impossible...? Just asking since the options of one of the fields depends on the selected value of another form-field.
Comment: Found a way. I'm calculating all possible allowed values in `allowed_values_function`, then getting those values inside my `buildForm()` via `$options = options_allowed_values($fields['field_id']);`and creating a subset of those, dependent on another form fields selected value. Works well. Thanks!


GameKit only records the user's highest score, but I need it to record the lowest - iPhone

Question: So I'm programming a game for the iPhone that the best score is the lowest score, but when I submit scores through the GameKit to the Gamecenter leaderboards, only the highest score shows up, aka the worst score for that player.  Is there a way to make Gamecenter accept lower scores, or a way to check the players score and force gamecenter to replace it if it's lower?
Thanks
Answer: According to the Game Kit Programming Guide, you can configure whether the scores are ranked in ascending or descending order through iTunes Connect.
On page 114 of the iTunes Connect
Developer Guide 6.6, you can see how to change this.
If you want the lowest score to be the best, you'll want to rank in ascending order.
Answer: You can try below link for reference.
Here I am talking about GKLeaderBoardViewController.This class is for counting Highest Score.For more details I suggested you to read below link.Thanks
http://developer.apple.com/library/ios/#documentation/GameKit/Reference/GKLeaderboardViewController_Ref/Reference/Reference.html


What are common analytic techniques for identifying phrases in music?

Question: I understand that the concept of "phrase" is not always very well defined, and that there contrasting "intuitive" and "analytical" ways of thinking about music phrases and phrasing, per Wikipedia.
My question is what are common analytic techniques for identifying phrases in music, based on the notes in a score as opposed to an audio recording of a performance?
Answer: A phrase is like a musical sentence. Like a typical sentence there's a pause that signifies the end of a sentance that in a typical sentence is denoted by a period and in music is marked by a cadence. The Wikipedia article you link even states:

In common practice phrases are often four bars or measures long
  culminating in a more or less definite cadence.

Let's just take a look at a simple example:

In Twinkle Twinkle Little Star, the half notes mark all the where cadences occur as that is where the melody rests. If you were to sing it, you would take a quick breath at every half note in the melody there. It's where the music takes a pause thus denotes the end of a phrase and the beginning of a new one.
This is not to say every longer duration note is the end of a phrase, but they are typically a good indicator of where they are.
Another thing to notice is at the end of measure 4, and 12 the bass notes(harmonic rhythm) speed up which is another indicator that you are at the cadence and at the end of a phrase.
Comment: I think your example would be more compelling if you add a second one with phrasing marks added, then readers will naturally look to the text in between to see how it is done.
Answer: When I'm looking for phrasing, I like to think of it as "musical resting places." It's really tied to performance, so always bear in mind whether it would sound right if you played a phrase there.
Usually phrases are pretty evident, so this answer is focused on times when they aren't. Often, if you can't see the phrases clearly, there's more than one possible way to do it.
What kind of music are you looking at?
If you're looking at rock music, phrases are going to be generally of approximately equal length and cued by rhythmic changes. Most vocal art music will have a mix of phrase lengths and can be divided based on melody contour and breath marks. Be aware of how the style you're looking at is normally phrased.
I am a percussionist, so I'm often playing avant-garde music where phrases are hard to spot, but important to making sense of the sound.
Types of Resting Places
This is often determined by the genre of music, but generally it will be some combination of these factors. Each individually is not usually enough to delimit a phrase, but if you see two or three, it's a good bet.
Rhythm is often a cue of the position within a phrase. Frequently a rhythmic motif will occur in similar locations in a phrase. Sustained pitches in the melody voice are often a resting place.
Harmony, generally cadences or other strong progressions, can also be a signal. A change in the overall harmonic motion can also signal you've started a new phrase. If you've been progressing I-IV-V-vi and find yourself playing IV-ii-V-I, you might have had a new phrase. As Dom pointed out, the harmonic rhythm is often an indicator as well.
Melody can also signal a phrase. In many types of music, phrases fall from a high point. When you leap back up, it's probably a new phrase.
Text is an indicator in a lot of music. It seems simple but sometimes it's easy to overlook. Generally well-set music will follow the punctuation of any text.
Notation. I often find that some of the phrases are marked but not all of them, especially in transcriptions of folk music. Look for patterns similar to the ones that are marked.
Elided/Overlapping Phrases
In polyphonic music, be aware that it's common to have overlapping phrases between the voices. These are harder to spot and often subject to interpretation.
In any case, remember that music is to be heard and performed* and that phrasing is based on how your brain perceives the sound of the music. The composer was hearing a sound, and you're trying to recreate their thoughts. Whenever I try to mark phrases academically, I generally end up with at least some erroneous results.
*I don't know of phrasing in danger music. But in that case it's ok to analyze without trying to hear it.
Answer:
My question is what are common analytic techniques for identifying
  phrases in music, based on the notes in a score as opposed to an audio
  recording of a performance?

A few points.
A phrase ends with a cadence. A cadence is indicated with some sort of point of rest. This is not always done with actual rests but sometimes with longer notes. Phrases are usually a set number bars. Four or eight bars phrases are common practice.
You can think of phrases as musical sentences. You say a sentence and then usually you say another one with different words in but still with the same subject.
In this analogy of musical sentences you can consider cadences full stops and just like a full stop indicates the ending of a sentence so does a cadence indicate the ending of a phrase.
Comment: This is pretty much the exact same response as my answer.
Comment: Sorry DOm I don't read the other answer when writing my own.


Is the I-IV-viio-I progression never usable?

Question: This question arose while studying the circle of fifths.
Along with the cadence, I learned the progressions below.

viio - iii - vi - ii - V - I
I - IV - I
I - V - I
I - IV - V - I

But if 'I - IV - V - I' can be possible
why can't a 'I - IV - viio - I'? Or is it possible that it is just not in the description?
And In that case, the circle of fifths is not fully achieved. But if don't mind the circle of fifth. can't we just proceed with that?
Comment: Why do you think the progression is _not_ possible?
Comment: @MichaelCurtis Because there was such an explanation. ' The IV function consists of only two chords (IV-I) except for the Diminished triad (viio). ' ...

It makes sense if you think about it limited to the circle of fifths, but seeing that I-IV-V-I progression is possible, it felt like there was a special limit to the use of viio.
Comment: Where did that statement come from? A book, a we page?
Comment: @michaelcurtis a book in main text (korean book)
Comment: @michaelcurtis sorry, main text in this post
https://music.stackexchange.com/questions/123504/unanswered-questions-about-second-inversion-and-perfect-fourth/123546#123546
Answer: All those progressions are likely to sound good. And actually, you can make pretty much any progression sound phenomenal in the right context.
I don't see any problem with I - IV - viio - I. It's actually a quite common progression in popular music, and it will sound great. It just doesn't follow the circle of fifths (Actually is kind of does if you think if the viio as a V7 in first inversion). But anyway you should think of the circle of fifths as a tool for writing progressions, not a dogmatic rule.
Answer: The I-IV-viio-I progression is possible, but is omitted from the examples, because they are focused on cadences by perfect fifth. In all of the cases above, the final I chord is approached by either descending or ascending fifth.
Comment: @guss2222 it might be worth noting that either IV or viiº would have to be in some inversion.  It would be odd for the bass to move from ^4 to ^7, which would be the case if they were both in root position (in fact viiº rarely appears in root position).
Comment: thanks but (IV-V) in 'I - IV - V - I' is not fifth too so why that is can?
Comment: Are you saying that when go to the last I, have to go to the fifth?
Comment: Right. I'm pointing out that each of the examples *ends* with a perfect fifth either descending (V-I) or ascending (IV-I).
Comment: @phoog aha Augmented 4th. maybe that's the reason to why not much come as an example. Thank you phoog . that's very good point
Comment: ^1 ^1 ^7 ^1 would make a nice base line for those chords. Or ^1 ^1 ^2 ^1
Answer: I think it helps to not think about the "circle of fifths" progression but instead think of "roots by descending fifth" progression. The ideas are more or less the same, but the latter wording focuses more on relative root progression rather than a specific chord template.
When you look at your several progressions you will see that all of them are based on root progression by descending fifth. The four progressions feature...

viio - iii - vi - ii - V - I, all descending fifths
I - IV - I, first change is descending fifth
I - V - I, second change is descending fifth
I - IV - V - I, a descending fifth progression harmonically sequenced up a fifth

Root progression by descending fifth is considered a strong progression. Other strong progressions are roots by descending fourth and roots by ascending step. Notice that all your examples are entirely combinations of those three strong progression types.
Other progression being considered weak should not be misunderstood to mean bad or not allowed. Strong progressions have a connection to rhythm, the bar line, and cadences, and so the handling of strong/weak progressions has structural importance for phrasing and form.

But if 'I - IV - V - I' can be possible why can't a 'I - IV - viio - I'?

Any chord progression is possible, but you might explain them different ways. I'm not sure why you say the second progression is possible despite with these chords, in your words, "the circle of fifths is not fully achieved". I mean only that I don't know why you recognize these chords can work regardless of whether they conform to the circle of fifths. But, probably the most common way to explain it would be through chord function.
In functional harmony chord functions are: tonic, dominant, and pre-dominant. You can read up on the details of functional harmony, but the main point for your question is dominant function can be achieved with either V or viio. In other words the two progressions - I IV V I and I IV viio I - are functionally the same. The are both tonic pre-dominant dominant tonic.
The viio chord will often be in first inversion viio6, but that is more of a voice leading issue and doesn't change what happens functionally.

But if don't mind the circle of fifth.

You really should not think of harmony being derived from the circle of fifths progression.
Instead think of...

relative root progressions
chord and scale degree functions
chords are the result of voice leading

From comments...

thanks but (IV-V) in 'I - IV - V - I' is not fifth too so why that is can?

As I mentioned above this is a descending fifth progression harmonically sequenced. I IV is a descending fifth, V I is a descending fifth. As a harmonic sequence you just take I IV and raise it a perfect fifth and repeat the progression. You can also think of it "grammatically." Using functional labels it's just tonic > pre-dominant > dominant > tonic the epitome of functional harmony. But, you can also think of it "grammatically" as a departure from the tonic I IV, which is a sort of "opening", like an antecedent, and a return to the tonic V I, which is sort of "closing", like a postcedent.

...but (IV-V)...

That is root progression by ascending step. Root progression by descending fifth is not the only usable progression. The basic run down of common root progressions are:

descending fifth, ex. V I, a "closing"
descending fourth, ex. I V, an "opening"
descending thirds, ex. I vi IV ii viio V, a movement from tonic through predominant/subdominant to the dominant
ascending step, ex. IV V, a movement from subdominant to dominant, of V vi, a "desceptive progression

You should also be aware of how important the bass line is apart from the chords and chord roots and the sort of harmonic "equivalence" some progressions have. Ex. IV V I and ii6 V I where the root progression are different, but the bass parts are the same. In common use those two progressions are effectively the same.
Also be aware that some relative root progressions are commonly found in specific regions of a key. Like roots by ascending step in IV V or V vi as very common, but ii iii being less common, but you could "explain" ii iii "working" with good voice leading an using the modal/secondary chords as a sort of functional pre-dominant depending on the specifics. In other words the position of roots in a key can often be more important than the interval/direction of the root progression.
Comment: I'm not sure why you say the second progression is possible. <-- did you mean to say actually 'is not possible' right?

But the reason was mentioned before. and i'm never think harmony being derived from the circle of fifths progression.
Comment: I wrote "...you say the second progression is possible." I was trying to summarize what I thought _you_ meant. You suggested the second progression should be possible. I agree that it is and just wanted to explain why.
Comment: "...i'm never think harmony being derived from the circle of fifths progression..." You mentioned "circle of fifths" three times in your question about chord progressions.
Comment: "But if don't mind the circle of fifth"

Don't you know why I said this?

That is to say I don't think all chords should go along with the circle of fifth.

I was just asking a question that arises when it is assumed that only the progress of the circle of fifth described in the book is made!!

Is that a difficult word? Why are you making puns in comments after a while? It's dawn here now, and it's absurd that I'm making such an explanation.


Save Print output in csv file

Question: I want to save this print output to CSV file but this code is not working, how can I save this output to CSV?
import csv

for x in range(2000, 3000):
    print('hi', x, sep='')

f = open('op2.csv', 'w')
writer = csv.writer(f)
writer.writerow(print())
f.close()

I want to save on CSV like this
hi2000
hi2001
hi2002

Comment: Please take a moment to read [ask] and edit your question to include more details, including what you want the contents of the CSV to be.
Comment: The big change that needs to be made here is moving your `writer.writerow` to be inside of your `for` loop. Just like `print` executes once for that `range(2000,3000)` you also need to `writerow` once per iteration in that range.
Comment: If you only want one column, why use a CSV file?
Comment: @TimPietzcker I want one column with hi2000 and I will create more than 5 columns like hi3000, hi4000, etc in different rows, that's why I'm using a CSV file.
Comment: Does this answer your question? [How to save the output of the print statements to a new file?](https://stackoverflow.com/questions/38832545/how-to-save-the-output-of-the-print-statements-to-a-new-file)
Answer: To write a row to a CSV file, the writerow() function argument should be an iterable object (e.g. list).
The following code will create a CSV file with one column of numbers ranging from 2000 to 2999.
import csv

with open('op2.csv', 'w', newline='') as f:
    writer = csv.writer(f)
    writer.writerow(['a'])  # output header row as first line
    for x in range(2000, 3000):
        writer.writerow([f'hi{x}'])

If want to format variables using the print() function then you can use str.format() method or formatted string literals (also called f-strings for short). Code above uses f-string f'hi{x}' to format each value of x to a string of the form: hi2000, hi2001, etc.
Comment: It works but I need to save it with 1 columns, sep='' can't add to writer.writerow(['hi',x])
Comment: @RasedulIslam - use `writer.writerow([f'hi{x}']) ` to output hi2000, etc.

Save Print output in csv file


Login with facebook app in ios app shows option in safari "Login with Facebook app" and its not working in ios 10.1

Question: In my app, i am using login with a Facebook option. Where I set Facebook SDK behavior"FBSDKLoginBehaviorNative"
When I try to login with facebook its show me two option "Login with the facebook app" or "Login with phone or email" in ios 10.1. In ios 9 its direct shows me login page where email/password I have to enter
But in ios 10.1 it shows above two option and when I click on "Login with the Facebook app", it shows dialog "open in facebook" and on click of "open" button it authorizes to my app, Now it has to come back to my app but it stay in Safari view controller where two options are given of login and never come back to my app
Comment: I had the same issue. When the dialog exits, it calls the "urlscheme" to launch your app again. It goes through the list url schemes as defined in the iOS app settings in the Facebook developer site. What happened for me was that I had the wrong url scheme defined there so it didn't know how to launch my app again.
Comment: The screen now shows on my iOS 9 device as well. The behaviour is the same that it stays in this view controller after navigating back from Facebook app, and no delegate method is called. Can someone please help us??
Comment: I found the reason why it's not working. It's because the url scheme returned when using "Log In With The Facebook App" option is different from the one returned from using "Log in with phone or email". One uses lower-cased suffix and the other is using upper-cased suffix which my program did not handle before. Fixing the suffix fixed the issue.
Comment: @user3216945 can you provide a answer with the description of what did you change, since I have the same issue
Answer: In my application its happening because of salesforce sdk security option which cancel facebook login when app went to facebook app for authorization.
I disable snapshotview and facebook login works fine
<code>[SalesforceSDKManager sharedManager].useSnapshotView = NO;
</code>
So this is not facebook issue but its happening due to third party sdk.
Comment: That is fine, however this issue exist also for other reasons and I don't think that accepting this answer will help the community, it would be interesting to find out what is the root cause in the Facebook SDK in order to make people having the same issue for different reason being able to use this question to solve that
Comment: I am not using SalesForce and I have the same issue, so this issue has nothing to do with a third party sdk
Comment: Hey  Marco Pappalardo, In my application salesforce creating issue and i fixed it . I clearly mentioned that any third party sdk may causing this issue.
Comment: Let me know if you find the root cause in the facebook sdk
Comment: Yea, I have a similar issue at the moment and I will update if I fix it :) thanks a lot
Answer: As of iOS 11, my in-app Facebook login was also going to the Facebook.com page instead of the device app. Based on the fix below, it seems that FB just changed the behavior default. Setting the button to system fixed it for me.
<code>self.fbloginButton.loginBehavior = FBSDKLoginBehaviorSystemAccount;
</code>
That switched the app back to the fast app switching.
Answer: <code>     func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

     /*

      for facebook login

    */

            if #available(iOS 9.0 , *){
                return ApplicationDelegate.shared.application(app, open: url, sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplication.OpenURLOptionsKey.annotation])

            }

      /*

       for google signin

     */
            return GIDSignIn.sharedInstance().handle(url as URL?,
                                                     sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
                                                     annotation: options[UIApplication.OpenURLOptionsKey.annotation])
        }
</code>


IE10 does not scale background SVG correctly when zoomed (on Surface/Windows 8 phone)

Question: Does anyone know if there is a workaround for this? Internet Explorer 10 and Window phone 8 are not able to correctly scale background SVG images when a user zooms. Looks like IE rasterizes the SVG on load.
Here is an example: The first image is the SVG as a background image. Zoom in on a MS Surface or Windows 8 phone and you'll see it blurs horribly.
The second image is the same SVG as an img tag. Zoom this on a Surface or Windows 8 mobile phone and it scales as you would expect (nice and clean).
Is there any property that can be added to make IE10 behave? Or is it merely a case of waiting for the folks at Redmond to fix it?
Comment: If I recall correctly IE10 uses hardware acceleration for SVG. If you re-insert the background src after a zoom event then it might 'sharpen', but not during the zoom (only after).
Comment: Hi Duopixel, you mean re-inserting with JS? If that's the only way to sharpen the background SVG on/after zoom I'd give it a miss and wait for MS to fix things.
Comment: It's mostly intuition, but I don't have a Windows Touch device to test. I'd like someone to actually give it a try. I'll add a bounty for this question when it's possible (I must wait 48h to add it).
Comment: Your demo is using a .png for both images. At least that is what I see in the debugger, and both images blur on zoom in all desktop browsers that I've tried.
Comment: Here is a version that is actually using SVG. The same scaling issue is also present in Firefox. http://codepen.io/dstorey/full/afwCk
Comment: @dstorey, apologies, not sure why it was hooked up to a PNG - amended the pen now. As mentioned from the outset, I feared it was merely IE rasterising the image so thanks for confirming. Having a cursory glance at Davids info I'll consider the 'upsizing' technique but wanted to know there wasn't anything else 'cleaner' that could be done.
Comment: I think that is probably as clean as you're going to get. It works quite well, mainly just extra memory required for a larger rasterised image before zooming.
Answer: The problem is that IE, and other browsers such as Firefox rasterise the SVG before displaying it, so it will become blocky when zoomed.
The easiest way to fix this is to make the SVG file larger than is needed. For example double the size, or more if the user is likely to zoom in further. You can then resize the SVG image with CSS to display it at the correct size. This way the image will be naturally larger, so wont become blocky, unless you zoom in even further. At default zoom level the image is scaled down rather than up, which browsers usually handle better.
Edit: You can find further info on this issue under the "SVG and CSS Backgrounds" heading at http://dbushell.com/2012/03/11/svg-all-fun-and-games/
Comment: When are you actually going to fix this, now that you, @David Storey, works on the IE team?


Trouble with calling PS script (with parameter) from C#

Question: I am trying to setup a simple .aspx web page that will accept a user's input of a  string (later, more than one string) and use that string as the parameter value for a Powershell script.
The PS script looks like this right now:
[CmdletBinding()]
param (
    [string] $ServiceName
)

$ServiceName | out-file c:\it\test.txt
$ServiceName | Out-String

The C# code looks like this:
var shell = PowerShell.Create();

// Add the script to the PowerShell object
shell.Commands.AddScript("C:\\it\\test.ps1 -ServiceName BITS");

// Execute the script
var results = shell.Invoke();

When I run that, I get "BITS" written to the test.txt file. What I need to do now, is setup the application to call the script, passing in the "ServiceName" parameter. I found this: Call PowerShell script file with parameters in C# and tried the following code:
PowerShell ps = PowerShell.Create();
ps.AddScript(@"c:\it\test.ps1").AddParameter("ServiceName", "BITS");
var results = ps.Invoke();

In this case, the script was called and the test.txt file was created, but the value (BITS) was not written to the file. What am I missing here? Why isn't the parameter being passed to the script?
Thanks.
Answer: I ended up using
var ps = @"C:\it\test.ps1";
processInfo = new ProcessStartInfo("powershell.exe", "-File " + ps + " -ServiceName BITS);

I don't like this as much, but it works. shrug
Answer: Here are three possible solutions for future readers including me:
using (PowerShell ps = PowerShell.Create())
{
   //Solution #1
   //ps.AddCommand(@"C:\it\test.ps1", true).AddParameter("ServiceName", "BITS");
   //Solution #2
   //ps.AddScript(@"C:\it\test.ps1 -ServiceName 'BITS'", true);
   //Solution #3
   ps.AddScript(File.ReadAllText(@"C:\it\test.ps1"), true).AddParameter("ServiceName", "BITS");

   Collection<PSObject> results = ps.Invoke();
}

I haven't seen solution #3 documented anywhere else, though I got the idea for it from https://blogs.msdn.microsoft.com/kebab/2014/04/28/executing-powershell-scripts-from-c/


Surjectivity of operator $(\lambda I-A)x$, where A is a linear operator on a Hilbert space $X$, for non-real $\lambda$

Question: In other words, I want to prove that if $\Im(\lambda)>0$, then for every $y\in X$ there exists $x\in X$, such that $(\lambda I-A)x=y$. How to go about proving that? (I assume this statement is correct but if it's wrong please correct me)

My attempt is as follows:
To use the property of the space $X$ being Hilbert, I make both parts of this equation inner products:
$\langle (\lambda I-A)x,y\rangle =\langle y,y\rangle=||y||_X^2$.
Then I would want to use the fact that the imaginary part of the left hand side is $0$:
$\Im(\langle \lambda x,y\rangle)=\Im(\langle Ax,y\rangle)$.
I suppose $\Im(\lambda )=0$, and want to come to contradiction:
$\Im(\langle x,y\rangle)=\Im(\langle Ax,y \rangle)$ (for every $y\in X$).
I'm not sure what to do next and whether I've done anything useful. I also make no use of linearity of $X$.

My question is part of the question (Spectrum of self-adjoint operator on Hilbert space real), but I don't understand the proof there.
Answer: What you are attempting to show is that every bounded linear operator on a Hilbert space has real spectrum. In the finite-dimensional case, this amounts to saying that every linear map $\mathbb{C}^n \to \mathbb{C}^n$ has only real eigenvalues. This is false. Take, for example, take the operator $T: \mathbb{C} \to \mathbb{C}$ to be multiplication by $i$: $z \mapsto i z$. Then $T - i I = 0$, so $T - i I$ is not surjective.
The standard example of sufficient conditions for an operator on a Hilbert space to have real spectrum is that $A$ be self-adjoint, which is to say $\langle Ax, y\rangle = \langle x, A y \rangle$ for all $x$ and $y$.


How to prove this function isn't differentiable at origin

Question: [Exercise 5.18 - Pugh] Show that the function $f:\mathbb{R}^2\rightarrow \mathbb{R}$ defined by
$$ f(x,y)= \begin{cases} \frac{x^3y}{x^4+y^2} \ ; (x,y)\neq 0 \\\quad 0\quad\ ;(x,y)=0 \end{cases}$$
has $\nabla_{(0,0)}f(u)=0$ for all $u$ but is not differentiable at $(0,0)$.
My attempt Isn't hard to show the first part (that all directional derivatives exist) but I cannot show that this function is differentiable. My ideia is standard, I need to find a path such that $\lim\limits_{\gamma\;\mapsto (0,0)} f(\gamma)$ doens't exist. In order to achieve this I tried $y=mx, y=mx^2, y=mx^3$ but no one gave me a clear result. At best, I was able to show that
$$\lim\limits_{(x,y)\mapsto(0,0)}\frac{f(x,y=x^2)}{f(x,y=-x^2)}=-1 $$
But I don't think that's enough. Is that enough ? If yes, why? If not, is there a better method to solve this ?
Answer: We need to check if $$\frac{x^2y}{x^4+y^2} \overset?= 0 + 0x + 0y + o\left(\sqrt{x^2+y^2}\right) \\
\lim_{(x,y)\to(0,0)} \frac{x^2y}{(x^4+y^2)\sqrt{x^2+y^2}} \overset ? = 0$$
but when $y=kx$
$$\lim_{x\to0}\frac{kx^3}{x^2(x^2+k^2)x\sqrt {1+k^2}} = \frac{1}{k\sqrt{1+k^2}}\ne 0$$
Comment: Thanks! I'll try use this idea, unfortunately the $x^3 y$ on the top give to us an extra $x$, turning this limit to zero.
Comment: I got it. Thanks to you and also this answer

https://math.stackexchange.com/questions/4151122/prove-f-mathbbr2-to-mathbbr-has-directional-derivatives-in-0-0?rq=1
Answer: Let  $\gamma :\mathbb{R}^{2} \rightarrow  \mathbb{R}^{2},~ \left( x,y \right) \mapsto \left( r\cos  \vartheta ,~r\sin  \vartheta  \right) .$  Then, it follows that
$$
f\circ \gamma ≔f \left(  \gamma  \left( x,y \right)  \right) =f \left( r\cos  \vartheta ,r\sin  \vartheta  \right) =\frac{r^{4}\cos ^{3} \vartheta \sin  \vartheta }{r^{4}\cos ^{4} \vartheta +r^{2}\sin ^{2} \vartheta }=\frac{r^{4}\cos ^{3} \vartheta \sin  \vartheta }{r^{4} \left( \cos ^{4} \vartheta +\frac{1}{r^{2}}\sin ^{2} \vartheta  \right) }=\frac{\cos ^{3} \vartheta \sin  \vartheta }{\cos ^{4} \vartheta +\frac{1}{r^{2}}\sin ^{2} \vartheta } \
$$
Then, if we compute the limit, it is easy to see that it does converge to $0$. So why this method doesn't work? I'm a bit lost.
Comment: I think I got it, being continuous is a necessary condition, but not a sufficient condition. We need to calculate manually the differential with the definition, right?
Comment: At Pugh 2nd edition page 284 we have this following result >
   Theorem: If the partial derivatives of $f$ exist and are continuous then f is differentiable.


Double partial derivative proof

Question: Let $z=f(x,y)$  where $x:=r \cos \theta$ and $y := r \sin \theta$.
I had to prove that $\frac {\partial ^{2}z}{\partial \ x^{2}} + \frac {\partial ^{2}z}{\partial \ x^{2}} = \frac {\partial ^{2}z}{\partial \ r^{2}} \ + \dots$ The whole equation was given.
My doubt:
I applied Jacobian and tried to solve this but I ended up in a loop where I was substituting the same things back and forth.
The solution provided said this.
$\frac {\partial ^{2}z}{\partial r^{2}} \ = \frac {\partial}{\partial r}(\frac {\partial z}{\partial r})  = \frac {\partial}{\partial r}(\cos \theta \frac {\partial z}{\partial x} + \sin \theta \frac {\partial z}{\partial y})$
$ = \cos \theta \ [ \cos \theta \frac {\partial}{\partial x} + \sin \theta \frac {\partial }{\partial y} ](\frac {\partial z}{\partial x}) \ + \sin \theta [ \cos \theta \frac {\partial }{\partial x} + \sin \theta \frac {\partial }{\partial y} ] (\frac {\partial z}{\partial y}).$
I do not understand the last step. What exactly is happening? Why do we use the partial derivative of $z$ with respect to $r$ (and skip the $z$ in the numerator) and multiply it with partial derivative of z with respect to $x$ and $y$? Since $x$ and $y$ are functions of $r$ and $\theta$ and since in $\frac {\partial z}{\partial x}$ we have kept $y$ constant are we accounting for that? I am really confused as this relevant theory wasn't taught in class and the professor hasn't been helpful to clear this part. Any insight is highly appreciated.
Comment: Does this help: https://math.stackexchange.com/questions/548715/computing-second-partial-derivative-with-polar-coordinates/?
Answer: It sounds like your question is really why
$$ \frac{\partial}{\partial r} = \cos(\theta) \frac{\partial}{\partial x} + \sin(\theta) \frac{\partial}{\partial y} $$
since this is what is being used in the last step.
The short answer: the chain rule
The long answer: $x$ and $y$ can be written as functions of $r$ and $\theta$, as you've written at the very top of your post. Then a function $f(x,y)$ can be thought of as $f\Big(x(r,\theta), \; y(r,\theta)\Big)$. Then the chain rule says that
$$ \frac{\partial f}{\partial r} = \frac{\partial f}{\partial x} \frac{\partial x}{\partial r} + \frac{\partial f}{\partial y}\frac{\partial y}{\partial r} $$
You get the result by seeing that $\frac{\partial x}{\partial r} = \cos(\theta)$ and $\frac{\partial y}{\partial r} = \sin(\theta)$.
Answer: Here we look at first at the general situation and develop the second partial derivative by consequently applying the chain rule. This way we can better see  symmetries which is helpful when calculating the special case.
We consider the functions
\begin{align*}
z=f(x,y)\qquad\qquad x&=x(r,\theta)=r\cos\theta\\
y&=y(r,\theta)=r\sin\theta
\end{align*}
First partial derivative:$\quad\Large{\frac{\partial z}{\partial r}}$

We obtain by applying the chain rule
\begin{align*}
\frac{\partial z}{\partial r}=\frac{\partial z}{\partial x}\cdot\frac{\partial x}{\partial r}
+\frac{\partial z}{\partial y}\cdot \frac{\partial y}{\partial r}\tag{1}
\end{align*}

Second partial derivative:$\quad\Large{\frac{\partial^2 z}{\partial r^2}}$

We obtain by applying $\frac{\partial}{\partial r}$ to (1) using the chain rule again as well as the product rule of derivatives
\begin{align*}
\frac{\partial^2 z}{\partial r^2}
&=\frac{\partial }{\partial r}
\left(\frac{\partial z}{\partial x}\cdot\frac{\partial x}{\partial r}
+\frac{\partial z}{\partial y}\cdot \frac{\partial y}{\partial r}\right)\tag{2}\\
&=\frac{\partial }{\partial r}
\left(\frac{\partial z}{\partial x}\cdot\frac{\partial x}{\partial r}\right)
+\frac{\partial }{\partial r}\left(\frac{\partial z}{\partial y}\cdot \frac{\partial y}{\partial r}\right)\tag{3}\\
&=\color{red}{\frac{\partial }{\partial r}\left(\frac{\partial z}{\partial x}\right)}\cdot\frac{\partial x}{\partial r}
+\frac{\partial z}{\partial x}\cdot\frac{\partial }{\partial r}\left(\frac{\partial x}{\partial r}\right)\\
&\qquad+\color{blue}{\frac{\partial }{\partial r}\left(\frac{\partial z}{\partial y}\right)}\cdot\frac{\partial y}{\partial r}
+\frac{\partial z}{\partial y}\cdot\frac{\partial }{\partial r}\left(\frac{\partial y}{\partial r}\right)\tag{4}\\
&=\color{red}{\left(\frac{\partial^2 z}{\partial x^2}\cdot\frac{\partial x}{\partial r}
+\frac{\partial^2 z}{\partial y\partial x}\cdot \frac{\partial y}{\partial r}\right)}\cdot\frac{\partial x}{\partial r}
+\frac{\partial z}{\partial x}\cdot\frac{\partial^2 x}{\partial r^2}\\
&\qquad+\color{blue}{\left(\frac{\partial^2 z}{\partial x\partial y}\cdot\frac{\partial x}{\partial r}
+\frac{\partial^2 z}{\partial y^2}\cdot \frac{\partial y}{\partial r}\right)}\cdot\frac{\partial y}{\partial r}
+\frac{\partial z}{\partial y}\cdot\frac{\partial^2 y}{\partial r^2}\tag{5}\\
&=\frac{\partial^2 z}{\partial x^2}\cdot\left(\frac{\partial x}{\partial r}\right)^2
+\frac{\partial^2 z}{\partial y\partial x}\cdot \frac{\partial x}{\partial r}\cdot\frac{\partial y}{\partial r}
+\frac{\partial z}{\partial x}\cdot\frac{\partial^2 x}{\partial r^2}\\
&\qquad\frac{\partial^2 z}{\partial y^2}\cdot \left(\frac{\partial y}{\partial r}\right)^2
+\frac{\partial^2 z}{\partial x\partial y}\cdot\frac{\partial x}{\partial r}
\cdot\frac{\partial y}{\partial r}
+\frac{\partial z}{\partial y}\cdot\frac{\partial^2 y}{\partial r^2}\tag{6}
\end{align*}
Comment: This is due to presentation issues a rather lengthy calculation. Usually we might skip (3) and (4) and obtain (5) directly from (2).

In (2) we apply the chain rule as we did in (1)

In (3) we use the linearity of the differential operator

In (4) we apply  the product rule

In (5) we apply the chain rule again

In (6) we multiply out and do a few rearrangements

Special case: $x(r,\theta)=r\cos \theta,\ y(r,\theta)=r\sin \theta$

The partial derivatives of the special case give
\begin{align*}
&x(r,\theta)=r\cos \theta&&\frac{\partial}{\partial r}x(r,\theta)=\cos \theta&&\frac{\partial^2}{\partial r^2}x(r,\theta)=0\\
&y(r,\theta)=r\sin \theta&&\frac{\partial}{\partial r}y(r,\theta)=\sin \theta&&\frac{\partial^2}{\partial r^2}y(r,\theta)=0
\end{align*}
Putting these results in (6) we finally obtain
\begin{align*}
\color{blue}{\frac{\partial^2 }{\partial r^2}}&\color{blue}{f(x(r,\theta),y(r,v\theta))}=\frac{\partial^2 }{\partial r^2}f(r\cos \theta,r\sin \theta)\\
&=\frac{\partial^2 z}{\partial x^2}\cdot \cos^2\theta
+\frac{\partial^2 z}{\partial y\partial x}\cdot \cos \theta\cdot\sin\theta
+\frac{\partial z}{\partial x}\cdot 0\\
&\qquad+\frac{\partial^2 z}{\partial y^2}\cdot \sin^2 \theta
+\frac{\partial^2 z}{\partial x\partial y}\cdot \cos\theta\cdot\sin\theta
+\frac{\partial z}{\partial y}\cdot0\\
&\,\,\color{blue}{=\frac{\partial^2 z}{\partial x^2}\cdot\cos^2\theta
+\left(\frac{\partial^2 z}{\partial y\partial x}+\frac{\partial^2 z}{\partial x\partial y}\right)\cdot\cos \theta\cdot\sin\theta
+\frac{\partial^2 z}{\partial y^2}\cdot\sin^2 \theta}\tag{7}
\end{align*}
in accordance with OPs formula.
Comment: Thank you. This was extremely informative and my doubt has been cleared quite well. I know i am not supposed to use the comment to give thanks but this answer was really helpful to me.
Comment: @ShauryaGoyal: Many thanks for your nice comment. Good to see, the answer is useful! :-)

Double partial derivative proof


Show that all elements in the conjugacy class of $\sigma$ in $S_n$ are conjugate in $A_n$ if and only if $\sigma$ commutes with an odd permutation.

Question: Let $\sigma\in A_n$. Show that all elements in the conjugacy class of $\sigma$ in $S_n$ (i.e. all elements of the same cycle type as $\sigma$) are conjugate in $A_n$ if and only if $\sigma$ commutes with an odd permutation.
Hint: Use the previous proven fact: Assume $H$ is normal subgroup of $G$, $\mathcal{K}$ is a conjugacy class of $G$ contained in $H$ and $x\in\mathcal{K}$. Prove that $\mathcal{K}$ is a union of $k$ conjugacy classes of equal size in $H$, where $k=|G:HC_G(x)|$. Deduce that a conjugacy class in $S_n$ which consists of even permutations is either a single conjugacy class under the action of $A_n$ or is a union of two classes of the same size in $A_n$.
Proof ($\Rightarrow$): Let $\sigma\in A_n$. Assume that all elements in the conjugacy class of $\sigma$ in $S_n$ (i.e. all elements of the same cycle type as $\sigma$) are conjugate in $A_n$. We  need to show that $\sigma$ commutes with an odd permutation. By our assumption we have for all $x\in \sigma S_n\sigma^{-1}$, $\sigma\in \sigma A_n \sigma^{-1}$
Proof ($\Leftarrow$): Let $\sigma\in A_n$. Assume that $\sigma$ commutes with an odd permutation. We need to show all the elements in the conjugacy class of $\sigma$ in $S_n$ (i.e. all elements of the same cycle type as $\sigma$) are conjugate in $A_n$.
Let $\tau$ be an odd permutation in $S_n$. We know that $\sigma$ commutes with $\tau$. i.e. $$\sigma\tau=\tau\sigma \iff \tau\sigma\tau^{-1}=\sigma.$$ Let $\rho$ be an element of the conjugacy class of $\sigma$ in $S_n$
I have tried to do something for each direction but I don't see how the hint is going to help me. Can I get any tips on finishing each direction?
Comment: Another solution using the given exercise. ⇐: Suppose that $\sigma$ commutes with an odd permutation. We show that its conjugacy class in $S_n$ cannot split in $A_n$ and we are done, since there are only two options. If that happens, by the orbit-stabilizer theorem we get: $|S_n:C_{S_n}(\sigma)| = 2|A_n:C_{A_n}(\sigma)|$ and then by opening the definition of these indexes, we get $|C_{S_n}(\sigma)|=|C_{A_n}(\sigma)|$ and therefore $C_{A_n}(\sigma)=C_{S_n}(\sigma)$, but this condradicts the fact that $\sigma$ commutes with and odd element.
Answer: It's not very hard to prove without using the hint:

$ \Rightarrow \,:$ Suppose a permutation in the conjugacy class in $S_n$ of $\sigma$ is also in the conjugacy class of $\sigma$ in $A_n$, i.e. a permutation $ \tau \sigma \tau^{-1} $, $\tau \in S_n\smallsetminus A_n$ can be written as $\alpha \sigma \alpha^{-1} $, $\alpha \in A_n$. Then
$$\tau \sigma \tau^{-1} = \alpha \sigma \alpha^{-1} \iff (\alpha^{-1}\tau )\sigma= \sigma (\alpha^{-1}\tau ),$$
multiplying both sides by $\alpha^{-1}$ on the left and by $\tau$ on the right. This means $\sigma$ commutes with $\beta=\alpha^{-1}\tau $, which is an odd permutation.
$ \Leftarrow \::$ If $\sigma$ commutes with an odd $\beta$ and $\tau \sigma \tau^{-1} $ is the conjugate of $\sigma$ by an odd permutation, then
\begin{alignat}{2}
\tau \sigma \tau^{-1}&= \tau (\beta \sigma \beta^{-1})\tau^{-1}&&\qquad\text{since $\beta$ and $\sigma$ commute}\\
&=(\tau \beta) \sigma (\beta^{-1}\tau^{-1})&&=(\tau \beta) \sigma (\tau \beta)^{-1}
\end{alignat}
As $\beta$ is odd, we've finished since $\tau \beta$ is even
Answer: If no odd permutation commutes with $\sigma$, then $H=C_{S_n}(\sigma)\leq A_n$, and so half of the cosets of $H$ lie in $A_n$ and the other half in $S_n\backslash A_n$. So the orbit of $A_n$ containing $\sigma$ contains just half of the conjugacy class $\mathcal{K}$, and $\mathcal{K}$ splits into two classes of equal size.
On the other hand, suppose that $H$ contains an odd permutation. Then $C_{A_n}(\sigma)=C_{S_n}(\sigma)\cap A_n$ is a subgroup of index 2 in $H$. Now the size of the $A_n$-conjugacy class is the index of the stabilizer, which is
$$|A_n:C_{A_n}(\sigma)|=\dfrac{|S_n:C_{A_n}(\sigma)|}{2}=|S_n:C_{S_n}(\sigma)|=|\mathcal{K}|.$$
So $\mathcal{K}$ is a conjugacy class in $A_n$.


Automatic test measuring dissimilarity between two time series

Question: I have two time series, series1 and series2. My aim is to find how much Series2 is different from Series1, automatically/quantitatively.
Image can be seen in its original size by clicking here.

Series1 is the expected result.
Series2 is the test/incoming series.
I am providing a histogram plot, where Series2 is represented in dark brown colour. You can also note in the x-axis between 221 and 353 there is a significant variation. ie Series2 is less than Series1. I am coding using C++.
I think, crosscorrelation will help, but produces a value based on similarity rather than dissimilarity. I see people talk about Kolmogorov-Smirnov Test. Is this the test which i should be performing?
UPDATE 1: I am trying to perform a template matching. I have divided my template image in to 8x8 blocks as well as my incoming test image. I am trying to compare one block in template image with the same block(based on the spatial pixel positions) in the test image. I calculate the intensity sum within each block. I obtain series1 for the Template image and have Series2 for the test image.
Comment: I would suggest you to work on clarity of the question; this helps in getting answers.
Comment: @mbq, i have updated to my post
Answer: There are many different distance measures.  For starters, there's always the correlation.
You can look at the mean square error.  In R, you can see the algorithm for time series in Rob Hyndman's ftsa package (see the error function).
See Liao (2005) for a nice short survey of time series similarity measures, including euclidean distance, root mean square distance, mikowski distance, pearson's correlation, dynamic time warping distance, kullback-liebler disance, symmetric Chernoff information divergence, and cross-correlation.

T. Warren Liao, "Clustering of time series data—a survey" Pattern Recognition, 2005
Comment: Thanks for your input. Will test this approach and will update. Also, do you think, i can use Kolmogorov-Smirnov Test in my case. Please see the plot, http://img254.imageshack.us/img254/9645/25971376.gif


What configuration should I use for TFS 2010 on my WHS machine?

Question: I would like to perform a fresh install of TFS 2010 on my HP MediaSmart Server EX 490. The EX 490 has a 900 GB drive with a 20 GB partition for the OS. I have added two additional 1.5 TB drives extending the storage space. This balances those two drives and the D:\ partition of the first drive across as one volume.
This article (Installing Team Foundation Server 2010 on Windows Home Server)
seems to indicate that I should not have included both drives as storage hard drives, but rather have one separate for the SQL Server Express 2008 database.
I am incline to just put the database in D:\, which is magically across these three drives, by installing SQL Server Express first. Is this a good approach? Finally how do I install anything, given that I have ISO files to work with?
Answer: SQL server data files are best put on their own drive.  Due to the large number of reads and writes this may overwhelm WHS drive extender.  Your second question about ISO files...these are image files that need to be burnt to a DVD (not copied).
Since you have TFS2010 I assume you have an MSDN subscription.  I'd suggest installing 2K8R2 on a separate server and putting TFS there.  Personally I wouldn't want to mess with my WHS functionality.
Comment: I do have MSDN. I don't have the luxury of another server right now. My other machines are not that powerful either. I hope to change that and migrate later. For a single user is the performance load that great?
Answer: I assume that only you will be using the TFS system?  Given that you probably don't want to loose things if a hard drive fails, putting the two disks in a mirror is probably best.
With a single user, performance isn't going to be as important as redundancy.
Comment: I should already have redundancy across drives 1 and 2 right?
Comment: If they are setup with a RAID card, or Windows is doing actual mirroring between them then yes.  Without looking at the system I couldn't say for sure as I don't know Home Server well enough.


Show book tree from page on down

Question: Using Views I've created a block which show the immediate children of the current parent book page. What I really want is a block that shows the total child hierarchy of the current parent book page. My intention is to place these blocks on just certain pages which have no content but are there for content grouping. I'm on Drupal 9 if it matters.
This is the screenshot of the fields in the block view.

This is the screenshot showing the first advanced settings of the view.

This is the screenshot of the block rendered on one of my book pages.

Each of those headings have a hierarchy beneath them. I want to see the expanded tree rather than just the immediate child pages.
Is there a way to modify the view to show all children pages?
Comment: What the screenshot shows isn't how the view looks, but part of the advanced settings of that view. Knowing more about its settings would probably help to provide a better answer. It would also help if the question described exactly what you don't understand in achieving the described task.
Comment: @kiamlaluno I've added more detail to the original post.
Answer: It's been more than a year, but I'll drop my solution:
You can tweak Drupal's book navigation block (that's displayed under nodes) usinghook_preprocess_book_navigation to add full tree.
use Drupal\book\BookManager;

function MYTHEME_preprocess_book_navigation(&$variables) {

  $book_link = $variables['book_link'];
  $variables['tree'] = ''; //Remove existing tree

  $book_manager = \Drupal::service('book.manager');
  if ($book_link['nid']) {
    $book_tree = $book_manager->bookSubtreeData($book_link); //Get the full tree for the current node
    $book_tree = reset($book_tree)['below']; //Remove current node from tree.
    $variables['tree'] = $book_manager->bookTreeOutput($book_tree); // re-create the tree
  }
}

You can tweak the layout of the items with book-tree.html.twig and the main block with book-navigation.html.twig

Show book tree from page on down


improve 'check if true' function

Question: I have an object that looks like this
$scope.object = {
  Title: 'A title',
  Status: 'Open',
  Responsible: 'John Doe',
  Author: 'Jane Doe',
  Description: 'lorem ipsum dolor sit'
}

Now I want to see if the current user has permission to edit this item, for the user to be able to edit, the item has to

Exist (is not null, undefiend etc)
Responsible is equal $scope.currentUser
Status is equal 'Open'

if all these are true, our function should return true, I am doing it like this
$scope.isTrue = function(){

  if($scope.object && $scope.object.Status == 'Open' && $scope.object.Responsible == $scope.currentUser){
    return true;
  }else { return false; }

}

Pretty straight forward, but are there a better way to do these kind of checks?
Comment: You don't have to return `true/false`, you can just return everything in the if statement, this itself will already be true or false. so: `return $scope.object && $scope.object.Status == 'Open' && $scope.object.Responsible == $scope.currentUser`
Comment: @MartijnWelker that got a whole lot cleaner, thanks!
Answer: The condition in the if statement is already true or false, you can just return that.
return ($scope.object && $scope.object.Status == 'Open' && $scope.object.Responsible == $scope.currentUser);

Answer:
Converting the result to Boolean (So, if $scope.object is undefined result is false instead of undefined)
Making comparisons using ===
Just declaring function and assigning it to scope(personal preference)

$scope.isTrue = isTrue;

function isTrue() {
  return Boolean($scope.object && $scope.object.Status === 'Open' && $scope.object.Responsible === $scope.currentUser);
}

improve 'check if true' function


How to prevent bandwidth theft of my website and why I find my website IP address sometimes dedicated & sometimes shared

Question: I think someone is stealing bandwidth of my website. To prevent this I enabled hotlink. But there are only extensions related to image. How can I protect my other files with extensions like .php or .asp? When I add .php or .asp extensions, I was unable to access in my website.
Another thing is, I found, in my cpanel IP address of my website sometimes appears as dedicated and sometimes as shared. Why is this happening?
I found static.reverse.softlayer.com in my visitors list. But which web pages it visited are not displayed. Please help me.
Answer: You can only protect secondary material from hotlinking, for example images, Javascript files and CSS files. Because those are fetched from a page in your site, the server can determine if they are used correctly or not.
If you try to keep primary material (e.g. the actual web pages) from being hotlinked, you are actually keeping them from being fetched at all. Any resource that you want to be available directly can't be locked down that way.
Comment: So, what should I do to prevent bandwidth theft & what is the reason of changing the status sometimes dedicated or sometimes shared of the IP address of website?
Comment: Requesting web pages to steal bandwith doesn't make sense. This might be relevant: http://stackoverflow.com/questions/19901039/websites-traffic-increases-suddenly-found-static-reverse-softlayer-com-in-visi Regarding the cpanel issue I don't have anything to contribute. Sounds like it's confused, as a dedicated IP address isn't something that just changes on it's own.


What is the $server_name variable set to?

Question: I have a server block to redirect all http requests to https as follows:
server {
   listen 0.0.0.0:80;
   listen [::]:80;
   server_name a.com b.com c.com;
   return 301 https://$server_name$request_uri;
}

It seems that requests coming in using all three domain names on port 80 will be redirected to https://a.com. Is this how $server_name is set?
Comment: You probably want to use `$host` instead of `$server_name`. See [What is the difference between Nginx variables $host, $http_host, and $server_name?](https://serverfault.com/q/706438/126632)
Answer: http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name

The first name becomes the primary server name.

You can use three separate server blocks, or Michael Hampton's excellent suggestion of the $host variable instead.
Comment: Thanks. I was looking at http://nginx.org/en/docs/http/ngx_http_core_module.html#var_server_name which was vague.
Comment: `server_name_in_redirect` won't help here, and it's off by default anyway.
Comment: @MichaelHampton Yeah, your `$host` thing is much better.


The HTTP header line [group Name: XXX-OR-Migration^XXX-OR-Novation] does not conform to RFC 7230 and has been ignored

Question: Our application was working fine on tomcat 8.5.5.   Recently, we have upgraded to tomcat 9.0.31 and the login now fails with the below error
Message: The HTTP header line [group Name: XXX-OR-Migration^XXX-OR-Novation] does not conform to RFC 7230 and has been ignored.
Description: The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
I have added the below attributes in server.xml under the Connector section and the request still fails:
relaxedPathChars="^:{}[]|""
relaxedQueryChars="[]|{}^:\`"<>""
Answer: <code>java.net.URLEncoder
URLEncoder.encode(String, StandardCharsets.UTF_8)
</code>
Please escape these characters