Finding the nth term part of a Taylor Series

Question: We're just starting Taylor series now, and I got kind of stumped on a problem. Is there a way to find the nth term part of the series, or is it just intuition by looking at some of the terms?
$$f(x)=(1+x)^{-3}.$$
$\sum_{n=0}^\infty\frac{(-1)^n x^n(1 + n)(2 + n)}2$ is the answer but, looking at the terms, the $\frac{1}{2}(n+1)(n+2)$ part doesn't jump out at me. Perhaps I just lack the number sense to do this, but help would be appreciated.
Comment: Start from the expansion of $$\frac1{1+x}$$ which you should know, and differentiate it twice to get the expansion of $2f(x)$.
Answer: For problems of the form $(a+x)^n$, you can actually cheat and use the generalized binomial expansion (which is secretly just Taylor expansions for a binomial to a power)
$$(a+x)^n=\sum_{k=0}^\infty\binom nk a^{n-k}x^k$$
where
$$\binom nk=\frac{n(n-1)(n-2)\cdots(n-k+1)}{k!}$$
Which should help make the answer jump out at you as more clear.
Comment: I'm still not getting it. I've written out the first few terms, and, after simplifying it:
${1-3x+6x^2-10x^3+15x^4+...}$
I'm not sure where to go, or how that theorem fits into it
Comment: You should note that you get something of the following form: $$\binom{-3}k=\frac{(-3)(-4)(-5)\cdots(-2-k)}{k!}=(-1)^k\frac{3\cdot4\cdot5\cdots(k+2)}{1\cdot2\cdot3\cdots k}=?$$
Comment: Since my $a=1$, $a^{-3-k}=1$, so it's just the sum of $(-1)^k\frac{k+2}{k}x^k$?
Comment: @addadisplayname Actually, you should check how the numbers cancel.  Everything in the denominator cancels out except $1\cdot2$.  Everything in the numerator cancels except $(k+1)(k+2)$.  Thus, we are left with$$\binom{-3}k=\frac{(-1)^k(k+1)(k+2)}2$$And$$(1+x)^{-3}=\sum_{k=0}^\infty\frac{(-1)^k(k+1)(k+2)}2x^k$$
Comment: Thank you. I wasn't thinking of it in the sense of the actual terms, I just thought of the whole thing in terms of k, now I see where the 1/2 comes from.
Comment: @addadisplayname Hopefully you'll see that this works nicely for $\frac1{(1+x)^5}$ and similar and that it'll save you a ton of trouble ;-)
Answer: We already know that
$$(1+x)^{-1}=\frac{1}{1+x}=1-x+x^2-x^3+x^4-x^5+x^6-x^7+\dots,\qquad |x|<1.$$
Applying term-by-term differentiation, we get
$$(-1)(1+x)^{-2}=0-1+2x-3x^2+4x^3-5x^4+6x^5-7x^6+\dots,\qquad |x|<1.$$ So get,
$$(-1)(1+x)^{-2}=-1+2x-3x^2+4x^3-5x^4+6x^5-7x^6+\dots,\qquad |x|<1.$$
Applying again the term-by-term differentiation, we get
$$(-1)(-2)(1+x)^{-3}=0+2-6x+12x^2-20x^3+30x^4-42x^5+\dots,\qquad |x|<1.$$ Simplifying, we get
$$\frac{2}{(1+x)^3}=2-6x+12x^2-20x^3+30x^4-42x^5+\dots,\qquad |x|<1.$$ Finally, by multiplying $\frac{1}{2}$ to both sides, we get
$$\frac{1}{(1+x)^3}=1-3x+6x^2-10x^3+15x^4-21x^5+\dots,\qquad |x|<1.$$
Observe that $1,3,6,10,15,21,\dots$ are called triangular numbers. Thus,
$$\frac{1}{(1+x)^3}=\sum_{n=1}^\infty(-1)^{n-1}\frac{n(n+1)}{2}x^{n-1},\quad |x|<1$$
Equivalently, we get
$$\frac{1}{(1+x)^3}=\sum_{n=0}^\infty(-1)^{n}\frac{(n+1)(n+2)}{2}x^n,\quad |x|<1$$
NOTE: In case you don't know the properties of triangular numbers: Observe the following.
$$\begin{align}
1&=1\\
3&=1+2\\
6&=1+2+3\\
10&=1+2+3+4\\
15&=1+2+3+4+5\\
21&=1+2+3+4+5+6\\
\end{align}
$$
In general, $$\frac{n(n+1)}{2}=1+2+3+\dots+n.$$


Comparing the distribution

Question: I want to compare the distribution of 2 independant datasets. Measurements were performed on an experimental dataset (TEST) and compared with a completely independant reference dataset (REF). The idea is to determine if the measurements in the experimental dataset follow the same distribution as the reference.
I looked at the Kolmogorov-Smirnov test (two-sided) but I am not sure it does exactly what I think it does.
Can anyone suggest a test more appropriate to test the difference/similarity in distribution of these 2 datasets?
Thanks!
Comment: What is your objection to Kolmogorov-Smirnov?
Comment: You could measure the distance between the two distributions using Kullback Leibler divergence to get a better feeling for the dissimilarity and then use the  Kolmogorov-Smirnov test just for computing the p-value.
Comment: Try also the Baumgartner-Weiss-Schindler test, _cf_ https://cran.r-project.org/web/packages/BWStest/index.html
Answer: I still want to hear your reasons for doubting KS as an appropriate method, but now that I've looked at your graph more, I say that KS does not apply. Your data are discrete, and KS does not apply to data drawn to discrete distributions. However, you could use a chi-squared test! I wrote about this yesterday. Instead of checking if frequencies match the frequencies expected from a fair die, you'd be checking if the TEST frequencies match the REF frequencies.
Just looking at the graph, the answer is that the distributions are different. There are almost 400 blue observations (seems like it's about 30% of the blue observations) at 0.08, yet red does not get even one instance of 0.08.
For a discussion of KS on discrete distributions: Is Kolmogorov-Smirnov test valid with discrete distributions?
My description of the chi-squared test (turns out to be unrelated to skewness): How to identify if my data set is skewed or not?
Comment: Thanks! The data measured is biological, so in theory it is continous: any sample can have a measurement between 0 and 512 (even theoretically more); but the method used for the measurements only records values based on the exponential function. Additionally we know that, due to biological (genetic) constrains, there are more samples showing values around 0.016, 0,25 and 32.
I will use a chi-square, seems more appropriate.
Comment: Do you have ties in your data? The graph makes it look like you do, but your comment makes it sound like you don't.
Comment: Yes, the test set has several "0" counts for the low and high values, which means I could not use the KS test on the whole range of measured values.
Comment: Then it sounds like most of your distribution is continuous, so chi-squared would not apply. I'm curious...what process is giving you data, microarray?
Comment: The data represented is minimum inhibitory concentration (MIC), a measure of bacterial antibiotic susceptibility, and obtained using a method called microbroth dilution. The antibiotic is diluted 2X for each measurement point (hence the exponential function). We record how many bacterial strains can resist each concentration. Looking more into the chi-square (I don't use it often), I am not sure if it's appropriate indeed.
Comment: I agree that $\chi^2$ would not be the right test for you.

Comparing the distribution


Updating a field value in database via submit handler doesn't update the user profile in UI

Question: I've created the field "Attending" that is attached to the user profile.
I have created a form with one checkbox element; when submitted, I've confirmed that the attending_fielddatabase is being updated with the current value (0 or 1), but when I view the user profile through the UI, the updated value isn't being displayed.
The submit handler I am using is the following:
<code>function rsvp_aform_submit($form, &$form_state) {
  global $user;
  db_query("UPDATE {field_data_field_attending} SET field_attending_value = :val WHERE entity_id = :eid", array(':val' => $form_state['values']['rsvp'], ':eid' => $user->uid));
  drupal_set_message(t('Your form has been saved.'));
}
</code>
Do you have any idea?
Answer: I think that's the caching. First try to clear the cache manually. If that helps you should use cache_clear_all() to clear the corresponding cache tables (e.g. cache_content, cache_views_data) after you update the db.
Comment: Hah! I thought I was done getting blindsided by caching... thanks so much. I'll upvote when I have the reputation
Comment: In fact, what worked for me was drupal_flush_all_caches().
Comment: ok, but it's a little overkill to clear all caches and rebuild the theme_registry every time this form is submitted. thats simply not necessary and could result in performance shortage.
Comment: Hmm.. I'll need to dig into it then - cache_clear_all() didn't do the trick..
Comment: have you passed the $table parameter? check which cache table you need to clear. maybe just take a look inside your db to find the guilty ones and try. take a look at api for more info on how to use cache_clear_all().
Comment: field_cache_clear() seems to do the trick (for what I assume is a more slight performance hit)


How to add permissions to a Lambda function using the CDK?

Question: I have a Lambda function that utilizes the AWS Python SDK to manage AWS CodeCommit repositories.  I create the Lambda function using the CDK like so:
from aws_cdk import aws_lambda as _lambda
from aws_cdk.aws_lambda_python import PythonFunction

service = PythonFunction(
    self, 'Svc',
    entry='./path/to',
    index='file.py',
    runtime=_lambda.Runtime.PYTHON_3_8,
    handler='handler',
)

After deployment, I run the Lambda function, the following error occurs which is sent to CloudWatch logs:
An error occurred (AccessDeniedException) when calling the GetRepository operation: User: arn:aws:iam::XXXXXXXXXXXX:user/XXXX is not authorized to perform: codecommit:GetRepository on resource: arn:aws:codecommit:us-east-1:XXXXXXXXXXXX:XXXX

How can I allow the Lambda function to call codecommit:GetRepository on any repository in my account?
Answer: Create an IAM Policy Statement and add it to your Function's role policy:
from aws_cdk import aws_iam as iam

service.add_to_role_policy(iam.PolicyStatement(
    effect=iam.Effect.ALLOW,
    actions=[
        'codecommit:*',
    ],
    resources=[
        'arn:aws:codecommit:us-east-1:XXXXXXXXXXXX:*',
    ],
))


HP Procurve 2910 Inter VLAN routing partially working

Question: I'm in the middle of slowly trying to solve my inherited ip range issue.
Currently everything is on 100.100.100.x. I am slowly moving things over to a 10.12.x.x range. Currently my Watchguard firewall on 220.127.116.11 is doing my for users, I want to change so the Procurve on 220.127.116.11 does the routing instead.
The first stage has been to set up a second connection to the firewall on VLAN 99 10.12.99.1 so internet access works and I've got it working on VLAN 123.
Here is my vlan setup.
VLAN ID Name                 | Status     Voice Jumbo
------- -------------------- + ---------- ----- -----
1       DEFAULT_VLAN         | Port-based No    No
20      ISCSI                | Port-based No    No
99      DMZ                  | Port-based No    No
121     Client_PCs           | Port-based No    No
122     Production           | Port-based No    No
123     Servers              | Port-based No    No

I can ping between VLAN 1 and 123.
I can't ping between VLAN 122 and 123.
Here is my running config
    ; J9145A Configuration Editor; Created on release #W.14.38
hostname "AKS-BROX-SW2"
module 1 type J9145A
interface 24
   name "LINK TO FP"
exit
trunk 19-22 Trk1 LACP
trunk 6-9 Trk2 LACP
ip default-gateway 188.8.131.52
ip routing
vlan 1
   name "DEFAULT_VLAN"
   untagged 1-3,5,10,24,Trk1-Trk2
   ip address 188.8.131.52 255.255.255.0
   no untagged 4,11-18,23
   exit
vlan 20
   name "ISCSI"
   untagged 11-18
   ip address 172.16.230.253 255.255.255.0
   tagged Trk1
   exit
vlan 121
   name "Client_PCs"
   ip address 10.12.1.254 255.255.255.0
   tagged Trk2
   exit
vlan 122
   name "Production"
   ip address 10.12.2.254 255.255.255.0
   tagged 1-2,5,10-11,Trk2
   exit
vlan 123
   name "Servers"
   ip address 10.12.3.254 255.255.255.0
   tagged 1-2,4-5,10-11,Trk2
   exit
vlan 99
   name "DMZ"
   untagged 23
   ip address 10.12.99.254 255.255.255.0
   exit
fault-finder bad-driver sensitivity high
fault-finder bad-transceiver sensitivity high
fault-finder bad-cable sensitivity high
fault-finder too-long-cable sensitivity high
fault-finder over-bandwidth sensitivity high
fault-finder broadcast-storm sensitivity high
fault-finder loss-of-link sensitivity high
fault-finder duplex-mismatch-HDx sensitivity high
fault-finder duplex-mismatch-FDx sensitivity high
timesync sntp
sntp unicast
sntp server priority 1 184.108.40.206 3
ip route 0.0.0.0 0.0.0.0 10.12.99.1
ip route 10.12.1.0 255.255.255.0 10.12.99.1
ip route 10.12.2.0 255.255.255.0 10.12.99.1
ip route 10.12.3.0 255.255.255.0 10.12.99.1
ip route 188.8.131.52 255.255.255.0 10.12.99.1
snmp-server community "snmp-public" operator
snmp-server community "monitor" operator
spanning-tree
spanning-tree 4 path-cost 41000
spanning-tree Trk1 priority 4
spanning-tree Trk2 priority 4
spanning-tree priority 7
no autorun
password manager

And last but not least the routing...
                               IP Route Entries

  Destination        Gateway         VLAN Type      Sub-Type   Metric     Dist.
  ------------------ --------------- ---- --------- ---------- ---------- -----
  0.0.0.0/0          10.12.99.1      99   static               1          1
  10.12.1.0/24       Client_PCs      121  connected            1          0
  10.12.2.0/24       Production      122  connected            1          0
  10.12.3.0/24       Servers         123  connected            1          0
  10.12.99.0/24      DMZ             99   connected            1          0
  126.96.36.199/24   DEFAULT_VLAN    1    connected            1          0
  127.0.0.0/8        reject               static               0          0
  127.0.0.1/32       lo0                  connected            1          0
  172.16.230.0/24    ISCSI           20   connected            1          0

I can't get VLAN 122 and VLAN 123 to talk to each other, so I assume the route is wrong, but if I try to add a route...
ip route 10.12.2.0/24 10.12.3.254
I get this error.
    10.12.3.254 can not be switch IP address and route gateway at the same time.
I must have something configured wrongly, but I can't work out what it is.
Thanks
Answer: A 2910 with activated ip routing routes from and to any VLAN that it has an IP address assigned in.
So, if a node can't reach one VLAN subnet from another it's likely not in the correct VLAN.
ip route 10.12.2.0/24 10.12.3.254 can't work since 10.12.2.0/24 is already connected locally and 10.12.3.254 is the switch itself - you can't tell it to route back to itself.
Additionally,
ip route 0.0.0.0 0.0.0.0 10.12.99.1
ip route 10.12.1.0 255.255.255.0 10.12.99.1
ip route 10.12.2.0 255.255.255.0 10.12.99.1
ip route 10.12.3.0 255.255.255.0 10.12.99.1
ip route 126.96.36.199 255.255.255.0 10.12.99.1

don't make sense. All these subnets are local and can't be routed elsewhere.
btw: firmware version 14.38 is ancient (before 2011 when we bought 2910s)...
PS: You're binding IP addresses to all VLANs, including iSCSI and DMZ - as stated above, the 2910 will route into and out of all these networks which is most surely not intended. You'll need to either remove these IP addresses and route/filter between these VLANs elsewhere or configure ACLs that allow the traffic you want while filtering everything else. Note that the 2910 doesn't allow VLAN ACLs, only port ACLs.
Comment: Ah, last time I checked I didn't find updated firmware, though I have just now, I'll give it an upgrade and see what happens.
Comment: HPE downloads are a mess currently. You can find the 2910al-24G downloads in https://h10145.www1.hpe.com/Downloads/SoftwareReleases.aspx?ProductNumber=J9145A⟨=en&cc=us&prodSeriesId=3901671 right now.


Meta-logical terminology

Question: What do we call a theory $\Gamma$ when...

For every sentence $\varphi$, either $\Gamma\vdash\varphi$, or $\Gamma\vdash\neg\varphi$?
There is no sentence $\varphi$ such that both $\Gamma\vdash\varphi$ and $\Gamma\vdash\neg\varphi$? ($\Gamma$ is consistent?)
For every sentence $\varphi$ such that $\Gamma\vdash\varphi$, $\Gamma\vDash\varphi$? ($\Gamma$ is sound?)
For every sentence $\varphi$ such that $\Gamma\vDash\varphi$, $\Gamma\vdash\varphi$? ($\Gamma$ is complete?)
For every sentence $\varphi$, either $\Gamma\vDash\varphi$ or $\Gamma\vDash\neg\varphi$?
There is no sentence $\varphi$ such that both $\Gamma\vDash\varphi$ and $\Gamma\vDash\neg\varphi$?

Are all these concepts well-defined even for non standard logics, such as many-valued logic, and intuitionistic logic?
Comment: Any decent introductory text on logic will answer questions like this: which texts have you read that have left you puzzled?
Comment: @PeterSmith *A mathematical introduction to logic* by Herbert Enderton.
Answer: Briskly:

The theory is (syntactically) negation-complete.
The theory is syntactically consistent

Soundness and completeness are standardly taken to be features of the deductive apparatus of a theory, of its proof system. So better:

If for every $\Gamma, \varphi$, we have $\Gamma\vdash \varphi$ implies $\Gamma\vDash \varphi$, then proof system giving the deducibility relation $\vdash$ is sound.
If for every $\Gamma, \varphi$, we have $\Gamma\vDash \varphi$ implies $\Gamma\vdash \varphi$, then proof system giving the deducibility relation $\vdash$ is complete.

Then

The theory is semantically negation-complete.
The theory is semantically consistent
Comment: Thanks. Since you mentioned in a comment to my original post that any decent introductory text on logic will answer questions as in my original post, would you please refer me to one such specific text that will corroborate your answer?
Comment: Enderton p.131, p. 156 for a start. Though helpful to distinguish completeness of logic and completeness of theory, hence (and commonly) negation-completeness for the second.
Comment: Thanks. The concept defined on p. 156 of Enderton's textbook is that of theory completeness, which I didn't ask about. The concepts defined on p. 131 of Enderton's textbook are those of soundness and completeness of a deductive calculus, and in both cases I correctly specified these terms next to the corresponding question in my original post (though, as you mentioned in your answer, I didn't get their definitions quite right, and thank you for pointing this out). The terminology "negation complete", and the distinction between syntactic and semantic consistency don't appear in Enderton afaik.
Comment: My question had another part, which you didn't address. That of many-valued logic and intuitionistic logic. When talking about many-valued logic, is it customary to talk about logical implication $\Gamma\vDash\varphi$? It so, what does it mean? That $\varphi$ evaluates to *true* under every structure and variable assignment that make all the members of $\Gamma$ *true*? What about intuitionistic logic?
Comment: https://plato.stanford.edu/entries/logic-manyvalued/ and https://plato.stanford.edu/entries/logic-intuitionistic/

Meta-logical terminology


Augment seperate values in observable of array - RxJS

Question: I've been trying to tackle this problem for a while now, I would guess this is a pretty common problem but what I want to do is augment items in an array coming from an observable, and the augmentation happens with an observable or promiselike
So I want something like the following:
function augment(person: Person): Observable<PersonWithAddress> {
    // does ajax call or something
}

const items$: Observable<Person[]>;

items$
    .do(x => {}) // x would be of type Person[]
    .flatFlatMap(person => { // person would be of type Person
        return augment(person); // this would return an Observable<PersonWithAddress>
    })
    .subscribe(peopleWithAddresses => { // peopleWithAddresses would be of type PersonWithAddress[]
    })

Is there some kind of operator for this, I get I can augment or map a single item emitted from an observable to something else coming from an observable with flatMap, but is there something like flatFlatMap or so.
Answer:
You can use forkJoin to do what you want.
It takes an array of observables (or promises) and, when all have completed (or resolved), it emits an array containing the last emitted (or resolved) values:
import { Observable } from "rxjs/Observable";
import "rxjs/add/observable/forkJoin";

items$
  .flatMap((people: Person[]) => Observable.forkJoin(
    people.map(person => augment(person))
  ))
  .subscribe((peopleWithAddresses: PersonWithAddress[]) => {
    // ...
  });

Comment: Yeah, there are a few to learn. You might not have seen it, but there's a wizard at the bottom of the RxJS web page, which you might find useful: http://reactivex.io/rxjs/
Comment: Omg, thanks very much, I've been struggling with this for a while now. There are so many operators


retrieving values from plm xml adding them using xslt and displaying in excel

Question: plmxml code exported from teamcenter structure manager:
    <?xml version="1.0" encoding="utf-8"?>

    <PLMXML xmlns="http://www.plmxml.org/Schemas/PLMXMLSchema"
     schemaVersion="6" language="en-us" date="2014-12-30" time="18:11:34" author="Teamcenter V10000.1.0.20130604.00 - infodba@IMC--1989821519(-1989821519)">

    <RevisionRule id="id2" name="Latest Working">
    <Description>Latest Working else Latest Any Status</Description>
    <ApplicationRef version="QEaRaYqhYa1ubA" application="Teamcenter" label="QEaRaYqhYa1ubA"></ApplicationRef></RevisionRule>
    <ProductView id="id4" ruleRefs="#id2" rootRefs="id7" primaryOccurrenceRef="id7">
    <ApplicationRef application="Teamcenter" label="QvfRqkT9Ya1ubA/QEaRaYqhYa1ubA/AAAAAAAAAAAAAA/BOM"></ApplicationRef>
    <UserData id="id3" type="TC Specific Properties">
    <UserValue value="imprecise" title="BOM_precision_type"></UserValue></UserData>
    <Occurrence id="id7" occurrenceRefs="id11 id15">
    <ApplicationRef application="Teamcenter" label="QvfRqkT9Ya1ubA/"></ApplicationRef>
    <UserData id="id6">
    <UserValue value="" title="bl_quantity"></UserValue></UserData>
    <UserData id="id8" type="AttributesInContext">
    <UserValue value="" title="AO_ID"></UserValue>
    <UserValue value="" title="SequenceNumber"></UserValue>
    <UserValue value="" title="OccurrenceName"></UserValue>
    <UserValue value="" title="Quantity"></UserValue></UserData>
    <Transform id="id5">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</Transform></Occurrence>
    <Occurrence id="id11" parentRef="#id7">
    <ApplicationRef application="Teamcenter" label="QvfRqkT9Ya1ubA/Q3YRqkT9Ya1ubA/"></ApplicationRef>
    <UserData id="id10">
    <UserValue value="10" title="bl_quantity"></UserValue></UserData>
    <UserData id="id12" type="AttributesInContext">
    <UserValue value="" title="AO_ID"></UserValue>
    <UserValue value="10" title="SequenceNumber"></UserValue>
    <UserValue value="" title="OccurrenceName"></UserValue>
    <UserValue value="10" title="Quantity"></UserValue></UserData>
    <Transform id="id9">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</Transform></Occurrence>
    <Occurrence id="id15" parentRef="#id7">
    <ApplicationRef application="Teamcenter" label="QvfRqkT9Ya1ubA/gTVRqkT9Ya1ubA/"></ApplicationRef>
    <UserData id="id14">
    <UserValue value="15" title="bl_quantity"></UserValue></UserData>
    <UserData id="id16" type="AttributesInContext">
    <UserValue value="" title="AO_ID"></UserValue>
    <UserValue value="20" title="SequenceNumber"></UserValue>
    <UserValue value="" title="OccurrenceName"></UserValue>
    <UserValue value="15" title="Quantity"></UserValue></UserData>
    <Transform id="id13">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</Transform></Occurrence></ProductView></PLMXML>

xsl code to display 10 & 15(from plm xml) and them display in adjacent  cell:
    <?xml version="1.0" encoding="utf-8" ?>

         <xsl:stylesheet version="1.0"
               xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
               xmlns:plm="http://www.plmxml.org/Schemas/PLMXMLSchema"
               xmlns="urn:schemas-microsoft-com:office:spreadsheet"
               xmlns:o="urn:schemas-microsoft-com:office:office"
               xmlns:x="urn:schemas-microsoft-com:office:excel"
               xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
               xmlns:html="http://www.w3.org/TR/REC-html40" >
        <xsl:output method="xml" version="1.0" indent="yes" />
         <xsl:strip-space elements="*"/>

         <xsl:template match="/">
             <xsl:processing-instruction name="mso-application">progid="Excel.Sheet"</xsl:processing-instruction>
            <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
              xmlns:o="urn:schemas-microsoft-com:office:office"
              xmlns:x="urn:schemas-microsoft-com:office:excel"
              xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
              xmlns:html="http://www.w3.org/TR/REC-html40">

              </Styles>

              <Worksheet ss:Name="Sheet1">

                  <Column ss:AutoFitWidth="0" ss:Width="150" AutoFitWidth="1"/>
                  <Column ss:AutoFitWidth="0" ss:Width="150" AutoFitWidth="1"/>
                  <Column ss:AutoFitWidth="0" ss:Width="150" AutoFitWidth="1"/>
                  <Column ss:AutoFitWidth="0" ss:Width="100" AutoFitWidth="1"/>
                  <Column ss:AutoFitWidth="0" ss:Width="100" AutoFitWidth="1"/>
                  <Column ss:AutoFitWidth="0" ss:Width="100" AutoFitWidth="1"/>
                  <Column ss:AutoFitWidth="0" ss:Width="100" AutoFitWidth="1"/>
                  <Column ss:AutoFitWidth="0" ss:Width="100" AutoFitWidth="1"/>
                  <Column ss:AutoFitWidth="0" ss:Width="100" AutoFitWidth="1"/>
                  <Column ss:AutoFitWidth="0" ss:Width="100" AutoFitWidth="1"/>
                  <Column ss:AutoFitWidth="0" ss:Width="100" AutoFitWidth="1"/>
                <Row>
                    <Cell ss:StyleID="s22">
                      <Data ss:Type="String">
                        Assembly
                      </Data>
                    </Cell>
                  </Row>

                   <Row>
                   <Cell ss:StyleID="s22">
                      <Data ss:Type="String">

                      </Data>
                    </Cell>
                    <Cell ss:StyleID="s22">
                      <Data ss:Type="String">
                        PartA
                      </Data>
                    </Cell>
                    <Cell ss:StyleID="s22">
                      <Data ss:Type="String">
                       PartB
                      </Data>
                    </Cell>
                     <Cell ss:StyleID="s22">
                      <Data ss:Type="String">
                       PartA+PartB
                      </Data>
                    </Cell>
                  </Row>

                   <xsl:variable name="sum" select="'0'" />
                  <xsl:for-each select="plm:PLMXML/plm:ProductView/plm:Occurrence/plm:UserData/plm:UserValue[@title='bl_quantity']">
                  <xsl:variable name="a" select="@value" />
                  <xsl:variable name="sum" select="$sum + $a" />
                  </xsl:for-each>

                  <Row>
                        <xsl:for-each select="plm:PLMXML/plm:ProductView/plm:Occurrence/plm:UserData/plm:UserValue[@title='bl_quantity']">
                        <Cell ss:StyleID="s22">
                        <Data ss:Type="String">

                        <xsl:value-of select="@value"/>

                    </Data>
                         </Cell>
                         </xsl:for-each>
                         <Cell ss:StyleID="s22">
                       <Data ss:Type="String">
                       <xsl:value-of select="$sum"/>
                      </Data>
                    </Cell>
                  </Row>

                <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
                  <Selected/>
                  <ProtectObjects>False</ProtectObjects>
                  <ProtectScenarios>False</ProtectScenarios>
                </WorksheetOptions>
              </Worksheet>
            </Workbook>

          </xsl:template>

        </xsl:stylesheet>

I am able to display 10 & 15 in excel but adding part is not working. Please help me with this.
Answer: In XSLT, variables are immutable, and cannot be changed. This means your code to increment sum does not work as you expect
<xsl:variable name="sum" select="'0'" />
<xsl:for-each select="plm:PLMXML/plm:ProductView/plm:Occurrence/plm:UserData/plm:UserValue[@title='bl_quantity']">
    <xsl:variable name="a" select="@value" />
    <xsl:variable name="sum" select="$sum + $a" />
</xsl:for-each>

In fact, this may even be considered an error in XSLT 1.0, because according to the W3C specification "It is an error if a binding established by an xsl:variable or xsl:param element within a template shadows another binding established by an xsl:variable or xsl:param element also within the template". (It is not an error in XSLT 2.0, but the second sum is local to the xsl:for-each only, and different to the first sum. See http://www.w3.org/TR/xslt20/#scope-of-variables)
Anyway, to solve this, you should be using the sum function. Instead of doing
<xsl:value-of select="$sum"/>

Do this
<xsl:value-of
     select="sum(plm:PLMXML/plm:ProductView/plm:Occurrence/plm:UserData/
                 plm:UserValue[@title='bl_quantity' and normalize-space(@value)]/@value)"/>

Actually, you could simplify things by making use of a variable here. Try this XSLT snippet
<xsl:variable name="bl_quantity" select="plm:PLMXML/plm:ProductView/plm:Occurrence/plm:UserData/plm:UserValue[@title='bl_quantity']" />
<Row>
    <xsl:for-each select="$bl_quantity">
        <Cell ss:StyleID="s22">
            <Data ss:Type="String">
                <xsl:value-of select="@value"/>
            </Data>
        </Cell>
    </xsl:for-each>
    <Cell ss:StyleID="s22">
       <Data ss:Type="String">
        <xsl:value-of select="sum($bl_quantity[normalize-space(@value)]/@value)"/>
      </Data>
    </Cell>
</Row>


How do I construct a basis for the orthogonal complement of a subspace?

Question:
I was told that i can make a matrix A with vectors that span the subspace W which makes my the column space of my matrix equal to W. Then I can take the Null Space of A transpose which gives me (1,2,3,1). Does this mean the dim is one and it's automatically a basis because there is one vector?
Comment: How can a matrix be equal to a vector space?
Comment: i meant to say the column space of the matrix would equal W
Answer: You have line spanned by the vector $v=[2,1,-6,18]^t.$ Then
$$W^{\perp } = \{w \in \mathbb{R}^4: w\cdot v=0 \}\\
=\{w\in \mathbb{R}^4:2w_1+w_2-6w_3+18w_4=0\}.$$
If you fix $w_2 = \alpha, w_3= \beta, w_4 = \gamma$ then
$$\begin{bmatrix} w_1 \\
w_2\\
w_3\\
w_4
\end{bmatrix} =\begin{bmatrix} -\alpha/2+3\beta-9\gamma \\
\alpha\\
\beta\\
\gamma
\end{bmatrix}=
 \alpha\begin{bmatrix} -1/2 \\
1\\
0\\
0
\end{bmatrix} +  \beta \begin{bmatrix} 3 \\
0\\
1\\
0
\end{bmatrix} + \gamma \begin{bmatrix} -9 \\
0\\
0\\
1
\end{bmatrix}.$$
So the space $W^{\perp}$ is spanned by the vectors $$(-1/2,1,0,0), (3,0,1,0), (-9,0,0,1)$$
and its dimension is $3.$
Comment: How would I construct a basis for W?
Comment: The basis of $W$ is simply the vector spanning it $(2,1,-6,18).$
Comment: I was given this explanation, If you have a basis for W, and take A to be the matrix with columns span those basis vectors, then the column space of A is W. Thus the perpendicular complement of W is exactly the perpendicular complement of Col(A), which we know is Null(A) Transpose. Wouldn't this yield a different answer?
Comment: @SamuraiBale It in fact yields the same answer, up to sign.
Comment: how would this matrix look like?


how to save data on database using checkbox in cakephp

Question: I am new in cakephp so I want to store value 1 in db when user checked the  check box also stay checked after update please help me to resolve this issue.
One more thing default value to Userhistory.tillnow is 0
 <?php echo $this->Form->create('Userhistory', array('class' => 'form-inline')); ?>
 <?php echo $this->Form->input('Userhistory.tillnow', array('type' => 'checkbox')); ?>`
 <?php echo $this->Form->end(); ?>`

Answer: Follow these steps

Change the Database column to a TINYINT(1) for Boolean columns.
Save your request data
$this->Userhistory->save($this->request->data);


Why I feel like my guitar strings are very hard?

Question: I bought an Acoustic guitar six months ago, and I am trying to learn with the help of YouTube videos. And in those videos, it seems like it is not hard for them to press the strings for a chord.
However, when I try to play the same chord, the sound becomes mute, or my fingers hurt a lot. Is this normal, or should I change my steel strings?
Comment: Also, there's something wrong with your guitar. The 6th string is going through the nut at the same place as the 5th string... have you fixed that? That will improve your sound noticeably
Comment: Measure what height they are at the 12th fret, and post it.
Comment: The height at the nut is also important. Many acoustic guitars come with very high nuts.
Comment: 1/8th" will be so much better. Even 1/4" is way too big - so 1/3" is not a good sign. That guitar needs to go to someone who knows what they're doing, and *either* straighten the neck *and/or* lower the bridge. Neither job seems like you could do safely, if it's the first time. Is that measurement from string to top of fret or string to wood?
Comment: If you are a newbie, you will get used to it and then you will hear more clear sounds.
Comment: @Tim Thanks, your comments helped me realize the actual problem. I will seek for help from a professional.
Comment: Maybe show us a front and side picture of your guitar too...
Comment: I have added the pic in my question.
Comment: Yes already fixed it
Comment: @Tim It's 0.30 inches
Comment: Maybe you need someone who can really see you play and get you set with the basics until one point. Because watching youtube and learning, you might miss out on a few things probably not noticing them.
Comment: @RishiNandha_M Yes you are right, but if my guitar would be easily playable, then I would have learned all the chords and could practice strumming patterns too. Now I am stuck into this thing and not able to play until I get it fixed.
Answer: Many newcomers to guitar playing  don't realize the importance of having their guitar properly set-up in order for it to be easily playable. A qualified tech can look at your guitar and make adjustments to the neck, the bridge, the nut, and the string gauge which will greatly improve the playability of your instrument. If you are handy with tools, there are books that explain the process step by step and you can learn to do these adjustments yourself, but beginners are usually advised to seek professional help with their set-ups. You'll be amazed at how much easier your guitar will be to play, and how much less pain is involved in your finger tips.
Answer: First of all based on your pic the low E string is in the A string nut groove.  I don't know how you can play that at all.  It is common for finger tips to hurt you are exposing them to something new.  There is the pressure if the string digging into the flesh and that will cause calluses to develop.  Then there is the issue of your forearm muscles and other elements of your hand and wrist getting used to the new tasks you are demanding of them.  This is all new to your body and will take time to adjust.  There will be fatigue among other things.  However, as already mentioned guitars need to be adjusted.  If you bought it new there is a good chance that it has never been properly set up.  A pro set up can run $50-$100 in the US depending on where you get it done.  The feel of the guitar will depend on factors like string gauge, bridge height, nut grooves, truss rod tension etc.  When it's all in the right place it should be fairly easy to play.  That doesn't mean you will be a virtuoso in no time.  One thing to keep in mind is that YOU will be introducing your own internal tension due to not being able to properly finger chords, locate the right frets, etc.  All this translates to fatigue.  It takes considerable time to teach your hand the correct posture and beginners frequently have trouble getting every note to sound right.  Some may be muted due to other fingers touching the strings slightly (no adjustment will fix this), or buzz due to the finger placement not being directly behind the fret.  Set it up correctly first then see how it feels.  You should probably takes lessons from a real persona and not You Tube.
Answer: There are a few possibilities due to which you might be facing this issue. First, as you mentioned that you bought the guitar six months ago and are trying to learn via YouTube, it is possible that you haven't yet developed the required finger strength which is very common among new players. Second possibility which I think is very likely the cause of your problem is that you might be using a set of heavy gauge strings which are generally harder to play. Try using low gauge strings like d'addario extra light or maybe Ibanez extra light or fender etc. Go for 0.009 to 0.045 guage strings. Third possible issue can be that your strings might be far away from fretboard. This might be fixed by adjusting the elevation of your guitar bridge. It can be also be due to some upbow which means that your guitar neck is bent outward moving the strings far from frets. This can be easily fixed by adjusting your truss rod. If you can't do it, seek help from an experienced guitar player or a professional.
I really think that the problem is with the guage of your strings. Try using low guage strings.
Click a photo from the side of the fretboard so that the distance between your guitar strings and frets is visible.


Can't hear Directsound unless I debug step

Question: My issue is that I only hear sounds when I hit a breakpoint in debug and then resume. If I attempt otherwise I will not hear the sounds; even though everything appears to be playing. For example, onComplete callbacks get triggered at the correct time.
I have tried sprinkling Sleeps in the code to simulate the breakpoints, but it doesn't work.
This bug only occurs when I am using OpenGL for graphics. If I use GDI+ for graphics, then everything sounds fine.
DirectSound is the only sound implementation I have, so I have not tested with other sound packages.
I did find some info suggesting to disable Visual Studio Hosting Process, but I am using C++ which doesn't use the Visual Studio Hosting Process anyways.
Any help would be appreciated
Thanks
Les
Comment: try to reproduce issue with small code snippet and post code.
Answer: The problem was the HWND used in DirectSound's SetCooperativeLevel(). I was fetching the HWND via GetForegroundWindow() right after finishing glutCreateWindow(). Instead, I had until the next tick to call GetForegroundWindow(), because until then the glut window was not actually created and the call to GetForegroundWindow() was actually referencing the shell window used in glut.


Computing étale cohomology group $H^1( \text{Spec}(k), \mu_n)$ and $H^1( \text{Spec}(k), \underline{\Bbb{Z}/\mathord{n \Bbb{Z}}})$

Question: I am starting to learn about étale cohomology and would like to compute a simple example. Let $k$ be a field with a fixed separable extension $k^s.$ I want to compute $H^1( \operatorname{Spec}(k), \mu_n)$ (I am speaking about the étale cohomology groups)
Here is what I tried:
$\bullet \quad H^1( \operatorname{Spec}(k), \mu_n)$
According this question here, we have an isomorphism $H^1( \operatorname{Gal}(k^s|k),A)  \simeq H^1( \operatorname{Spec}(k),\mu_n),$ where the cohomology on left hand side is Galois cohomology and $A = \varinjlim_{L|k} \mu_n(L)$ with $L$ running through the Galois extensions of $k$. Then, if I am not mistaken, we have $A= \mu_n(k^s)$ and it follows (explained in detail in Serre's book) that $H^1( \operatorname{Gal}(k^s|k),\mu_n(k^s))= (k^s)^{\times}/ \mathord{{(k^s)^{\times}}^n}.$
I think this is right, but again I am just beginning with this and perhaps I may have overlooked something and there is something wrong with my reasoning.
$\bullet \quad H^1(\operatorname{Spec}(k), \underline{\mathbb{Z}/\mathord{n \mathbb{Z}}})$
Here $\underline{\mathbb{Z}/ \mathord{n \mathbb{Z}}}$ is the constant sheaf associated to $\mathbb{Z}/ \mathord{n \mathbb{Z}}$ and $k$ is a field with characteristic prime to $n.$
Following the same line of reasoning yields $H^1( \operatorname{Gal}(k^s|k), \underline{\mathbb{Z}/ \mathord{n \mathbb{Z}}}(k^s)).$ Now, when $k$ is a perfect field, we have $k^s= \bar{k}$ and under algebraically closed fields the sheaves $\mu_n$ and $\mathbb{Z}/ \mathord{n \mathbb{Z}}$ coincide. However, if we don't have the guarantee that $\mathbb{Z}/ \mathord{n \mathbb{Z}}$ I am not sure how to proceed.
My field theory is a bit rusty, is it true that for any $n$-th root of unity of $k$ is a separable element over $k.$ If so then can I proceed as above?
What if the characteristic is not prime to $n$. Is there a general method to compute $H^1(\operatorname{Spec}(k), \underline{\mathbb{Z}/ \mathord{n \mathbb{Z}}})$
Answer: The computation of $H^1(\operatorname{Spec}(k), \mu_n)$ is not completely correct: in Serres book it is written the correct answer $H^1( \operatorname{Gal}(k^s|k),\mu_n(k^s))= k^{\times}/ \mathord{{k^{\times}}^n}.$
Another possible way to prove it is to consider the sequence
$$0\to \mu_n \to \mathbb Gm \to \mathbb Gm \to 0,$$
where the map between the multiplicative groups is the "power-to-the-$n$". The sequence is exact for the etalé topology (but not for the Zarisky topology), hence you get a long exact sequence for the cohomology. But $ H^1(\operatorname{Spec}(k), \mathbb{G}m)=0$ for Hilbert's theorem 90, hence you get the result.
About the second case, so  $H^1(\operatorname{Spec}(k), \underline{\mathbb{Z}/\mathord{n \mathbb{Z}}})$, you cannot reduce to the previous case since $\underline{\mathbb{Z}/\mathord{n \mathbb{Z}}}\not{\cong}\mu_n$ even if $k$ contains all $n$-roots of unity. But you can reduce to compute Galois cohomology as you did, so you want to compute $H^1(\operatorname{Gal}(k^s/k), \mathbb{Z}/\mathord{n \mathbb{Z}})$, where now we have a constant group, since the points over $k^s$ of the constant sheaf is the constant group (and over every field). But now we have group cohomology, where the group acts trivially, hence the $H^1$ is just the hom's, so
$$H^1(\operatorname{Gal}(k^s/k), \mathbb{Z}/\mathord{n \mathbb{Z}})\cong \operatorname{Hom}(\operatorname{Gal}(k^s/k),\mathbb{Z}/\mathord{n \mathbb{Z}}).$$
This last group can be big in general, but it is small for example if $k$ is finite: it is isomorphic to $\mathbb{Z}/\mathord{n \mathbb{Z}}$.
In down to earth terms, the elements of $H^1(\operatorname{Spec}(k), \underline{\mathbb{Z}/\mathord{n \mathbb{Z}}})$ correspond essentially to Galois extensions of $k$ with cyclic Galois group of order dividing $n$.
Comment: If the field contains all roots of unity why still $\underline{\mathbb{Z}/n\mathbb{Z}}$ is not same as $\mu_n$? It seems in that action of Galois group on the roots of unity becomes trivial and they become exactly the same thing.
Comment: @user127776 The problem is with the characteristic of the field; if it divides $n$, then $\mu_n$ contains less elements than the contant sheaf.
Comment: I am a little confused: the OP stated $(k^s)^\times /((k^s)^\times)^n$ for $H^1(\mathrm{Spec}(k), \mu_n)$, but the long exact sequence argument gives $k^\times/(k^\times)^n$. Yet you say OP is correct.
Comment: @SpencerLeslie  You are right. The OP is not correct. The correct answer is what you said. I correct the answer.


What is the posterior in-sample vs the posterior out-of-sample?

Question: I'm watching this video on Bayesian modelling for the stock market by Thomas Wiecki, Thomas has a slide with two posterior distribution over the mean parameter in his stock return model. Around 18:26 we see this slide:

The phrase "in-sample" and "out-of-sample" in regard to a posterior distribution, both in regard to the same latent variable, confuses me.
If one wants to look at the latent variables, the way I understand it, one can:

Look at the prior of a latent variable, which is designed by the user.
Look at the posterior of a latent variable, which one can obtain after observing some data.

At no point in the Bayesian workflow does an "out-of-sample" vs "in-sample posterior" come up, just posterior vs prior.
Question: What does "in-sample posterior" vs "out-of-sample posterior" mean?
Comment: I haven't watched the video, but I'd imagine he is referring to a posterior distribution estimated under training data (in-sample in finance") and test data (out-of-sample).
Comment: @Forgottenscience One might think, but in both cases one would normally use the same posterior distribution of a latent variable for in-sample and out-of-sample predictions and in his presentation they are clearly different. Look at the image of the slide I posted if you haven't already. Updating the posterior using out-of-sample data would be inappropriate, otherwise it would be called in-sample data.
Answer: This is explained earlier in the talk, from around 3:12 (link).

Quantopian users train financial models on historical data ("in-sample period"), and test them on new data ("out-of-sample period"). Due to overfitting, the models usually do better on the in-sample data.
The speaker's job is to evaluate how well these financial models perform, by considering both their in-sample and out-of-sample performance. He fits a model to evaluate the performance data generated by the users' models. This is where the terminology gets confusing!


How to find the solution to following IVP?

Question: If the IVP is
$$\frac{dx}{dt}=x\sin(t)+\sin(x^2) $$ subjected to $$x(a)=b. $$
I want to know in which interval this IVP has unique global solution? Further what is that solution?
Answer: You have $$|x'|\le |x|+1.$$ Such linear bounds on the derivative are sufficient to show the existence of a solution over all of $\Bbb R$.
Indeed consider $\phi(t)=\ln(1+|x(t)|)$, then
$$
|\phi'(t)|=\frac{|x'(t)|}{1+|x(t)|}\le 1
$$
so that $$\phi(t)\le |t-a|+\phi(a)$$ or
$$
|x(t)|\le (1+|x(a)|)e^{|t-a|}-1
$$
so that $x$ is bounded at all times, no divergence to infinity in finite time is possible.
Answer: Only a  comment:
$$x'(t)=x(t) \sin (t)+\sin \left(x^2\right) => t'(x)=\frac{1}{x \sin (t(x))+\sin \left(x^2\right)}$$
$$ t'(x)=\frac{1}{x \sin (t(x))+\sin \left(x^2\right)}=\\t'(x)=\frac{1}{x \sin (t(x))+\sum _{k=0}^{\infty } \frac{(-1)^k x^{4 k+2}}{(2 k+1)!}}$$
With CAS help:
$$C+\int_{} ^{t(x)} \left(\sum _{k=0}^{\infty } \frac{(-1)^k e^{-(1+4 k) \cos (s)}}{(1+2 k)!}\right) \, ds+\sum _{k=0}^{\infty }
   \frac{e^{-(1+4 k) \cos (t(x))} x^{-1-4 k}}{1+4 k}=0$$
$$C+\int_{}^{t(x)} \left(\sum _{j=0}^{\infty } \left(\sum _{k=0}^{\infty } \frac{(-1)^k (-1-4 k)^j \cos ^j(s)}{j! (1+2 k)!}\right)\right)
   \, ds+\frac{e^{-\cos (t(x))} \, _2F_1\left(\frac{1}{4},1;\frac{5}{4};\frac{e^{-4 \cos (t(x))}}{x^4}\right)}{x}=0$$
$C+\sum _{j=0}^{\infty } \left(\sum _{k=0}^{\infty } \frac{(-1)^{1+k} (-1-4 k)^j \cos ^{1+j}(t(x)) \,
   _2F_1\left(\frac{1}{2},\frac{1+j}{2};\frac{3+j}{2};\cos ^2(t(x))\right) \sin (t(x))}{(1+j) j! (1+2 k)! \sqrt{\sin
   ^2(t(x))}}\right)+\frac{e^{-\cos (t(x))} \, _2F_1\left(\frac{1}{4},1;\frac{5}{4};\frac{e^{-4 \cos (t(x))}}{x^4}\right)}{x}=0$
subjected to
$$t(b)=a$$
then:
$\color{Blue}{\sum _{j=0}^{\infty } \left(\sum _{k=0}^{\infty } \frac{(-1)^{1+k} (-1-4 k)^j \cos ^{1+j}(t(x)) \,
   _2F_1\left(\frac{1}{2},\frac{1+j}{2};\frac{3+j}{2};\cos ^2(t(x))\right) \sin (t(x))}{(1+j) j! (1+2 k)! \sqrt{\sin
   ^2(t(x))}}\right)+\frac{e^{-\cos (t(x))} \, _2F_1\left(\frac{1}{4},1;\frac{5}{4};\frac{e^{-4 \cos (t(x))}}{x^4}\right)}{x}-\sum
   _{j=0}^{\infty } \left(\sum _{k=0}^{\infty } \frac{(-1)^{1+k} (-1-4 k)^j \cos ^{1+j}(a) \,
   _2F_1\left(\frac{1}{2},\frac{1+j}{2};\frac{3+j}{2};\cos ^2(a)\right) \sin (a)}{(1+j) j! (1+2 k)! \sqrt{\sin
   ^2(a)}}\right)-\frac{e^{-\cos (a)} \, _2F_1\left(\frac{1}{4},1;\frac{5}{4};\frac{e^{-4 \cos (a)}}{b^4}\right)}{b}=0}$
probably can't be solvelable.


GMap Module, How do I make my map change its marker icons faster/without hang?

Question: A bit of a newbee, but I have a somewhat complex issue.
Background: I am creating a map for a client, with a filtered list beneath it. when they click one of the categories at the top, the list filters to that category, and the respective markers on my GMap view change icons from a light blue to dark blue if they are the active category, and vice-versa if inactive. I have been working on this on and off for a little over a month, but the deadline is the end of the month. I'm on the last few steps, namely optimizing. The Module I am using is GMap 2.11-7.x
The problem:  I have everything working, but not very quickly. When I go to switch the categories, it calls
<code>
var map=Drupal.gmap.getMap('auto1map');
      map.bind('addmarker', function (m) { ... }); //bind addmarker-handler, the marker is available as callback-argument
</code>
However, I noticed, to update a marker, it calls that method for each marker, AND it calls the methods within to update each marker, which seems necessary because otherwise it stops after the first marker.... Ultimately, it hangs for a few seconds where the webpage freezes up, which is not ideal.
I get my brain all jumbled up, this is my first web dev job, and I don't have the most solid grasp on JavaScript. Do I need to extract the setIcon code from the bind event? Is there a better way to update Icons on a Google Map?
Full code is as follows:
<code>(function ($) {
  //When click on marker, act on related link

  //initiates drupal gmap module
  Drupal.behaviors.gmap = {
    attach: function (context, settings) {
      //I get all the html list elements
      var listBlock = $('.project-prof'); //choose .project-prof elements
      var li = $(listBlock).parent().parent().parent(); //chooses the list item of .project-prof elements
      var activeCategory = "Healthcare"; //sets default activeCategory
      var activeLi = $("."+activeCategory).parent().parent().parent(); //chooses list item of active .project-prof
      var location = []; //this will be used to keep track of the locations of each activeLi in the array of <li>
          // now we .push() the position(integer) of each list item that has activeCategory
      $(li).each(function(i){
        if($(this).children().children().children().hasClass(activeCategory)){
                location.push(i);
            }
      });
      console.log(location); //debug

      //Set index to associate list element and markers
      var index = 0;

      //reference for the map
      var map=Drupal.gmap.getMap('auto1map');
      //bind addmarker-handler, the marker is available as callback-argument
      map.bind('addmarker', function (m) {
        var element = $(li)[index];
        m.marker.index=index;

        //remove listeners set automatically by the library
        google.maps.event.clearListeners(m.marker, 'mouseover mouseout click');

        //hover over markers
        google.maps.event.addListener(m.marker, 'mouseover',function(){
          //Hide other elements
          //so activeLi toggle here hides the active category
                $(activeLi).stop().animate({
                  height: "toggle",
                  width:"toggle",
                  opacity: "toggle"
                });
      //element toggles the specific moused-over object
                $(element).stop().animate({
                  height: "toggle",
                  width:"toggle",
                  opacity: "toggle"
                });
        });
        //same thing but just mouseout
        google.maps.event.addListener(m.marker, 'mouseout',function(){
                $(activeLi).stop().animate({
                  height: "toggle",
                  width:"toggle",
                  opacity: "toggle"
                });
                $(element).stop().animate({
                  height: "toggle",
                  width:"toggle",
                  opacity: "toggle"
                });
        });
        //hover is set

        //filter list after button press (button event further down)
        function toggleCategory(thisVar) {
            //console.log("" + thisVar+ " "); //debug to make sure activeCategory is bound correctly

            activeLi = $("."+thisVar).parent().parent().parent(); //gotta set activeLi again
            var location = []; //empty out the old location array
                        //do it again
            $(li).each(function(i){
                if($(this).children().children().children().hasClass(thisVar)){
                    location.push(i);
                }
            });
            console.log(location); //more debug
            //fancy animations
            $(activeLi).stop().animate({
                  height: "toggle",
                  width:"toggle",
                  opacity: "toggle"
            });
                        //this is how the icons are actually set for the markers to their correct active or inactive look
            if($.inArray(m.marker.index,location) != -1){
                console.log("2." + m.marker.index + " = " + "true"); //debug
                m.marker.setIcon('marker.png');
            } else {
                m.marker.setIcon('marker2.png');
            }
        }
        //filter is set

        //setting defaults
                //initial setup on page load of which markers are active and inactive
        if($.inArray(m.marker.index,location) != -1){
                console.log("2." + m.marker.index + " = " + "true"); //debug
                m.marker.setIcon('marker.png');
        } else {
                m.marker.setIcon('marker2.png');
        }
        $(listBlock).not($(".Healthcare")).parent().parent().parent().hide();
        //defaults are set

        //filtering buttons
        $("#block-block-38 input").on("click", function(){
            $(activeLi).stop().animate({
                  height: "toggle",
                  width:"toggle",
                  opacity: "toggle"
            }); //fancy animations
            activeCategory = $(this).attr('name'); //set activeCategory to this new button's name
            toggleCategory(activeCategory); //pass activeCategory into the above function (it becomes thisVar)
        });
        //buttons set

        //toggle marker location's modal, same as clicking on respective list item
        google.maps.event.addListener(m.marker, 'click',function(){
            $($(element).find('a').attr("data-target")).modal("show");
        });
        //modal is set

        index++; //increment index so we can do this all over again for each marker?
      });
    }
  }
})(jQuery);
</code>
How can I cut the fat out of this code/make this work faster?
Here's a visual aid:
Answer: I have managed to fix the hang. I learned a lot about Google Maps in general, but as I was clicking a filter button, it would add new markers, which would make new arrays, which would then execute 66 more times, doing all of it at once. So I realized after a while, why not just take out all the code from that addmarker block, putting it below?
To replace all that code, the most important thing was to stuff each new marker into an array, to compare their index later to the "active" list that resides below the map. If this helps anyone, yet they need help, let me know, I might be able to assist.
<code>(function($) {
    //When click on marker, act on related link
    //initiates drupal gmap module
    Drupal.behaviors.gmap = {
        attach: function(context, settings) {
            //I get all the html list elements
            var listBlock = $('.project-prof'); //choose .project-prof elements
            var li = $(listBlock).parent().parent().parent(); //chooses the list item of .project-prof elements
            var activeCategory = "Healthcare"; //sets default activeCategory
            var activeLi = $("." + activeCategory).parent().parent().parent(); //chooses list item of active .project-prof
            var location = [];
            var markers = [];
            //Set index to associate list element and markers
            var index = 0;
            //reference for the map
            var map = Drupal.gmap.getMap('auto1map');

            //pushes the location of the active list item into the location array
            $(li).each(function(i) {
                if ($(this).children().children().children().hasClass(activeCategory)) {
                    location.push(i);
                }
            });

            //bind addmarker-handler, the marker is available as callback-argument
            map.bind('addmarker', function(m) {
                var element = $(li)[index];
                m.marker.index = index;

                //remove listeners set automatically by the library
                google.maps.event.clearListeners(m.marker, 'mouseover mouseout click');

                //hover over markers
                google.maps.event.addListener(m.marker, 'mouseover', function() {
                    //Hide other elements
                    //so activeLi toggle here hides the active category
                    $(activeLi).stop().animate({
                        height: "toggle",
                        width: "toggle",
                        opacity: "toggle"
                    });
                    //element toggles the specific moused-over object
                    $(element).stop().animate({
                        height: "toggle",
                        width: "toggle",
                        opacity: "toggle"
                    });
                });
                google.maps.event.addListener(m.marker, 'mouseout', function() {
                    $(activeLi).stop().animate({
                        height: "toggle",
                        width: "toggle",
                        opacity: "toggle"
                    });
                    $(element).stop().animate({
                        height: "toggle",
                        width: "toggle",
                        opacity: "toggle"
                    });
                });
                //hover set

                //now we push this marker into an array that contains the markers
                markers.push(m.marker);

                //now check if this marker's index in that array is a number in location[]
                if ($.inArray(m.marker.index, location) != -1) {
                    m.marker.setIcon('../markers/stevens.png');
                } else {
                    m.marker.setIcon('../markers/stevens2.png');
                }

                //toggle marker location's modal, same as clicking on list
                google.maps.event.addListener(m.marker, 'click', function() {
                    $($(element).find('a').attr("data-target")).modal("show");
                });
                //modal set

                index++;
            });

            //filtering buttons
            $("#block-block-38 input").on("click", function() {
                $(activeLi).stop().toggle();
                $(".prof-cat-active").removeClass("prof-cat-active");
                $(this).addClass("prof-cat-active");
                activeCategory = $(this).attr('name');
                location = [];
                $(li).each(function(i) {
                    if ($(this).children().children().children().hasClass(activeCategory)) {
                        location.push(i);
                    }
                });
                console.log(location);
                toggleCategory(activeCategory);
            });
            //buttons set

            //default for the list below map
            $(listBlock).not($(".Healthcare")).parent().parent().parent().hide();

            //function that toggles the category
            function toggleCategory(thisVar) {

                activeLi = $("." + thisVar).parent().parent().parent();
                $(activeLi).stop().toggle();

                for (var i = 0; i < markers.length; i++) {
                    console.log(markers[i]);
                    console.log($.inArray(markers[i].index, location));
                    if ($.inArray(markers[i].index, location) != -1) {
                        console.log("2." + markers[i] + " = " + "true");
                        markers[i].setIcon('../markers/stevens.png');
                    } else {
                        markers[i].setIcon('../markers/stevens2.png');
                    }
                }

            }
        }
    };
})(jQuery);
</code>


Probability of the maximum of n dice rolls being equal to k

Question: As part of my recent interest in university-level statistics, I'm trying to figure out what the probability distribution is for the following scenario, without having to resort to counting the number of outcomes:
Suppose I roll two dice, but rather than adding them together I use the higher of the two as the "result" of the event.
This is not a homework question, I'm just trying to learn some "advanced" statistics techniques out of personal interest (for example, I've recently learned that you can find the probability distribution for the sum of two independent events by convolving the individual distributions). So I'd like to know if there's a "better" way to do this than enumerating all the possible outcomes and counting those that fit the criterion. I suppose the criteria for "better" would be:

Less computationally expensive (i.e. faster if it were to be implemented on a computer)
More interesting from a mathematical analysis standpoint.

Thank you

Update to question
How would I generalize the explanation in dsaxton's answer, namely:
$P(\max(X_1, X_2) = k) = 2 P(X_1 = k \cap X_2 \leq k) - P(X_1 = k \cap X_2 = k)$
to the maximum of three or more dice?
In the case of the max of three dice, it looks like the cases are:

$x1 = k$ and $x2 \leq k$ and $x3 \leq k$
$x2 = k$ and $x1 \leq k$ and $x3 \leq k$
$x3 = k$ and $x1 \leq k$ and $x2 \leq k$

which suggests that the probability would be
$P(\max(x1, x2, x3) = k) = P(x1 = k \cap x2 \leq k \cap x3 \leq k) + P(x2 = k \cap x1 \leq k \cap x3 \leq k) + P(x3 = k \cap x1 \leq k \cap x2 \leq k) - P(x1 = k \cap x2 = k \cap x3 = k)$
(though maybe this is still multi-counting?)
Is there some way to use combinatorics or some other technique to express the expanded formula for the max of $n$ dice?
Comment: This looks like a you made a major change to your question after getting a good answer, which would invalidate the answer you already have (since it doesn't answer the new question). It would be best to ask that as a new question and link the question back here for context, unless dsaxton is happy to answer it here as well. (On the other hand, I think even the extended question may be a duplicate so this may close in any case.)
Comment: The answer you got sounds great (+1), but [here is an alternative derivation](https://drive.google.com/file/d/0Bwl-HpVJ_5Peb1RwWFVlZnI0TlU/view?usp=sharing).
Comment: Generally, when $n$ independent observations of random variables following a common cumulative distribution $F$ are made, the cdf of the maximum of those observations is $F^n$ (this is an easy deduction from the probability axioms). Thus, the chance that the maximum *exactly equals* some value $x$ is the chance that it is less than or equal to $x$ but not less than or equal to any number less than $x.$ In short, you seek $\lim_{\epsilon\to 0^+} F^n(x) - F^n(x-\epsilon).$ For the dice and values $x\in\{1,2,\ldots,6\}$ this directly gives $(x/6)^n-((x-1)/6)^n.$
Answer: You don't need to enumerate all possibilities, just consider that $\max(X_1, X_2) = k$ simply means $X_1 = k$ and $X_2 \leq k$ or $X_2 = k$ and $X_1 \leq k$.  So we just add the probabilities of these events (which by symmetry are equal) and subtract their intersection to avoid double counting,
\begin{align}
P(\max(X_1, X_2) = k) &= 2 P(X_1 = k \cap X_2 \leq k) - P(X_1 = k \cap X_2 = k) \\
&= \frac{2k}{36} - \frac{1}{36} \\
&= \frac{2k - 1}{36} .
\end{align}
To extend this idea to $m$ dice it gets a bit more complicated as we need to be more careful about applying the inclusion exclusion principle.  Let $A_i \equiv \{ X_i = k \cap X_j \leq k \text{ for $j \neq i$}\}$.  Then
\begin{align}
P(\max(X_1, \ldots , X_m) = k) =& P(\cup_{i=1}^{m} A_i) \\
=& \sum_{i=1}^{m} P(A_i) - \sum_{i \neq j} P(A_i \cap A_j) + \\
& \sum_{i \neq j, i \neq l, j \neq l} P(A_i \cap A_j \cap A_l) - \\
& \ldots + (-1)^{m + 1} P(\cap_{i=1}^{m} A_i) \\
=& \frac{m k^{m - 1}}{6^m} - \binom{m}{2} \frac{k^{m - 2}}{6^m} + \\
& \binom{m}{3} \frac{k^{m - 3}}{6^m} - \ldots + (-1)^{m + 1} \frac{1}{6^m} \\
=& \frac{1}{6^m} \sum_{i=1}^{m} (-1)^{i+1} \binom{m}{i} k^{m - i} .
\end{align}
Edit:
I just realized the title of your post seems to be asking a different question than what's in the post itself.  If you want to find the probability that $X_1 \geq X_2$ then you can take a conditional expectation,
\begin{align}
P(X_1 \geq X_2) &= \text{E}[P(X_1 \geq X_2 \mid X_1)] \\
&= \text{E} \left ( \frac{X_1}{6} \right ) \\
&= \frac{3.5}{6} .
\end{align}
Here we've used the general result that $\text{E}(X) = \text{E}[\text{E}(X \mid Y)]$ for random variables $X$ and $Y$, and that probabilities themselves may be viewed as expectations of indicator random variables.  Even simpler perhaps, we can arrive at the answer by basically only using the fact that probabilities sum to one,
$$
P(X_1 \geq X_2) + P(X_2 \geq X_1) - P(X_1 = X_2) = 1 \Rightarrow \\
2 P(X_1 \geq X_2) - \frac{1}{6} = 1 \Rightarrow \\
P(X_1 \geq X_2) = \frac{3.5}{6} .
$$
Comment: This helped greatly, thank you - I just worked it out on paper and I follow... How would I generalize this to the maximum of three or more dice?

In the case of the max of three dice, it looks like the cases are:
x1 = k and x2 <= k and x3 <= k ;
x2 = k and x1 <= k and x3 <= k ;
x3 = k and x1 <= k and x2 <= k.

Is there some way to use combinations to figure out what the expanded formula should be?
Comment: I added the mass function for general $m$ to the post.  It's a bit dense so let me know if anything isn't clear.
Comment: Actually, your first answer (before the edit) is exactly what I was looking for. I was trying to figure out the probability of the value k being the maximum of three d20 rolls. You used d6 dice but it's easy to generalize to others.
Answer: A simpler solution that gives the same final answer as for using the inclusion–exclusion principle is to define two event:
A = at least one of the n dice rolls results is k.
B = all of the dice rolls results is less or equal to k.
Now if X is the greatest result, then:
P(X=k) = P(A and B) = P(A|B)•P(B)
= (1-P(A^c|B))•P(B).
P(B) = the probability to get a number from the set {1,..,k} out of the 6 optional results.
P(B) = (k/6)^n
P(A^c|B) = considering the fact that every result can be either number from {1,..,k}, the probability not getting k at all will be choosing a number from the set {1,..,(k-1)} of the k optional results.
P(A^c|B) = ((k-1)/k)^n
So the final answer will be:
P(X=k) = (1-((k-1)/k)^n)•(k/6)^n
Comment: Are you sure about that? first of all, by simplifying "dsaxton" result using wolframalpha we get that both answers are identical. Second, how else would you calculate:
 P(A^c|B) ? which means - we wouldn't get k in the dice, knowing that the dice will fall on a number from {1,...,k}
Comment: The idea is good but the calculations aren't quite correct: $k$ should not appear in the denominators of the fractions.
Comment: You are correct: I did not notice that the powers of $k$ cancel in your formula.  For the simplified version, see my comment to the question.


How to prove that the equation $x^{2n}-2x^{2n-1}-\cdots-2nx+(2n+1)=0$ have no real roots?

Question: I came up with this:
Substitute with $y=\dfrac{1}{x}$, then $(2n+1)y^{2n}-2ny^{2n-1}-\cdots-2y+1=0$. Try to prove that the function $f(y)=y^{2n+1}-y^{2n}+y^{2n-1}+\cdots-y^2+y$ is increasing.
I tried to plot the graph of $f(y)$ and it looks like a monotonous increasing function, but how to prove it?
Comment: @Mason `My equation matches the title` Not quite: $x^{2n}-2x^{2n-1}\color{red}-\ldots-2nx+(2n+1)=0$. That $\,\color{red}-\,$ should be a $\,\color{red}+\,$ instead, and that's where I suspect the typo is.
Comment: Can you please write some more terms in $x^{2n}-2x^{2n-1}-\cdots-2nx+(2n+1)=0$?
Comment: @Mason Your 2nd & 3rd term are negative in question, which is different in your above comment.!
Comment: emmmm. It's a problem from my textbook, and I just copy-and-pasted it from my book. And I agree with @Mason
Comment: 2nd & 3rd term means for $j=1,2$
Comment: @Empty I guess that's a typo in either the problem or the transcription thereof.
Comment: @闫嘉琦 In case I am right about the typo, $f(y)$ is the sum of a geometric progression. Write it in the closed form and take the derivative, then you should be able to prove it's positive.
Comment: I have it in a closed form. But I am not sure how taking the derivative helps us out. Do you want me to post the closed form?
Answer: Multiplying your function
$$P(y)=\sum_{j=0}^{2n} (j+1)(-y)^j$$
by $(y+1)^2$ gives
$$P_2(y)=(2n+1)y^{2n+2}+(2n+2)y^{2n+1}+1.$$
Its derivative is
$$(2n+1)(2n+2)\left(y^{2n+1}+y^{2n}\right)=(2n+1)(2n+2)y^{2n}(y+1).$$
Can you see why this means that $P_2(y)\geq 0$ for all real $y$, with its minimum reached at $y=-1$ (the new root we have added and can check in $P$ instead of $P_2$ later)?


Track and fix swiftUI crash (saw PreferenceKeys, expected ViewList)?

Question: I'm getting a crash when I move quickly in my app (open a sub-page then go back to landing).
App crash log from TestFlight:

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x00000001c87ff334 __pthread_kill + 8
1   libsystem_pthread.dylib         0x00000001e6221aa0 pthread_kill + 272 (pthread.c:1392)
2   libsystem_c.dylib               0x00000001a3b86c10 __abort + 116 (abort.c:147)
3   libsystem_c.dylib               0x00000001a3b86b9c abort + 116 (abort.c:118)
4   AttributeGraph                  0x00000001c3c31a6c AG::precondition_failure(char const*, ...) + 192 (ag-util.cc:51)
5   AttributeGraph                  0x00000001c3c1f4cc AG::Graph::input_value_ref_slow(AG::data::ptr<AG::Node>, AG::AttributeID, unsigned int, AGSwiftMetadata const*, bool*, long) + 828 (ag-graph.cc:0)
6   AttributeGraph                  0x00000001c3c3109c AGGraphGetValue + 232 (ag-graph-impl.h:43)
7   SwiftUI                         0x00000001a140bbc4 AnyViewList.Item.list.getter + 72 (<compiler-generated>:0)
8   SwiftUI                         0x00000001a140b5e8 AnyViewList.updateValue() + 512 (AnyView.swift:333)
9   SwiftUI                         0x00000001a0f1f0c4 partial apply for specialized implicit closure #2 in implicit closure #1 in closure #1 in closure #1 in Attribute.init(_:) + 24 (<compiler-generated>:0)
10  AttributeGraph                  0x00000001c3c1977c AG::Graph::UpdateStack::update() + 492 (ag-closure.h:108)
11  AttributeGraph                  0x00000001c3c19bb4 AG::Graph::update_attribute(AG::data::ptr<AG::Node>, bool) + 332 (ag-graph-update.cc:563)
12  AttributeGraph                  0x00000001c3c22dc4 AG::Subgraph::update(unsigned int) + 884 (ag-subgraph.cc:613)
13  SwiftUI                         0x00000001a1735188 GraphHost.runTransaction() + 172 (GraphHost.swift:491)
14  SwiftUI                         0x00000001a11bd184 ViewGraph.updateOutputs(at:) + 108 (ViewGraph.swift:404)
15  SwiftUI                         0x00000001a1681688 closure #1 in ViewRendererHost.render(interval:updateDisplayList:) + 1508 (ViewRendererHost.swift:188)
16  SwiftUI                         0x00000001a1677bdc ViewRendererHost.render(interval:updateDisplayList:) + 308 (ViewRendererHost.swift:0)
17  SwiftUI                         0x00000001a1813920 _UIHostingView.layoutSubviews() + 200 (UIHostingView.swift:1557)
18  SwiftUI                         0x00000001a1813954 @objc _UIHostingView.layoutSubviews() + 28 (<compiler-generated>:0)
19  UIKitCore                       0x000000019d728c20 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2576 (UIView.m:17543)
20  QuartzCore                      0x000000019dbaf91c -[CALayer layoutSublayers] + 308 (CALayer.mm:10147)
21  QuartzCore                      0x000000019dbafe00 CA::Layer::layout_if_needed(CA::Transaction*) + 548 (CALayer.mm:10014)
22  QuartzCore                      0x000000019dbc4a38 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144 (CALayer.mm:2485)
23  QuartzCore                      0x000000019db06ca8 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 500 (CAContextInternal.mm:2510)
24  QuartzCore                      0x000000019db32eb8 CA::Transaction::commit() + 684 (CATransactionInternal.mm:449)
25  QuartzCore                      0x000000019db341e4 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 96 (CATransactionInternal.mm:932)
26  CoreFoundation                  0x000000019a77f440 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36 (CFRunLoop.c:1799)
27  CoreFoundation                  0x000000019a779564 __CFRunLoopDoObservers + 572 (CFRunLoop.c:1912)
28  CoreFoundation                  0x000000019a779b10 __CFRunLoopRun + 1052 (CFRunLoop.c:2953)
29  CoreFoundation                  0x000000019a7791c0 CFRunLoopRunSpecific + 600 (CFRunLoop.c:3242)
30  GraphicsServices                0x00000001b1d61734 GSEventRunModal + 164 (GSEvent.c:2259)
31  UIKitCore                       0x000000019d1e77e4 -[UIApplication _run] + 1072 (UIApplication.m:3269)
32  UIKitCore                       0x000000019d1ed054 UIApplicationMain + 168 (UIApplication.m:4740)
33  SwiftUI                         0x00000001a16bd350 closure #1 in KitRendererCommon(_:) + 112 (UIKitApp.swift:34)
34  SwiftUI                         0x00000001a16bd2dc runApp(_:) + 224 (<compiler-generated>:0)
35  SwiftUI                         0x00000001a11b5b4c static App.main() + 144 (App.swift:113)
36  xxx                         0x0000000102e05244 $main + 28 (<compiler-generated>:19)
37  xxx                         0x0000000102e05244 main + 40 (REST_API.swift:0)
38  libdyld.dylib                   0x000000019a435cf8 start + 4

The main landing UI :
import SwiftUI
struct w_landing: View {

  @State var daily_feed:CAT_BITE?
  @EnvironmentObject var env:Env
  @State var page:pages!

  public static var isAnimated:Bool = false
  let timer = Timer.publish(every: 1, on: .current, in: .common).autoconnect()

  @ViewBuilder
  var body: some View {

        NavigationView {

            ZStack {

                    deepLink(page: $page).onChange(of: env.open_page) { (Equatable) in
                        DispatchQueue.main.async {
                            page = Equatable
                        }
                    }.id("deep_link")

                    Color.black

                    //Backgroud
                    Image("background_landing")
                        .resizable()
                        .aspectRatio(contentMode: .fill)
                        .frame(width : UIScreen.main.bounds.width,
                               height : UIScreen.main.bounds.height)
                        .ignoresSafeArea(.all)
                        .onAppear(){
                            self.parseNotification()
                        }

                    //Grid
                    VStack {

                        //DAILY FEED BUTTON
                        if ( self.daily_feed != nil ){
                            Button(action: {

                                page = pages.withLabel( self.daily_feed!.type)

                            } ){ catBite( i:0, dto : self.daily_feed!).environmentObject(env)  }
                        }

                        //LIST GRID
                        LazyVGrid(columns: [GridItem(.flexible()),
                                            GridItem(.flexible())]
                                  ,spacing: 8){

                             if Env.sharedInstance.cats.count > 0 {

                                ForEach(0...Env.sharedInstance.cats.count - 1 , id : \.self) {i in

                                    if Env.sharedInstance.cats[i].type != "DAILY_FEED"  {
                                        Button(action: {

                                            page =  pages.withLabel( Env.sharedInstance.cats[i].type)

                                        }) {
                                            catBite( i:i - 1, dto : Env.sharedInstance.cats[i]  )
                                                .environmentObject(env)
                                        }
                                    }

                                }
                             }
                        }

                        Spacer()

                    }.padding(.top, Env.sharedInstance.hasNotch ? 80 : 50)
                     .padding([.leading,.trailing] , 20)
                     .id("the_main_list")

            }.id("landing")
             .navigationBarColor( .clear, textColor: .white )
             .accentColor(.white)
             .navigationBarTitleDisplayMode(.inline)
             .onAppear(){

                DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) {
                    w_landing.isAnimated = true
                }

                //CheckIn
                NF_APP.checkIn {
                    self.rebuild()
                } onFail: {

                }

             }
            .onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification), perform: { _ in
                parseNotification()
            })
            .onReceive(NotificationCenter.default.publisher(for: NSNotification.Name("pushRecieved")), perform: { _ in
                parseNotification()
             })
             .onReceive(timer) { time in
                env.seconds += 1
             }
            .navigationBarItems(leading:

                    Button(action : {

                        DispatchQueue.main.async{
                            self.page = .SHARE_APP
                        }
                    } ){
                             VStack(spacing: 0){
                                 Image( "icon-invite")
                                     .resizable()
                                     .aspectRatio(contentMode: .fit)
                                     .foregroundColor(.white)
                                     .frame(width : 28, height : 28)

                                 Text("Invite Friends")
                                       .foregroundColor(.white)
                                       .font(Font.custom("Poppins-Light", fixedSize: 8))
                             }
                     }

                , trailing:
                    HStack(spacing : 20){

                        Button(action : { page = .NOTIFICATIONS} ){
                            Image(systemName: "bell.fill")
                                .resizable()
                                .aspectRatio(contentMode: .fit)
                                .foregroundColor(.white)
                                .frame(width : 25, height : 25)
                        }

                        Button(action : { page = .SETTINGS} ){
                            Image(systemName: "gearshape.fill")
                                .resizable()
                                .aspectRatio(contentMode: .fit)
                                .foregroundColor(.white)
                                .frame(width : 25, height : 25)
                        }

                    }
            ).toolbar {

                //LOGO mid
                ToolbarItem(placement: .principal) {
                    Image("logo-splash").resizable()
                        .aspectRatio(contentMode: .fit)
                        .frame(width : 140, height: 50)

                }
            }

        }.navigationViewStyle(StackNavigationViewStyle())
    }

    fileprivate func parseNotification(){

        //Open deep link notification if exsits
        if  push_payload != nil {

            print("[PUSH] payload \(String(describing: push_payload))")

           if  let custom_data:[String:Any] = push_payload["custom_data"] as? [String:Any] {

                push_payload = nil

                let open_page:String = custom_data["open_page"] as? String ?? ""

                print("[PUSH] open page = \(open_page)")

                if open_page != "" {

                    DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                        page = pages.withLabel(open_page)
                    }

                }
           }else{
            print("[PUSH] No custom data found")
           }

        }else{
            print("[PUSH] Payload was nil")
        }

    }

    fileprivate func rebuild(){

        //Cats already loded
        if  Env.sharedInstance.cats.count > 0 {
            return
        }

        if let _cats:[Any] = Env.sharedInstance.checkin?.payload!["categories"] as? [Any] {

            Env.sharedInstance.cats = []
            for cat in _cats {

                guard  let cat = cat as? [String:Any] else {
                    continue
                }

                Env.sharedInstance.cats.append(CAT_BITE(cat))
            }

            if Env.sharedInstance.cats.filter({ $0.type == "DAILY_FEED"}).count > 0 {
                self.daily_feed = Env.sharedInstance.cats.filter({ $0.type == "DAILY_FEED"})[0]
            }
        }

    }
}

struct w_landing_Previews: PreviewProvider {
    static var previews: some View {
        w_landing()
    }
}

I've tried every solution in the Apple community and Stack Overflow, but I'm still stuck with this crash:

AttributeGraph precondition failure: invalid value type for attribute: 632448 (saw PreferenceKeys, expected ViewList).

and the only way to get the full log was to upload a version on TestFlight and send the report to myself once the app crashed On Xcode, the crash log is useless and I couldn't identify from where the crash is coming from.
Comment: Needed minimal reproducible example, otherwise you hardly get answer.
Comment: BTW, your view is tooooo-o complicated - try to break and compose from smaller subviews, probably it could solve the issue or find exact origin.
Comment: have you found your solution yet? I have the same problem.
Comment: If it only happens when you move quickly it is probably because you have the View doing so much "work" there are many posts in SO about clicking too fast causing issues or typing in the search bar too fast
Comment: @JKOU not yet , i hope someone will show up with a solution
Comment: the thing that stood out for me (apart from the code complexity) is the use of the word "Equatable". It is the name of a protocol. Try changing it to something else and make the code less complicated.
Comment: @workingdog sure i am gonna change it soon and update my question
Comment: the code has been updated
Comment: maybe it was another Equatable, because I can still see: "                        DispatchQueue.main.async {
                            page = Equatable
                        }" in the code.  Anyway, does it make any difference?
Comment: @workingdog , nope its not from page = Equatable , i've disabled it and still same issue
Comment: You're saying it happens when you "move quickly" through your app. Does it maybe have to do with the timer?  That or maybe the notification receipt triggering actions between your actions? I'm thinking it could be race conditions where slow activity is fine, but quick navigation is too fast for the more asynchronous listeners. Specifically referring to the `.onReceive(timer) { time in env.seconds += 1 }` part, your `env` variable might not be in the desired state when it's being accessed
Comment: Your revision is missing the code for the subviews: deepLink(), catBite()
Answer: It's difficult to say definitively what the issue is here, but this line:
DispatchQueue.main.async{
     self.listID = UUID().uuidString //Void apple SwiftUI big in AttributeGraph cycle ( seems it worked by Jack )
}

Leads me to think you may have lurking instabilities caused by overlapping view hierarchy updates.
There's a good discussion of how arbitrarily updating your view ids can lead to issues in this week's 2021 WWDC (Demystify SwiftUI): https://developer.apple.com/wwdc21/10022
You've also got this line:
}//end of geo
.id(  self.listID )

Which forces the geo view to update itself. That coupled with the above .onAppear reset of the listID is causing your entire view hierarchy to constantly update itself (and be unstable).
Here's another guide about how misplaced state changes can cause unstable behavior:
https://swiftui-lab.com/state-changes/
Comment: if i remove this code the crash will happen more
Comment: but how i can debug AttributeGraph crashes ? or iOS crashes in general from the store , i can't find it from the Orgnizer


Can there exist an FLT mapping UHD to UHP?

Question: Can there exist a fractional linear transformation mapping the upper half-disc conformally onto the upper half-plane? I think there cannot be, because I am looking for where the unit circle and the real line (whose union is a superset of the boundary of UHD) would be mapped. Since the boundary of $UHP$ is a single line, it seems there's no way it can work.
Side question: how can I make rigorous the notion that FLTs preserve boundaries? I remember something about this from my complex analysis course, but I'm forgetting where I should look for it.
Answer: Your logic is correct. There can not exist a FLT mapping the upper half-disc conformally to the upper half plane. FLTs take circles to circles (or lines through the origin), and such a map would necessarily map the boundary of the upper half disc (not a circle) to the boundary of UHP (which is a circle).
It is a theorem that every FLT of the UHP extends uniquely to a map on the boundary $\mathbb{R}\cup\{\infty\}\cong S^1$. This theorem (along with the Brower fixed point theorem) is used to show that every fractional linear transformation is either hyperbolic, parabolic, or elliptic. You can find a proof in any introductory hyperbolic geometry textbook (e.g., Anderson's Hyperbolic Geometry, or Marden Outer Circles for a more advanced perspective).
Comment: Small edit: I think the lines do not have to be through the origin.
Comment: @EricAuld You are correct. I also lied just a little about the characterization. The characterization is of LFTs $\frac{az+b}{cz+d}$ where $a,b,c,d\in\mathbb{R}$. These are the ones that preserve the UHP and act by isometries on this space.


Charge user after status of order is changed with eCommerce

Question: I am using the Drupal 7 eCommerce kickstart distribution.
I want to sell service (like cleaning, gardening...), and I want user to be able to create order, but I want to give them ability to do payment after service is done.
Is there any way to do this, to make user able to make payment after they create order.
Answer: You can use a payment gateway that allows for Authorization Only transactions. This will authorize a certain amount, but will not actually charge the credit card.  This is what gas stations, hotels, etc. do. They charge a preset amount, and then finalize the actual amount later.
commerce_authnet offers this capability. In the settings for the payment gateway you just set Authorize Only.
Once the administrator is ready to finalize the payment, they would go to the Orders page, and choose Payment on the Order.  You then 'capture' the amount to finalize the payment.
You can fine tune who has access to the Payments page on the Permissions page.
Comment: Thank you for answer, but I have to use Stripe service, sorry I did not mention it in original question.
Comment: I have implemented using Stripe the capture later functionality as I am using Stripe too.  I will clean that up and upload it to github sometime this week.  My implementation is based off of the stable release of 1.0 of Stripe.
Comment: The limitation with Stripe capture later functionality is that you only have a 7 day window to capture. If that isn't going to work for you, you should use commerce_card_onfile and store the user's credit card to be charged later.  I have NOT implemented this functionality yet.
Comment: I finally made a patch which has the authorization only functionality implemented for Stripe.  It has NOT been peer reviewed.  It is based of of the 7.x-1.x dev version of the Sept 15th commit.  https://www.drupal.org/node/2600690


PHP: How to set http response code?

Question: I am using wamp with PHP version 5.5.12. I am trying to use http_response_code to set the code. When I use it, it returns true and not the value I set. I am a PHP newbie, and I wanted to know what I am missing in this. How do I get it to return 300 and not true?
getCode(300); // returns true and not with the code I set.

function getCode($code)
{
  $statuscode = http_response_code($code);
  echo $statuscode;
}

Comment: Possible duplicate of [PHP: How to send HTTP response code?](http://stackoverflow.com/questions/3258634/php-how-to-send-http-response-code)
Comment: You can read the docs. If you specify/set a new code then you will get the previous status code. Call the method http_response_code again with no arguments to get the new code.
Comment: You mean this http://stackoverflow.com/questions/3258634/php-how-to-send-http-response-code#12018482 or?
Comment: @Andreas I did exactly what you said and ran it a second time without params. It worked. Thank You.
Comment: @Andreas I did read the docs first. I was unclear, so I needed help. There's nothing wrong with asking questions.
Answer: I suggest you read the doc regarding http_response_code: http://php.net/manual/en/function.http-response-code.php
TRUE will be returned if response_code is provided and it is not invoked in a web server environment (but only when no previous response status has been set).

Having true means "Ok, we'll send 300" and is therefore fine in your case.

PHP: How to set http response code?


How do I convert my server-side ASP XmlHttpRequest code to client-side JavaScript?

Question: i using below asp code for xml request
<%
pXML=Server.URLencode(SearchRequest)
set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhtt.open "post", http://OutSideDomain/xml_requests , false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send  "xml_request=" &pXML
htresult = xmlhttp.responsexml.xml
%>

I try to write the above code in javascript(Ajax)

The above asp code is working fine and get xml response,
But in the javascript i getting error is "Access Denied" in the like xmlHttp.send(params);
what is the problem for "Access Denied"?,
I here that from one HTTP to another HTTP is not possible ... But that thing is working in my asp page..
How i solve this ?
hoping your response
Answer: The problem is the difference in context. Your JavaScript code is running client-side and so it's subject to the Same Origin Policy. Your ASP code is running server-side and so it isn't.
You basically can't do this from the client right now, although there are initiatives going on that will make some limited amount of cross-site communication possible. For the moment, you're better off continuing to do this on the server-side (despite the bandwidth cost that will cause).
Alternately, if the source you're trying to reach provides a JSONP interface, you can use that.