text:
## Notes of Claire Mathieu’s lecture nr 5

Scribe: Eric Colin de Verdière

Here is the plan for today:

1. Duality in linear programming,
2. duality in semidefinite programming,
3. application to correlation clustering (work by Warren Schudy and
Claire Mathieu, SODA’10).

1. Duality

As an example, let us consider the following linear program (taken from
Va\v sek Chvátal’s book):

${\max (4x_1+x_2+5x_3+3x_4)}$

subject to ${x_i\ge0}$ for each ${i}$ and:

${\left\{\begin{array}{rcll}x_1-x_2-x_3+3x_4 & \leq & 1 & (1)\\5x_1+x_2+3x_3+8x_4 & \leq & 55 & (2)\\-x_1+2x_2+3x_3-5x_4 & \leq &3 & (3)\\\end{array}\right.}$

To prove a lower bound on the value ${OPT}$ of this program, it suffices to
find a feasible solution: ${(1,0,1,0)}$ is feasible and has value 9, so
${OPT\geq9}$.

Can we prove an upper bound on ${OPT}$? Yes! The second equation,
multiplied by two, reads ${10x_1+2x_2+6x_3+16x_4\leq 110}$. And its LHS is
at least the value of the objective (since the ${x_i}$‘s are nonnegative).
In other words, the second constraint, multiplied by two, has its
coefficients larger than in the objective function. So ${OPT\leq 110}$.

We may try some other combinations. (2)+(3) gives a proof that ${OPT\leq 55+3=58}$.

More generally, consider a nonnegative linear combination of the
constraints: ${(1)\times y_1+(2)\times y_2+(3)\times y_3}$ for nonnegative
${y_i}$‘s. The condition that all coefficients are larger than in the
objective function rewrites as:

${\left\{\begin{array}{rcl} y_1+5y_2-y_3 & \ge & 4\\ -y_1+2y_2+2y_3 & \ge & 1\\ -y_1+3y_2+3y_3 & \ge & 5\\ 3y_1+8y_2-5y_3 & \ge & 3\\\end{array}\right.}$

As long as these constraints are satisfied, we have ${y_1+55y_2+3y_3\ge OPT}$. So we want to minimize ${y_1+55y_2+3y_3}$ subject to these
constraints. This is a linear program in the ${y_i}$‘s, called the
dual linear program. Of course, taking the dual of the dual gives
the initial linear program.

Theorem 1

• If both values of the primal and dual LP are finite, then their
values are equal: ${\max(\text{primal})=\min(\text{dual})}$.
• If the solution to the primal is unbounded
(${\max(\text{primal})=+\infty}$), then the dual is not feasible
(${\min(\text{dual})=\min(\emptyset)}$).
• Dually, if the primal is not feasible
(${\max(\text{dual})=\max(\emptyset)}$), then the dual is unbounded
(${\min(\text{dual})=-\infty}$).

No case distinction is needed under the convention that
${\max(\emptyset)=-\infty}$ and ${\min(\emptyset)=+\infty}$.

Proof:
${\leq}$ is easy, we did this on an example. The other direction is
harder, and we will skip it.
$\Box$

2. Semi-definite programming duality

In general, in approximation algorithms, we follow the following steps:

• Solve a linear programming relaxation (say a maximization problem);
• round the solution to obtain an integer solution;
• for the analysis, argue that the value of the output is at least ${c}$
times the value of the linear program, for some value of~${c}$. This gives
a ${c}$-approximation.

Duality gives a new possibility for approximation algorithms: If we can
find one feasible solution ${(y_i)}$ in the dual, such that the value of the
output is at least ${c}$ times the value of this feasible solution, then we
know that ${OPT}$ is at most ${c}$ times the output.

SDP also have a dual, so this proof technique can in principle be used.
I will illustrate this by an example on correlation clustering, but SDP
duality potentially goes far beyond.

Let us consider the following SDP: ${\max\sum_{ij} c_{ij}x_{ij}}$

subject to: for every ${k}$, ${\sum_{ij} a_{ijk}x_{ij}\le b_k}$

and the SDP constraint: ${X=(x_{ij})}$ is semi-definite positive.

(This presentation differs from the one used in previous lectures, but it
is more convenient to demonstrate duality.)

We rewrite the SDP constraint as: For every ${u}$, ${u^T X u\ge 0}$. This
constraint is linear in the ${x_{ij}}$‘s. In this sense the SDP program is
just a LP with an infinite number of constraints.

We can write the dual like for a linear program. Eventually, we find that
${M=\sum\lambda_w w^T w}$, where ${w}$ is a vector, ${\lambda_w\ge0}$, and ${M}$
depends on the parameters of the primal. We recognize that this is
equivalent to having ${M}$ positive semi-definite.

Interlude by Nati Linial: This works for convex programming also, via
polarity.

More precisely, let ${X\subseteq{\mathbb R}^n}$ containing ${0}$ in its interior. Let
${X^o=\{y\in{\mathbb R}^n\mid\forall x\in X, x.y\ge0\}}$ be the polar
of~${X}$. Observe that if ${X}$ is the set of PSD matrices, then ${X^o=X}$.

${M}$ is PSD if and only if, for every ${A}$ PSD, we have ${A.M\geq0}$. (This
is not entirely trivial but easy.)

For each ${u}$, ${u^T X u\geq 0}$ is equivalent to: For each ${A\geq0}$, we
have ${\sum x_{ij}a_{ij}\ge0}$. This is the same phenomenon as LP duality.

3. Correlation clustering

Today we consider a graph with similarity or dissimilarity constraints, and
we want to partition the vertex set by minimizing the number of
disagreements. (This is more difficult than the previous clustering
problem we studied: the exact problem is the same, but in terms of
approximation, this is different.)

More precisely, given the complete graph where all edges are labeled either
${+}$ (similar) or ${-}$ (dissimilar), find a partition of the vertex set that
minimizes the number of inconsistent edges: an edge is inconsistent if it
is labeled ${+}$ but its two vertices are in different pieces of the
partition, or it is labeled ${-}$ but its two vertices are in the same piece
of the partition.

The problem is of course NP-hard, so let us look for an approximation
algorithm. If ${OPT=0}$, there exists a partition satisfying all the
constraints. In this case, the partition is easy to find using a simple
greedy algorithm: Iteratively take a vertex~${i}$ and put together with~${i}$
every ${j}$ such that ${ij}$ is a ${+}$. That’s one cluster. Set it aside and
repeat.

A simple randomized variant provides a good approximation for the problem
(even if ${OPT\neq0}$): We may take vertex ${i}$ uniformly at random. Let us
call this variant “Randomized greedy”.

Theorem 2
Randomized greedy is a 3-approximation for this problem.

Here is an example showing why randomization is necessary. Denote by
${\{1,\ldots,n\}}$ the vertex set. Put a ${+}$ edge for edge ${ij}$ iff ${i}$ or
${j}$ is equal to~${1}$. If ${1}$ is picked by the algorithm, then we are really
far from the optimum: we get a solution of cost ${\Theta(n^2)}$. On the
other hand, if we use “Randomized greedy”, then ${1}$ is picked with
probability ${\frac1n}$, and in the remaining cases the solution has cost
${\Theta(n)}$. On average, we obtain a solution with cost
${\Theta(n)=\Theta(OPT)}$.

Proof:
The analysis uses the notion of “bad triangle”. A triangle ${ijk}$ is
bad if exactly one of its edges is labeled ${-}$. Certainly, ${OPT}$ is at
least the maximum number of edge-disjoint bad triangles.

More generally, to every bad triangle~${t}$, we associate a value
${a_t\in\{0,1\}}$. We consider positive combinations of bad triangles
satisfying the following condition: For each edge, the sum of the ${a_t}$,
for every bad triangle ${t}$ containing~${e}$, is at most one. The same
argument shows that ${OPT\ge\sum_t a_t}$.

Analysis: Let ${a_t}$ be the probability that, during a random execution of
“Randomized greedy”, one of ${t}$‘s vertices is chosen before ${t}$
disappears. Then I claim that the ${a_t/3}$ form a feasible solution in
the dual.

Proof: Let ${e}$ be an edge, contained in ${k}$ bad triangles. Consider the
first vertex of the union of these triangles picked by the algorithm. If
it is an endpoint of~${e}$, then the algorithm destroys ${k}$ bad triangles.
If it is one of the ${k}$ other vertices, it destroys a single triangle.
Thus the sum of the ${a_t}$, where ${t}$ ranges over all bad triangles
containing~${e}$, is at most~3.

The rest of the proof is left as exercise.
$\Box$

Theorem 3
Consider now the complete graph with weighted edges ${w_e^+}$ and ${w_e^-}$
such that ${w_e^++w_e^-=1}$ (instead of ${+}$ and ${-}$, we have weights).
Then “Randomized greedy” (where you put the neighbor ${v}$ of the picked
vertex~${u}$ in the same cluster as~${u}$ iff ${w_{uv}^+}$ is at least ${.5}$) is
a 5-approximation.

Kleinberg proved that the problem does not admit a PTAS (unless P=NP).
Which variant of the problem admits a PTAS? Let us change the model and
move away from the worst case to the “planted model”.\footnote{The name
comes from the original study of such models in the max-clique problem;
cliques were “planted”, imposed on a random graph. See Uriel Feige’s
work.}

4. Other model

Assume that we are given a (possibly non-complete) graph with ${+}$ and ${-}$
on the edges. Assume that there is a perfect clustering, but that the
input is generated by a random perturbation: Flip independently the label
of every edge with probability~${p}$.

Theorem 4
There is an algorithm that achieves an ${(1+\frac1{\sqrt n})}$-approximation in expectation.

This slightly improves the state of the art, but with very different
(SDP) techniques.

\note{From here on, refer to Claire’s slides also.}

View the solution as a set of vectors ${v_i}$, such that ${v_{ij}}$ is ${0}$ iff
the ${i}$th vertex is in cluster~${j}$. In this sense we want to minimize the
Hamming distance between the input and ${v^T v}$.

The algorithm is now very simple: Solve the dual SDP relaxation using the
ellipsoid method. This defines ${x_{ij}}$ for every edge ${ij}$, which we
interpret as ${w_{ij}^+}$. This gives another clustering problem. We solve
it using the 5-approximation algorithm described before.

We assume here ${p}$ is a constant (say ${.3}$).

Let ${B}$ be the “true” clustering before applying the noise, ${E}$ be the
input, and ${X}$ be the solution of the SDP.

Lemma 5
${dist(B,X)\leq 1000 n\sqrt n}$.

Proof:
Assume not. Imagine that we add to the initial SDP, called SDP1, the
constraint that ${d(B,X)\leq 1000n\sqrt n}$. Let SDP2 be the resulting
SDP. We get a new solution that must have a larger value.

\note{To be filled…}

We obtain that a matrix ${M=1000n\sqrt n \text{Id} + \text{some noise}}$
must be SDP, where the noise comes from the perturbation of the input.
For this step, we find an oracle (a mathematician) and asks him about the
eigenvalues of random matrices. It turns out that the eigenvalues of the
noisy matrix are in expectation ${O(n\sqrt n)}$, so all eigenvalues are
nonnegative, so the matrix~${M}$ is SDP (with high probability). So with
high probability, the dual is feasible, so the two SDP are different.
$\Box$

In applications, ${w_e^+}$ and ${w_e^-}$ do not sum up to one. This extension
of the model has been studied also. The problem becomes more difficult to
approximate (best known is a ${O(\log n)}$-approximation or worse).

If ${w_{ij}^+=w_{ij}^-=0}$, it is just as if the edge ${ij}$ were not there.
And if the input is not really a complete graph, things become much more
complicated.

References:

• 3-approximation and 5-approximation: Ailon, Charikar, Newman, 2005.
• Inapproximability: Jon Kleinberg, 1990’s.

SDP duality has been used in problems related to the Unique Games
Conjecture. Maybe this will prove useful for other problems as well.
There are also recent algorithms for solving SDP that take advantage of the
dual, by Arora and one of his PhD students.

Next course in March: detailed presentation of the subexponential algorithm
for UGC presented by Arora and Steurer.


text:
Math Help - Finding the distance between two points

1. Finding the distance between two points

Let Q = (0,5) and R = (10,6) be given points in the plane. We want to find the point P = (x,0) on the x axis such that the sum of distances PQ+PR is as small as possible.
To solve this problem, we need to minimize the following function of x: f(x) = ?
over the closed interval [A,B] where A = ? and B = ?

2. Originally Posted by derekjonathon
Let Q = (0,5) and R = (10,6) be given points in the plane. We want to find the point P = (x,0) on the x axis such that the sum of distances PQ+PR is as small as possible.
To solve this problem, we need to minimize the following function of x: f(x) = ?
over the closed interval [A,B] where A = ? and B = ?
$PQ = d_1$

$d_1 = \sqrt{(x-0)^2 + (0-5)^2}$

$PR = d_2$

$d_2 = \sqrt{(x-10)^2 + (0-6)^2}$

$d_1 + d_2 = S$

find $\frac{dS}{dx}$ and minimize

3. Still not getting it...

Thank you for your help, I really appreciate it...

But I am still not getting what the technique is here to answer the question.

I understand finding distance (d1) and distance (d2)

but the derivative part has me thrown off. Also, I don't get what function is supposed to be minimized...

How do I go step by step through this?

4. Originally Posted by derekjonathon
Thank you for your help, I really appreciate it...

But I am still not getting what the technique is here to answer the question.

I understand finding distance (d1) and distance (d2)

but the derivative part has me thrown off. Also, I don't get what function is supposed to be minimized...

How do I go step by step through this?
minimize the function $S = \sqrt{x^2+25} + \sqrt{x^2-20x+136}$

start by finding $\frac{dS}{dx}$, set the result equal to 0, and solve for the value of x that minimizes S.

format: plain


text:
# Indices Rules Worksheets, Questions and Revision

GCSE 6 - 7AQAEdexcelOCRWJECAQA 2022Edexcel 2022OCR 2022WJEC 2022

## Indices Rules

Indices Rules builds on the 7 rules from Powers and Roots. We will cover 3 more complicated rules here. Make sure you are confident with the following topics before moving onto laws and indices.

Level 6-7 GCSE

## Indices Rule 8: Fractional Powers

The fractional indices laws apply when the power is a fraction.

$\textcolor{red}{a}^{\large{\frac{\textcolor{blue}{b}}{\textcolor{limegreen}{c}}}} = \sqrt[\textcolor{limegreen}{c}]{\textcolor{red}{a}^\textcolor{blue}{b}}$

This is commonly use to show square and cube roots.

$\textcolor{red}{x}^{\large{\frac{\textcolor{limegreen}{1}}{\textcolor{blue}{2}}}}= \sqrt[\textcolor{blue}{2}]{\textcolor{red}{x}^\textcolor{limegreen}{1}} =\sqrt[\textcolor{blue}{2}]{\textcolor{red}{x}}$

$\textcolor{red}{x}^{\large{\frac{\textcolor{limegreen}{1}}{\textcolor{blue}{3}}}}= \sqrt[\textcolor{blue}{3}]{\textcolor{red}{x}^\textcolor{limegreen}{1}} =\sqrt[\textcolor{blue}{3}]{\textcolor{red}{x}}$

Note: it doesn’t matter which order you carry out the square root and multiplication operations. In other words, the rule can also be written as

$\textcolor{red}{a}^{\large{\frac{\textcolor{blue}{b}}{\textcolor{limegreen}{c}}}} = (\sqrt[\textcolor{limegreen}{c}]{\textcolor{red}{a}})^\textcolor{blue}{b}$

You should try to carry out the operations in the order that makes the calculation as simple as possible.

Level 6-7 GCSE

## Indices Rule 9: Multi-step Fractional Powers

You may also be asked to simplify expressions where the numerator is not $\bf{1}$.

$\textcolor{red}{64}^{\large{\frac{\textcolor{limegreen}{2}}{\textcolor{blue}{3}}}}= \sqrt[\textcolor{blue}{3}]{\textcolor{red}{64}^\textcolor{limegreen}{2}}$

$\sqrt[\textcolor{blue}{3}]{\textcolor{red}{64}} = \textcolor{red}{4}$

$\textcolor{red}{4}^\textcolor{limegreen}{2} = \textcolor{red}{16}$

Level 6-7 GCSE

## Indices Rule 10: Negative Powers

Negative powers flip the fraction and put $1$ over the number

In general, the result of a negative power is “$\bf{1}$ over that number to the positive power”, i.e.

$\textcolor{red}{a}^{-\textcolor{limegreen}{b}} = \dfrac{1}{\textcolor{red}{a}^\textcolor{limegreen}{b}}$

for any value of $a$ or $b$. When the power is $\textcolor{blue}{-1}$, this takes the form,

$\textcolor{red}{a}^{\textcolor{blue}{-1}}=\dfrac{1}{\textcolor{red}{a}}$ or $\textcolor{red}{10}^{\textcolor{blue}{-1}} = \dfrac{1}{\textcolor{red}{10}}$

When the number is a fraction, the negative power flips the fraction.

$\bigg(\dfrac{\textcolor{blue}{a}}{\textcolor{limegreen}{b}}\bigg)^{-\textcolor{red}{x}} = \bigg(\dfrac{\textcolor{limegreen}{b}}{\textcolor{blue}{a}}\bigg)^\textcolor{red}{x}$

Level 6-7 GCSE
Level 6-7 GCSE

## Example 1: Negative Powers

Simplify the following,  $4^{-3}$.

[2 marks]

We now know that $4^{-3}$ is equal to $\dfrac{1}{4^3}$. We also know that

$4^3=4\times 4\times 4=16\times 4=64$.

So, we get that

$4^{-3}=\frac{1}{64}$.

Level 6-7 GCSE

## Example 2: Fractional Powers and Roots

Simplify the following,  $9^{\frac{3}{2}}$.

[2 marks]

So, we know that $9^{\frac{3}{2}}$ is equal to $\sqrt[2]{9^3}$ or $(\sqrt[2]{9})^3$.

So, to work out $(\sqrt[2]{9})^3$, we first have to square root $9$, which is easy enough – the square root of $9$ is $3$. So, $(\sqrt[2]{9})^3$ becomes $3^3$, which is

$3^3=3\times 3\times 3 = 27$

Level 6-7 GCSE

## Example 3: Multiplication and Powers

Write $2^{15}\times 8^{-4}$ as a power of $2$, and hence evaluate the expression. (Non calculator)

[3 marks]

The first part of the expression is a power of $2$, whilst the second part is a power of $8$.

we know that

$8 = 2^3$

This means we can rewrite the following,

$8^{-4}=\left(2^3\right)^{-4}$

Next, using Rule 3, we can simplify,

$\left(2^3\right)^{-4}=2^{3\times(-4)}=2^{-12}$

So the whole expression can be written as

$2^{15}\times2^{-12},$

Finally using Rule 1 we simplify the expression further.

$2^{15}\times2^{-12}=2^{15+(-12)}=2^3$

Thus, we have written the expression as a power of $2$. Evaluating this final answer gives

$2^3 = 8$

Level 6-7 GCSE

## Example Questions

So, we can’t use any laws straight away since the terms don’t have the same base. However, if we recognise that $9=3^2$, then we can write the first term as

$\left(3^2\right)^5$

Using the power law, we get

$\left(3^2\right)^5=3^{2\times5}=3^{10}$

Therefore, the whole expression becomes

$3^{10}\times3^{-5}$

Applying the multiplication law, this simplifies to

$3^{10+(-5)}=3^5$

Thus, we have written the expression as a power of $3$.

Firstly, as $3^2=9$, the inverse operation gives, $\sqrt{9}=3$

So, that leaves $6^{-2}$, this becomes the following fraction,

$6^{-2}=\dfrac{1}{6^2}$

We know that $6^2=6\times 6=36$, so

$6^{-2}=\dfrac{1}{36}$

Multiplying our two answers together, we get

$\sqrt{9}\times 6^{-2}=3\times\dfrac{1}{36}=\dfrac{3}{36}=\dfrac{1}{12}$

This expression can be rewritten as,

$\sqrt4 \times (\sqrt4)^3$

Given we know that $\sqrt4=2$ , this becomes,

$2\times2^3$

Hence,

$2\times2^3=2\times8=16$

Notice that in this example we chose to perform the $\sqrt{4}$ operation before cubing the answer. We could alternatively write the expression as $\sqrt{4^3}$, but in this case the first option is easier.

As it is a negative power we can rewrite this as,

$8^{-\frac{5}{3}}=\frac{1}{8^{\frac{5}{3}}}$

Now, we can work out the denominator, which we will write as,

$8^{\frac{5}{3}}=\sqrt[3]{8^5}=(\sqrt[3]{8})^5$

We know that $\sqrt[3]{8}=2$. So this simplifies to,

$(\sqrt[3]{8})^5=2^5$

Counting up in powers of $2$: $4$, $8$, $16$, $32$ – we see that $32$ is the $5$th power of $2$, so

$\sqrt[3]{8}^5=32$

$8^{-\frac{5}{3}}=\dfrac{1}{32}$

Level 1-3GCSEKS3

Level 4-5GCSEKS3

## Worksheet and Example Questions

### (NEW) Rules of Indices Exam Style Questions - MME

Level 6-7 GCSENewOfficial MME

Level 4-5 GCSE

Level 6-7 GCSE

Level 6-7 GCSE

## You May Also Like...

### GCSE Maths Revision Cards

Revise for your GCSE maths exam using the most comprehensive maths revision cards available. These GCSE Maths revision cards are relevant for all major exam boards including AQA, OCR, Edexcel and WJEC.

From: £8.99

### GCSE Maths Revision Guide

The MME GCSE maths revision guide covers the entire GCSE maths course with easy to understand examples, explanations and plenty of exam style questions. We also provide a separate answer book to make checking your answers easier!

From: £14.99

### GCSE Maths Predicted Papers 2022 (Advance Information)

GCSE Maths 2022 Predicted Papers are perfect for preparing for your 2022 Maths exams. These papers have been designed based on the new topic lists (Advance Information) released by exam boards in February 2022! They are only available on MME!

From: £5.99

### Level 9 GCSE Maths Papers 2022 (Advance Information)

Level 9 GCSE Maths Papers 2022 are designed for students who want to achieve the top grades in their GCSE Maths exam. Using the information released in February 2022, the questions have been specifically tailored to include the type of level 9 questions that will appear in this year's exams.

£9.99


text:
My Math Forum Rigorous definition of "Differential"

 Calculus Calculus Math Forum

 January 5th, 2017, 05:44 AM #1 Newbie   Joined: Jan 2017 From: Tehran, Iran Posts: 5 Thanks: 0 Rigorous definition of "Differential" First of all I want to clarify that I posted this question on many forums and Q&A websites so the chances of getting an answer will be increased. So don't be surprised if you saw my post somewhere else. Now let's get started: __________________________________________________ _______________ When it comes to definitions, I will be very strict. Most textbooks tend to define differential of a function/variable in a way like this: --------------------------------------------------------------------------------Let $\displaystyle f(x)$ be a differentiable function. By assuming that changes in $\displaystyle x$ are small, with a good approximation we can say: $\displaystyle \Delta f(x)\approx {f}'(x)\Delta x$Where $\displaystyle \Delta f(x)$ is the changes in the value of function. Now if we consider that changes in $\displaystyle f(x)$ are small enough then we define differential of $\displaystyle f(x)$ as follows: $\displaystyle \mathrm{d}f(x):= {f}'(x)\mathrm{d} x$Where $\displaystyle \mathrm{d} f(x)$ is the differential of $\displaystyle f(x)$ and $\displaystyle \mathrm{d} x$ is the differential of $\displaystyle x$. -------------------------------------------------------------------------------- What bothers me is this definition is completely circular. I mean we are defining differential by differential itself. Although some say that here $\displaystyle \mathrm{d} x$ is another object independent of the meaning of differential but as we proceed it seems that's not the case: First of all we define differential as $\displaystyle \mathrm{d} f(x)=f'(x)\mathrm{d} x$ then we deceive ourselves that $\displaystyle \mathrm{d} x$ is nothing but another representation of $\displaystyle \Delta x$ and then without clarifying the reason, we indeed treat $\displaystyle \mathrm{d} x$ as the differential of the variable $\displaystyle x$ and then we write the derivative of $\displaystyle f(x)$ as the ratio of $\displaystyle \mathrm{d} f(x)$ to $\displaystyle \mathrm{d} x$. So we literally (and also by stealthily screwing ourselves) defined "Differential" by another differential and it is circular. Secondly (at least I think) it could be possible to define differential without having any knowledge of the notion of derivative. So we can define "Derivative" and "Differential" independently and then deduce that the relation $\displaystyle f'{(x)}=\frac{\mathrm{d} f(x)}{\mathrm{d} x}$ is just a natural result of their definitions (using possibly the notion of limits) and is not related to the definition itself. Though I know many don't accept the concept of differential quotient($\displaystyle \frac{\mathrm{d} f(x)}{\mathrm{d} x}$) and treat this notation merely as a derivative operator($\displaystyle \frac{\mathrm{d} }{\mathrm{d} x}$) acting on the function($\displaystyle f(x)$) but I think that it should be true that a "Derivative" could be represented as a "Differential quotient" for many reasons. For example think of how we represent derivatives with the ratio of differentials to show how chain rule works by cancelling out identical differentials. Or how we broke a differential into another differential in the $\displaystyle u$-substitution method to solve integrals. And it's especially obvious when we want to solve differential equations where we freely take $\displaystyle \mathrm{d} x$ and $\displaystyle \mathrm{d} y$ from any side of a differential equation and move it to any other side to make a term in the form of $\displaystyle \frac{\mathrm{d} y}{\mathrm{d} x}$, then we call that term "Derivative of $\displaystyle y$". It seems we are actually treating differentials as something like algebraic expressions. I know the relation $\displaystyle \mathrm{d} f(x)=f'(x)\mathrm{d} x$ always works and it will always give us a way to calculate differentials. But I (as an strictly axiomaticist person) couldn't accept it as a definition of Differential. So my question is: Can we define "Differential" more precisely and rigorously? Thank you in advance. P.S. I prefer the answer to be in the context of "Calculus" or "Analysis" rather than the "Theory of Differential forms". And again I don't want a circular definition. I think it is possible to define "Differential" with the use of "Limits" in some way(though it's just a feeling).
 January 5th, 2017, 05:54 AM #2 Math Team   Joined: Jan 2015 From: Alabama Posts: 2,210 Thanks: 555 Yes, "differential" can be defined rigorously but such a definition really has to wait until "differential geometry". See http://people.math.gatech.edu/~ghomi...ureNotes8U.pdf for "differential map". until then, it is better to stay with the rough concept which is, yes, circular. Essentially, the concept of "differential" in basic Calculus is an attempt to make use of a general observation- although the derivative, dy/dx, is NOT a fraction, it can be used AS if it WERE a fraction because it is a limit of a fraction. The "differentials", dy and dx are introduced, in a fairly hand-waving way, in order to be able to treat dy/dx as if it were a fraction.
 January 5th, 2017, 07:21 AM #3 Senior Member   Joined: May 2016 From: USA Posts: 421 Thanks: 169 I may be wrong, but I am missing the circularity in what, admittedly, is very obscurely written. Let's try to clean it up. $Given\ y = f(x).$ $\Delta y \equiv f(x + \Delta x) - f(x) \equiv \text{change in y if x changed by } \Delta x.$ No mention of a "differential." What is defined is quite clearly a difference. $\displaystyle f'(x) \equiv \lim_{\Delta x \rightarrow 0} \dfrac{f(x + \Delta x) - f(x)}{\Delta x}.$ $dy \equiv f'(x)\ * \Delta x \equiv \text{differential of y.}$ The differential is a product, not a difference. Once the definitions are clarified, I am missing any circularity. Finally we have a proposition to be proved: $Given\ arbitrary\ \epsilon > 0,\ \exists\ \lambda\ such\ that$ $0 < | x - \Delta x | < \lambda \implies | dy - \Delta y | < \epsilon.$ In English, that proposition says that if the change in x is sufficiently small, the differential of y approximates the change in y. That as yet unproved proposition may or may not be true, and it may or may not be provable, but it is not circular. What am I missing? Last edited by JeffM1; January 5th, 2017 at 07:25 AM.
January 5th, 2017, 07:30 AM   #4
Newbie

Joined: Jan 2017
From: Tehran, Iran

Posts: 5
Thanks: 0

Quote:
 Originally Posted by Country Boy Yes, "differential" can be defined rigorously but such a definition really has to wait until "differential geometry". See http://people.math.gatech.edu/~ghomi...ureNotes8U.pdf for "differential map". until then, it is better to stay with the rough concept which is, yes, circular. Essentially, the concept of "differential" in basic Calculus is an attempt to make use of a general observation- although the derivative, dy/dx, is NOT a fraction, it can be used AS if it WERE a fraction because it is a limit of a fraction. The "differentials", dy and dx are introduced, in a fairly hand-waving way, in order to be able to treat dy/dx as if it were a fraction.
In this case, I think it's really bad to use Leibniz's notation in basic calculus. We should reformulate Calculus using Lagrange's notation for both derivative and antiderivative operations so we get rid of this nonsense differential.

January 5th, 2017, 07:55 AM   #5
Newbie

Joined: Jan 2017
From: Tehran, Iran

Posts: 5
Thanks: 0

Quote:
 Originally Posted by JeffM1 $dy \equiv f'(x)\ * \Delta x \equiv \text{differential of y.}$
Once again the main problem is when we reach this point we easily take $\Delta x$ as $\mathrm{d} x$ without any reason and then treat the derivative of $y$ as the ratio of two differentials: $\frac{\mathrm{d} y}{\mathrm{d} x}$.

Was $\mathrm{d} x$ as the same as $\Delta x$ then we wouldn't need to introduce a new concept such as differential. Or maybe I'm missing something?

January 5th, 2017, 08:56 AM   #6
Senior Member

Joined: May 2016
From: USA

Posts: 421
Thanks: 169

Quote:
 Originally Posted by HamedBegloo Once again the main problem is when we reach this point we easily take $\Delta x$ as $\mathrm{d} x$ without any reason and then treat the derivative of $y$ as the ratio of two differentials: $\frac{\mathrm{d} y}{\mathrm{d} x}$. Was $\mathrm{d} x$ as the same as $\Delta x$ then we wouldn't need to introduce a new concept such as differential. Or maybe I'm missing something?
I did not try to grasp whatever subtext may have been in your original post. I was merely responding to your statement that the differential must necessarily involve circularity. I don't believe Weirstrauss et al. were guilty of circularity.

I simply did not address the issues of what is the most intuitive notation for introducing calculus or what is the best way to let students learn how to apply calculus. I am dubious that any analysis should be included in introductory calculus, and if it must, I might lean in favor of some form of simplified non-standard analysis. To put it differently, I think understanding should precede rigor. Understanding the utility of calculus justifies rigor; without that understanding, rigor is without motivation.

January 5th, 2017, 09:25 AM   #7
Newbie

Joined: Jan 2017
From: Tehran, Iran

Posts: 5
Thanks: 0

Quote:
 Originally Posted by JeffM1 I did not try to grasp whatever subtext may have been in your original post. I was merely responding to your statement that the differential must necessarily involve circularity. I don't believe Weirstrauss et al. were guilty of circularity.
For me circularity is a real headache and I couldn't withstand it.
I think at least in mathematics circularity is very frowned upon.
Anyway now I get what you meant.

Quote:
 Originally Posted by JeffM1 I simply did not address the issues of what is the most intuitive notation for introducing calculus or what is the best way to let students learn how to apply calculus. I am dubious that any analysis should be included in introductory calculus, and if it must, I might lean in favor of some form of simplified non-standard analysis.
Well that seems a really good idea. Shouldn't it be better if we taught "Hyperreal analysis" instead of "Real analysis" in introductory calculus?

Quote:
 Originally Posted by JeffM1 I think understanding should precede rigor. Understanding the utility of calculus justifies rigor; without that understanding, rigor is without motivation.
This seems important too. I wish there were a way too keep rigor and intuition at the same time.

January 5th, 2017, 01:01 PM   #8
Senior Member

Joined: Aug 2012

Posts: 824
Thanks: 140

Quote:
 Originally Posted by HamedBegloo In this case, I think it's really bad to use Leibniz's notation in basic calculus. We should reformulate Calculus using Lagrange's notation for both derivative and antiderivative operations so we get rid of this nonsense differential.
I agree with you that it would be better if calculus texts said, "For now, just manipulate differentials the way we tell you to. It's not possible to give a rigorous definition till much later in your math education." Instead, the books tell confusing half-truths.

Quote:
 Originally Posted by HamedBegloo Well that seems a really good idea. Shouldn't it be better if we taught "Hyperreal analysis" instead of "Real analysis" in introductory calculus?
Since Keisler wrote his infinitesimal-based calculus text in 1976, two things have NOT happened.

* Nobody else has bothered to write a similar text; and

* Hyperreal-based teaching of calculus has not caught on.

Studies have been done showing that students are equally confused no matter which approach is taken. And if you teach calculus using nonstandard terminology and concepts ("nonstandard" having two meanings here, as in nonstandard analysis and also not the standard way of teaching calculus) you would leave students totally unprepared to study standard physics, math, biology, statistics, or any other subject.

The only thing I can imagine that would change this state of affairs is if tomorrow morning professor so-and-so from Helsinki proves P $\neq$ NP using hyperreals. If that happened, everyone would suddently develop tremendous interest in nonstandard analysis.

Absent a dramatic development along those lines, nobody is going to change the way calculus is taught. And as I say, I completely agree with you that the treatment of differentials in calculus texts is very confusing to students; and the more thoughtful and mathematically inclined the student, the more confused they are on this point.

Last edited by Maschke; January 5th, 2017 at 01:15 PM.

January 6th, 2017, 07:59 AM   #9
Newbie

Joined: Jan 2017
From: Tehran, Iran

Posts: 5
Thanks: 0

Quote:
 Originally Posted by Maschke I agree with you that it would be better if calculus texts said, "For now, just manipulate differentials the way we tell you to. It's not possible to give a rigorous definition till much later in your math education." Instead, the books tell confusing half-truths. Since Keisler wrote his infinitesimal-based calculus text in 1976, two things have NOT happened. * Nobody else has bothered to write a similar text; and * Hyperreal-based teaching of calculus has not caught on. Studies have been done showing that students are equally confused no matter which approach is taken. And if you teach calculus using nonstandard terminology and concepts ("nonstandard" having two meanings here, as in nonstandard analysis and also not the standard way of teaching calculus) you would leave students totally unprepared to study standard physics, math, biology, statistics, or any other subject. The only thing I can imagine that would change this state of affairs is if tomorrow morning professor so-and-so from Helsinki proves P $\neq$ NP using hyperreals. If that happened, everyone would suddently develop tremendous interest in nonstandard analysis. Absent a dramatic development along those lines, nobody is going to change the way calculus is taught. And as I say, I completely agree with you that the treatment of differentials in calculus texts is very confusing to students; and the more thoughtful and mathematically inclined the student, the more confused they are on this point.
Now that I noticed that, it seems there maybe a way to resolve this issue by staying in the "Real analysis" scope.

I remember someone pointed out that the main problem with defining Differential in "Real calculus" is that the mathematical objects $\displaystyle df(x)$ and $\displaystyle dx$ aren't even "Real numbers" or in some sense aren't "Real valued functions".

But I also remember there were a section in our "Calculus" course where they discussed "Infinite limits" and "Infinite derivatives" which were Limits and Derivatives that have a value of "Infinity". Since infinity isn't a real number sure they were treated as a kind of "Non-existent limit/derivative" but as a special kind of them. I mean this type of non-existence of limit/derivative had some significant properties which made them important.

Now why don't introduce "Infinitesimals" as some kind of non-existent limits and then relate the idea to the concept of "Differentials". By doing so we neither entered into non-standard analysis nor put down the differentials and even somehow made them more rigorous.

Do you think it's possible?

January 6th, 2017, 08:25 AM   #10
Senior Member

Joined: Dec 2012

Posts: 890
Thanks: 20

Quote:
 Originally Posted by Maschke ..., I completely agree with you that the treatment of differentials in calculus texts is very confusing to students; and the more thoughtful and mathematically inclined the student, the more confused they are on this point.
You gain lot of points as the most honest matematician of EVER

But I hope we are on the way to let think more and more clear.

New more simple and clear math is knocking on the door, it's just question of how many years it takes, to cancel out the old math generations...

 Thread Tools Display Modes Linear Mode

 Similar Threads Thread Thread Starter Forum Replies Last Post calebh Probability and Statistics 1 January 26th, 2013 03:41 PM SedaKhold Calculus 0 February 13th, 2012 12:45 PM Amir Kiani Algebra 2 March 19th, 2009 01:02 PM katie0127 Advanced Statistics 0 December 3rd, 2008 02:54 PM robocop_911 Applied Math 3 June 1st, 2008 09:43 PM

 Contact - Home - Forums - Top


text:
In the verge of coronavirus pandemic, we are providing FREE access to our entire Online Curriculum to ensure Learning Doesn't STOP!

# Ex.11.2 Q4 Constructions Solution - NCERT Maths Class 9

Go back to  'Ex.11.2'

## Question

Construct a triangle $$XYZ$$ in which $$\angle Y=30^{\circ}, \angle Z=90^{\circ}$$ and $$XY + YZ + ZX = 11 \;\rm{cm.}$$

Video Solution
Constructions
Ex 11.2 | Question 4

## Text Solution

Steps of Construction:

(i) Draw line  $$BC=11\;\rm{cm}$$.

(ii) Make angle of $$30^\circ$$ at $$B$$ and $$90^\circ$$ at $$C$$ using a protractor.

(iii) Bisect angle $$B$$.

With $$B$$ as centre and any radius draw a wide arc to intersect both the arms of angle $$B$$.

(iv) With intersecting points as the centre and same radius draw two arcs to intersect each other at $$P$$ Draw line joining $$B$$ and $$P$$ and extend it beyond $$P$$

(v) Bisect angle $$C$$.

With $$C$$ as the centre and radius draw two arcs to intersect each other at $$Q$$. Join $$Q$$ and $$C$$such that it intersects ray $$BP$$ at $$X$$.

(vi) Perpendicular bisector of $$BX$$.

With $$B$$ and $$X$$ as centres and radius greater than half of $$BX$$ draw arcs on either side of line $$BX$$ to intersect each other. Join the intersecting lines such that the perpendicular bisector intersects $$BC$$ at $$Y$$.

(vii) Perpendicular bisector of $$CX$$

With $$C$$ and $$X$$ as centres and radius greater than half of $$CX$$ draw arcs on Join the intersecting lines such that the perpendicular bisector intersects $$BC$$ at $$Z$$.

(viii) Join $$XY$$ and $$XZ$$. $$XYZ$$ is the required triangle.

Learn from the best math teachers and top your exams

• Live one on one classroom and doubt clearing
• Practice worksheets in and after class for conceptual clarity
• Personalized curriculum to keep up with school


text:
# Divided by Pie Squared. Aaahhh

I have a machine that can divide a square pie into 9 equal square pieces using 4 blades:

The blades can be moved, but there is only one control - which defines the width of the blades in both dimensions

We simply have to set the width, then place the centre of the pie at the centre of the blades and we can chop any size pie into 9 equal pieces:

Someone has just brought me a round pie.

I still need to locate the centre of the pie in the centre of the blades, so I'm expecting to get 3 different shapes; 1 centre, 4 "corners" and 4 "edges".

If I set the blades to 1/3rd of the diameter of the pie, the "edge" pieces and "corner" pieces will be smaller than the middle one.

But it occurs to me that I can make the blades narrower so that the middle piece is smaller and the outer pieces are bigger.

For a pie of given radius r, is it possible to find a setting that produces 9 equal area pieces? If not, what setting will give 9 pieces of pie with the least variation, i.e. the difference between area of the smallest piece and the largest piece is minimised.

## 4 Answers

It is

not possible

to divide the cake into 9 equal pieces in this way,

and

the best you can do (by the criterion given in the question) is to have each parallel pair of blades separated by about 0.558 times the radius of the circle, in which case (taking that radius to be 1, so the "ideal" piece area is about 0.349) the max minus min area is about 0.083.

Details:

Let $$d$$ be half the separation between the blades. Then the middle piece is of size $$4d^2$$. If we take our circle to have radius 1, the middle piece is 1/9 of the area iff $$4d^2=\pi/9$$ or equivalently $$d=\sqrt{\pi}/6$$. Each "middle-edge" piece, if we add in half of the middle piece, can be divided into a sector of the circle, with angle $$2\sin^{-1}d$$, and two right-angled triangles with legs $$d,\sqrt{1-d^2}$$, so the total area of one of these pieces is $$\sin^{-1}d+d\sqrt{1-d^2}-2d^2$$. The corner piece's area is accordingly $$\pi/4+d^2-\sin^{-1}d-d\sqrt{1-d^2}$$. At $$d=\sqrt{\pi}/6$$, we can check that the middle piece's area is about 0.349 while the middle-edge piece's area is about 0.408, a bit bigger. (The corners will be too small.) Taking a look at the graphs of these, the largest-minus-smallest function is largest when corner = middle, at which point d is just over 0.279 and the difference between largest and smallest areas is a little over 0.083.

Some more details:

To see that we don't have middle = corner when $$d=\sqrt{\pi}/6$$: that would mean $$3d^2+\sin^{-1}d+d\sqrt{1-d^2}=\pi/4$$ or, since $$3d^2=\pi/12$$, $$\sin^{-1}d+d\sqrt{1-d^2}=\pi/6$$. Let's prove that the LHS is too big to equal the RHS. Well, we have $$\sin^{-1}d\geq d$$ and $$\sqrt{1-d^2}\geq 1-d^2$$ so it's enough to prove $$d+d(1-d^2)>\pi/6$$; the RHS equals $$6d^2$$ so this is equivalent to $$2-d^2>6d$$ or $$d^2+6d-2<0$$ or $$(d+3)^2-11<0$$ or $$d+3<\sqrt{11}$$. 11 doesn't have a nice square root but $$10.89=3.3^2$$ does, so it suffices to prove that $$d+3<3.3$$ or $$d<0.3$$. Since $$d=\sqrt{pi}/6$$ this is the same as $$\pi<1.8^2=3.24$$, and this is both well known and easy to prove.

And

Over the range $$d=0\ldots\sqrt{2}/2$$ (beyond which the corner piece disappears altogether), the middle piece's area is obviously increasing, and the corner piece's area is obviously decreasing. Initially, of course the middle-edge piece's area is increasing, and in fact it's clear that this holds until the point at which $$y=2x$$ (think about how much the width and height of the upper middle-edge piece change when you make a small increase in $$d$$) by which point it's clear that the corners are too small relative to the middle. As you gradually increase $$d$$, the sequence of events is as follows. Initially middle (inc.) <= edge (inc.) <= corner (dec.); so the first pair to meet is therefore edge and corner, and clearly max-min is decreasing because max is decreasing while min increases. After they cross over we have middle (inc.) <= corner (dec.) <= edge (inc.), so next pair to meet is middle and corner. It's not so obvious what's happening to max-min over this range but it happens to be decreasing. After they cross over we have corner (dec.) <= middle (inc.) <= edge (inc.), and now clearly the max is increasing and the min decreasing so the range is increasing. It turns out that eventually those two increasing things change places and we end up with corner <= edge <= middle, but of course it remains true that max - min = increasing - decreasing = increasing.

• lots of math, but no final answer? – Ben Barden Jan 20 at 14:35
• Looks to me like a final answer is there: look in the first spoiler block and at the end of the second. – Gareth McCaughan Jan 22 at 3:52
• Ahh. Yep. I see it. Answer would be improved by putting that up in the initial conclusion. – Ben Barden Jan 22 at 15:13
• You might be right. I've reorganized things slightly. – Gareth McCaughan Jan 22 at 17:40

partial answer:

It is not possible to make them all the same size.

To demonstrate, assume that they are the same size. Thus, the side pieces must be the same overall area as the center piece. Supposing an edge size of A, that area must be a^2. By further extension, the distance from the inner square to the outer edge along the cuts must be slightly less than A, jsut as the distance from the inner square to the outer edge along the radius must be slightly greater than A. That's the only way to have the side pieces be the same size as the center piece, and there's jsut not that much play there.

If we then look at the corner pieces, considering where the distance A fromt eh center square is along the cut lines, it becomes clear that they would exist entirely inside of an AxA square drawn using their cuts and those points. They cannot be the same size as the central square, and thus it is not possible for all of the pieces to be the same size.

further insight:

If we start from that position, it is clear that the ideal position is going to have the cuts closer together than that - as we bring the cuts closer together, the corners (which are too small) grow, while the center and sides (which are too large) shrink. The center is shrinking significantly faster than the sides, though. if we push them together by x, the area of the center becomes (roughly) (A-x)(A-x), while the the area of the sides becomes (A-x)(A+x/2)

It is clear, then, that we want to shrink it at least until the point where the center is the same size as the corners. Up until that point, the smallest pieces (the corners) are growing and the largest (the sides) are shrinking. Once you hit that point, however, the smallest becomes the central piece, which is shrinking. If we were optimizing for multiplicative difference we'd be done, but for additive difference it will depend on whether the sides or the center are at that point losing more additively, and I'm not absolutely certain on that. Regardless, the largest is still the sides, which are also shrinking, and that persists until the corners become the same size as the sides, at which point the largest is the corners (growing) and the smallest is the center (shrinking) and it's clear that we should go no further.

Thus the ideal state is the one where the corners are grater than or equal to the center, less than or equal to the sides, and side minus center is as small as possible.

Actually, working that our is pretty close to algebraic. The rounded end on the sides throws it off a touch, but it's close enough that we can largely ignore that and still expect to be basically correct. Finding minimum for (A-x)(A+x/2)-(A-x)(A-x) where x<A. (A-x)*(3x/2) = (3Ax-3xx)/2. We can ignore the scalars, so we're looking at minimum of Ax-xx where A>x. So we want to push that as far as we can... which means we're looking for the case where the sides and corners are the same size. Huh.

Final result: looking for the situation where sides and corners are the same size. Expect the center to be smaller.

• @xhienne read the last sentence of the question. – Ben Barden Jan 19 at 15:05
• Ah OK, I missed that! – xhienne Jan 19 at 15:19

First, we have to find the areas of the pieces (the inner square $$I$$, the midsections $$M$$, and the corners $$C$$) in terms of $$r$$ and the setting $$2w$$:

Obviously, $$I$$ has area $$4w^2$$.
A sector defined by two corners and a midsection has area $$\theta r^2$$, where $$\theta = cos^{-1}(\frac{w}{r})$$, and so $$I+2M = (\pi-2\theta)r^2$$ and $$M = (\frac{\pi}{2}-\theta)r^2 -2w^2$$.
Revisiting sector area, we have $$M+2C = \theta r^2$$, from which a bit of manipulation gives $$C = (\theta - \frac{\pi}{4})r^2 + w^2$$. Assuming that a perfect division is possible, setting $$I=M=C$$ and manipulating yields the equations $$\pi-2\theta = \frac{12w^2}{r^2}, \frac{3\pi}{4}-2\theta=\frac{3w^2}{r^2}$$. Using the proportion of the two differences yields $$\theta = \frac{\pi}{3}$$, but substituting back into the equations themselves requires $$\frac{w}{r}$$ to equal $$\frac{\sqrt{\pi}}{6}$$ when the above $$\theta$$ forces it to be $$\frac{1}{2}$$.
Therefore, it doesn't quite work.

• It's been a bit too long since I've done enough trig to get to the actual solution, but you might find my "further insight" helpful in working out the final answer for yourself. – Ben Barden Jan 19 at 18:49

My answer is:

Yes you can. When you can divide the cake into 3 equal pieces horizontally, you can cut the cake into 9 equal pieces. The side of the middle square will be $$\frac {\sqrt\pi r} 3$$

Proof?

It's obvious that one could divide the middle part into 3 equal pieces. The edge and the center will have area $$\frac {\pi r^2} 9$$ Then $$\pi r^2-\frac {5\pi r^2} 9=\frac {4\pi r^2} 9$$, which can be divided into four.

• Does not necessarily follow. You have three different shapes of piece, and your solution simply assumes that all three can be made the same size. There's no guarantee of that. Or... more precisely, you haven't proved that the side pieces and the corner pieces will be the same size with that size of side. – Ben Barden Jan 19 at 14:25


text:
# Mean value thereom application

1. Dec 10, 2016

### Arnoldjavs3

1. The problem statement, all variables and given/known data
Suppose that x,y are in (0,0.5). Show that:
$$\left|\frac{1}{x^3}-\frac{1}{y^3}\right| ≥ 48|x-y|$$

2. Relevant equations

3. The attempt at a solution
I think that we need a function $f(t) = t^{-3}$ & $f'(t) = -3t^{-4}$. Now we use the MVT here to show that there is some c that makes the expression in the problem correct right? My question is how do I incorporate the absolute value notations in the statement here?
$$-3c^{-4} = \frac{f(y) - f(x)}{y-x}$$
I think we have to assume that either x or y is greater than the other(because if they were equal then the above owuld be proven). Do I just input c for 0.5? I'm unsure.

2. Dec 10, 2016

### PeroK

It's not clear why the MVT would help here.

3. Dec 10, 2016

### Arnoldjavs3

I forgot to add that they are differentiable on the interval (x,y)

4. Dec 10, 2016

### PeroK

I still can't see why you think the MVT helps you.

5. Dec 10, 2016

### LCKurtz

Remember that all your variables are in $(0,\frac 1 2)$. If you take the absolute value of both sides of what you have written you get$$\frac 3 {c^4} =\frac{|f(y) - f(x)|}{|y-x |}$$which can be rewritten$$\frac 3 {c^4} |y-x| =\left | \frac 1 {x^3} - \frac 1 {y^3}\right |$$Think about how large or small the left side can be.

6. Dec 12, 2016

### Arnoldjavs3

Since c is an element of x,y then it can't be larger than 0.5 or smaller than 0? And as such this proves that since 48|y-x| will be greater since y is greater than c? So the side with c will always be smaller.

Last edited: Dec 12, 2016
7. Dec 12, 2016

### LCKurtz

That doesn't make any sense. $c$ is a number in $(0,.5)$, not an "element" of x,y, whatever that means.

Stating the result doesn't prove anything. You need to show some inequalities.

Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted


text:
# direct image inverse image

• November 4th 2012, 08:50 AM
jojo7777777
direct image inverse image
Show that the mapping f: R2->R2 given by f(x,y)=(x+y,x-y) is linear. For each subspace X of R2 describe f-->(X) and f<--(X).
My question is whether f-->(X) means that the image of the x-axis is the line y=x and the image of the y-axis is the line y=-x, so how am I describe f<--(X)?
• November 4th 2012, 09:23 AM
Plato
Re: direct image inverse image
Quote:

Originally Posted by jojo7777777
Show that the mapping f: R2->R2 given by f(x,y)=(x+y,x-y) is linear. For each subspace X of R2 describe f-->(X) and f<--(X).
My question is whether f-->(X) means that the image of the x-axis is the line y=x and the image of the y-axis is the line y=-x, so how am I describe f<--(X)?

$\overleftarrow f \left\{ {\left( {x,y} \right)} \right\} = \left( {\frac{{x + y}}{2},\frac{{x - y}}{2}} \right)$
• November 4th 2012, 09:59 AM
HallsofIvy
Re: direct image inverse image
Quote:

Originally Posted by jojo7777777
Show that the mapping f: R2->R2 given by f(x,y)=(x+y,x-y) is linear. For each subspace X of R2 describe f-->(X) and f<--(X).
My question is whether f-->(X) means that the image of the x-axis is the line y=x and the image of the y-axis is the line y=-x, so how am I describe f<--(X)?

The image of the x-axis (points of the form (x, 0)) is the set (x+ 0, x- 0)= (x, x) so y= x, and the image of the y-axis (points of the form (0, y)) is (0+ y, 0- y)= (y, -y) so y= -x.

The inverse image of a set X is the set of all points (x, y) such that f(x,y) is in X. If f(x,y)= (x+ y, x- y)= (u, v) then x+ y= u, x- y= v. Adding the two equations 2x= u+ v so x= (u+ v)/2. Subtracting x- y= v from x+ y= u, 2y= u- v so y= (u- v)/2. That is, $f^{-1}(u, v)= ((u+ v)/2, (u- v)/2)$ which is the same as $f^{-1}(x, y)= ((x+ y)/2, (x- y)/2)$.
• November 4th 2012, 12:08 PM
Deveno
Re: direct image inverse image
since we are dealing with R2, which is finite-dimensional, we can use matrices. of course, to do that, we need to pick a basis, so we can use that basis to turn f into a matrix.

but the standard basis B = {(1,0),(0,1)} will do just fine.

note that f(1,0) = (1,1), and f(0,1) = (1,-1), so relative to the standard basis f has the matrix:

$M = \begin{bmatrix}1&1\\1&-1 \end{bmatrix}$.

this has determinant -2 ≠ 0, so it has an inverse matrix M-1, which corresponds to f-1 (relative to the same (standard) basis).

the inverse is found to be:

$M^{-1} = \begin{bmatrix}\frac{1}{2}&\frac{1}{2}\\ \frac{1}{2}&-\frac{1}{2} \end{bmatrix}$.

thus f-1(x,y) = (1/2)(x+y,x-y), as the previous posts have already indicated.

R2 has a particularly simple subspace structure:

if U is a subspace of R2, there are 3 possibilities:

U = R2 (the only 2-dimensional subspace)

U = {a(x0,y0): a in R}, the set of all scalar multiples of a particular non-zero vector (x0,y0) of R2 (1-dimensional subspaces)

U = {(0,0)} (the only trivial subspace).

since f is bijective, if U = R2, then f(U) = f(R2) = R2, and f-1(U) = f-1(R2) = R2.

similarly if U = {(0,0)}, f(U) = {(0,0)} and f-1(U) = {(0,0)}.

so the only "interesting" case is where U = {a(x0,y0): a in R}.

by the linearity of f (or by the linearity of the matrix for f, which is the same thing), f(U) = {a(x0+y0,x0-y0): a in R}.

for example if (x0,y0) = (3,4), f(U) has basis {(7,-1)}.

interestingly enough, f-1 = (1/2)f, so f-1(U) = f(U) (since for any non-zero vector v, {v} and {(1/2)v} generate the same subspace).

*********

while the x-axis and the y-axis are indeed each subspaces of R2 (as is any line through the origin), they are by no means the ONLY subspaces of R2.
• November 5th 2012, 01:35 AM
jojo7777777
Re: direct image inverse image
Thank you very much...your answers are explained clearly and help to put in order the information I have...
Just a point I wish to make sense out of it...According to the book (whence this question) the answer involves "the image of the line y=mx where m ≠ 1 is the line y=x(1+m)/(1-m)", how does it fit?
• November 5th 2012, 07:59 AM
Deveno
Re: direct image inverse image
claim: the subset U = {(x,y) in R2: y = mx} is a subspace of R2 of dimension 1.

proof:

we must show 3 things:

a) if (u,v) and (u',v') are in U, so is (u,v) + (u',v').
b) if c is any real number, and (u,v) is in U, so is c(u,v).
c) (0,0) is in U.

we start with (a). if (u,v) and (u',v') are in U, then v = mu, and v' = mu'.

thus (u,v) + (u'v') = (u,mu) + (u',mu') = (u+u',mu+mu'), and mu+mu' = m(u+u'), so (u,v) + (u'v') is in U.

now (b): if (u,v) is in U, then v = mu. so c(u,v) = c(u,mu) = (cu,c(mu)). since c(mu) = (cm)u = (mc)u = m(cu), we see c(u,v) is also in U.

and finally, (c): (0,0) = (0,m0), so (0,0) is in U.

this shows U is indeed a subspace of R2. to prove it has dimension 1, we need to find a basis.

i claim {(1,m)} is a basis for U. clearly this is linearly independent, since (1,m) is a non-zero vector. so all we have to do is show {(1,m)} spans U.

again, suppose that (x,y) is any point of U. then, by the definition of U, y = mx, so (x,y) = (x,mx). thus (x,y) = (x,mx) = x(m,1), so {(m,1)} spans U.

claim 2: if U is a 1-dimensional subspace of R2, then either U is the line y = mx, for some real number m, or U is the y-axis.

suppose U is not the y-axis. since U is one dimensional, some non-zero vector (a,b) is a basis for U. suppose that a ≠ 0.

let m = b/a. then for any vector (x,y) in U, (x,y) = c(a,b) = (ca,cb). thus y = cb = c(b/a)a = (b/a)(ca) = m(ca) = mx, that is: U is the line y = mx.

on the other hand, suppose our basis for U is (0,b), where b ≠ 0. then U = {(x,y) in R2: (x,y) = c(0,b), for some c in R}.

but c(0,b) = (0,cb), so every point of U lies on the y-axis, and every point of the y-axis is in U, so U = the y-axis.

***********

so yes, the 1-dimensional subspaces of R2 are "lines through the origin" (perhaps explaining why its called "linear" algebra: bases consisting of a single vector are LINES, lines are the "building blocks" by which we make "bigger spaces" (planes, and 3-spaces, etc.)).

***********

now a linear map, takes lines (through the origin) to "some other lines" (also through the origin).

consider, what happens when we take f and apply it to the vector (x,mx) (that is: a point lying on the line y = mx).

we get f(x,mx) = (x + mx,x - mx).

which line is this?

we can use the "two-point" formula for a line:

$y - y_1 = \left(\frac{y_2-y_1}{x_2-x_1}\right)(x - x_1)$

which two points shall we use?

how about (x1,y1) = f(0,0) = f(0,m0) = (0+m0,0-m0) = (0,0), and:

(x2,y2) = f(1,m) = (1+m,1-m)

then our line formula becomes:

$y - 0 = \left(\frac{1-m-0}{1+m-0}\right)(x - 0)$

which simplifies to y = [(1-m)/(1+m)]x (perhaps there is a typo in your book?).

the "bad value" for m would be m = -1:

in this case, f maps (x,-x) to (0,2x), which lies on the y-axis (a line of "infinite slope", that is: vertical).
• November 6th 2012, 06:58 AM
jojo7777777
Re: direct image inverse image
I am grateful to you for your help...! It is a perfect explanation!


text:
# 1 Functions

You can do a lot with the basic operators like +, -, and *, but to do more advanced calculations you’re going to need to start using functions.1

Watch this 1-minute video for a quick summary of functions

R has a lot of very useful built-in functions. Suppose I wanted to take the square root of 225. The usual notation for this is $$\sqrt{25}=5$$, though sometimes you’ll also see it written like this $$25^{0.5} = 5$$. This second way of writing it is kind of useful to “remind” you of the mathematical fact that “square root of $$x$$” is actually the same as “raising $$x$$ to the power of 0.5”. And since we already know how to raise things to powers in R, we could do this:

225 ^ 0.5
## [1] 15

However, we could also compute this using R’s built-in square root function sqrt():

sqrt(225)
## [1] 15

Not sure what a particular function does? You can ask R for help by typing ? and then the function name, and R will return documentation on the function. For example, ?sqrt() will return information about the sqrt() function.

## 1.1 Some common functions

Function Description Example
exp() Exponential exp(0) returns 1
sqrt() Square root sqrt(64) returns 8
log(x) Natural log of x log(1) returns 0
factorial() Factorial factorial(5) returns 120
round(x, digits=0) Round x to the digits decimal place round(3.1415, digits=2) returns 3.14
abs(x) Absolute value of x abs(-42) returns 42

## 1.2 Combining functions

In the same way that R allows us to put multiple operations together into a longer command (like 1 + 2 * 4 for instance), it also lets us put functions together and even combine functions with operators if we so desire. For example, the following is a perfectly legitimate command:

sqrt(1 + abs(-8))
## [1] 3

When R executes this command, starts out by calculating the value of abs(-8), which produces an intermediate value of 8. The command then simplifies to sqrt(1 + 8). To solve the square root2 it first needs to add 1 + 8 to get 9, at which point it evaluates sqrt(9), and so it finally outputs a value of 3.

# 2 Arguments

When we use a function to do something, we generally refer to this as calling the function. The values that we type into the function are referred to as the arguments of that function. Some functions can have more than one argument.

Watch this 1-minute video for a quick summary of arguments

## 2.1 Multiple arguments

Some functions have more than one argument. For example, the round() function can be used to round some value to the nearest whole number. For example, I could type this:

round(3.1415)
## [1] 3

Pretty straightforward. However, suppose I only wanted to round it to two decimal places: that is, I want to get 3.14 as the output. To do this, you can input a second argument that specifies the number of decimal places that you want to round the number to. To get 3.14, I would type this:

round(3.14165, 2)
## [1] 3.14

## 2.2 Argument names

In this simple example, it’s not too hard to remember which argument comes first and which one comes second, but it starts to get very difficult once you start using complicated functions that have lots of arguments. Fortunately, most R functions use argument names to make your life a little easier. For the round() function, for example, the number that needs to be rounded is specified using the x argument, and the number of decimal points that you want it rounded to is specified using the digits argument:

round(x = 3.1415, digits = 2)
## [1] 3.14

## 2.3 Default values

Notice that the first time I called the round() function I didn’t actually specify the digits argument at all, and yet R somehow knew that this meant it should round to the nearest whole number. How did that happen? The answer is that the digits argument has a default value of 0, meaning that if you decide not to specify a value for digits then R will act as if you had typed digits = 0. This is quite handy: most of the time when you want to round a number you want to round it to the nearest whole number, and it would be pretty annoying to have to specify the digits argument every single time. On the other hand, sometimes you actually do want to round to something other than the nearest whole number, and it would be even more annoying if R didn’t allow this! Thus, by having digits = 0 as the default value, we get the best of both worlds.

Finally, not all functions have (or require) arguments:

date()
## [1] "Tue May 26 18:18:39 2020"

# 3 Objects

In R, all “assignments” have this form:

objectName <- value

where the arrow, <-, means “assign value to objectName”.

Watch this 1-minute video for a quick summary of objects

The operator <- is a pain to type, so RStudio has a keyboard shortcut: Alt + - (the minus sign). RStudio offers many other handy keyboard shortcuts. Also, Alt+Shift+K brings up a keyboard shortcut reference card.

To practice, try assigning 2 to x:

x <- 2

Now type x again - notice that it returns the value assigned to it!

x
## [1] 2

If you overwrite an object with a different value, R will “forget” the previous assigned value and only keep the new assignment:

x
## [1] 2
x <- 42
x
## [1] 42

A note on formatting: Always surround <- with spaces! Otherwise your code can be confusing. For example, if you typed x<-2 (no spaces), it’s not clear if you meant x <- 2 or x < -2. The first one assigns 2 to x, but the second one compares whether x is less than -2.

## 3.1 Object names

You can choose almost any name you like for an object, as long as the name does not begin with a number or a special character like +, -, *, /, ^, !, @, or &. You will be wise to adopt a convention for demarcating words in names. Here are a few:

• snake_case_is_one_choice
• other.people.use.periods
• camelCaseIsAlsoGood

Make another assignment:

this_is_a_really_long_name <- 2.5

To inspect this, try out RStudio’s completion facility: type the first few characters, press TAB - voila! RStudio auto-completes the long name for you :)

R is case sensitive. To understand what this means, try this:

cases_matter <- 2^2
Cases_matter <- 2^3

Let’s try to inspect:

cases_matter
## [1] 4
Cases_matter
## [1] 8

Although the two objects look similar, one has a capital “C”, and R stores that as a different object.

In general, type carefully. Typos matter. Case matters. Get better at typing.

## 3.2 The workspace

Look at your workspace in the upper right pane. The workspace is where user-defined objects accumulate. You can also get a listing of these objects with commands:

objects()
## [1] "cases_matter"               "Cases_matter"
## [3] "this_is_a_really_long_name" "x"
ls()
## [1] "cases_matter"               "Cases_matter"
## [3] "this_is_a_really_long_name" "x"

If you want to remove the object named x, you can do this

rm(x)

To remove everything, use this:

rm(list = ls())

or click the broom in RStudio’s Environment pane.

# 4 Data types

Every programming language has the ability to store data of different types. R recognizes several important basic data types (there are 6 total, but these 4 are all we’ll ever use):

Type Description Example
numeric Numbers 3.14, 42, 1.61803398875
integer A number with no decimal 1L, 7L
character Text data, a.k.a. “strings” "this is a string", "3.14"
logical Used for comparing objects TRUE, FALSE

To assess the type of any variable, R has two different functions:

• class() tells us the high level object type
• typeof() tells us the low level object type

We’ll use these to explore each data type.

## 4.1 Numeric types

Numbers in R are of the numeric data type, and it is the default computational type. There are two types of numeric data types: integers and floats. The difference is floats have decimals and integers don’t. At the lower level, floats have the type “double” while integers have the type “integer”.

By default, R assumes all numbers are floats, even if it looks like an integer:

class(3.14)
## [1] "numeric"
class(3)
## [1] "numeric"
typeof(3.14)
## [1] "double"
typeof(3)
## [1] "double"

The fact that 3 is not an integer can be confirmed with the is.integer()function:

is.integer(3)
## [1] FALSE

To make a number an integer, you have to either add an L to the end, or use the as.integer() function to coerce it into an integer type:

typeof(3L)
## [1] "integer"
typeof(as.integer(3))
## [1] "integer"

Note that you can have a decimal of 0 but the data types can be different:

typeof(7)
## [1] "double"
typeof(7.0)
## [1] "double"
typeof(7L)
## [1] "integer"

## 4.2 Character types

A character object is used to represent string values in R. Anything put between single quotes ('') or double quotes ("") will be stored as a character. For example:

s <- '3.14'
class(s)
## [1] "character"

Notice that even though the value assigned to s is a number, it is stored as a character because the number is surrounded by quotes. If you mistakenly thought it was stored as a number, R will gladly return an error when you try to do a numerical operation with it:

s + 7
## Error in s + 7: non-numeric argument to binary operator

We can also convert objects into character values with the as.character() function:

a_number <- 3.14
class(a_number)
## [1] "numeric"
a_string <- as.character(a_number)
class(a_string)
## [1] "character"

We will go into much more detail about character data later on in Week 6

## 4.3 Logical types

A logical value is usually created when comparing variables. For example, let’s compare whether one value is greater than another:

x <- 1
y <- 2
z <- x > y # Is x greater than y?
z
## [1] FALSE

The object z now stores the value (FALSE) that resulted from comparing x and y.

To compare whether two values are equal, you have to type the = sign twice:

x == y
## [1] FALSE

Here I am asking, “is x equal to y”? In this case, the answer is FALSE.

We will go into more detail about comparing values in R later on in Week 4

## 4.4 Special values

In addition to the four main data types mentioned, there are a few additional “special” types: Inf, NaN, NA and NULL.

Infinity: Inf corresponds to a value that is infinitely large. You can also have -Inf. The easiest way to get Inf is to divide a positive number by 0:

1/0
## [1] Inf

Not a Number: NaN is short for “not a number”, and it’s basically a reserved keyword that means “there isn’t a mathematically defined number for this.” For example:

0/0
## [1] NaN

Not available: NA indicates that the value that is “supposed” to be stored here is missing. We’ll see these much more when we start getting into data structures like vector, matrices, and data frames.

No value: NULL asserts that the variable genuinely has no value whatsoever, or does not even exist.

## 4.5 Coercing data types

In general, you can force an object into a different type using as.something(), replacing “something” with a data type:

as.numeric(3.1415)
## [1] 3.1415
as.integer(3.1415)
## [1] 3
as.character(3.1415)
## [1] "3.1415"
as.logical(3.1415)
## [1] TRUE

Note that as.logical() returns TRUE for any numeric value other than 0, for which it returns FALSE.

If you try to coerce a string into a number, R will return NA:

as.numeric('foo')
## Warning: NAs introduced by coercion
## [1] NA

If you want to force a float number (i.e. one with decimals) into an integer value, but you don’t want to change the actual type to an integer type, use round(), ceiling(), or floor(). This will turn the number into an integer in value, but will still technically be float types. Note that these functions produce different outcomes.

round(3.1415)   # Typical rounding
## [1] 3
ceiling(3.1415) # Rounds *up* to nearest integer
## [1] 4
floor(3.1415)   # Rounds *down* to nearest integer
## [1] 3

# 5 Packages

When you start R, it only loads the “Base R” functions. But there are thousands and thousands of additional functions stored in packages.

Watch this 1-minute video for a quick summary of packages

There is a critical distinction that you need to understand, which is the difference between having a package installed on your computer, and having a package loaded in an R session. You only need to install a package to your computer once, but you will need to load it whenever you want to use it in any one R session. This relationship is illustrated in the image below:

When installing a package, you must put the package name in quotes:

install.packages("packagename") # This works
install.packages(packagename)   # This doesn't work

When loading a package in an R session, you don’t have to use quotes (but you can if you want):

library("packagename") # This works
library(packagename)   # This also works

As an example, try installing the Wikifacts package, by Keith McNulty:

install.packages("wikifacts") # Remember - you only have to do this once!

Now that you have the package installed on your computer, try loading it using library(wikifacts), then trying using some of it’s functions:

library(wikifacts) # Load the library
wiki_randomfact()
## [1] "Did you know that on this day in 1328 – English friar William of Ockham, who popularised the methodological principle known as Occam's razor, secretly left Avignon under threat from Pope John XXII. (Courtesy of Wikipedia)"
wiki_didyouknow()
## [1] "Did you know that CIA officer Howard Bane proposed that the Special Operations Group storm the Chinese embassy in Ghana and kill all its occupants during the 1966 coup? (Courtesy of Wikipedia)"

In case you’re wondering, the only thing this package does is generate messages containing random facts from Wikipedia.

# 6 Tips

## 6.1 Check if a number is an integer

If you use the is.integer() function to check if a number that looks like an integer, you might get a surprising result:

is.integer(7)
## [1] FALSE

This is because the default numeric type is a float. The safer way to check if a number is an integer in value is to compare it against itself as an integer:

7 == as.integer(7)
## [1] TRUE

In your assignments, use this method to check if something is an integer!

Page sources:

Some content on this page has been modified from other courses, including:

Footnotes

1. Technically speaking, operators are functions in R: the addition operator + is a convenient way of calling the addition function '+'(). Thus 10+20 is equivalent to the function call '+'(20, 30). Not surprisingly, no-one ever uses this version.↩

2. R does support complex numbers, but unless you explicitly specify that you want them it assumes all calculations must be real valued. By default, the square root of a negative number is treated as undefined: sqrt(-9) will produce NaN (not a number) as its output. To get complex numbers, you would type sqrt(-9+0i) and R would now return 0+3i.↩

EMSE 6574, Sec. 11: Programming for Analytics (Fall 2019)
George Washington University | School of Engineering & Applied Science
Dr. John Paul Helveston | jph@gwu.edu | Mondays | 6:10–8:40 PM | Phillips Hall 108 | |


text:
# Simplify huge chain of if's and else's, some of them quite similar to each other

If anyone could help me simplify this code, it would be greatly appreciated. There are plenty of if's and else's, and someone else told me that using switch/case statements could really clean up the code. However, he didn't implement it for me, so I don't know what I should switch/case.

Also take note that the "if (!stricmp(argv[arg], "-vmf"))" and "if (!stricmp(argv[arg], "-bsp"))" blocks are exactly the same, minus the usage of "vmf" and "bsp", and that the "wad" block is somewhat similar.

#include <cstdio>
#include <cstring>
#include <fstream>
#include <sys\stat.h>

#include "arg.h"
#include "files.h"
#include "stricmp.h"

using namespace std;

//"ifError" takes all the argument flags, as well as a string to output. If silent flag is
//enabled, then "ifError" will not output that text. I put this into the function to reduce
//lines and characters of code.
void ifError(argFlags& argFlags, char* errorMessage)
{
if (!argFlags.sil)
{
if (!argFlags.err)
{
printf("Converts DOOM WAD into VMF and/or BSP file(s).\n\n");
printf("DOOM2BSP [-silent] [-WAD [path][name]] [-VMF [path]] [-BSP [path]]\n\n");
printf("  -VMF     Create VMF file(s) in path.\n");
printf("  -BSP     Create BSP file(s) in path.\n");
printf("  -silent  Disable text output.\n\n");
}
printf(errorMessage);
}
argFlags.err = true;
}

//Checks if directory exists.
bool checkDir(char* path)
{
struct stat st;
if (!stat(path, &st))
if (st.st_mode & S_IFDIR != 0)
return true;
return false;
}

//This function analyzes our arguments, deals with them accordingly, and decides if there
//are any errors or not. Also opens wad if it exists.
void handleArgs(argFlags& argFlags, files& files, int& argc, char**& argv)
{
//Analyzes all arguments to find "-silent" arg. If silent arg is found, the silent flag
//is turned on, signifying that this program should not output any text.
for (int arg = 1; arg < argc; ++arg)
if (!stricmp(argv[arg], "-silent"))
argFlags.sil = true;

//Analyzes the rest of the arguments, with the silent flag in mind.
for (int arg = 1; arg < argc; ++arg)
{
//found, check if for its validity and existance. If check fails or if wad name arg
{
if ((arg + 1) < argc)
{
files.wad.open(argv[arg + 1], fstream::out | fstream::binary);
ifError(argFlags, "Error: WAD name is invalid or does not exist.\n");
}
else
ifError(argFlags, "Error: WAD name is not specified.\n");
}
//If the "-vmf" arg is found, turn on vmf flag. Look for vmf path name. If vmf path
//name is found, check for its validity and existance. If check fails or if vmf
else if (!stricmp(argv[arg], "-vmf"))
{
argFlags.vmf = true;
if ((arg + 1) < argc)
{
files.vmfPath = argv[arg + 1];
if (!checkDir(files.vmfPath))
ifError(argFlags, "Error: VMF path is invalid or does not exist.\n");
}
else
ifError(argFlags, "Error: VMF path is not specified.\n");
}
//If the "-bsp" arg is found, turn on bsp flag. Look for bsp path name. If bsp path
//name is found, check for its validity and existance. If check fails or if bsp
else if (!stricmp(argv[arg], "-bsp"))
{
argFlags.bsp = true;
if ((arg + 1) < argc)
{
files.bspPath = argv[arg + 1];
if (!checkDir(files.bspPath))
ifError(argFlags, "Error: BSP path is invalid or does not exist.\n");
}
else
ifError(argFlags, "Error: BSP path is not specified.\n");
}
}

//Decently self-explanatory.
if (argc == 1)
ifError(argFlags, "Error: No parameters.\n");
else if ((!argFlags.vmf) && (!argFlags.bsp))
ifError(argFlags, "Error: VMF/BSP parameters missing.\n");
}

-
I think you should read a book about refactoring code, as it will help you to understand the changes you will make, and how to set up testing, etc. –  Horus Feb 11 '13 at 3:53
–  Nicol Bolas Feb 11 '13 at 5:18
I'll take this opportunity to strongly recommend reading Clean Code by Robert C. Martin. The examples may be in Java, but it really applies to any language. –  codesparkle Feb 15 '13 at 18:03

I think you should separate the logic parsing the arguments provided from the logic using the argument parsed. At the moment, you are trying to do everything in one place and I'm not quite sure this is correct (for instance, if a filename is also an option name, this leads to an unexpected behavior).

I'd suggest something like (I'm not even sure it would compile but that just to give you an idea) :

void handleArgs(argFlags& argFlags, files& files, int& argc, char**& argv)
{
int waitingForArg = 0; // To know if we are expecting an other argument to be provided : 0:no, 1:wad, 2:vmf, 3:bsp
for (int i = 1; i < argc; i++)
{
char* arg = argv[i];
switch (waitingForArg)
{
case 0:
if (!stricmp(arg, "-silent"))
argFlags.sil = true;
waitingForArg = 1;
else if (!stricmp(arg, "-vmf")
waitingForArg = 2;
else if (!stricmp(arg, "-bsp")
waitingForArg = 3;
break;
case 1:
argFlags.wadFile = arg; waitingForArg = 0;
break;
case 2:
argFlags.vmfFile = arg; waitingForArg = 0;
break;
case 3:
argFlags.bspFile = arg; waitingForArg = 0;
break;
}
}

if (waitingForArg)
{
ifError(argFlags, "Error: file name must be provided with option -wad, -vmf or -bsp");
return;
}

// Logic involving wadFile, wmfFile, bspFile. Checking if they are set and/or if they correspond to existing files.
}

This is just a first step to make things easier to follow (on top of being more correct and more efficient).

Then to remove code duplication, you might want to do something like using an array to store the different possible options (["-wad","-vmf","-bsp"]). In order to do so, you'd replace the "else if (!stricmp(arg, "OPTIONS"))" with a loops on the different options. Then you might also be happy to store the flags as an array. I think this would make more sense if you had more flags to handle.

I also notice that you have tagged your question as C++ but your code seems to be using some C-style (printf and stuff). This might be something you should fix as well.

-

Josay is correct and you should accept his answer. I'd like to mention a few more things.

1. Please use braces everywhere, the code you're using is known to lead to difficult reading and subtle bugs. Consider:

if (condition)
a();
b();

b() will be executed unconditionally.

2. switch wouldn't have helped with your code since you can only switch on integers. It doesn't make the code much shorter unless you have a lot of cases to handle, and the main benefit isn't shorter code anyway: it's better readability.

3. stricmp is Windows-only, the POSIX equivalent is strcasecmp, but I don't think Windows supports it. If you want to be cross-platform, go for Boost and iequals.
4. You're using C++, so you may want to take advantage of it. With your current code it mostly means using string instead of char* and std::cout instead of printf.
-

Here's a version of ifError() with reduced nesting level by bailing out with an early return:

void ifError(argFlags& argFlags, char* errorMessage)
{
argFlags.err = true;
if (argFlags.sil)
return;
if (!argFlags.err)
{
printf("Converts DOOM WAD into VMF and/or BSP file(s).\n\n");
printf("DOOM2BSP [-silent] [-WAD [path][name]] [-VMF [path]] [-BSP [path]]\n\n");
printf("  -VMF     Create VMF file(s) in path.\n");
printf("  -BSP     Create BSP file(s) in path.\n");
printf("  -silent  Disable text output.\n\n");
}
printf(errorMessage);
}

In checkDir() you can merge the two if statements. Make sure to keep the same order, because the second condition needs to operate on st which is initialized in the first condition:

bool checkDir(char* path)
{
struct stat st;
if (!stat(path, &st) && st.st_mode & S_IFDIR != 0)
return true;
return false;
}

There's not much to simplify in handleArgs(). Note that using switch is not possible because in C++ strings cannot be used with switch (neither C-strings, nor std::string.)

-

I suggest using a table of :

for each entry in table do:
if entry.text == parameter
execute entry.function_pointer
end-if
end-for

Example table:

"WAD", Process_WAD_argument
"VMF", Process_VMF_argument

The nice feature about tables in this scenario is that you can add parameters without changing the parsing code: add another line to the table.

-


text:
#StackBounty: #self-study #pca #linear-model #functional-data-analysis Asymptotic properties of functional models

Bounty: 100

When working in Functional Data Analysis, a classical "preprocessing" step is to represent the "observations" using a B-spline expansion:

$$X_i(t) approx sum_{j=1}^J lambda_{ij} f_j(t) qquad i=1, ldots, n$$

where $$J$$ is the number of elements in the basis and $$f_1, ldots, f_J$$ are suitably defined B-spline functions.
Then, statistical methods are performed by working directly on the coefficients $${lambda_{ij}}$$.

My question is if there are some asymptotic guarantees that as the number of data $$n$$ and the truncation level $$J$$ increase to $$+infty$$ the statistical methods converge to a "true" idealized solution.

In particular, I’m interested in functional on functional regression an functional PCA.
I know the literature is huge, but it would be great to have some papers to start from!

Get this bounty!!!

This site uses Akismet to reduce spam. Learn how your comment data is processed.


text:
# Treating the spinors as Grassmann numbers or as c-number objects

+ 2 like - 0 dislike
209 views

In the literature on supersymmetry, the following spinor summation convention is often used (eg. Wess & Bagger's book Supersymmetry and Supergravity) $$\psi\chi = \psi^{\alpha}\chi_{\alpha} = -\psi_{\alpha}\chi^{\alpha} = \chi^{\alpha}\psi_{\alpha} = \chi\psi$$ where the spinors are treated as Grassmann numbers and anticommute with each other. However, in some articles like arXiv:hep-th/0312171, the angle spinor bracket is defined as $$\langle\lambda_1\lambda_2\rangle = \lambda_1^{\alpha}\lambda_{2\alpha} = \varepsilon_{\alpha\beta} \lambda_1^{\alpha}\lambda_2^{\beta} = -\varepsilon_{\beta\alpha} \lambda_2^{\beta}\lambda_1^{\alpha} = -\lambda_2^{\beta}\lambda_{1\beta} = -\langle\lambda_2\lambda_1\rangle$$ Here the spinors are treated as c-number objects and commute with each other. Why can we use such two different conventions? Are they contradictory?

This post imported from StackExchange Physics at 2014-12-08 12:15 (UTC), posted by SE-user soliton
asked Dec 8, 2014
The spinors in Wess & Bagger corresponds to fermionic fields and hence have anti-commuting components. The spinors in Witten's papers, on the other hand, are part of the twistor formalism and encode the momentum in a convenient way. They do not represent fields and are not fermionic, so their components still commute.

This post imported from StackExchange Physics at 2014-12-08 12:15 (UTC), posted by SE-user Olof

+ 0 like - 0 dislike

Lorentz spinors appear as irreducible representations of the group SL(2,C). Elements of the group are 2x2 matrices with complex entries and unity determinant. A Lorentz spinor is a two component vector $\psi^{A},\chi^{A}\in V_{2}$ with $A=1,2$. The Levi-Civita tensor $\epsilon_{AB}$ is an invariant tensor under SL(2,C). This means that if we have an irrep $\psi^{A}$ of SL(2,C) we can transform it with the Levi-Civita tensor and this will give an equivalent irrep. So, the covariant vectors $\psi_{A}\in \tilde{V}_{2}$ made as $\psi_{A}=\psi^{B}\epsilon_{BA}$ are equivalent to the contravariant vectors $\psi^{A}$; it doesn't matter whether we use $\psi^{A}$ or $\psi_{A}$ because both quantities represent the same physical thing.

The situation is the same as in Minkowski spacetime when we use $x^{\mu}$ or $x_{\mu}=\eta_{\mu\lambda}x^{\lambda}$. Covariant and contravariant vectors in Minkowski spacetime are equivalent irreps of the Lorentz group $O(1,3)$ because the metric $\eta_{\mu\lambda}$ is an invariant tensor.

The only problem with using the Levi-Civita tensor to lower a spinor index is that it is antisymmetric so that it matters which index is summed. I've decided to lower spinor indices as $\psi_{A}=\psi^{B}\epsilon_{BA}$ and so, for consistency, I've got to stick to this convention and not be tempted to use $\psi_{A}=\epsilon_{AB}\psi^{B}$.

Having picked a lowering convention, I'm forced to raise a spinor index with $\psi^{A}=\epsilon^{AB}\psi_{B}$ because then both operations are consistent. $$\psi_{A}=\psi^{B}\epsilon_{BA}=\epsilon^{BC}\psi_{C}\epsilon_{BA}=\delta^{C}_{A}\psi_{C}=\psi_{A}$$

Now we can make a SL(2,C) scalar $\psi_{A}\chi^{A}=\chi^{A}\psi_{A}$. The order of the vectors does not matter because the components $\psi^{1},\psi^{2}$ are just complex numbers. The following bit of index gymnastics recovers the property in the second equation in soliton's question. $$\psi_{A}\chi^{A}=\psi^{B}\epsilon_{BA}\chi^{A}=-\psi^{B}\chi^{A}\epsilon_{AB}=-\psi^{A}\chi_{A}$$

Everything so far has been classical. When we go over to quantum theory, the spinors are promoted to operators $\psi^{A}\rightarrow \hat{\psi}^{A}$. These operators represent fermions: as operators, they have to obey anticommutation relations, in this case $[\hat{\psi}^{A},\hat{\chi}^{B}]_{+}=0$. So, repeating the last calculation with operators, $$\hat{\psi}_{A}\hat{\chi}^{A}=\hat{\psi}^{B}\epsilon_{BA}\hat{\chi}^{A}=-\hat{\psi}^{B}\hat{\chi}^{A}\epsilon_{AB}=-\hat{\psi}^{A}\hat{\chi}_{A}=+\hat{\chi}_{A}\hat{\psi}^{A}$$ recovers the first equation in soliton's question.

I have to own up to the fact that I've not yet studied supersymmetry, but I think this is what must be going on based on general principles.

This post imported from StackExchange Physics at 2014-12-08 12:15 (UTC), posted by SE-user Stephen Blake
answered Dec 8, 2014 by (70 points)

 Please use answers only to (at least partly) answer questions. To comment, discuss, or ask for clarification, leave a comment instead. To mask links under text, please type your text, highlight it, and click the "link" button. You can then enter your link URL. Please consult the FAQ for as to how to format your post. This is the answer box; if you want to write a comment instead, please use the 'add comment' button. Live preview (may slow down editor)   Preview Your name to display (optional): Email me at this address if my answer is selected or commented on: Privacy: Your email address will only be used for sending these notifications. Anti-spam verification: If you are a human please identify the position of the character covered by the symbol $\varnothing$ in the following word:p$\hbar$ysicsOver$\varnothing$lowThen drag the red bullet below over the corresponding character of our banner. When you drop it there, the bullet changes to green (on slow internet connections after a few seconds). To avoid this verification in future, please log in or register.


text:
TH BSM Forum

# Gauge Anomaly Cancellation in Effective Field Theories

## by Ferruccio Feruglio (University of Padova)

Europe/Zurich
Zoom only (CERN)

### Zoom only

#### CERN

Description

In Effective Field Theories, gauge anomalies are expected to be determined by the charge assignment of the fermion sector, as in renormalizable theories. Nevertheless, the mechanism of gauge anomaly cancellation is nontrivial and has direct consequences on the computation of physical quantities. By considering a simple explicit model that mimics the SMEFT properties and includes a complete set of dimension six operators, the (candidate) anomaly is evaluated in the regularized theory. The contribution to the anomaly from the non-renormalizable sector can be removed by a local counterterm, having a direct impact on the computation of scattering amplitudes in perturbation theory.

https://cern.zoom.us/j/99113688676


text:
© 2019 GitHub, Inc.

## Cumulative Distribution Function (CDF)

There are many ways of specifying distributions. We have sometimes used a table to display the distribution of a random variable $X$. At other times we have written $P(X = k)$ as a formula for each possible value $k$ of $X$.

Another useful function that encapsulates all the information about the distribution of $X$ is called the cumulative distribution function of $X$. That's a real mouthful, so it is usually abbreviated to the cdf of $X$.

Let's see what the cdf is in an example.

Suppose $X$ has the distribution given below. It happens to be the binomial $(3, 1/2)$ distribution, but that is not important for this discussion.

$~~~~~~~~~~~~~~~~~~~~~x$ 0 1 2 3
$P(X=x)$ 1/8 3/8 3/8 1/8

The cdf of $X$ is another way of providing the same information. It is the function $F$ defined by

$$F(x) ~ = ~ P(X \le x), ~~~~~ -\infty < x < \infty$$

The cdf of the random variable $X$, evaluated at the point $x$, is the chance that the value of $X$ is at most $x$.

The gold area in the probability histogram below is $F(2)$.

We will sometimes use the loose term "left hand probabilities" to denote values of $F$. Each of those values $F(x)$ is the area of the bar at $x$ as well as all the bars to the left. In the figure above,

$$F(2) ~ = ~ P(X \le 2) ~ = ~ P(X = 0) + P(X = 1) + P(X = 2)$$

We will now augment the distribution table by a row containing some values of $F$. These are obtained obtained by adding the probabilities $P(X=x)$ successively from the left end. This cumulative sum is the reason for the name of the function.

$~~~~~~~~~~~~~~~~~~~~~x$ 0 1 2 3
$P(X=x)$ 1/8 3/8 3/8 1/8
$F(x)$ 1/8 4/8 7/8 1

Notice that we can recover $P(X=x)$ from values of $F$ as follows. For integer $x$,

$$P(X = x) ~ = ~ P(X \le x) - P(X \le x-1) ~ = ~ F(x) - F(x-1)$$

These calculations show that if you know the distribution of $X$ then you know the cdf of $X$, and vice versa. The distribution and the cdf contain the same information.

### Graph of the CDF

The graph of every cdf has some properties that are easy to see:

• The graph is non-decreasing.
• The values are on the vertical axis are probabilities and hence are between 0 and 1.
• The graph starts out at or near 0 for large negative values of $x$, and ends up at or near 1 for large positive values of $x$.

You can see all these properties in the graph of the function $F$ defined above.

You can see also that the graph has flat parts and jumps.

• Flat parts: These are in-between the possible values of $X$ and also beyond the possible values in both directions. Since $X$ is a non-negative variable, for all negative $x$ we have $F(x) = P(X \le x) = 0$. Since $X$ is always at most 3, for all $x > 3$ we have $F(x) = P(X \le x) = 1$. For $x$ in between two possible values, say $x = 1.6$, we have $F(1.6) = P(X \le 1.6) = P(X \le 1) = F(1)$. So for $x \in [1, 2)$, the graph is flat at $F(1)$. You can explain all the other flat parts analogously.

• Jumps: The graph has a jump (or discontinuity) at each possible value $x$ of $X$. That is, the graph jumps at each value $x$ such that $P(X = x) > 0$. The size of the jump at $x$ is equal to $P(X = x)$. For example, $P(X = 2)$ is the size of the jump at $x=2$, which is $0.875 - 0.5 = 0.375 = 3/8$.

### Computation

We will have many uses for the cdf in this course. In fact, we have already used it several times without giving it a name.

For example, the chance of at most 3 sixes in 20 rolls of a die is given by the binomial formula and the addition rule:

$$P(\text{at most 3 sixes in 20 rolls}) ~ = ~ \sum_{k=0}^3 \binom{20}{k}(1/6)^k(5/6)^{20-k}$$

This can be computed as

sum(stats.binom.pmf(np.arange(4), 20, 1/6))

0.5665456377756688

Let $X$ be the number of sixes in 20 rolls. Then $X$ has the binomial $(20, 1/6)$ distribution. The answer above is $P(X \le 3)$. That's $F(3)$ where $F$ is the cdf of $X$.

The stats module includes a cdf method that allows us to obtain the answer directly without summing.

The expression stats.binom.cdf(k, n, p) evaluates to $F(k)$ where $F$ is the cdf of a binomial $(n, p)$ random variable.

So our answer can also be found as follows.

stats.binom.cdf(3, 20, 1/6)

0.5665456377756695

Probabilities are frequently computed as sums. The cdf is a very useful tool for doing this, so stats provides a cdf method associated with each distribution.

You can use stats.hypergeom.cdf(k, N, G, n) to find the value of $F(k)$ for a random variable that has the hypergeometric $(N, G, n)$ distribution.

For example, recall that a standard deck contains 52 cards of which 12 are face cards. The chance of more than 5 face cards in a bridge hand of 13 cards dealt from a standard deck is

\begin{align*} &P(\text{more than 5 face cards in a hand of 13 cards}) \\ &= ~ 1 - P(\text{at most 5 face cards in the hand}) \\ &= ~ 1 - \sum_{k=0}^{5} \frac{\binom{12}{k}\binom{40}{13-k}}{\binom{52}{13}} \end{align*}

Now you can get the numerical value by using stats.hypergeom.pmf:

1 - stats.hypergeom.cdf(5, 52, 12, 13)

0.03246092516982357


text:
SEARCH HOME
 Math Central Quandaries & Queries
 Anita, a student: A variable Y has a distribution of mean of Y =80 and standard deviation of Y=36. Find the values of A and B for transforming y*=A +BY so that mean of y* =0 and standard deviation of y*=1.

Hi Anita,

What you are trying to find is standard normal distribution where mean is 0 and the standard deviation is 1. We can convert any normally distributed population to standard normal distribution using z-scores.

The z- score is z = (x-μ)/σ where
x is a raw score to be standardized
σ is the standard deviation of the population
μ is the mean of the population.

For example: Find the z-score corresponding to a raw score of 132 from a normal distribution with mean 100 and standard deviation 15.

z = (132-100)/15 = 32/15= 2.133

Our new raw score is 2.133.

Hope this helps,

Janice

Math Central is supported by the University of Regina and The Pacific Institute for the Mathematical Sciences.


text:
# Presentation: problem with figure captions

I am using LaTeX to make a presentation and I do not want to have captions labeled "Figure 1: " etc., so I followed the help from this page:

\setbeamertemplate{caption}{\raggedright\insertcaption\par}

that worked fine and I got only mine caption without "Figure:" before it. However, when I load the package subcaption (which I need because I am also doing subfigures), the above command stops working and it shows "Figure:" before the captions. Is there any way to use a package subcaption and be able to get rid of those at the same time in presentation?

• Yes, there is. Use the interface caption and subcaption provide. Is that all you wanted to know? You don't give any code, so I assume so. – cfr Jan 30 '18 at 2:26

If you want to use the subcaption package, you can use the mechanism of the caption package to change the appearance of the captions

\documentclass{beamer}

\usepackage[labelformat=empty]{caption}
\usepackage{subcaption}

\begin{document}

\begin{frame}
\begin{figure}
\caption{text}
\end{figure}
\end{frame}

\end{document}