text:
# disposal of fixed assets procedure

The account is sometimes called the disposal account, gains/losses on disposal account, or sales of assets account. Therefore, for any asset that has not been fully depreciated, a business must record the current period’s depreciation expense before recording the disposal of the asset. transmit the completed form to Fixed Asset Department. It standardizes the procurement of Fixed Assets in accordance with the Capital ... Major Disposal of Fixed Assets 1. } ] Let’s say Sinra Inc sells a machinery of $200,000 for$70,000 cash This should include the unique asset tag number and a general description of the asset. When the disposal process is completed, journal entries are reviewed by the Assistant Controller before being posted to the general ledger from the Fixed Asset Module. Fixed assets are those long-term assets which can benefit the enterprise for more than 12 months and is above the particular threshold as defined by the enterprise as guidelines made in compliance with laws and regulations as well as align with the applicable accounting standards and frameworks. Situation A: The truck is completely worthless and is scrapped for $0. • Establishes a fixed asset management program within Finance & Administration (F&A) to coordinate the development and dissemination of fixed asset policies and procedures and to facilitate all of the necessary activities to establish asset accountability. The At the end of its useful life, the delivery truck is represented in the books as: Consider these three situations in which Bold City disposes of the delivery truck. The department completes an NYU Asset Surplus Form to request authorization for disposal of any NYU Asset, and/or to report any surplus items. Debit all accumulated depreciation and credit the fixed asset. A gain on the exchange occurs because Bold City received a truck with a cost of$\$78,000$ for assets worth $\$74,500$(a truck that had a net book value of$\$6,000$ plus cash of $\$68,500$). Moves. Reconciling & Reporting Regardless of the method of disposal, it is important to ensure that depreciation expense on the asset is up to date before recording the disposal. Appendix A to Fixed Asset Policy Asset Disposal Procedure 1. So, Truck (new) is debited for$\$78,000$. Let’s say Sinra Inc purchases an asset for $100.000 and recognizes$10,000 of depreciation every year. Once again, the gain equals the amount necessary to bring the entry into balance. If item is found to be a fixed asset: Asset is physically placed in holding area. Bold City trades the delivery truck in toward the purchase of a new truck that costs 9,500 and pays for the difference in cash. To remove the asset, we must zero out both the Asset and Accumulated Depreciation accounts. "item": If it was on credit, then account receivable is where it should charge to. Observe that the credit to the gain account equals the amount needed to bring the entire entry into balance. sale/scrap/part exchange/other. Dispose of assets individually to record the gains and losses that result from a disposal, and to record the new asset cost if there is a trade-in. "position": 1, This is to make sure that the disposed assets are not take advantages by anyone in the company. } How much gain or loss would be recognized on the sale? "url": "https://accountingproficient.com/category/financial-accounting/", "@type": "ListItem", In all cases, assets disposed of must be reported and subsequently removed from the asset register. accumulated depreciation of $40,000 with another asset B that has fair market Must regularly conduct a physical inventory, verify the existence, condition and location of all assets subject to audit, and reconcile to the IEC Asset Management System. },{ If fixed assets are routinely shifted between departments, there should be a procedure that ensures the related records are updated. We will discuss here the administrative and accounting procedure for fixed assets disposal. If you received a piece of equipment, then you would debit the Equipment account for the fair value (cost) of the equipment you received. To do this, we need to debit the Accumulated Depreciation, Truck account for 61,000 dollars and credit the Truck account for 67,000 dollars. eval(ez_write_tag([[250,250],'wikiaccounting_com-medrectangle-4','ezslot_4',104,'0','0'])); There is no other entries is necessary for this disposal since the company just write the assets off without any gain. Step 2 Record “what you gave up.” Once again, Bold City gave up the old delivery truck and should remove it from the books. [ or junk and the department wishes to dispose of the equipment the department must follow the below steps: a. FIXED ASSETS DISPOSAL PROCEDURE: Fixed Assets property that are not being used, or are obsolete and/or beyond repair, are to be disposed of through submission of form PDR to Physical Plant. } Bold City sells the truck for$8,000 cash. If the asset has very little or no value, it can be recycled through e-waste, or sold as scrap. Step 2 Record “what you gave up.” In this case, Bold City gave up the old delivery truck and should remove it from the books. Disposal of fixed means discarding the fixed asset from the performance to create any value. after having completed $140,000 of accumulated depreciation. Step 1 Record “what you got.” In this transaction, Bold City received a$\$78,000$ new truck. All disposals are assumed to take place after the delivery truck has been fully depreciated. There are certain procurement procedures when the fixed assets are purchased. Administrative procedures:. The truck is completely worthless and is scrapped for $0. Then, if you paid out any cash, you would credit Cash. "url": "https://accountingproficient.com/financial-accounting/disposal-fixed-assets-procedure-example/", Let’s demonstrate asset disposals by once again using Bold City’s delivery truck as an example. A form for disposal shall be filled while disposing off the assets. the goods for disposal and by their location and market value. "name": "Financial Accounting" },{ Similarly, the disposal is treated. Sinra Inc replaces the asset A that has original cost of$80,000 and The following are the procedures to be considered by administration while disposing off the asset: We will discuss the accounting aspects for disposal of fixed assets as following with help of an example: Fixed assets can be disposed through various methods as sale, scrap, part exchanges of asset and other methods. You can find new, In addition to acquiring and depreciating. Fixed Assets Policies and Procedures 9 (FXDM), where the disposal date, disposal method, disposal price, and/or disposal cost are entered. 1.1 Once the assets are identified, the DII section will have to propose for write-off / disposal of the identified assets in the Format-Aor Format-Bdepending upon their written down value as per the DOP. { Step 3 Record any gain or loss on the transaction. "itemListElement": } Maintaining a fixed asset register and/or master file is only important for the accuracy, completeness, and existence of fixed assets. Step 3 Record any gain or loss recognized on the transaction. Gain from selling of assets compare to the net book value are charged to income statement. further into a fixed asset accounting system and a fixed asset management system. Bold City credits Gain on Sale of Truck for $\$2,000$. And both accumulation and gross value of assets are discharged from financial statements. A fixed asset accounting system is a system of policies, procedures, and methods for recording and reporting monetary amounts associated with fixed asset transactions. Accumulated Depreciation, Truck is debited for$\$61,000$ and the Truck (old) account is credited for $\$67,000$. It is depending on the complexity of entity’s nature of business. "@type": "BreadcrumbList", The same as above case, accumulated depreciation and the gross value of the disposed assets should removed from financial statements and also from listing accordingly. Finance Office Fixed Asset Custodian follows the procedures listed on page FA-47 in User Guide. "url": "https://accountingproficient.com", 1.2. This Policy document establishes policy & procedures for accounting of Fixed Assets as per relevant Accounting Standards. The company received$\$8,000$ for a piece of equipment with a book value of $\$7,000\left(\$42,000-\$35,000\right)$, so a gain of$\$1,000$ should be recognized on the sale. Assets disposed of with a carrying amount (Cost less Accumulated Depreciation) above £500 must be approved by the Finance, Resource and Sinra Inc has made $20,000 of accumulated depreciation on the A more detailed description of each disposal option is set out below: 5.1 Tender Tendering procedures for disposal are detailed in section 7 below. Sinra Inc sells machinery that has original cost of$80,000 for \$ It shall contain the details such as: Method of disposal i.e. Government regulations require us to track an asset’s cost, depreciation, and the disposal of the asset. Procurement Procedures and Disposal of Fixed Assets Procurement procedures of fixed assets are the process of purchasing which usually starts from requesting in purchase to finding quotes and then to the approval the purchase and payment. The department having fixed assets for disposal should fill out a property control form and contact Property Management so the assets … Surplus is checked by Inventory Control to determine fixed asset or non-fixed asset. "item": If this is the case, the auditor should review not only the procedures of disposal, accounting recognition but also the main reason for disposal which might affect the others recoverable of fixed assets. In addition to acquiring and depreciating fixed assets, businesses often dispose of them.

Scroll to Top


text:
# HEGL Community Seminar SoSe22

## Location

The Seminar takes place in Seminar Raum C (Mathematikon) or online via Zoom. Contact us or join the HEGL Mailing List to get the Zoom coordinates.

## Schedule

### 20.07.2022 – Final Project Presentations

Time: 13:00 (Seminar Raum C)
Abstract: Join us to learn about the HEGL Student Projects from the Summer 2022 Semester. There will be lightning talks on:

• Symplectic billiards
• Hyperbolic billiards
• Ray marching in translation surfaces
• Hyperbolic shooting game
• Moebius paint
• Mirrors
• Hopf Fibration

Pizza and refreshments will be presented in the Foyer after the talks. Note the unusual date and time.

### 18.07.2022 – Periodic billiards on regular polygons

Speaker: Diana Davis (Phillips Exeter Academy)
Time: 14:15 (Seminar Raum C)
Abstract: Imagine that you hit a ball in a regular polygon-shaped billiard table, and after bouncing around for a while, the ball comes back to where it started and then repeats its path. I’ve been studying these “periodic” paths for many years, and it turns out that they’re very beautiful, like mathematical art. I’ll show lots of pictures, and explain the underlying tree and group structures. This is joint work with Samuel Lelièvre.

### 04.07.2022 – Counting Pairs of Saddle Connections

Speaker: Sam Fairchild (MPI)
Time: 14:15 (Seminar Raum C)
Abstract: A translation surface is a collection of polygons in the plane with parallel sides identified by translation to form a Riemann surface with a singular Euclidean structure. A saddle connection is a special type of geodesic, and the set of saddle connections form discrete subsets of the Euclidean plane. Studying the set of saddle connections is a long standing problem in the field of translation surfaces. I will discuss problems and results related to counting pairs of saddle connections. This talk will include some computer experiments, number theory, dynamics, and geometry. No previous knowledge of translation surfaces or counting problems is necessary.

### 20.06.2022 – A tour of 3D printed mathematics: Tritangentless trefoils, ideal graph configurations, and chaotic attractors

Speaker: Laura Taalman & Steve Lucas (James Madison)
Time: 14:15 (on Zoom)
Abstract: In this talk, we’ll take a 3D-printed tour of a collection of mathematical objects we have made over the years. We’ll start with building tritangentless trefoils and show how to make them roll as easily as possible. We will then look at ways to construct collections of ideal graph configurations in three dimensions. Finally, we will show how to create 3D mesh models to accurately visualize a variety of chaotic orbits. Along the way, we will explore the technical and computational tools needed for creating 3D-printable mathematical models, including OpenSCAD, Mathematica, and MATLAB, and provide resources to help students and mathematicians who wish to create their own models.

### 15.06.2022 – Mid-Semester Presentations

Time: 13:00 (Seminar Raum A)
Organizers: Zachary Greenberg, Merik Niemeyer, Diaaeldin Taha
Abstract: Join us to learn about the HEGL Student Projects from the Summer 2022 Semester. There will be lightning talks on:

• Symplectic billiards
• Hyperbolic billiards
• Ray marching in translation surfaces
• Hyperbolic shooting game
• Moebius paint
• Mirrors
• Hopf Fibration

Pizza and refreshments will be presented in the Foyer after the talks. Note the unusual time and location.

### 30.05.2022 – What is Research in Mathematics

Time: 14:15 (on Zoom)
Abstract: What does it mean to create/discover new mathematics? How does one get involved in this process? We’ll discuss this via a couple of examples: no background needed, and there will be *lots* of pictures!

### 16.05.2022 – $$C^1$$ Isometric Embedding of the Hyperbolic Plane

Speaker: Mélanie Theillière (Luxembourg)
Time: 14:15 (Seminar Raum C)
Abstract: In this talk, we will construct explicitly a $$C^1$$ isometric embedding of the Poincaré disk. And we will see propreties of the limit set (which can be seen as its limit edge) of such a construction. In particular, the Hausdorff dimension of the limit set of the surface built with the explicit parameters of the first part is $$1$$.

### 02.05.2022 – Dynamics, Finite Fields, and Character Varieties:  A Geometry Lab Project Working!

Speaker: Sean Lawton (George Mason)
Time: 15:00 (on Zoom)
Abstract: In 2014, the Mason Experimental Geometry Lab (MEGL) was founded at George Mason University (GMU). During Fall and Spring of that year, MEGL obtained funding, space, equipment, and participants. In Summer 2015, the first research  (and outreach) projects began. One of the first projects explored dynamics on the finite field points of certain algebraic varieties. This project continued every semester and summer until Fall 2018. In addition to interesting conjectures with substantial data to support them and 1000’s of lines of code generating said data, the project created awesome visualizations (images and 3D prints), a GMU-College of Science research award, an undergraduate honors thesis, a PhD thesis, a community of mathematicians (11 student participants, most in PhD programs or in professional scientific positions), and many fond memories. This talk is about that story.

format: plain


text:
+1.617.933.5480

# Q: Find the P-value for the indicated hypothesis test

An article in a journal reports that 34% of American fathers take no responsibility for child care. A researcher claims that the figure is higher for fathers in the town of Littleton. A random sample of 225 fathers from Littleton, yielded 97 who did not help with child care. Find the P-value for a t...

Get notified immediately when an answer to this question is available.

Related Questions in Theory of probability
• Q:
Statistics Homework (Solved) July 18, 2012

BUS 219 / MAT 167 Summer, 2012 Final Exam 300 points# Please show all pertinent steps. A top-notch solution is complete and is easy to # follow from beginning to end.The...

• Q:
Student Expenditures: The average expenditure per student (based on average... (Solved) January 27, 2015

Student Expenditures: The average expenditure per student (based on average daily attendance) for a certain school year was $10,337 with a population standard deviation of$1560. A survey...

• Q:
Testing Statistic, pvalue and hypothesis with calcium April 30, 2012

HELP !!! A nutritionist thinks the average person with an income below the poverty level gets less than the recommended daily allowance (RDA) of 800 mg of calcium. To test ...

• Q:
stat218 #4 (Solved) October 08, 2012

, would you care whether the dice are fair? 2. Two fair dice are rolled. Compute the probability that the number on the ¯rst is smaller that the number on the second. 3.

Solution Preview :
Question 1 Given, X follows Binomial with n=100, p=0.65 Thus Normal approximation for binomial is Using correction for continuity Question 2 Let X be the total number of cavities in mouth of...
• Q:
fixed level test, pvalue, CI (Solved) January 12, 2011

A random sample of five observations with an aqueous film forming foam had a sample mean of 4.340 and a standard deviation of .508. A random sample of five observations...

Solution Preview :
a. The test hypothesis is Ho:µ1=µ2 Ha:µ1 not equal to µ2 The test statistic is t=(xbar1-xbar2)/v[s1^2/n1 s2^2/n2] =(4.34-7.091)/sqrt(0.508^2/5 0.43^2/2) = -7.25 Given a=0.1, the critical...

Copy and paste your question here...
Have Files to Attach?

Similar question? edit & resubmit »


text:
# Thermodynamics of baryonic matter with strangeness within non-relativistic energy density functional model

Abstract : The phase diagram of dense baryonic matter is investigated in the non-relativistic mean-field framework including the full baryonic octet. It is shown that, depending on the thermodynamic conditions, up to three strangeness-driven phase transitions may occur, such that a huge fraction of the total baryonic density domain corresponds to phase coexistence. The phase transitions are associated to the onset of the different hyperonic species or hyperonic families. We demonstrate that, due to a moderate component of the order parameter along the direction of charge density, phase coexistence persists if the Coulomb coupling to the electrons is accounted for. This makes the phase transition potentially relevant for neutron star and supernova evolution. The sensitivity of the results on the hyperonic coupling constants is explored, both for purely phenomenological energy functionals and for functionals adjusted to microscopic BHF calculations. We show that the presence of a phase transition is compatible both with the observational constraint on the maximal neutron star mass, and with the present hypernuclei experimental information. We also show that two solar mass neutron stars are compatible with important hyperon content. Both the $Y$-$N$ channel and the $Y$-$Y$ channel contribute to the phase transition. Still, the parameter space is too large to give a definitive conclusion of the possible occurrence of the phase transition, and further constraints from multiple-hyperon nuclei and/or hyperon diffusion data are needed.
Document type :
Preprints, Working Papers, ...
Complete list of metadatas

http://hal.in2p3.fr/in2p3-01017199
Contributor : Sandrine Guesnon <>
Submitted on : Wednesday, July 2, 2014 - 9:02:07 AM
Last modification on : Tuesday, February 19, 2019 - 10:02:03 AM

### Identifiers

• HAL Id : in2p3-01017199, version 1
• ARXIV : 1406.0395

### Citation

Ad. R. Raduta, F. Gulminelli, M. Oertel. Thermodynamics of baryonic matter with strangeness within non-relativistic energy density functional model. 2014. ⟨in2p3-01017199⟩

Record views


text:
5.2k views

An IP machine $Q$ has a path to another $IP\ machine\ H$ via three $IP\ routers \ R1, R2,$ and $R3$.

$Q-R1-R2-R3-H$

$H$ acts as an $HTTP\ server$, and $Q$ connects to $H$ via $HTTP$ and downloads a file. Session layer encryption is used, with $DES$ as the shared key encryption protocol. Consider the following four pieces of information:

$[I1]$ The $URL$ of the file downloaded by $Q$

$[I2]$ The $TCP$ port numbers at $Q$ and $H$

$[I3]$ The $IP$ addresses of $Q$ and $H$

$[I4]$ The link layer addresses of $Q$ and $H$

Which of $I1$, $I2$, $I3$, and $I4$ can an intruder learn through sniffing at $R2$ alone?

1. Only $I1$ and $I2$
2. Only $I1$
3. Only $I2$ and $I3$
4. Only $I3$ and $I4$
edited | 5.2k views
0

Q1. Can intruder see the link layer addresses of R1 and R2?
Q2. Why can't intruder see the link layer addresses of Q and H ?

+4
A1. Yes, the link layer addresses of R1 and R2 would be visible at Router R2. Since the link addresses are modified at every hop, it would be R2 and R3's addresses visible by sniffing at Router R3.

A2. Due to the above reason the link layer addresses of Q and H wouldn't be available at Router R2.
+2
whithout DES encryption URL would be visible, right?

[I1] intruder cant see URL because it is well encrypted by DES at session layer..
[I2] TCP PORT number available to intruder because TCP header contains source as well as destination address.

[I3] Network layer header contains Source as Well as Destination IP.
[I4] Link address unavailable because on sniffing at $R2$  intruder can see link address of $R$1, $R3$ ,only not link address of  $Q$ and $H$

answered by Veteran (59.9k points)
edited
+2
Your forgot to comment on IP address.
+27
Well I know that :) Maybe somebody might not know ! Felt like it should be there, for sake of completeness !
0
@digvijay, Why can't intruder be able to see link address of Q & H at R2 unlike at R1 & R3.?????
+7
How TCP port number visible to router as it has only 3 layer; Physical, DLL, Network.

Clarify.
0
router doesnt contain transport layer, so how it is able to look into port no [email protected]
+6
I think Sniffer uses SPAN(switched packet analyzer) to receive a copy of each packet send from one host to other at router.......so it can analyze the packet and can know upto transport layer...but since packet is encrypted at session layer ,so it can't know about data or url of host. @Rajesh Raj
+2
Because During Journey of Packet from Q to H, PORT Number which is added by Q by Transport Layer wil not change thats why Intruder can see port number therefore I2 is true

And IP address of Source and Destination will also not change therefore i3 is also true

only mac addresses will change and URL is encrypted as mentioned by DES
0
@rude , @habib khan , @rajesh pradhan bro tell me "How TCP port number visible to router as it has only 3 layer; Physical, DLL, Network."
+5
The intruder will be able to see TCP port nos. although it belongs to transport layer because TCP segment is in the payload of IP datagram
0
@digvijay  how can an intruder see TCP port number on router R2 ...router contains only up to network layer right ??
+1
@Tuhin dutta TCP segment is in the payload of IP datagram that is correct but it will be uncovered on a device which has transport layer. we can only wrap off up to IP header and that doesnt contain the port number.some  body please explain it with valid reasons.
+6
Since the IP datagram contains within the TCP segment the intruder can see the TCP port nos( bcz intruder has access to datagram) but not beyond that.Now, this is bcz from session layer onwards it is encrypted till application or message.
+2
@ Tuhin yeah now i got it thanxxx :)
+1
If session layer encryption is not used then sniffer can also see through URL of the file downloaded by Q??
0
Nice explanation.
0
router has data link layer then why intruder cant see link layer address please explain??
+3
@garimanand it cant see link layer address  because dll works at hop to hop so packet contains link layer address of R1 and R2 not of Q and H.
0
Then layer 3 Firewall can do the filtering based on Port No?
0
@akash kanse are u nuts??
I1 is encrypted by DES at the Session layer so intruder can't see that.

I2 is a part of TCP header(below Session layer), so it is not encrypted. Obv., the intruder can see that.

I3 is a part of the IP header(below TCP layer), so again, it is not encrypted and the intruder can see that as well.

I4 is not a part of the DLL header(below the IP layer), since the DLL always contains the Mac Addresses of the immediate sender(previous hop-R1) and the immediate destination(next hop-R3), so the intruder cannot see I4.

So, answer - (C)
answered by Active (3.4k points)
+1
Router works at network layer. So how is it possible for someone to see TCP port numbers at the routers. As router doesn't have any visibility of Transport layer. Please explain
+2
According to me ,
Router can't learn.
But attacker can learn bcoz attacker is sniffing.
An Intruder can’t learn [I1] through sniffing at R2 because
URLs and Download are functioned at Application layer of OSI Model.

An Intruder can learn [I2] through sniffing at R2 because
Port Numbers are encapsulated in the payload field of IP Datagram.

An Intruder can learn [I3] through sniffing at R2 because IP
Addresses and Routers are functioned at network layer of OSI Model.

An Intruder can’t learn [I4] through sniffing at R2 because
it is related to Data Link Layer of OSI Model.
answered by Loyal (9.3k points)
Router works at network layer. So it has only three layers.(physical,datalink,network). since the intruder is sniffing at R2 so intruder can only see the ip address of Q and H becoz the source and destination ip address can't change.
answered by Active (4.6k points)
0
someone  pls clarify answer if its C or only I3
answered by (39 points)
0
hey can you please explain your ans ?
+10
I don't know the exact reason I'm making a guess here.. Please tell me whether my guess is correct or not for the reason...

Encryption happens at session also it is clearly mentioned..

So from session layer and above session layer intruder can not analyze the data and get information from it...

I1: He can not make URL, since URL is of application layer information because he can't make url from packet snifing because packet is well encrypted..!!

I2: TCP port can be made through packet sniffing because this information comes below session layer, so it was not encrypted..

I3: same reason as that of I2

let me know if I m wrong!!
+3
No, its not that like the layer above session are only encrypted and so the URL remains safe.

Actually, its the general SSL encryption to wrap HTML. (See http://security.stackexchange.com/questions/19681/where-does-ssl-encryption-take-place) . And in actual SSL encryption happens in session layer ( that's why the name => sessiin layer encryption). And all this is basically done for securing iur data.

Now, in given question all data exchanged should be secured (and so does the URL). And as you MUST not violate your basic objective of "communication of machines" , you will always require port nos, ip addreses and MAC(dll) addresses, so you cant encrypt these. But, as MAC address is only exposed from Link-to-Link fashion, one can never find Mac id of Q and H by sniffing at R2 alone.
dyrgdj
answered by (39 points)

1
2


text:
# Using factor theorem, show that g(x) is a factor of p(x), when

Question:

Using factor theorem, show that g(x) is a factor of p(x), when

$p(x)=2 \sqrt{2} x^{2}+5 x+\sqrt{2}, g(x)=x+\sqrt{2}$

Solution:

Let:

$p(x)=2 \sqrt{2} x^{2}+5 x+\sqrt{2}$

Here,

$x+\sqrt{2}=0 \Rightarrow x=-\sqrt{2}$

By the factor theorem, $(x+\sqrt{2})$ will be a factor of the given polynomial if $p(-\sqrt{2})=0$.

Thus, we have:

$p(-\sqrt{2})=\left[2 \sqrt{2} \times(-\sqrt{2})^{2}+5 \times(-\sqrt{2})+\sqrt{2}\right]$

$=(4 \sqrt{2}-5 \sqrt{2}+\sqrt{2})$

$=0$

Hence, $(x+\sqrt{2})$ is a factor of the given polynomial.


text:
homechevron_rightStudychevron_rightMath

# Proportion

This online calculator finds unknown member of proportion. Created by user's request

### This page exists due to the efforts of the following people:

#### Timur

• Article : Proportion - Author, Translator ru - en
• Calculator : Proportion - Author, Translator ru - en

One of our users asked how much it will be for 25 liters if 2 liters cost .50.

This is simple proportion, and this is simple calculator which finds unknown member of proportion. For those who lazy to do one multiplication and one division.

The formula is
$\frac{A}{B}=\frac{C}{X}$

For given A, B, С, calculator finds X as
$X=\frac{B*C}{A}$

#### Proportion

Digits after the decimal point: 2
X

#### Similar calculators

local_offer Math proportion
PLANETCALC, Proportion


text:
# Commutative diagrams and quantifiers

I encountered in Freyd and Scedrov's book "Categories, Allegories" a diagram of this sort:

I wonder how to write this kind of diagram using tikz-cd, TikZ or any other combination of LaTeX packages.

EDIT:

Since I posted this question I came up with a more elementary solution (by means of a little research and a lot of monster bashing), because I needed a more straightforward way of producing this kind of diagram, but most of all, because I'm far from an expert at TikZ. I also forgot to mention that as the diagram is used for a definition, it can't be included as a figure, it has to be exactly where it's needed.

My solution is as follows:

\documentclass{tufte-book}

\usepackage{tikz-cd,scalerel,multirow}

%% Puncture mark for removing equations in diagrams

\def\punct{%
\tikz{
\draw (0.08,0) -- (0.18,0);
\draw (0,0.08) -- (0,0.18);
\draw (-0.08,0) -- (-0.18,0);
\draw (0,-0.08) -- (0,-0.18);
}
}

%quantifiers

\def\diagforall{%
\tikz{\draw (0,-1) -- (0,1);\node at (0,1.2) {$\forall$};}
}

\def\diagexists{%
\tikz{\draw (0,-1) -- (0,1);\node at (0,1.2) {$\exists$};}
}

\def\diagexun{%
\tikz{\draw (0,-1) -- (0,1);\node at (0,1.2) {$\exists !$};}
}

%% Larger \cdot

\def\Lcdot{%
\raisebox{-0.7ex}{\hstretch{2}{\vstretch{2}{\cdot}}}
}

\begin{document}

\begin{displaymath}
\begin{array}{ccccc}

%% Quantifiers

& \multirow{3}{*}{\diagforall} & & \multirow{3}{*}{\diagexun} & \\

%% Diagram in first column

\begin{tikzcd}

\Lcdot \ar{r} & \Lcdot \arrow[yshift=-0.9ex]{r}{\ast} \ar[yshift=0.9ex]{r} & \Lcdot

\end{tikzcd} & &

%% Diagram in third column

\begin{tikzcd}

& \Lcdot \ar{d}  & \\
\Lcdot \ar{r} & \Lcdot \arrow[yshift=-0.9ex]{r}{\ast} \ar[yshift=0.9ex]{r} & \Lcdot

\end{tikzcd}

& &

%% Diagram in last column

\begin{tikzcd}

& \Lcdot \ar{d} \ar{dl} & \\
\Lcdot \ar{r} & \Lcdot \arrow[yshift=-0.9ex]{r}{\ast} \ar[yshift=0.9ex]{r} & \Lcdot

\end{tikzcd} \\

%% This is padding

& & & & \\

\end{array}
\end{displaymath}

\end{document}

which produces the following output:

By tweaking it a bit, I was able to produce

which is what I was going for initially. Now, I had to change that puncture mark between the two horizontal arrows given that when I tried my little TikZ command it came out like this:

Is there any way to make the little puncture mark work?

• Yes, add - as an option to the four lines. – Qrrbrbirlbel May 9 '15 at 21:37

Another solution, using MetaPost. I have included it in a LuaLaTeX program (MetaPost is sort of embedded in LuaTeX) for typesetting convenience. If you do not use LuaLaTeX, you can include the PDF figure resulting from this program in your own file, via the graphicx package. Or you can use the gmp package to include this code in a LaTeX/PDFLaTeX/XeLaTeX file.

Edit Following a remark of Barbara Beeton on Qrrbrbirlbel's answer, I have made the vertical lines and their markers bolder. To make the latter bold, I switched to the XITS fonts: contrary to the Latin Modern default fonts, the quantifiers symbols have a bold version in XITS.

\documentclass[border=2mm]{standalone}
\usepackage{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
v := 1.75cm; len := 3bp; input boxes
def bullet = btex $\bullet$ etex enddef;
def cross = image(for angl = 0 step 90 until 270:
draw ((.5len, 0) -- (len, 0)) rotated angl; endfor)
enddef;
beginfig(1);
for i = 1 upto 9:
boxit.a[i](bullet); a[i].c = ((i-1)*v, 0); drawunboxed(a[i]);
endfor
for i = 1 upto 3:
boxit.cr[i](cross); cr[i].c = ((1.5+ 3(i-1))*v, 0); drawunboxed(cr[i]);
endfor
for i = 1 step 3 until 9:
drawarrow a[i].e -- a[i+1].w;
drawarrow a[i+1].ne -- a[i+2].nw; drawarrow a[i+1].se -- a[i+2].sw;
endfor
for i = 1,2:
boxit.u[i](bullet); u.[i]c = a[5+3(i-1)].c + (0, v);
drawunboxed(u[i]); drawarrow u[i].s -- a[5+3(i-1)].n;
endfor
drawarrow u2.sw -- a7.ne;
pickup pencircle;
draw (2.5v, 1.25v)--(2.5v, -.5v);
label.top(btex $\mathbf\forall$ etex, (2.5v, 1.25v));
draw (5.5v, 1.25v)--(5.5v, -.5v);
label.top(btex $\mathbf{\exists!}$ etex, (5.5v, 1.25v));
endfig;
\end{mplibcode}
\end{document}

Here is a possible solution using xypic. Since I don't know that cross symbol for the double arrows, I used +. Afterwards, you can replace it.

\documentclass[11pt,a4paper]{report}
\usepackage{amsmath}
\usepackage[all,cmtip]{xy}
\usepackage{lipsum}

\begin{document}
\lipsum*[2]
$$\begin{gathered} \xymatrix@C=.5cm@R=.5cm{% &&& \forall \ar@{-}[ddd] & &&& \exists! \ar@{-}[ddd] \\ &&& & & \bullet\ar[d] & &&& \bullet\ar[d] \ar[dl] \\ \bullet \ar[r] & \bullet \ar@<1ex>[r] \ar@<-1ex>[r] \ar@{}[r]|{+} & \bullet & & \bullet\ar[r] & \bullet \ar@<1ex>[r] \ar@<-1ex>[r] \ar@{}[r]|{+} & \bullet & & \bullet\ar[r] & \bullet \ar@<1ex>[r] \ar@<-1ex>[r] \ar@{}[r]|{+} & \bullet \\ &&& & &&& } \end{gathered}$$
\lipsum*[2]
\end{document}

• It's better to use gathered for vertically centering an \xymatrix (it's more efficient). – egreg May 9 '15 at 9:16
• @egreg, thanks. I edited. Do you have some counter example? – Sigur May 9 '15 at 9:19
• The effect is the same, with gathered no alignment is used. – egreg May 9 '15 at 9:33
• in the original, the distance between the dots in the main line is uniform, and the long verticals sit halfway in between. in this rendition, the long verticals are positioned where a dot would be. not sure how easy that is to adjust with xypic'. – barbara beeton May 9 '15 at 13:54
• @barbarabeeton, I don't think that the distance between the dots separated by the vertical rules are the same. But if I'm not wrong is possible to make a vertical line in the middle of the column in XYpic. I'll check. – Sigur May 9 '15 at 14:29

## Code

\documentclass{standalone}
\usepackage{tikz-cd}
\usetikzlibrary{decorations.markings, arrows.meta, calc}
\tikzset{my Barb/.tip={Straight Barb[round,angle=45:1pt 3]}}
\tikzset{
plus mark/.style={-,
decorate, decoration={markings, mark=at position .5 with {
\draw[-,dash pattern=on #1 off 2*#1 on #1] (left:2*#1) -- (right:2*#1)
(up:2*#1) -- (down:2*#1);}}},
plus mark/.default=1pt}
\tikzcdset{
dots in cells/.style={
cells={nodes={shape=circle, fill, draw, inner sep=+0pt, minimum size=+3pt}}}}
\newcommand*\plar[1][r]{%
\arrow[#1, plus mark]
\arrow[#1, shift left=1.5]
\arrow[#1, shift right=1.5]}
\begin{document}
\begin{tikzcd}[dots in cells, cells={nodes={outer sep=+2pt}},
every arrow/.append style=-my Barb,
every matrix/.append style={name=M},
/tikz/execute at end picture={
\foreach \col/\t[evaluate={\Col=int(\col+1)}] in {3/\forall,6/\exists!}
\draw ([yshift=.2cm]perpendicular cs: horizontal line through={(M.north)},
vertical line through={($(M-2-\col)!.5!(M-2-\Col)$)})
node[above](@){$\t$}
-- ([yshift=-.3cm]@|-M.south);}]
&          &    &[-.5em]  & {} \dar  &    &[-.5em]    & {} \dar\dlar &   \\
{} \rar & {} \plar & {} & {} \rar & {} \plar & {} & {} \rar & {} \plar     & {}
\end{tikzcd}
\end{document}
`

## Output

• It is also possible to do the vertical lines in the same way as in Sigur’s answer (i.e. in seperate rows and columns of the matrix). – Qrrbrbirlbel May 9 '15 at 11:34
• i think the spacing to the left/right of the long verticals is closer here to the original; the distance between the horizontal dots in the main line is uniform there; there is no dot coincident with the long verticals. on the other hand, the long verticals and their "markers" appear bold(er) in the original. – barbara beeton May 9 '15 at 13:51


text:
• # question_answer Define the Q value of a nuclear process. When can a nuclear process not proceed spontaneously? If both the number of protons and the number of neutrons are conserved in a nuclear reaction, in what way is mass converted into energy (or vice-versa) in a nuclear relation? Or Using Bohr's postulates, derive the expression for the frequency of radiation emitted when electron is hydrogen atom undergoes transition from higher energy state (quantum number ${{n}_{i}}$) to the lower state $({{n}_{f}}).$ When electron in hydrogen atom jumps from energy state ${{n}_{i}}=4$ to ${{n}_{f}}=3,$ identify the spectral series to which the emission lines belong.

The Q-value of a nuclear process refers to the energy release in the nuclear process which can be determined using Einstein's mass energy relation $E=m{{c}^{2}}.$ The Q-value is equal to the difference of mass of products and reactants multiplied by square of velocity of light. The nuclear process does not proceed spontaneously when Q-value of a process is negative or sum of masses of product is greater than sum of masses of reactant. Since, mass defect occurs in nucleus which converts into energy as per Einstein's mass energy relation $E=m{{c}^{2}}$ and produces binding energy. This energy binds nucleons together due to nuclear forces inspite of repulsive Coulombian forces. Or According to Bohr, energy is radiated in the form of a photon when the electron of an excited hydrogen atom returns from higher energy state to the lower energy state. So, energy is radiated in the form of a photo when electron jumps from higher energy orbit $(n={{n}_{i}})$ to lower energy orbit  $(n={{n}_{f}}),$ ${{n}_{i}}>{{n}_{f}}$ The energy of the emitted photon is given by             $hv={{E}_{{{n}_{i}}}}-{{E}_{{{n}_{i}}}}$ Energy of nth orbit, ${{E}_{n}}=\frac{-m{{e}^{4}}}{8{{h}^{2}}\varepsilon _{0}^{2}{{n}^{2}}}$ $\therefore$      $hv=-\frac{m{{e}^{4}}}{8\varepsilon _{0}^{2}n_{i}^{2}{{h}^{2}}}-\left( -\frac{m{{e}^{4}}}{8{{h}^{2}}\varepsilon _{0}^{2}n_{f}^{2}} \right)$ When electron jumps from n = 4 to n = 3 state, the spectral series is called Paschen series.


text:
Use this URL to cite or link to this record in EThOS: https://ethos.bl.uk/OrderDetails.do?uin=uk.bl.ethos.724202
Title: Study of Higgs boson production through its decay to two photons using data collected at a centre-of-mass energy of 13 TeV with the CMS detector
Author: Corpe, Louie
ISNI:       0000 0004 6423 7285
Awarding Body: Imperial College London
Current Institution: Imperial College London
Date of Award: 2017
Availability of Full Text:
 Access from EThOS: Access from Institution:
Abstract:
A study of $H \rightarrow \gamma \gamma$ with 12.9 fb$^{-1}$ of data from p-p collisions at $\sqrt{s}=13$ TeV is presented. The data were collected at the start of LHC Run 2 by the CMS experiment between April and July 2016. The result is a new standalone observation of the Higgs boson in the diphoton decay channel. The significance of the excess is observed to be $5.7\sigma$ ($6.3\sigma$ expected) at the combined Run 1 best-fit Higgs boson mass of $m_{H}=125.09$ GeV. The maximum significance of $6.1\sigma$ ($6.3\sigma$ expected) is observed at $m_{H}=125.09$ GeV. The measured Higgs boson signal strength is $\hat{\mu} = 0.89^{+0.20}_{-0.17} = 0.89 \pm 0.15 {~(stat.)~} ^{+0.09}_{-0.06} {~(syst.)~} ^{+0.07}_{-0.05} {~(theo.)}$. The signal strength is measured separately for: fermionic and bosonic production modes, giving $\hat{\mu}_{{VBF},{VH}} = 1.00^{+0.10}_{-0.10}$ and $\hat{\mu}_{{ggH},{ttH}} = 1.00^{+0.10}_{-0.10}$; and for the ggH, VBF and ttH production modes, giving $\hat{\mu}_{{ggH}} = 0.73^{+0.24}_{-0.22}$, $\hat{\mu}_{{VBF}} = 1.45^{+0.8}_{-0.7}$, and $\hat{\mu}_{{ttH}} = 1.75^{+1.4}_{-1.1}$. Measurements of the Higgs boson coupling modifiers yield $\hat{\kappa}_{{f}} = 0.66^{+0.43}_{-0.22}$, $\hat{\kappa}_{{V}} = 0.90^{+0.10}_{-0.10}$ for the fermionic and bosonic coupling modifiers and $\hat{\kappa}_{g} = 0.66^{+0.27}_{-0.19}$, $\hat{\kappa}_{\gamma} = 1.23^{+0.24}_{-0.26}$ for the gluon and photon effective coupling modifiers. All measurements are found to be consistent with the theoretical expectation for a SM-like Higgs boson.
Supervisor: Dauncey, Paul ; Seez, Christopher Sponsor: Science and Technology Facilities Council
Qualification Name: Thesis (Ph.D.) Qualification Level: Doctoral
EThOS ID: uk.bl.ethos.724202  DOI: Not available
Share:


text:
APM346-2018S > APM346--Lectures

excersice 1, chap 7.3

(1/1)

Jingxuan Zhang:
http://www.math.toronto.edu/courses/apm346h1/20181/PDE-textbook/Chapter7/S7.3.html#sect-7.3.1

Exercise 1 appears quite strange. if $f=0$ on $\Omega=\{\|x\|\geq R\}$ and $u(y)=\int_\Omega G(x,y)f(x)\,dx$, then shouldn't this integral vanish instead of giving that curious form?

Victor Ivrii:
The formula you refer to is good only for $\Omega=\mathbb{R}^n$. In all other cases it contains integrals over boundary, which are not $0$


text:
# Did the ancient Greeks have zero in their number system?

I was taught that the Arabs introduced zero in their Arabic numerals and it was depicted as a decimal point. They got their number system from India in turn in Sanskrit where the zero digit was also used.

Roman numerals, however, didn't have a zero digit. This article says Europe did not get it until 1200AD. If the ancient Greeks did not have zero, they would have had great difficulty with some of their calculations, such as the circumference of the Earth.

So, how did the Greeks perform these calculations without it, or did they have it back then?

• Why do you think that not having a zero would have caused difficulties to Eratosthenes calculating the circumference of the earth? – ShreevatsaR May 26 '17 at 0:26
• @ShreevatsaR well, try it. You would need pi to very precise decimal places and how can you have non-integers without zeros or decimal points? – Ed Kideys May 26 '17 at 0:35
• @ShreevatsaR my bad, didn't need pi, he used geometry. Eratosthenes used a bit more geometry to reason that the shadow's angle would be the same as the angle between Alexandria and Syene as measured from the Earth's center. Conveniently, 7.2 degrees is 1/50th of a full circle ( 50 x 7.2° = 360° ). Eratosthenes understood that if he could determine the distance between Alexandria and Syene, he would merely have to multiply that distance by 50 to find the circumference of Earth! – Ed Kideys May 26 '17 at 0:51
• Modern notation can be very tempting. You don't need decimal points even to know π precisely. First, you realize that the circumference is proportional to (scales linearly with) the diameter. Then, you just have to determine the constant of proportionality, for which any notational system will do. For example, Āryabhaṭa (despite being in India) represented the value of π by saying that the circumference of a circle with diameter 20000 is close to 62832. (In Roman numerals, to lower precision: “a circle of diameter MM has circumference close to MMMMMMCCLXXXIII” — less convenient, but workable.) – ShreevatsaR May 26 '17 at 0:52
• Just to add this - Although the Greeks did not have zero, they used the obol to represent nothing, which was a symbol (not actually a number) used for purely notational purposes. The Romans used the Latin word nulla, which means "nothing". – user10930 Jan 10 '20 at 10:42

During the classical and early Hellenistic period (until 200 BC) Greeks did not use any positional system, they had their own which was decimal but not positional. The units from 1 to 9 are assigned to the first nine letters of the archaic Greek alphabet from $\alpha$ to $\theta$. Each multiple of ten from 10 to 90 was assigned its own separate letter from the next nine letters from $\iota$ to ϙ. And so on, see Greek numerals. This worked fine for practical and even some scientific calculations. In the 3rd century BC Eratosthenes and Aristarchus, Archimedes's contemporaries, did calculations for estimating the circumference of the Earth and distances to the Moon and the Sun without the benefit of not only zero but even of a positional system.

However, there weren't enough letters to express very large numbers (which is where placeholder zeros may come handy), no more than the myriad ($10^4$) could be expressed. When the need arose Archimedes in Sand Reckoner invented his own number system capable of expressing them. He introduced "orders" based on the myriad, which was the "unit of the first order". The myriad myriads ($10^8$) was unit of the second order, and so on. Archimedes did not have zero either, but one can manage without it even for something like a positional system. Archimedes's was akin to the system with base $10^8$, but it did not take.

After 200 BC Hellenistic astronomers, such as the father of astronomy Hipparchus, started using the sexagesimal system (with base $60$), imported from Babylon along with long term precise astronomical data Greeks lacked. This gave a great boost to the development of mathematical astronomy, and the sexagesimal system was sometimes used for doing astronomical calculations, in particular by Ptolemy in Almagest in the second century AD (presumably he was a Greek ethnically, but he lived and worked in Alexandria, Egypt). However, the sexagesimal system made no advances beyond a very narrow circle of practitioners, not even all astronomers used it. Zero was used as a punctuation mark for purely notational purposes, not as a number, and the symbol for it, when not simply blank space, was $\omicron$ for "obol" (a coin of smallest value). For details and further developments see Was the concept of zero ever developed without relation to positional number systems?

It depends on the definition of the "Ancient Greeks". Ptolemy, who lived in 2 century AD, lived on the territory of the Roman empire, but wrote in Greek, and probably worked in Alexandria (modern Egypt) most of the time. He is usually considered Greek. He used zero with sexagesimal Babylonian system (base 60, and digits were Greek letters). Zero was used as a place holder (which is actually its main function) and was denoted by Greek letter $$\omicron$$ (omicron).

The work of Ptolemy, or some related/derived work spread to the East eventually reaching India, as seen from its influence on the later Arab and Indian astronomy. But I do not know whether invention of zero in India was dependent of this or not.

• very interesting. they used base 60 instead of base 10, why? I'm having great difficulty understanding having zero as just a decimal point (assuming that's what place holder means) and not actually including it as one of the digits. – Ed Kideys May 25 '17 at 19:48
• Place holder is not a decimal point. Place holder is what we need to distinguish between 2, 20 and 200. Base 60 came from Babylon where astronomy originated. 60 is convenient because it has many factors. We still use base 60 in measuring angles. – Alexandre Eremenko May 26 '17 at 6:24
• Another good base is 12 which also comes from Babylon (Zodiac signs) and also used nowadays for time measurement. The only advantage of 10 is that we have 10 fingers, but 12 and 60 are much more convenient for mental calculation. – Alexandre Eremenko May 26 '17 at 6:33


text:
# breqn with superscript in a newcommand

I am getting unfortunate behavior with the the most recent version of breqn.sty with regards to how it handles a newcommand that begins with a superscript. Considering the following code

\documentclass{article}
\usepackage{breqn}
\newcommand{\hc}{^\dagger}
\begin{document}
\begin{dmath}
A\hc
\end{dmath}
\end{document}

This code will not stop compiling, and hangs on this error:

! Missing { inserted.
\penalty
l.6   A\hc

! Missing } inserted.
<inserted text>
}
l.7 \end{dmath}

(Note that older iterations of breqn.sty did not give me this issue.)

However, if I just replace \hc with ^\dagger, everything works. Also, if I replace dmath with any of the standard math environments, it works (I've been using this particular newcommand for years).

Is it bad practice to have a superscript begin a newcommand? Is there a way to modify my \hc to make the above code just work?

-

The way breqn works is rather complex, and so I'm not surprised that it fails in the case you give. I'd suggest sticking rigidly to the formally-allowed syntax for superscripts:

\documentclass{article}
\usepackage{breqn}
\newcommand{\hc}{^{\dagger}}
\begin{document}
\begin{dmath}
A\hc
\end{dmath}
\end{document}

As Bruno observes, this is to do with category codes. The following also works

\documentclass{article}
\usepackage{breqn}
\catcode\^=12 %
\newcommand{\hc}{^\dagger}
\begin{document}
\begin{dmath}
A\hc
\end{dmath}
\end{document}

as breqn makes ^ an 'other' character.

which works fine.

-
I strongly suspect that it has to do with the catcode of ^ being set to active by breqn \AtBeginDocument. Can't test at the moment, though. – Bruno Le Floch Oct 11 '11 at 16:54

To complement Joseph's answer and Bruno's comment, here's some analysis of the situation.

breqn changes all mathcodes to "8000 so that characters in math mode behave like macros; and changes also the meaning of commands such as \dagger.

The meanings of ^, A and \dagger become

> ^=macro:
#1->\mathsup {\protect \subsupstyle #1}.

> A=\protected\long macro:
->\@sym A\math_sym_Var:Nn \mg@Latin {41}.

> \dagger=\protected\long macro:
->\@sym \dagger \math_sym_Bin:Nn \mg@bin {79}.

where \mathsup is an alias for the usual category 7 ^.

With \newcommand{\hc}{^\dagger} given in the preamble, ^ still has category 7 and such remains when \hc is expanded. But an important property of category 7 ^ in math mode is that it keeps expanding the next token until an unexpandable one is found (and it has better be a mathchardef token or a chardef token or a left brace). After a good deal of expansions, in the present case ^ is presented \penalty, which is not a good token after it.

The safest definition would be

\begingroup\lccode?=^
\lowercase{\endgroup\newcommand{\hc}{?{\dagger}}}

or

{\catcode^=12 \gdef\hc{^{\dagger}}}

as changing at that point the catcode of ^ could be dangerous. Maybe issuing

\catcode^=12
\newcommand{\hc}{^{\dagger}}

just before \begin{document} may not have unexpected consequences. In any case, defining \hc with a catcode 7 ^ should be avoided, as it can interfere with the workings of breqn: there's quite a difference between

\mathsup{\protect\subsupstyle \dagger}

and

\mathsup{\dagger}

The latter is what LaTeX would see with the catcode 7 ^` definition.

-


text:
Filter Content By
Version

addConstr ( lhs, sense, rhs, name="" )

Add a linear constraint to a model.

Note that this method also accepts a TempConstr as its first argument (with the name as its second argument). This allows you to use operator overloading to create constraints. See TempConstr for more information.

Arguments:

lhs: Left-hand side for new linear constraint. Can be a constant, a Var, or a LinExpr.

sense: Sense for new linear constraint (GRB.LESS_EQUAL, GRB.EQUAL, or GRB.GREATER_EQUAL).

rhs: Right-hand side for new linear constraint. Can be a constant, a Var, or a LinExpr.

name: Name for new constraint.

Return value:

New constraint object.

Example usage:

  model.addConstr(x + 2*y, GRB.EQUAL, 3*z, "c0")
model.addConstr(x + y <= 2.0, "c1")


text:
Showing:
Handle Score
@Ibrahim Nash 5725
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Two Repeated Elements
Easy Accuracy: 40.12% Submissions: 8615 Points: 2

You are given an array of N+2 integer elements. All elements of the array are in range 1 to N. Also, all elements occur once except two numbers which occur twice. Find the two repeating numbers.

Example 1:

Input:
N = 4
array[] = {1,2,1,3,4,3}
Output: 1 3
Explanation: In the given array,
1 and 3 are repeated two times.

Example 2:

Input:
N = 2
array[] = {1,2,2,1}
Output: 2 1
Explanation: In the given array,
1 and 2 are repeated two times
and second occurence of 2 comes
before 1. So the output is 2 1.

The task is to complete the function repeatedElements() which takes array arr[] and an integer N as inputs (the size of the array is N + 2 and elements are in range[1, N]) and finds the two repeated element in the array and return them in a pair.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).

Constraints:
2 ≤ N ≤ 105
1 ≤ array[i] ≤ N


text:
# Magnetic Dipole Moment Formula

I've been looking at the formulae for magnetic dipole moments, and keep coming across something like this:

$$\mathbf{m}=\int \mathbf{r}\times\mathbf{J}dV$$

Which is something I would be perfectly happy with, if anything actually explained what $\mathbf{r}$ was. I've been told that this is the position vector of the moment, but not with respect to what - and I would assume that the origin would make a difference to the dipole moment. It would also beg the question of where the dipole moment actually is. Should the formula, to be more specific, actually say:

$$\mathbf{m}(\mathbf{r})=\int \mathbf{r}\times\left(\mathbf{J}\left(\mathbf{r'}\right)\right)d^3\mathbf{r'}$$

Basically I'm just not certain on what the $\mathbf{r}$ actually refers to. Any help would be appreciated!

A more explicit formula is $${\bf m} = \int {\bf r}\times {\bf j}({\bf r})\, d^3{\bf r}$$ so ${\bf r}$ is the quantity being integrated over. Consequently ${\bf m}$ is independent of ${\bf r}$. You might be happier if, instead, we wrote
$${\bf m} = \int ({\bf r}-{\bf r}_0)\times {\bf j}({\bf r})\, d^3{\bf r}$$ so that ${\bf r}_0$ is the point about which the moment is being taken. However, since ${\nabla}\cdot {\bf j}=0$ for all cases of interest, we have (by using Stokes' theorem) $$\int {\bf j}({\bf r})\,d^3 {\bf r}= 0$$ so the moment is independent of the choice of ${\bf r}_0$.
Added comment: Emilio says that the last step is not obvious, so here it is: As ${\bf j}$ is zero outside some volume $\Omega$ with boundary $\partial\Omega$ $$0= \int_{\partial\Omega} j^\mu x^\nu dS^\mu= \int_\Omega \partial_\mu (x^\nu j^\mu)= \int x^\nu \partial_\mu j^\mu d^3x + \int (\partial_\mu x^\nu) j^\mu d^3 x.$$
$$0= \int (\partial_\mu x^\nu) j^\mu d^3 x= \delta^\nu_\mu \int j^\mu d^3x = \int j^\nu d^3 x$$


text:
# Linear Algebra for Data Science

Linear Algebra for Data Science and machine learning is very essential as the concepts of linear algebra are used to understand the working of algorithms. In this post, we are going to discuss the basic concepts of linear algebra.

## Why Linear Algebra?

Enormous datasets mostly contain hundreds to a large number of individual data objects.

It is simpler to work with this information and operate on it when it is characterized in the form of matrices and vectors.

Linear Algebra is a branch of mathematics that manages vectors and tasks on vectors. Linear Algebra is significantly essential for Artificial Intelligence and information handling calculations.

Data Scientists must have basic knowledge of mathematics to solve complex data problems in an efficient way to boost the company revenue.

Linear Algebra is mostly concerned with operations on vectors and matrices, so let’s start learning about matrices and vectors.

## What is the Matrix?

Usually, it corresponds to a collection of information stored in an arranged manner. Mathematically, it states to a set of numbers, variables or functions arranged in rows and columns.

Matrices are generally represented by the capital English alphabets like A, B, C……, etc. For example,

$$\displaystyle A=\left[ {\begin{array}{*{20}{c}} 3 & 4 & 5 \\ 6 & 7 & 8 \\ 9 & 2 & 3 \end{array}} \right]$$

The order of a matrix is defined by the number of rows and columns in a matrix.

Order of a matrix = number of rows × number of columns

$$\displaystyle A=\left[ {\begin{array}{*{20}{c}} 1 & 2 & 3 \\ 2 & 5 & 8 \\ 8 & 2 & 3 \end{array}} \right]$$

In above example, number of rows is 3 and number of columns is also 3, therefore,

Order of matrix A is 3 × 3.

There are following types of matrices:

• Row Matrix
• Column Matrix
• Unit or Identity Matrix
• Null or Zero matrix
• Square Matrix
• Rectangular Matrix
• Diagonal Matrix
• Scalar Matrix
• Negative of a Matrix
• Transpose of a Matrix
• Symmetric Matrix
• Skew-Symmetric Matrix.

The basic operations on matrices are:

• Subtraction of Matrices
• Product of Matrices

## What is a Vector?

Vectors can be considered as an array of numbers having two independent properties that is magnitude and direction where the order of the numbers also matters.

A vector is the simplest linear algebraic object. Vectors are usually represented by a lowercase bold letter like x, y. For example,

$$\displaystyle x=\left[ {\begin{array}{*{20}{c}} {{{x}_{1}}} \\ {{{x}_{2}}} \\ . \\ . \\ . \\ . \\ . \\ . \\ . \\ {{{x}_{n}}} \end{array}} \right]$$

Usually, there are two types of vectors i.e. row vectors and column vectors, examples of which are given below:-

### Row Vector

$$\displaystyle \left[ {\begin{array}{*{20}{c}} 1 & 2 & 3 \end{array}} \right]$$

The length of this vector is 3.

### Column Vector

$$\displaystyle \left[ {\begin{array}{*{20}{c}} 1 \\ 2 \\ 3 \\ 4 \end{array}} \right]$$

The length of this vector is 4.

The addition of two vectors can be performed by adding the corresponding elements of each vector.

The dot product or scalar product of two vectors is the addition of the product of the individual components of the two vectors.

Furthermore, the two vectors ‘a’ and ‘b’ are called orthogonal to each other if their dot product is zero. However, if both the orthogonal vectors have unit norm then they are known as orthonormal vectors.

A set of vectors (v1, v2, .., vn) is known as linearly independent if no vector of the set can be denoted as a linear combination of other vectors.

Simply, you can say that a matrix is a collection of vectors. For example,

$$\displaystyle \left[ {\begin{array}{*{20}{c}} 1 & 4 & 1 \\ 2 & 5 & 3 \\ 3 & 6 & 2 \end{array}} \right]$$

In above example, there are three vectors. First vector contains 1, 2, 3, second vector contains 4, 5, 6 and third vector contain 1, 3, 2.

Therefore, a matrix has two dimensions M by n vectors, whereas, the vector has a single dimension ‘m’ by 1 while scalar has no dimension as shown below: –

$$\displaystyle Matrix\,\,{{A}_{{m\times n}}}=\left[ {\begin{array}{*{20}{c}} {{{a}_{{11}}}} & {{{a}_{{12}}}} & {{{a}_{{13}}}} & {…..} & {{{a}_{{1n}}}} \\ {{{a}_{{21}}}} & {{{a}_{{22}}}} & {{{a}_{{23}}}} & {…..} & {{{a}_{{2n}}}} \\ {{{a}_{{31}}}} & {{{a}_{{32}}}} & {{{a}_{{33}}}} & {…..} & {{{a}_{{3n}}}} \\ . & . & . & . & . \\ . & . & . & . & . \\ . & . & . & . & . \\ . & . & . & . & . \\ . & . & . & . & . \\ . & . & . & . & . \\ {{{a}_{{m1}}}} & {{{a}_{{m2}}}} & {{{a}_{{m3}}}} & {…..} & {{{a}_{{mn}}}} \end{array}} \right]$$

$$\displaystyle Vector\,\,\,\,\,x=\left[ {\begin{array}{*{20}{c}} {{{x}_{1}}} \\ {{{x}_{2}}} \\ . \\ . \\ . \\ . \\ . \\ . \\ . \\ {{{x}_{m}}} \end{array}} \right]$$

$$\displaystyle Scalar\,\,=\,\,\,\left[ x \right]$$ A scalar has no dimension and direction.

Now, let’s explore the linear algebra and geometry.

A two-dimensional space can be defined by two lines and two lines mean two vectors.

As we have already learned that a matrix is a collection of vectors in linear algebra. So, any two-dimensional space can easily be represented by a matrix.

The following two matrices can be graphically represented in two dimensions as

$$\displaystyle \,\left[ {\begin{array}{*{20}{c}} 2 \\ 4 \end{array}} \right]$$

$$\displaystyle \left[ {\begin{array}{*{20}{c}} {-2} \\ {-4} \end{array}} \right]$$

You can see that, the direction is always from the origin of the graph to the end point. The vector -2 and – 4 is exactly opposite of the first one. Therefore, if we take two vector.

$$\displaystyle \left[ {\begin{array}{*{20}{c}} 1 \\ 0 \end{array}} \right]$$ and

$$\displaystyle \,\left[ {\begin{array}{*{20}{c}} 0 \\ 1 \end{array}} \right]$$

then by taking these two vectors together we can generate a matrix i.e. $$\displaystyle \,\left[ {\begin{array}{*{20}{c}} 1 & 0 \\ 0 & 1 \end{array}} \right]$$ which is made up of small portions of two axes x and y as shown in figure.

## Linear Algebra Applications in Data Science

• Vectorized Code (also known as Array Programming)
• Image Recognition
• Deep Learning
• CNNs (Convolutional Neural Networks)
• Dimensionality Reduction
• Eigenvalues
• Eigenvector

Next Post: Scalars, Vector and Matrices in Python

Read also: Statistics for Data Science

### 2 thoughts on “Linear Algebra for Data Science”

1. Very nice article and very useful. I appreciate your work, thanks for sharing for all the informative content.


text:
LuminousMonkey

First Post of 2017

Of course, it's so close to the end of the year, you would wonder why I would bother at all. The usual problem, I'm not in the habit of writing, and I really should write more. But, I always say that.

I've started playing PUBG, I'm not really a big FPS player, but, I thought, as an experiment, what I will do, is try to journal my progress. Writing something would be better than writing nothing, so, I guess I would just record my progress at PUBG. Currently I've been playing the game for a week or so, and I die pretty quickly and often.

I am favouring the more intense areas on the drop, since I need to get combat experience, as much of it as I can get. Also, I've been watching a few YouTube tutorials, and Twitch streams. I've also got to do some aim practice sessions on the servers (since it doesn't provide a offline practice mode). I'll try to write something about it every few days, or at least once a week.

Shit Project

So, I've been a bit busy lately, so much so, that I had to defer a semester of Uni. The reason? I've had to manage the installation of a bunch of GPS trackers for a large state government organisation. It's been, in a word, shit.

I inherited the management from someone, who, basically, didn't do much except attempt to make pretty graphs of unrealistic timelines in Microsoft Project. They left, so I was thrown into the project. Now, even though it's not related to a software project, you still have the same sort of things that projects get (funny that).

So, I will write a few blog posts, when I can, to cover just some minor things that I found.

Beep Beep Beep

I use ZFS, and I love it, I think it is the best filesystem out there. It's primary focus is on integrity, which is the most important thing. What is also important, backups. Even with the data integrity that ZFS offers (which far surpasses any hardware RAID), you still have to backup.

Again, with ZFS, this is much easier than with other solutions (like Bacula for example). Since we run Sun servers, we also run Solaris, since when you run Solaris on Sun hardware, the licence is relatively cheap. As a result, I use the Timeslider service to automatically create snapshots (which, when you share a ZFS filesystem out via CIFS shows up in the Windows GUI as "previous versions").

Because of this, I also use the "zfs-send" plugin, basically backing up snapshots to a separate Solaris server. However, there are some gotchas which may catch you out if you had a working config, and then change things around and find the zfs-send service failing.

First, zfs-send will put a hold on snapshots. It does this so they don't get deleted before they're used to send to the remote server. However, if you're in the situation where you need to clear all the snapshots (for example, you've moved, or changed zfs filesystems you want to backup). Then you will find you can't delete these, what you have to do is "zfs release" the snapshots.

Here is a little snippet that will do this (and delete ALL zfs-auto-snap snapshots on the system):

for snap in zfs list -H -o name -t snapshot | grep @zfs-auto-snap;
do zfs release org.opensolaris:time-slider-plugin:zfs-send $snap; zfs destroy$snap;
done

Then, secondly, zfs-send stores the name of the previously sent snapshot as a property on the filesystem. It does this, so it knows it can use an incremental zfs send. However, if you have broken this sequence, or deleted the snapshots, then this will cause it to break.

You can look for it with:

zfs get -r org.opensolaris:time-slider-plugin:zfs-send storage

Where "storage" can be replaced with your particular zpool name. To clear a property, you use "zfs inherit", like so:

zfs inherit org.opensolaris:time-slider-plugin:zfs-send storage/shares

Changing "storage/shares" to the particular ZFS file system you want to clear the property from. You can clear this property recursively by just adding the "-r" option:

zfs inherit -r org.opensolaris:time-slider-plugin:zfs-send storage/shares

Once you've done this, just enable the service (or clear it if it was forced into maintenance) and you should be golden.

I'm not joking

Jonathan Blow of Software Quality, you should watch this if you're interested in writing software. I used to have an Amiga, and to be honest, it was far more responsive than my current beast of a PC.

She Blinded Me With Science

It seems to me, that one of the most important aspects of software development is one that doesn't get a great amount of focus. Debugging. Sure, it's mentioned here and there, but, for example, first year students aren't even taught about the command line Java debugger.

So, I believe this video of Stuart Halloway, "Debugging with the Scientific Method" is required viewing. Of course, it's not just debugging, but any sort of performance or work on a website or application. Take stackoverflow for example, it's a popular site and hosted on their own servers. I have been reading lately on their setup and the monitoring they do, not only for uptime, but for performance.

For example, they use HAProxy to load balance to their web tier servers, obviously not unusual, that's what HAProxy is for. But, they also have these proxies capture and filter performance data from their application via headers in the HTTP response. It's probably something that everyone does, but to be honest, I've never come across any mention of this trick. (There's also their miniprofiler tool, which I'm using a variant of).

Given how little debugging is taught in university (well, my university) I can't judge on how common and detailed this sort of performance measurement is. I suspect that it might not be very common, so could be an interesting area for me to focus on.


text:
# Import latex file in specific note

if I have some predefined commands in latex and would like to import
$\require{mhchem}$
$\newcommand{\bfy}{\mathbf{y}}$
without copy pasting every time but just importing a single file ?

You can try obsidian-latex plugin.


text:
On-premises environments may require a license upgrade to renew, extend an expiration date, enable new features, add a service (Sysdig Secure), or change the number of licensed agents.

## For Kubernetes On-Prem Installations

As described in the Kubernetes installation instructions, the license file is simply entered as one of many configuration user settings in the ConfigMap (config.yaml) (manual install) or values.yaml (installer-based).

The relevant parameter is:

 # Required: Sysdig Cloud license
sysdigcloud.license: ""

To apply the new license, update the yaml file with the new license and then restart all Sysdig API, Worker, and Collector pods.

## For Replicated On-Prem Installations

1. Log in to the Replicated Management Console and choose Console Settings from the gear icon drop-down menu.

Review the current airgapped settings and note the pathname to the license file.

If you followed the Airgapped Installation instructions, your current .rli license file will be in the/var/tmp/sysdigdirectory as shown below.

(The name of your .rli file will vary.)

2. From the Linux shell, cd to the directory shown as the Update Path and replace your prior RLI license file with the new one, saving the prior one to a backup filename.

NOTE: the new license file may have a different name than the prior one, and may have a non-RLI extension if it was sent to you as an email attachment (to avoid being removed by firewalls).

The steps below are an example of renaming the license as necessary for the environment shown above (your filenames will vary).

/var/tmp/sysdig# mv my-replicated-license.rli prior-replicated-license-1.rli
/var/tmp/sysdig# mv newer-license.allow my-replicated-license.rli
3. Continue in the Replicated Management Console to sync the license and restart the Sysdig application, as described in the non-airgapped instructions below.


text:
# Thread: Helppp PLS 2U MATH QUESTION

1. ## Helppp PLS 2U MATH QUESTION

5. Find the equation of the straight line that contains the POI of 3x+2y-12=0 and 5x-y-7=0 and that:
c) is perpendicular to the line y=5

I can do it doing simultaneous equations but thats beta shit and takes to long
How do i do it using k's
3x + 2y - 12 + k(5x - y - 7) = 0
(3+5k)x + (2-k)y + (-12-7k) = 0
WTF DO I DO NOW

2. ## Re: Helppp PLS 2U MATH QUESTION

Originally Posted by pencilspanker
5. Find the equation of the straight line that contains the POI of 3x+2y-12=0 and 5x-y-7=0 and that:
c) is perpendicular to the line y=5

I can do it doing simultaneous equations but thats beta shit and takes to long
How do i do it using k's
3x + 2y - 12 + k(5x - y - 7) = 0
(3+5k)x + (2-k)y + (-12-7k) = 0
WTF DO I DO NOW
The desired line has equation 3x + 2y - 12 + k(5x - y - 7) = 0 for some value of k. All you need to do is find what k is.

Hint: To do this, note that the desired line should be of the form ''x = something'', because it should be perpendicular to y = 5,

3. ## Re: Helppp PLS 2U MATH QUESTION

Yeah i know the line has to be x = something because it has to be a straight line up. But im confused because with a straight line up the gradient is infinity so wtf do i do

4. ## Re: Helppp PLS 2U MATH QUESTION

Originally Posted by pencilspanker
Yeah i know the line has to be x = something because it has to be a straight line up. But im confused because with a straight line up the gradient is infinity so wtf do i do
If the line is $x = c \implies x-c=0$, then there is no $y$ (or more precisely, the co-efficient of $y$ is zero).

How could you make your equation's $y$ co-efficient be zero?

5. ## Re: Helppp PLS 2U MATH QUESTION

Do you do (2-k) = 0??? therefore k = 2?

6. ## Re: Helppp PLS 2U MATH QUESTION

someone plss a nibba got a math exam tmrw

7. ## Re: Helppp PLS 2U MATH QUESTION

Originally Posted by pencilspanker
someone plss a nibba got a math exam tmrw

Here is a quick explanation. The line required only has an x-value since it's perpendicular to y=5. It also has to go through the point of intersection between the two lines mentioned in the question, so the first thing you need to think about is finding that point of intersection I(x,y) BUT since the y-value is irrelevant here (since the equation of our line is x='something'), we only need to find the x value;

Two ways you can go about it ( which are essentially the same); either find a value of k such that y is eliminated which you have done correctly or eliminate y using the elimination method of simultaneous equations, which is basically the same as the first method.

8. ## Re: Helppp PLS 2U MATH QUESTION

Thank u so much ur amazing

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•


text:
# Why it's hard to go fast

Bicyclists and other things that go fast must overcome air resistance, or drag, even to maintain a constant speed. A simple empirical model for the drag force on an object when the air flows smoothly around the object is $\vec{F}_{Drag}=-c\vec{v}$, where $\vec{v}$ is the velocity of the object and $c$ is a constant that depends on the size and shape of the object. Consider a bicyclist putting out some power $P_0$ (in watts) to overcome drag and maintain some constant speed $v_0$. She then increases her speed to $1.2 v_0$, which requires her to put out a power $P_1$ to maintain. What is the ratio $\frac{P_1}{P_0}$?

×


text:
# Math Help - Mathematical Model

1. ## Mathematical Model

With 1000ft of fencing, a person wishes to fence a field into three parts as shown in the diagram. (The diagram is just a rectangle with it sectioned into three portions, y being height, x width)

How would you determine the values of x and y that give the maximum area?

** I tried to write down y in terms of x for a previous question, and I got $a(x)=-x^2+500$ but I really don't know if I even did that correctly.

2. I'm going to assume that it's split into three along its height, if it's not then just switch x and y in my explanation.

We know then that the total perimeter is 4x+2y=1000 or y=500-2x. The area is A=xy=x(500-2x)=500x-2x^2.


text:
# Minimizing a Median

$$\def\xorder#1{x_{\left(#1\right)}} \def\xset{\mathbb{X}} \def\xvec{\mathbf{x}}$$A somewhat odd (to me) question was asked on a forum recently. Assume that you have continuous variables $$x_{1},\dots,x_{N}$$ that are subject to some constraints. For simplicity, I’ll just write $$\xvec=(x_{1},\dots,x_{N})\in\xset$$. I’m going to assume that $$\xset$$ is compact, and so in particular the $$x_{i}$$ are bounded. The questioner wanted to …

More

# Pragmatism and the Cultivation of Digital Democracies

As technology enables us to communicate with one another in unpredictable ways that allow for an unprecedented public exchange of diverse ideas, cultivating the philosophical habits of an engaged fallibilistic pluralism gains in urgency. The emergence of the World Wide calls us to consider how an ethics of philosophy might enable us to cultivate practices …

More

# Comparing MPLUS and MCLUST output

Introduction At present, MPlus is a widely-used tool to carry out Latent Profile Analysis, and there does not seem to be a widely-accepted or used way to carry out Latent Profile Analysis in R. This compares output from MPlus to output from the R package MCLUST, which is accessed through the package tidymixmod which I …

More

# Public data and digital research ethics

The Verge recently posted an article that highlights some of the ethical dilemmas involved in collecting publicly-available data for research purposes. The article begins by describing the work of a researcher working on facial recognition of people before and after hormone replacement therapy: On YouTube, he found a treasure trove. Individuals undergoing HRT often document their progress …

More

# Varieties of Snowflakes

I was pleasantly surprised that New Yorker editor David Remnick and Berkeley law professor Melissa Murray continue to support the First Amendment, even if some of her students do not. Remnick gives Historian Mark Bray (author of Antifa: The Anti-Fascist Handbook) a tough time about the role of violence in political movements. After Charlottesville, the Limits …

More

# How to be an effective acting director, chair or dean — Part II (essay)

Last week, Inside Higher Ed published an essay of mine describing my experience as an interim dean. It covered several practical, task-oriented topics: identifying one’s core mission for the interim period, allaying colleagues’ fears, acquiring reliable information and triaging the issues that land in your inbox. But leading a college that includes a department of theater helped me recognize …

More

# Using notebooks for beginning-of-semester planning

One of the first posts I published to this blog was a lament that I just couldn’t get notebooks to work for me. About a year ago, though, I finally found a routine that got notebooks working for me. I started off working my way through two copies of a Self Journal before borrowing some …

More

# DeepMind and StarCraft II Learning Environment

This Learning Environment will enable researchers to attack the problem of building an AI that plays StarCraft II at a high level. As observed in the video, this infrastructure development required significant investment of resources by DeepMind / Alphabet. Now, researchers in academia and elsewhere have a platform from which to explore an important class …

More

# Using MPlus from R with MPlusAutomation

According to the MPlus website, the R package MPlusAutomation serves three purposes: Creating related groups of models Running batches Extracting and tabulating model parameters and test statistics. Because modeling involves comparing related models, (partially) automating these is compelling. It can make it easier to use model results in subsequent analyses and can cut down on copy and pasting …

More


text:
## Project Euler个人解答(Problem 51~60)

2013年12月28日 发表评论 阅读评论

# Problem 51:Prime digit replacements

By replacing the 1st digit of the 2-digit number *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime.

By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit number is the first example having seven primes among the ten generated numbers, yielding the family: 56003, 56113, 56333, 56443, 56663, 56773, and 56993. Consequently 56003, being the first member of this family, is the smallest prime with this property.

Find the smallest prime which, by replacing part of the number (not necessarily adjacent digits) with the same digit, is part of an eight prime value family.

 1 2 3 4 5 6 7 8 9 10 0 6 6 0 6 6 0 6 6 0 6 1 7 7 10 7 7 10 7 7 10 7 2 7 7 10 7 7 10 7 7 10 7

• 最后一位必须是1,3,7,9其中之一
• 除去最后一位，剩余位数至少有3个0或者三个1或者三个2
• 这个数本身是个质数【顺便保证了这个数不可能被3整除】

[0, 1, 1, 1, 0]，[1, 0, 1, 1, 0]
[1, 1, 0, 1, 0]，[1, 1, 1, 0, 0]

[0, 0, 1, 1, 1, 0]，[0, 1, 0, 1, 1, 0]
[0, 1, 1, 0, 1, 0]，[0, 1, 1, 1, 0, 0]
[1, 0, 0, 1, 1, 0]，[1, 0, 1, 0, 1, 0]
[1, 0, 1, 1, 0, 0]，[1, 1, 0, 0, 1, 0]
[1, 1, 0, 1, 0, 0]，[1, 1, 1, 0, 0, 0]

### Code：Python

#判断是否是质数
def PrimeQ(n):
for i in range(2,int(sqrt(n))+1):
if n%i == 0:
return False;
return True;

#生成n挑k个数的模板，比如bits=5,k=3，返回会类似[1,0,1,0,1]
def NPickK(bits,k):
if k == 0:
yield [0]*bits
elif k == bits:
yield [1]*k
else:
for first in [0,1]:
for sub in NPickK(bits-1,k-first):
yield [first]+sub

#生成实际可用的模板，比如bit=7
#那么会生成NPickK(6,3)和NPickK(6,6)的模板，然后最后一位补零

#判断模板内是不是同一个数
return len(set(num)) == 1

#计算根据模板替换后质数的个数
counter = 0;
strlist = [str(dig) if mask[x]==1 else strlist[x]
counter += PrimeQ(int(''.join(strlist)))
return counter

#测试这个数是否有符合条件
def template_test(n):
strlist = list(str(n))
return True
return False

#main
num = 1000
while True:
#是否是1,3,7,9结尾
if not mod(num,10) in [1,3,7,9]:
pass
#是不是有超过3个的0,1,2
elif not (list(str(num)).count('0')>=3 or \
list(str(num)).count('1')>=3 or \
list(str(num)).count('2')>=3):
pass
elif not PrimeQ(num):
pass
elif not template_test(num):
pass
else:
print num;
break
num += 1

# Problem 52:Permuted multiples

It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.

Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.

125874和它的二倍，251748, 包含着同样的数字，只是顺序不同。

### Code：Python

def sortchar(n):
L = list(str(n))
L.sort()
return L

def QQ(n):
if sortchar(n)==\
sortchar(2*n)==\
sortchar(3*n)==\
sortchar(4*n)==\
sortchar(5*n)==\
sortchar(6*n):
return True
return False

bit = 3
k = 102
while True:
if QQ(k):
print k
break
k += 3
if k*6 > 10**bit:
k = 10**bit+2
bit += 1

# Problem 53:Combinatoric selections

There are exactly ten ways of selecting three from five, 12345:

123, 124, 125, 134, 135, 145, 234, 235, 245, and 345

In combinatorics, we use the notation, $^5C_3=10$.

In general,

$^nC_r=\dfrac{n!}{r!(n-r)!}$,where r ≤ n, n! = n×(n−1)×...×3×2×1, and 0! = 1.

It is not until n = 23, that a value exceeds one-million: $^{23}C_{10}= 1144066$ .

How many, not necessarily distinct, values of $^nC_r$, for 1 ≤ n ≤ 100, are greater than one-million?

123, 124, 125, 134, 135, 145, 234, 235, 245, and 345

$^nC_r=\dfrac{n!}{r!(n-r)!}$,其中 r ≤ n, n! = n×(n−1)×...×3×2×1, 并且0! = 1.
n = 23时产生第一个超过一百万的数:$^{23}C_{10}= 1144066$ .

$\dfrac{^nC_{r+1}}{^nC_r}=\dfrac{n-r}{r+1}$

### Code：Python

counter = 0;
for n in range(23,101):
d = n;
r = 1;
while d < 1000000 and r <= int(n/2):
d = d * (n-r)/(r+1)
r += 1
counter += n-2*r+1
print counter

# Problem 54:Poker hands

In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way:

• High Card: Highest value card.
• One Pair: Two cards of the same value.
• Two Pairs: Two different pairs.
• Three of a Kind: Three cards of the same value.
• Straight: All cards are consecutive values.
• Flush: All cards of the same suit.
• Full House: Three of a kind and a pair.
• Four of a Kind: Four cards of the same value.
• Straight Flush: All cards are consecutive values of same suit.
• Royal Flush: Ten, Jack, Queen, King, Ace, in same suit.

The cards are valued in the order:
2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.

If two players have the same ranked hands then the rank made up of the highest value wins; for example, a pair of eights beats a pair of fives (see example 1 below). But if two ranks tie, for example, both players have a pair of queens, then highest cards in each hand are compared (see example 4 below); if the highest cards tie then the next highest cards are compared, and so on.

Consider the following five hands dealt to two players:

 Hand Player 1 Player 2 Winner 1 5H 5C 6S 7S KD Pair of Fives 2C 3S 8S 8D TD Pair of Eights Player 2 2 5D 8C 9S JS AC Highest card Ace 2C 5C 7D 8S QH Highest card Queen Player 1 3 2D 9C AS AH AC Three Aces 3D 6D 7D TD QD Flush with Diamonds Player 2 4 4D 6S 9H QH QC Pair of Queens Highest card Nine 3D 6D 7H QD QS Pair of Queens Highest card Seven Player 1 5 2H 2D 4C 4D 4S Full House With Three Fours 3C 3D 3S 9S 9D Full House with Three Threes Player 1

The file, poker.txt, contains one-thousand random hands dealt to two players. Each line of the file contains ten cards (separated by a single space): the first five are Player 1's cards and the last five are Player 2's cards. You can assume that all hands are valid (no invalid characters or repeated cards), each player's hand is in no specific order, and in each hand there is a clear winner.
How many hands does Player 1 win?

• High Card: 最高值的牌.
• One Pair: 两张面值一样的牌.
• Two Pairs: 两个值不同的One Pair.
• Three of a Kind: 三张面值一样的牌.
• Straight: 所有的牌面值为连续数值.
• Flush: 所有的牌花色相同.
• Full House: Three of a Kind 加一个One Pair.
• Four of a Kind: 四张牌面值相同.
• Straight Flush: 所有的牌花色相同并且为连续数值.
• Royal Flush: 10，J，Q，K和A，并且为相同花色。

2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace.

 局 玩家 1 玩家 2 胜利者 1 5H 5C 6S 7S KD 一对5 2C 3S 8S 8D TD 一对8 玩家 2 2 5D 8C 9S JS AC 最大面值牌A 2C 5C 7D 8S QH 最大面值牌Q 玩家 1 3 2D 9C AS AH AC 三个A 3D 6D 7D TD QD 方片Flush 玩家 2 4 4D 6S 9H QH QC 一对Q 最大牌9 3D 6D 7H QD QS 一对Q 最大牌7 玩家 1 5 2H 2D 4C 4D 4S 三个4的Full House 3C 3D 3S 9S 9D 三个3的Full House 玩家 1

### Code：Mathematica

PokeInfo = Import["poker.txt", "Table"];

GetWinner[game_] := Block[{p1p, p2p, p1c, p2c, lv1, lv2},
(*替换成数字，并排序*)
p1p = ToExpression[(StringTake[#, 1] & /@ game[[1 ;; 5]]) /.
{"A" ->14, "K" -> 13, "Q" -> 12, "J" -> 11, "T" -> 10}] // Sort;
p2p = ToExpression[(StringTake[#, 1] & /@ game[[6 ;; 10]]) /.
{"A" -> 14, "K" -> 13, "Q" -> 12,"J" -> 11, "T" -> 10}] // Sort;
(*分别获取玩家的牌*)
p1c = StringTake[#, {2}] & /@ game[[1 ;; 5]];
p2c = StringTake[#, {2}] & /@ game[[6 ;; 10]];
(*获得玩家的牌的类型*)
lv1 = GetLevel[p1p, p1c];
lv2 = GetLevel[p2p, p2c];
WHOWIN[lv1, lv2]]

GetLevel[p_, c_] := Block[{},
Which[
(*等级1000，同花顺*)
Length@Union@c == 1 && Differences[p] === {1, 1, 1, 1},{100,Reverse[p]},
(*等级99，四带一*)
Sort[Tally[p][[All, 2]]] === {1,4},
{99, {Select[Tally[p], #[[2]] == 4 &][[1, 1]],
Select[Tally[p], #[[2]] == 1 &][[1, 1]]}},
(*等级98，三带二*)
Sort[Tally[p][[All, 2]]] === {2,3},
{98, {Select[Tally[p], #[[2]] == 3 &][[1, 1]],
Select[Tally[p], #[[2]] == 2 &][[1, 1]]}},
(*等级97，一色*)
Length@Union@c == 1 , {97, Reverse[p]},
(*等级96，一条龙*)
Differences[p] === {1, 1, 1, 1}, {96, Reverse[p]},
(*等级95，三张一样*)
Sort[Tally[p][[All, 2]]] === {1, 1,3},{95, {Select[Tally[p], #[[2]] == 3 &][[1, 1]],
Select[Tally[p], #[[2]] == 1 &][[All, 1]] // Sort // Reverse} //Flatten},
(*等级94，两对*)
Sort[Tally[p][[All, 2]]] === {1, 2, 2},
{94, {Select[Tally[p], (#[[2]] == 2 &)][[All, 1]]//Sort//Reverse,
Select[Tally[p], #[[2]] == 1 &][[1, 1]]} // Flatten},
(*等级93，一对*)
Sort[Tally[p][[All, 2]]] === {1, 1, 1, 2},
{93, {Select[Tally[p], (#[[2]] == 2 &)][[All, 1]],
Select[Tally[p], #[[2]] == 1 &][[All, 1]] // Sort // Reverse} //Flatten},
(*啥都没有，等级为最大那张牌的点*)
True, {Max[p], Reverse[p]}]
]

(*判断胜负*)
WHOWIN[v1_, v2_] := Block[{},
Which[v1[[1]] > v2[[1]], 1,
v1[[1]] < v2[[1]], 2,
v1[[2, 1]] > v2[[2, 1]], 1,
v1[[2, 1]] < v2[[2, 1]], 2,
v1[[2, 2]] > v2[[2, 2]], 1,
v1[[2, 2]] < v2[[2, 2]], 2,
v1[[2, 3]] > v2[[2, 3]], 1,
v1[[2, 3]] < v2[[2, 3]], 2,
v1[[2, 4]] > v2[[2, 4]], 1,
v1[[2, 4]] < v2[[2, 4]], 2,
v1[[2, 5]] > v2[[2, 5]], 1,
v1[[2, 5]] < v2[[2, 5]], 2,
True, 0
]]

(*计算A胜了多少场*)
Select[PokeInfo, GetWinner[#] == 1 &] // Length

# Problem 55:Lychrel numbers

If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.

Not all numbers produce palindromes so quickly. For example,

349 + 943 = 1292,
1292 + 2921 = 4213
4213 + 3124 = 7337

That is, 349 took three iterations to arrive at a palindrome.

Although no one has proved it yet, it is thought that some numbers, like 196, never produce a palindrome. A number that never forms a palindrome through the reverse and add process is called a Lychrel number. Due to the theoretical nature of these numbers, and for the purpose of this problem, we shall assume that a number is Lychrel until proven otherwise. In addition you are given that for every number below ten-thousand, it will either (i) become a palindrome in less than fifty iterations, or, (ii) no one, with all the computing power that exists, has managed so far to map it to a palindrome. In fact, 10677 is the first number to be shown to require over fifty iterations before producing a palindrome: 4668731596684224866951378664 (53 iterations, 28-digits).

Surprisingly, there are palindromic numbers that are themselves Lychrel numbers; the first example is 4994.

How many Lychrel numbers are there below ten-thousand?

NOTE: Wording was modified slightly on 24 April 2007 to emphasise the theoretical nature of Lychrel numbers.

349 + 943 = 1292,
1292 + 2921 = 4213
4213 + 3124 = 7337

10000以下一共有多少个Lychrel数？

### Code：Python

def GetPalindromic(n):
return int(''.join(list(str(n))[::-1]))

def IsPalindromic(n):
return n == GetPalindromic(n)

def IsLychrel(n):
cc = 0
n = n + GetPalindromic(n)
while cc <= 50:
if IsPalindromic(n):
return False
n = n + GetPalindromic(n)
cc += 1
return True

result = filter(IsLychrel,range(10001))
print len(result)

### Code：Mathematica

GetHW[x_] := FromDigits@Reverse@IntegerDigits[x]
IsNotHW[x_] := FromDigits@Reverse@IntegerDigits[x] != x

IsLychrel[t_] := Block[{x = t + GetHW[t], Result = True},
For[i = 1, i < = 50, i += 1,
If[IsNotHW[x], x = x + GetHW[x], Result = False; Break]];
Result]

Select[Range[1, 10000], IsLychrel] // Length

# Problem 56:Powerful digit sum

A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1.

Considering natural numbers of the form, ab, where a, b < 100, what is the maximum digital sum?

Python表示不甘示弱。。

### Code：Mathematica

Max@Table[Total@IntegerDigits@(a^b), {a, 1, 99}, {b, 1, 99}]

### Code：Python

print max([sum(map(int,list(str(a**b))))
for a in range(1,100)
for b in range(1,100)])

# Problem 57:Square root convergents

It is possible to show that the square root of two can be expressed as an infinite continued fraction.

$\sqrt{2}=1+\dfrac{1}{2+\dfrac{1}{2+\dfrac{1}{2+...}}}=1.414213...$

By expanding this for the first four iterations, we get:

1 + $\dfrac{1}{2}$ = 3/2 = 1.5
1 + $\dfrac{1}{2+\dfrac{1}{2}}$ = 7/5 = 1.4
1 + $\dfrac{1}{2+\dfrac{1}{2+\dfrac{1}{2}}}$= 17/12 = 1.41666...
1 + $\dfrac{1}{2+\dfrac{1}{2+\dfrac{1}{2+\dfrac{1}{2}}}}$ = 41/29 = 1.41379...

The next three expansions are 99/70, 239/169, and 577/408, but the eighth expansion, 1393/985, is the first example where the number of digits in the numerator exceeds the number of digits in the denominator.

In the first one-thousand expansions, how many fractions contain a numerator with more digits than denominator?

2的平方根可以被表示为无限延伸的分数：

$\sqrt{2}=1+\dfrac{1}{2+\dfrac{1}{2+\dfrac{1}{2+...}}}=1.414213...$

1 + $\dfrac{1}{2}$ = 3/2 = 1.5
1 + $\dfrac{1}{2+\dfrac{1}{2}}$ = 7/5 = 1.4
1 + $\dfrac{1}{2+\dfrac{1}{2+\dfrac{1}{2}}}$= 17/12 = 1.41666...
1 + $\dfrac{1}{2+\dfrac{1}{2+\dfrac{1}{2+\dfrac{1}{2}}}}$ = 41/29 = 1.41379...

### Code：Python

a = 2
b = 3
counter = 0
for i in range(1,1001):
a,b = b+a,2*a+b
if len(str(b)) > len(str(a)):
counter += 1
print counter

### Code：Mathematica

Select[NestList[{2 #[[2]] + #[[1]], #[[2]] + #[[1]]} &, {3, 2}, 1000],
Length[IntegerDigits[#[[1]]]] > Length[IntegerDigits[#[[2]]]] &] // Length

# Problem 58:Spiral primes

Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length 7 is formed.

37 36 35 34 33 32 31
38 17 16 15 14 13 30

39 18  5   4   3  12 29
40 19  6   1   2  11 28
41 20  7   8   9  10 27
42 21 22 23 24 25 26
43 44 45 46 47 48 49

It is interesting to note that the odd squares lie along the bottom right diagonal, but what is more interesting is that 8 out of the 13 numbers lying along both diagonals are prime; that is, a ratio of 8/13 ≈ 62%.

If one complete new layer is wrapped around the spiral above, a square spiral with side length 9 will be formed. If this process is continued, what is the side length of the square spiral for which the ratio of primes along both diagonals first falls below 10%?

37 36 35 34 33 32 31
38 17 16 15 14 13 30

39 18  5   4   3  12 29
40 19  6   1   2  11 28
41 20  7   8   9  10 27
42 21 22 23 24 25 26
43 44 45 46 47 48 49

### Code：Python

def PrimeQ(n):
if n <= 1:
return False
for i in xrange(2,int(n**0.5+1)):
if n%i == 0:
return False;
return True;

k = 1
dif = 2
prime_counter = 0
while True:
k += dif * 4
dif += 2
prime_counter += PrimeQ(k+dif)
prime_counter += PrimeQ(k+2*dif)
prime_counter += PrimeQ(k+3*dif)
if prime_counter*10<(2*dif+1):
print dif+1
break

# Problem 59:XOR decryption

Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107.

A modern encryption method is to take a text file, convert the bytes to ASCII, then XOR each byte with a given value, taken from a secret key. The advantage with the XOR function is that using the same encryption key on the cipher text, restores the plain text; for example, 65 XOR 42 = 107, then 107 XOR 42 = 65.

For unbreakable encryption, the key is the same length as the plain text message, and the key is made up of random bytes. The user would keep the encrypted message and the encryption key in different locations, and without both "halves", it is impossible to decrypt the message.

Unfortunately, this method is impractical for most users, so the modified method is to use a password as a key. If the password is shorter than the message, which is likely, the key is repeated cyclically throughout the message. The balance for this method is using a sufficiently long password key for security, but short enough to be memorable.

Your task has been made easy, as the encryption key consists of three lower case characters. Using cipher1.txt (right click and 'Save Link/Target As...'), a file containing the encrypted ASCII codes, and the knowledge that the plain text must contain common English words, decrypt the message and find the sum of the ASCII values in the original text.

### Code：Mathematica

(*读取文件，转为数字*)
cipher = ToExpression@StringSplit[ToLowerCase@Import["cipher1.txt"], ","];

(*获得加密原文*)
decodetext[key_, ci_] := Block[{test, result},
(*循环密钥使之与密文等长*)
test = Table[key[[Mod[i - 1, 3] + 1]], {i, 1, Length[ci]}];

(*译码，key是密钥，ci是密文,返回a,e,i,s的词频数*)
decode[key_, ci_] := Total[
Count[decodetext[key, ci], #]&/@(ToCharacterCode/@{"e", "a", "i", "s"}//Flatten)]

(*测试所有加密方案*)
ParallelTable[{{a, b, c}, decode[{a, b, c}, cipher]},
{a, 97, 122}, {b, 97, 122}, {c, 97, 122}];

(*找出加密方案中最佳的那个*)
(Reverse@SortBy[Flatten[%, 2], Last])//First

(*获得原文全部ASCII码之和*)
decodetext[First@%, cipher] // Total

(*统计the*)
decode2[key_, ci_]:=StringCount[FromCharacterCode@decodetext[key, ci], "the"]

(*获取原文*)
decodetext[First@%, cipher]//FromCharacterCode

# Problem 60:Prime pair sets

The primes 3, 7, 109, and 673, are quite remarkable. By taking any two primes and concatenating them in any order the result will always be prime. For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of these four primes, 792, represents the lowest sum for a set of four primes with this property.

Find the lowest sum for a set of five primes for which any two primes concatenate to produce another prime.

### Code：C++

#define T 100000000

int IsPrime[T] = {1};
int* primelist = NULL;

//初始化质数表
void init()
{
for(int i = 0;i < T;i++)
IsPrime[i] = 1;

IsPrime[0] = -1;
IsPrime[1] = -1;
}

//筛选法找质数
void Seive()
{
int counter = T-2;
for(int i = 2;i <= T/2;i++)
{
if(IsPrime[i] != 1)
continue;
int j = 2*i;
while(j < T)
{
if(IsPrime[j] == 1)
counter--;
IsPrime[j] = -1;
j += i;
}
}

primelist =new int[counter];
int cc = 0;
for(int i = 0;i < T;i++)
if(IsPrime[i] == 1)
primelist[cc++] = i;
}

//数字拼接，673+123=673123
int join(int a,int b)
{
int k = int(log10(double(a))+1);
return int(b*pow(10.0,k)+a);
}

//判断两个数连接起来后是不是质数
bool Judge(int i,int j)
{
return IsPrime[join(i,j)] == 1 && IsPrime[join(j,i)] == 1;
}

//判断list里面最后一个数和前面每个数连接起来后都是质数
int JudgeList(int list[],int num)
{
for(int i = 0;i < num-1;i++)
if(!Judge(list[i],list[num-1]))
return 0;
return 1;
}

//递归求解，i是前一个数，idx是现在算到第几个数了
void figure(int i,int list[],int idx)
{
if(idx == 6)
{
for(int d = 0;d < 5;d++)
cout<<list[d]<<"  ";
system("pause");
}
for(int j = i-1;j >= 5-idx;j--)
{
list[idx-1] = primelist[j];
if (!JudgeList(list,idx))
continue;
figure(j,list,idx+1);
}
}

int main(int argc,char* argv[])
{
init();
Seive();

int list[5];
for(int i = 4;i < T;i++)
{
list[0] = primelist[i];
figure(i,list,2);
}
return 0;
}

【完】

1. 2013年12月28日13:26 | #1

看起来好高端，啊哈哈

• 2013年12月28日13:29 | #2

其实一点也不。。只是练练算法题和编程。。。防止头脑老化。。

• 2013年12月28日13:30 | #3

真上进

• 2013年12月28日13:33 | #4

爱好而已。。。将来找工作希望有点用。。

2. 2014年1月5日21:07 | #5

pe57：Count[NestList[{2 #2 + #, #2 + #} & @@ # &, {3, 2}, 1000], {a_, b_} /; IntegerLength@a > IntegerLength@b]

• 2014年1月6日00:04 | #6

研读完您的留言代码，获益良多，学会了很多新函数和思想，非常感谢！

3. 2014年11月10日17:55 | #7

打扰了！， 关于PE51，我找到个11113，替换三个数之后得{11113, 19993, 22123, 31333, 41443, 77713, 81883, 88813}都是质数，一共刚好8个，，这样行不？

• 2014年11月10日18:00 | #8

对于56**3，两个星号替换的数字必须一样

• 2014年11月11日08:45 | #9

哈哈，，有道理，，看题不仔细

4. 2014年11月11日23:22 | #10