text:
# Solving a convex resource allocation problem

I want to solve the following optimization problem

$$\begin{array}{ll} \text{maximize} & \displaystyle\sum_{i=1}^n \log_{2}(1+a_i x_i)\\ \text{subject to} & \displaystyle\sum_{i=1}^n (c_i - x_i) a_i = b\\ & 0 \leq x_i \leq c_i\end{array}$$

where $a_i \geq a_2 \geq \dots \geq a_n$, $b \in \mathbb R^+$ and $c_1 = c_2 = \dots = c_n$ are given.

I tried to solve this problem using Lagrange multipliers

$$\mathcal{L}(x,\lambda,\mu,\nu)=\sum_{i=1}^n\log_{2}(1+a_ix_i) + \lambda \left( \sum_{i=1}^n(c_i-x_i)a_i - b \right) - \mu_i (x_i-c_i) + \nu_ix_i$$

We need to have $\frac{d\mathcal{L}}{dx_i}=0$; therefore

$$\sum_{i=1}^n \frac{a_i}{\ln(2)\times(1+a_ix_i)}-\lambda a_i-\mu_{i}+\nu_{i}=0$$

In particular, my problem always has

$$\sum_{i=1}^{n-1} a_i c_i < b < \sum_{i=1}^n a_i c_i$$

How can I obtain the optimal values of $x_i$

• One "trick" would be to discard the inequality constraints and add $$\gamma \displaystyle\sum_{i=1}^n \left( \log (x_i) + \log (c_i -x_i) \right)$$ to the objective function, where $\gamma > 0$. In other words, "hard" constraints are replaced by "soft" constraints. – Rodrigo de Azevedo Mar 28 '18 at 14:15
• @RodrigodeAzevedo Thank you for your response.Does this mean that I need to solve the following optimization problem$\gamma \displaystyle\sum_{i=1}^n \left( \log (x_i) + \log (c_i -x_i) \right)$constrained by $\sum_{i}^{n}(c_i-x_i)a_i=b$. What abot $\gamma$? How can I deal with it? – user841315 Mar 28 '18 at 17:13
• No, you solve $$\begin{array}{ll} \text{maximize} & \displaystyle\sum_{i=1}^n \log_{2}(1+a_i x_i) + \gamma \displaystyle\sum_{i=1}^n \left( \log (x_i) + \log (c_i -x_i) \right)\\ \text{subject to} & \displaystyle\sum_{i=1}^n (c_i - x_i) a_i = b\end{array}$$ As you vary parameter $\gamma > 0$, you weigh more the original objective or the soft constraints. The optimal solution should not be the same as the optimal solution of the original problem, but it should be much easier to find. – Rodrigo de Azevedo Mar 28 '18 at 17:31
• @RodrigodeAzevedo Thank you for the clarification. It seems the optimal values of $x_i$ can be obtained only numerically. I thought an analytical solution exists for this problem. – user841315 Mar 28 '18 at 18:26

I think your best approach is duality. First, note that $\log_2$ and $\ln$ differ by a multiplicative constant $\ln(2)$. Thus, we can minimize with $\ln$ and obtain the same optimal value, and I will use $\ln$ instead of $\log_2$ in my derivations. Second, I will treat it as a minimization problem, and therefore write $-\ln$ instead of $\ln$.

Giving a Lagrange multiplier only to the equality constraint, you obtain the Lagrangian \begin{aligned} L(x, \lambda) &= -\sum_{i=1}^n \ln(1+a_i x_i) + \lambda \left[ \sum_{i=1}^n (c_i - x_i) a_i - b \right] \\ &= \sum_{i=1}^n \left[-\ln(1+a_i x_i) - \lambda a_i x_i \right] + \lambda \Bigl[\underbrace{-b + \sum_{i=1}^n a_i c_i}_{C} \Bigr] \end{aligned} Since the Lagrangian and the constraints $0 \leq x_i \leq c_i$ are both separable in $x_i$, the dual objective is: $$q(\lambda) = \sum_{i=1}^n \min_{x_i} \biggl\{ -\ln(1+a_i x_i) - \lambda a_i x_i :~ 0 \leq x_i \leq c_i \biggr\} + \lambda C$$ Note, that each of the elements in the sum above is a minimization of a convex function of the form $-\ln(1+ax) -bx$ over an interval, and it is quite easy to find a closed form solution (if you need help, please say so). From this solution you will also obtain a formula from recovering the optimal $x_i$ from the optimal $\lambda$.

Now, your dual problem is the one-dimensional optimization problem $\max_{\lambda} q(\lambda)$, which can be easily solved by a numerical method, such as the Golden Section search. After finding the optimal $\lambda^*$ you can recover $x^*$.

P.S. If you really want a really reliable method in terms of approximating the optimum in terms of the objective value, you can compute an approximate $x_i$ after every iteration of the the Golden Section search, and stop when the primal-dual gap is below some threshold.

# Update

Since there are many questions about computing $q(\lambda)$, here are the details. First, I will denote by $g_i(x_i, \lambda)$ the objective inside the minimum. That is, we solve $$\min_{x_i} \biggl\{g_i(x_i, \lambda) = -\ln(1+a_i x_i) - \lambda a_i x_i :~ 0 \leq x_i \leq c_i \biggr\}$$ The minimum is either a stationary point inside the interior of the interval $I = [0, c_i]$ or one of its endpoints. First, note that if $\lambda \geq 0$ then $g_i$ is a decreasing function, and in this case there are no stationary points. Thus, for any stationary point we must have $\lambda < 0$.

To find a stationary point, we solve: $$\frac{d g_i}{d x_i} = -\frac{a_i}{1+a_i x_i} - \lambda a_i = 0.$$ Since $a_i > 0$ we can divide both sides by $a_i$, and obtain the equation $$\frac{1}{1+a_i x_i} = -\lambda$$ Since $\lambda \neq 0$, we take the inverse on both sides, multiply by $a_i$, and obtain $$1+a_i x_i = -\frac{1}{\lambda},$$ which is equivalent to $$a_i x_i = -1-\frac{1}{\lambda},$$ or $$x_i = -\frac{1+\lambda}{a_i \lambda}.$$ Using the fact that $\lambda < 0$, we conclude that the point above is inside the interior of $I$ if and only if $$-1 < \lambda < -\frac{1}{1 + c_i a_i},$$ in that case the expression for $x_i$ above is the minimizer, and the minimum is $$g_i\left(-\frac{1+\lambda}{a_i \lambda}, \lambda\right) = \ln(-\lambda) + \lambda + 1$$ Otherwise, either the left endpoint $x_i=0$ or the right endpoint $x_i=c_i$ is the minimizer. To summarize, $$q_i(\lambda) = \min_{x_i} \biggl\{g_i(x_i, \lambda) :~ 0 \leq x_i \leq c_i \biggr\} = \begin{cases} \ln(-\lambda) + \lambda + 1 & -1 < \lambda < -\frac{1}{1 + c_i a_i} \\ \min(0, -\ln(1+a_i c_i)-\lambda a_i c_i) & \text{otherwise} \end{cases}$$ The dual objective is $$q(\lambda) = \sum_{i=1}^n q_i(\lambda) + \lambda C$$ It is possible to simplify the expressions above, but it is not required to do so in order to write code which evaluates $q(\lambda)$ in order to solve it numerically.

• Thank you for your efforts. Do you mean that I need to minimize the function $-\ln(1+ax)-bx$ to obtain $x$ as a function of $a$ and $b$ then substitute this $x$ in the given Lagrangian $q(\lambda)$ and finally numerically solve $\text{max}_{\lambda}q(\lambda)$? – user841315 Mar 28 '18 at 20:48
• Exactly. You need to find a closed form expression for the minimizer $x$ and the resulting minimum as a function of $a,b$ and the endpoints of the interval. In that way you will have a formula for $q$ and you can use it to numerically maximize $q$. – Alex Shtof Mar 29 '18 at 7:08
• I have computed the minimizer $x$ by taking the derivative of $\tilde{f}(x)=-\ln(1+ax)-bx$ then $\tilde{f}'(x)=0$ so we have $x=\frac{-a-b}{ab}$. I'm confused about the value of $x$ because it always returns a negative number and the $\ln$-function is undefined then – user841315 Mar 29 '18 at 10:05
• First, the sign of $-b$ is not always negative in our case So it depends on whether $\lambda$ is positive or negative. Second and much more important, when minimizing over an interval you cannot just use the stationary point obtained from the "derivative=zero" equation. You need to take the endpoints of the interval into account too. – Alex Shtof Mar 29 '18 at 13:15
• The strong duality theorem ensures that a pair feasible solutions, one for the primal and the other for the dual, are optimal if and only if the objectives of both problems at these points are equal. You can certify optimality by taking the results you obtained numerically and show that the difference between the primal and the dual objectives is less than some very small threshold, say $10^{-6}$. – Alex Shtof Apr 3 '18 at 5:41


text:
aGE package

2018-11-19

This package implements aGE tests, which is a data-adaptive set-based gene-environment interaction (GxE) test, specifically designed for rare variants.

• Works both on linux R and windows R
• See more in the paper: Yang T, et al. (2018) <10.1002/sim.8037>

• The method is able to control type 1 error rates when the environmental variable is a linear or nonlinear function of the outcome.
• Incorporate a wide range of tests, including burden test, variance component tests (rareGE), and beyond
• The test is adaptive to different directions of GxE effects and the different number of neutral varints, i.e., variants with no GxE effects.
• Works for both binary and continuous outcome

Model

The model is $$g(\mu_i)= X_i\beta_0+ G_i\beta_1 + S_i\beta_2$$,

where $$g(\cdot)$$ is the link function, $$X_i$$ is the covariate matrix including the environmental variable, $$G_i$$ is the $$q \times q$$ genotype matrix and $$S_i$$ is the $$q \times q$$ GxE interaction matrix.

The interaction test, the null hypothesis is that $$\beta_2=[\beta_{21},\ldots,\beta_{2q}]^T=[0,\ldots,0]^T.$$

For joint test,the null hypothesis is that $$\beta_1=\beta_2=[0,\ldots,0]^T.$$

Installation

Other than CRAN, github can be checked for most recent update.

Install from github

• Step 2: open R, and set the directory to this local folder
 setwd('local folder')
• Step 3: install the package in R
install.packages('aGE.version.tar.gz',repos=NULL,type='source')

Usage

Two functions are available: aGE and aGE.joint. The former performs adaptive GxE test and the later performs joint test for both genetic main and GxE effects. The details of inputs of the functions can be foound by typing ?aGE and ?aGE.joint in R command line.

A simple example

A simple demonstration of the usage and output of the package. The simulation method is recommended to use for sample size $$>$$ 500.

     library(aGE)
set.seed(12345)
phenotype <- c(rep(1,50),rep(0,50))
genotype <- data.frame(g1=sample(c(rep(1,10),rep(0,90))),g2=sample(c(rep(1,5), rep(0,95))))
covariates <- data.frame(Envir=rnorm(100), Age=rnorm(100,60,5))
exD <- list(Y=phenotype, G=genotype, X=covariates)
aGE(Y=exD$Y, G=exD$G, cov=exD$X, model='binomial', nonparaE=F, stepwise=F)  ## aGEsm1 aGEsm2 aGEsm3 aGEsm4 aGEsm5 ## 0.02800000 0.11800000 0.11900000 0.17000000 0.16000000 ## aGEsm6 aGEsm aGEsm_fisher ## 0.19100000 0.05194805 0.10389610  aGE.joint(Y=exD$Y, G=exD$G, cov=exD$X, model='binomial', nonparaE=T, DF=5, method='Simulation')
##       aGEj1       aGEj2       aGEj3       aGEj4       aGEj5       aGEj6
##   0.4870000   0.2000000   0.2120000   0.2430000   0.2200000   0.2410000
##        aGEj   aGEj_minp aGEj_fisher
##   0.3316683   0.1198801   0.1228771

The stepwise option in aGE function is suggested for real-data GxE analysis, where a high genome-wide significant level is required. It performs Monte Carlo method with the number of permutation (B) equals 1,000 and then increase B gradually if small p-values are observed.

format: plain


text:
I've moved here.

## Tuesday, January 21, 2014

### Interactive Lissijous Curves in d3

On a visit to San Francisco's Exploratorium, I saw an oscilloscope they had making Lissijous curves. So I decided to make a version in d3:

You can play with it (and see the code) here

## Saturday, October 26, 2013

### dithering

I was converting a PNG (which represented partials sums of the Weierstrass elliptic function) to a GIF and was confused about why the PNG looked fine at low resolution but the GIF looked bad.

Then I learned that GIFs can only use 256 colors and we have to do something to map the many colors to the fewer colors. We could just use the closest available color in the new set of colors, but that results in sharp jumps and "color banding" where the colors change.
So instead we use (and ImageMagick's default is) dithering, which assigns pixels to a mixture of color values that locally average to the appropriate shade. I had a great time reading about this in ImageMagick's documentation! Here's a description of the default method:
The pixel is assigned the color closest to that pixels value, and any difference between the pixels original color and the selected color, is saved and added to the next pixels color values (which is always a neighbouring pixel) before a new color is again selected. In this way any color variations between selected colors and the images original color is distributed to the other pixels in the same area. The result is that while only specific colors will be assigned to the final image, the same basic overall color for that area will closely match the original image.
When there aren't enough dots, the picture looks blurry.
 Resolution: 800x600 Resolution: 200x150 PNG (lots of colors) no dither (GIF, 256 colors) default dither (GIF, 256 colors)
Here's my code on Github, and here are the ImageMagick commands that produced these:
convert -resize 100% -dither None ./zoomed_in/Weierstrass001.png ./res100no_dither.gif
convert -resize 50% -dither None ./zoomed_in/Weierstrass001.png ./res50no_dither.gif
convert -resize 100%  ./zoomed_in/Weierstrass001.png ./res100default_dither.gif
convert -resize 25%  ./zoomed_in/Weierstrass001.png ./res25default_dither.gif
convert -resize 100%  ./zoomed_in/Weierstrass001.png ./res100many_colors.png
convert -resize 25%  ./zoomed_in/Weierstrass001.png ./res25many_colors.png

## Wednesday, October 16, 2013

### A Bayesian Model for a Function Increasing by Chi-Squared Jumps (in Stan)

This post will describe a way I came up with of fitting a function that's constrained to be increasing, using Stan. If you want practical help, standard statistical approaches, or expert research, this isn't the place for you (look up “isotonic regression” or “Bayesian isotonic regression” or David Dunson, whose work Andrew Gelman pointed me to). This is the place for you if you want to read about how I thought about setting up a model, implemented the model in Stan, and created graphics to understand what was going on.

Here's the source for this post, including markdown and and R code, and here's the Stan model it uses.

Many thanks to Naftali Harris for comments and insights on an earlier version.

I recently read a paper that Andrew Gelman wrote back in 1996 about theoretical considerations that can restrict model choice even “in the abence of data with minimal applied context”. As one example, he describes the problem fitting a function $$f(t)$$ that is known to be increasing and where $$f(0)=0$$ and $$f(1)=1$$ are known. We estimate the function given noisy observations of its value at $$(N-1)$$ equally spaced sample points $$\theta_i=f(\frac{i}{N})$$ (for $$i \in \{1,2,3,...,N-1\}$$).

What prior should we use for the $$\{\theta_i\}$$? It might seem like a reasonable “uninformative” prior would make the $$\{\theta_i\}$$ independent and uniform on $$[0,1]$$, with the restriction that non-increasing sets of $$\{\theta_i\}$$ are given zero probability. But this turns out badly! Gelman notes that this prior on the $$\{\theta_i\}$$ is the same as the distribution of the order statistics of a samples of size $$N-1$$ from the uniform distribution on $$[0,1]$$. As the number of points in the discretization increases, the mass of the prior concentrates around a straight line, which will overwhelm the data.

To illustrate, here are some samples from this distribution, for various $$N$$:

This weird! Under the uniform distribution, each (legal) path is equally likely. That's why if we fit this model to noisy data, the maximum likelihood estimate (which is the mode of the posterior) would be reasonable. But it turns out that for large $$k$$, almost all legal paths are basically straight lines, so the bulk of the posterior would be basically a straight line no matter what the data say. It reminds me a bit of statistical mechanics, which is largely about micro-level randomness determining macro-level properties. (I'm no expert, but I recommend this book.)

## Tuesday, July 2, 2013

### Mine Depth (Make your axes meaningful!)

At the Empire Mine State Historic Park, you can walk 30 feet into the old gold mine, meet a quirky and knowledgeable blacksmith named David, see an awesome scale model of the mine (above--very secret during the years of operation!), and see this chart visualizing the depth of the mine over time:

I usually like axes to be as meaningful as possible, so I redrew the chart (code below) representing the year with the horizontal axis:
The original version probably has its own advantages as well, but some observations and questions comes a little more quickly from my version:

• From 1886 onward, the mine seems to get deeper as a roughly constant rate (averaged over time).
• Are they digging it deeper smoothly over time, or does the depth increase in spurts?
• Why do we have so much more data in the period from 1886 to 1892 than the rest?

Before drawing the chart this way, I figured that depth would increase faster in more recent years (with better technology), which isn't true at all. But note that this is just the maximum depth -- maybe they can dig much more easily with better technology, but that's spread across more tunnels, so the depth doesn't increase any faster? Or maybe each bar on the original chart represents a short, concentrated digging effort (meaning they can increase the depth much faster in recent years, but also go for much longer without increasing it at all)?

## Wednesday, June 19, 2013

### Effective altruists -- lifestyle changes for animals vs. the environment

A good question from the Effective Altruism group on Facebook: "why EAs [people in the effective altruism community] often think that making changes to their personal lifestyles in order to reduce factory farming is worth it while hardly any EAs seem to think that making changes in their personal lifestyles in order to reduce global warming is not worth it."

Here are some guesses:

## Monday, March 11, 2013

### Weierstrass Elliptic Function

(where  $\omega\in\Lambda$ are the points of a lattice in the complex plane).

The technique of adding up one term for each lattice point is really neat, and it's extra great that the function turns out to have such amazing properties

Since John's post showed what pretty pictures come from using phase portraits to visual complex functions, I decided to make a video to show me what the partial sums that converge to the Weierstrass function. I'm adding a bunch of terms starting from the origin going outward, but you could add the terms in any order.

The picture on the left is a zoomed in version showing two periods in each direction. You can see the function getting more periodic as we add more terms.

The code is here. The code is O(n^2) (where n is the number of terms I want images for) when it really should be O(n), since I'm in effect asking for a lot of repeated computation by making each image separately. Sorry!

## Sunday, August 5, 2012

### Visualize a random forest that classifies digits

My last post uses random forest proximity to visualize a set of diamond shapes (the random forest is trained to distinguish diamonds from non-diamonds).

This time I looked at the digits data set that Kaggle is using as the basis of a competition for "getting started". The random forest is trained to classify the digits, and this is an embedding of 1000 digits into 2 dimensions preserving proximities from the random forest as closely as possible:

The colors of the points show the correct label. The larger points are incorrectly classified, and you can see that in general those are ones that the random forest has put in the wrong "region". I've shown some of the digits themselves (instead of colored points) -- the red ones are incorrectly classified.

Here's the same but just for the 7's:

The random forest has done a reasonable job putting different types of 7's in different areas, with the most "canonical" 7's toward the middle.

You can see all of the other digits  http://www.learnfromdata.com/media/blog/digits/.

Note that this random forest is different from the one in my last post -- here it's built to classify the digits, not separate digits from non-digits. I wonder what kind of results a random forest to distinguish 7's from non-7's would look like?

Code is on Github.

### Random forests for visualizing data

Recently I read about using random forests as a way to visualize data. Here's how it works:
1. Have a data set
2. Create a set of fake data by permuting the columns randomly -- each column will still have the same distribution, but the relationships are destroyed.
3. Train a random forest to distinguish the fake data from the original data.
4. Get a "proximity" measure between points, based on how often the points are in the same leaf node.
5. Embed the points in 2D in such a way as to distort these proximities as little as possible.
I decided to try this in a case where I would know what the outcome should be, as a way of thinking about how it works. So I generated 931 images of diamonds varying in two dimensions:
1. Size
2. Position (only how far left/right)

Then I followed the above procedure, getting this:

Neat! The random forest even picked up on a feature of this space that I wasn't expecting it to: for the same difference in position, small diamonds need to be closer to each other than large diamonds. None of my diamonds have a diameter smaller than 4 pixels, but imagine of the sizes got so small the diamond wasn't even there -- then position wouldn't matter at all of those diamonds.

I set one column of pixels to random values, and the method still worked just as well. (Which makes sense, as the random forest only cares about pixels that help it distinguish between diamonds and non-diamonds.)

A cool technique that I'd love to try some more! For one, I'd like to understand better how it differs from various manifold learning methods. One nice feature is that you could easily use this with a mix of continuous and categorical variables.

Note that starting with Euclidean distance between images (as vectors in R^2500) and mapping points to 2D doesn't seem to produce anything useful:

Code available on github.

## Tuesday, July 10, 2012

### Tweaks to Instapaper "Read Later" Button

I love Instapaper (please support it by becoming a premium member!). Being able to easily save articles for reading later lets me move the article-reading time from when I shouldn't be getting distracted to when I'm happy to relax on the couch (or train, or airplane, or line at the coffee shop, ...) with an interesting article.

Tonight I worked on fixing two small things that were bugging me:

1. When I'm reading an article, I'd like to know where I came across it. The code below uses the javasript "document.referrer" property and adds a link back to the referrer, before saving to Instapaper.
2. I don't like when I hit "Read Later" before the page has finished loading and get a complaint that I should wait for the page to load. This lets me hit "Read Later" while it's loading and get back to ordering my coffee.
You can use the code below just like the original "Read Later" link, but I'll warn you it's had about 5 minutes of testing. Please give me any feedback you have!

I'd like to have much more extensive history/referral tracking, and even what it's supposed to do now doesn't always work. Let me know if you can help!


text:
# How can electrons and quarks be composite?

There are theories suggesting that the electrons and quarks are not elementary particles, but instead are composite particles of two or more yet undiscovered elementary particles. However experimentally we know the upper limits of the radii of these particles, and they are very small indeed. Any particles "inside" an electron would be confined to a very small volume. By Heisenberg's uncertainty principle, the particles inside would experience large fluctuations of momentum, making the total energy larger than the mass-energy of electron. Therefore the measured mass of the electron should actually be several orders of magnitude larger. This seems like a paradox.

How do composite-electron and composite-quark theories avoid this?

• not the best question(linked, not above), but this related question does have quite a good answer attached to it: physics.stackexchange.com/q/507454 – Alex Robinson Oct 15 '19 at 15:09
• The fluctuations you imagine are virtual. How can the neutron decay involve a W when the mass of the W is 80 GeV and the mass of the neutron less than 1? It is all accommodated in the mathematics of the four vectors used in the theories. – anna v Oct 15 '19 at 15:37
• The focus on hypothetical models of composite electrons/quarks may be a distraction, because the same line of reasoning leads to the same question in simpler cases. Consider QCD with the quark masses set to zero. In this model, pions are massless (because they're Goldstone bosons of the spontaneously broken chiral symmetry), even though they are composite in the sense that they don't correspond to any individual field in the QCD lagrangian. Would you agree that the same question also applies in this case? – Chiral Anomaly Oct 17 '19 at 13:04
• Yes, it would. Since quarks are confined, there is a characteristic energy scale corresponding to them. Massless quarks with energy $E$ would have an effective mass $E/c^2$, which should make the pion to have an effective mass $2E/c^2$. Is this what you mean? – Zeick Oct 17 '19 at 13:41

According to our currently accepted theory, the SM, electrons and quarks are elementary particles, pointlike, with zero spatial extension, and no substructure.

Now what you are suggesting, that the electron and quarks are not elementary, not pointlike and they do have a substructure, and some spatial extension could be based on two theories:

1. preons

Basically the point of these models are reducing the large number of particles, explaining the three generations of fermions, calculate parameters not explained by the SM (mass, charge, color charge), explain large differences in energy masses, explain electroweak symmetry breaking without Higgs, explain neutrino oscillation.

https://en.wikipedia.org/wiki/Preon

1. string theory

in this theory, pointlike particles are replaced by one dimensional strings.

In theories of particle physics based on string theory, the characteristic length scale of strings is assumed to be on the order of the Planck length, or 10−35 meters, the scale at which the effects of quantum gravity are believed to become significant.[15] On much larger length scales, such as the scales visible in physics laboratories, such objects would be indistinguishable from zero-dimensional point particles, and the vibrational state of the string would determine the type of particle.

https://en.wikipedia.org/wiki/String_theory


text:
Opened 6 years ago

# Add filter for ticket status

Reported by: Owned by: anonymous Terry Brown low ComponentsProcessorMacro minor 0.11

### Description

I think, it would be nice to be able to have the amount of open tickets displayed for each component, instead of the amount of all tickets per component.

### comment:2 Changed 6 years ago by Adrian Fritz

The ability to filter tickets is already addressed by query strings or almost equivalent macro, something like this [[TicketQuery(status!=closed&component=ComponentToFilter, count)]] which could be used as a reference to full fill the components wiki field.

Another way, maybe, is via establishing a configuration line at 'trac.ini', like tickets-to-show-on-components-macro=status!=closed&component=ComponentToFilter. This way has the benefit of not requiring the administrator to manually configure each wiki field.

Also, without adding any configuration, neither adding manual macros into wiki field is showing groups of tickets like done at every milestone (down the title).

### Modify Ticket

Change Properties


text:
# Error C2065 Example 2: undeclared identifier

Description:

An undeclared identifier error, error C2065, implies that there is no declaration for the particular item. However, this example shows that this error can be caused by mistyping a '1' (the number one) instead of an 'l' (lowercase L) in the word 'endl'. This is a very common mistake and is sometimes hard to see because of the visual similarity of the characters.

Code with Errors:

Compiler Error Message:

1>------ Build started: Project: myproj, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\xoax.net\myproj\myproj\main.cpp(5): error C2039: 'end1' : is not a member of 'std'
1>c:\xoax.net\myproj\myproj\main.cpp(5): error C2065: 'end1' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Fixed Code:

Output:


text:
# RankedMax and Max do not behave identically

I have spent three hours debugging some code and at the end I think I found a bug. Otherwise I cannot explain what I am seeing:

When I want to use RankedMax on nested sublists, Mathematica freaks out, but it works all smooth as I expect when I use Max.

Try:

tab = Table[{i, j, k}, {i, 1, 2}, {j, 1, 3}, {k, 1, 4}] // TableForm
Map[Function[{x}, x/Max[x]], tab] // TableForm
Map[Function[{x}, x/RankedMax[x, 1]], tab] // TableForm

The last line will cause an error, and I do not understand why, because the documentation says:

RankedMax[{Subscript[x, 1],...,Subscript[x, m]},1] is equivalent to Max[{Subscript[x, 1],...,Subscript[x, m]}].

Why is this happening? Do I understand something incorrectly?

-

I suspect this has to do with the fact that Max has attribute Flat, and RankedMax hasn't. To get the same behaviour, you could do

(tab = Table[{i, j, k}, {i, 1, 2}, {j, 1, 3}, {k, 1, 4}]) // TableForm
Map[Function[{x}, x/Max[x]], tab] // TableForm
Map[Function[{x}, x/RankedMax[Flatten[x], 1]], tab] // TableForm

As an aside, // binds stronger than = which means that is you do something like

a = b // TableForm

this is interpreted as a = TableForm[b] which is probably not what you want if you want to use a for further calculations. To prevent this you can use brackets to group the right terms together, i.e. (a = b) // TableForm.

-
I lost my internet connection while posting, thought it had posted. Now I see that it only posted it when my connection got back so I'm deleting it. It's too similar – Rojolalalalalalalalalalalalala Jun 19 '12 at 18:55
@Rojo our answers are eerily similar. – Heike Jun 19 '12 at 18:57
Yeah, +1 for you on behalf of both – Rojolalalalalalalalalalalalala Jun 19 '12 at 19:00
Thanks. I'm sure I'll even the score one day :-) – Heike Jun 19 '12 at 19:06
Thank you for making this a little bit more clear. I didn't know that // binds stronger, but I would have found out one day... regarding the "feature": how can I know and expect this behaviour? How can I check the "attributes" of the functions? Is there anything else that can go wrong if the documentation says they are equivalent when in fact they are not? – james Jun 19 '12 at 19:45


text:
We think you are located in United States. Is this correct?

## 4.3 Solving quadratic equations (EMA36)

A quadratic equation is an equation where the exponent of the variable is at most $$\text{2}$$. The following are examples of quadratic equations:

\begin{align*} 2{x}^{2} + 2x & = 1 \\ 3{x}^{2} + 2x - 1 & = 0 \\ 0 & = -2{x}^{2} + 4x - 2 \end{align*}

Quadratic equations differ from linear equations in that a linear equation has only one solution, while a quadratic equation has at most two solutions. There are some special situations, however, in which a quadratic equation has either one solution or no solutions.

We solve quadratic equations using factorisation. For example, in order to solve $$2{x}^{2} -x - 3 = 0$$, we need to write it in its equivalent factorised form as $$\left(x + 1\right)\left(2x - 3\right) = 0$$. Note that if $$a \times b = 0$$ then $$a = 0$$ or $$b = 0$$.

The following video shows an example of solving a quadratic equation by factorisation.

Video: 2FBM

### Method for solving quadratic equations (EMA37)

1. Rewrite the equation in the required form, $$a{x}^{2} + bx + c = 0$$.

2. Divide the entire equation by any common factor of the coefficients to obtain an equation of the form $$a{x}^{2} + bx + c = 0$$, where $$a$$, $$b$$ and $$c$$ have no common factors. For example $$2{x}^{2} + 4x + 2 = 0$$ can be written as $${x}^{2} + 2x + 1 = 0$$.

3. Factorise $$a{x}^{2} + bx + c = 0$$ to be of the form $$\left(rx + s\right)\left(ux + v\right) = 0$$.

4. The two solutions are $$\left(rx + s\right) = 0$$ or $$\left(ux + v\right) = 0$$, so $$x= -\dfrac{s}{r}$$ or $$x = -\dfrac{v}{u}$$, respectively.

5. Check the answer by substituting it back into the original equation.

## Worked example 4: Solving quadratic equations

Solve for $$x$$:

$3{x}^{2} + 2x - 1 = 0$

### Factorise

$\left(x + 1\right)\left(3x - 1\right) = 0$

### Solve for both factors

We have

\begin{align*} x + 1 & = 0 \\ \therefore x & = -1 \end{align*}

OR

\begin{align*} 3x - 1 & = 0 \\ \therefore x & = \frac{1}{3} \end{align*}

### Check both answers by substituting back into the original equation

The solution to $$3{x}^{2} + 2x - 1 = 0$$ is $$x = -1$$ or $$x = \frac{1}{3}$$.

temp text

## Worked example 5: Solving quadratic equations

Find the roots:

$0 = -2{x}^{2} + 4x - 2$

### Divide the equation by common factor $$-\text{2}$$

\begin{align*} -2{x}^{2} + 4x - 2 & = 0 \\ {x}^{2} - 2x + 1 & = 0 \end{align*}

### Factorise

\begin{align*} \left(x - 1\right)\left(x - 1\right) & = 0 \\ {\left(x - 1\right)}^{2} & = 0 \end{align*}

### The quadratic is a perfect square

This is an example of a special situation in which there is only one solution to the quadratic equation because both factors are the same.

\begin{align*} x - 1 & = 0 \\ \therefore x & = 1 \end{align*}

### Check the answer by substituting back into the original equation

The solution to $$0 = -2{x}^{2} + 4x - 2$$ is $$x = 1$$.

temp text
Textbook Exercise 4.2

Write the following in standard form

$$(r + 4) (5 r - 4) = -\text{16}$$

\begin{align*} (r + 4) (5 r - 4) & = -\text{16} \\ \text{5} {r}^2 -\text{4} r \text{+20} r -\text{16} + \text{16} &= \text{0}\\ \text{5} {r}^2 -\text{4} r \text{+20} r -\text{16} + \text{16} &= \text{0}\\ 5 r^{2} + 16 r & = \text{0} \end{align*}

$$(3 r - 8) (2 r - 3) = -\text{15}$$

\begin{align*} (3 r - 8) (2 r - 3) & = -\text{15} \\ \text{6} {r}^2 -\text{9} r -\text{16} r \text{+24} + \text{15} &= \text{0}\\ \text{6} {r}^2 -\text{9} r -\text{16} r \text{+24} + \text{15} &= \text{0}\\ 6 r^{2} - 25 r + 39 & = \text{0} \end{align*}

$$(d + 5) (2 d + 5) = \text{8}$$

\begin{align*} (d + 5) (2 d + 5) & = \text{8} \\ \text{2} {d}^2 \text{+5} d \text{+10} d \text{+25} - \text{8} &= \text{0}\\ \text{2} {d}^2 \text{+5} d \text{+10} d \text{+25} - \text{8} &= \text{0}\\ 2 d^{2} + 15 d + 17 & = \text{0} \end{align*}

Solve the following equations:

$$x^{2} +2x -15 = 0$$

\begin{align*} x^{2} +2x -15 &= 0 \\ (x -3)(x +5) &=0 \\ \therefore x = -5 & \text{ or } x = 3 \end{align*}

$$p^{2} -7p -18 = 0$$

\begin{align*} p^{2} -7p -18 &= 0 \\ (p -9)(p +2) =&0 \\ \therefore p = -2 &\text{ or } p = 9 \end{align*}

$$9x^{2} - 6x - 8 = 0$$

\begin{align*} 9x^{2} - 6x - 8 & = 0 \\ (3x + 2)(3x - 4) & = 0 \\ 3x + 2 & = 0 \\ x & = -\frac{2}{3} \\ \text{or} & \\ 3x - 4 & = 0 \\ x & = \frac{4}{3} \\ \therefore x = -\frac{2}{3} & \text{ or } x = \frac{4}{3} \end{align*}

$$5x^{2} + 21x - 54 = 0$$

\begin{align*} 5x^{2} + 21x - 54 & = 0 \\ (5x - 9)(x + 6) & = 0 \\ 5x - 9 & = 0 \\ x & = \frac{9}{5} \\ \text{or} & \\ x + 6 & = 0 \\ x & = -6 \\ \therefore x = \frac{9}{5} & \text{ or } x = -6 \end{align*}

$$4 z^{2} + 12 z + 8 = 0$$

\begin{align*} 4 z^{2} + 12 z + 8 &= 0\\ z^{2} + 3 z + 2 &= 0 \\ \left(z + 1\right) \left(z + 2\right)&= 0 \\ z = -2 &\text{ or } z = -1 \end{align*}

$$- b^{2} + 7 b - 12 = 0$$

\begin{align*} - b^{2} + 7 b - 12 &= 0 \\ b^{2} - 7 b + 12 &= 0 \\ \left(b - 4\right) \left(b - 3\right) &= 0 \\ b = 3 &\text{ or } b = 4 \end{align*}

$$- 3 a^{2} + 27 a - 54 = 0$$

\begin{align*} - 3 a^{2} + 27 a - 54 &= 0 \\ a^{2} - 9 a + 18 &= 0 \\ \left(a - 6\right) \left(a - 3\right) &= 0 \\ a = 3 &\text{ or } a = 6. \end{align*}

$$4y^{2} - 9 = 0$$

\begin{align*} 4y^{2} - 9 & = 0 \\ (2y - 3)(2y + 3) & = 0 \\ 2y - 3 & = 0 \\ y & = \frac{3}{2} \\ \text{or} & \\ 2y + 3 & = 0 \\ y & = -\frac{3}{2} \\ \therefore y = \frac{3}{2} & \text{ or } y = -\frac{3}{2} \end{align*}

$$4x^{2} + 16x - 9 = 0$$

\begin{align*} 4x^{2} + 16x - 9 & = 0 \\ (2x - 1)(2x + 9) & = 0 \\ 2x - 1 & = 0 \\ x & = \frac{1}{2} \\ \text{or} & \\ 2x + 9 & = 0 \\ y & = -\frac{9}{2} \\ \therefore x = \frac{1}{2} & \text{ or } x = -\frac{9}{2} \end{align*}

$$4x^{2} - 12x = -9$$

\begin{align*} 4x^{2} - 12x & = -9 \\ 4x^{2} - 12x + 9 & = 0 \\ (2x - 3)(2x - 3) & = 0 \\ 2x - 3 & = 0 \\ x & = \frac{3}{2} \end{align*}

$$20m + 25m^{2} = 0$$

\begin{align*} 20m + 25m^{2} & = 0 \\ 5m(4 + 5m) & = 0 \\ 5m & = 0 \\ m & = 0 \\ \text{ or } & \\ 4 + 5m & = 0 \\ m & = -\frac{4}{5} \\ \therefore m = 0 & \text{ or } m = -\frac{4}{5} \end{align*}

$$2x^{2} - 5x - 12 = 0$$

\begin{align*} 2x^{2} - 5x - 12 & = 0 \\ (2x + 3)(x - 4) & = 0 \\ 2x + 3 & = 0 \\ x & = -\frac{3}{2} \\ \text{or} & \\ x - 4 & = 0 \\ x & = 4 \\ \therefore x = -\frac{3}{2} & \text{ or } x = 4 \end{align*}

$$-75x^{2} + 290x = 240$$

\begin{align*} -75x^{2} + 290x & = 240 \\ -75x^{2} + 290x - 240 & = 0 \\ -15x^{2} + 58x - 48 & = 0 \\ (5x - 6)(3x - 8) & = 0 \\ 5x - 6 & = 0 \\ x & = \frac{6}{5} \\ \text{or} & \\ 3x - 8 & = 0 \\ x & = \frac{8}{3} \\ \therefore x = \frac{6}{5} & \text{ or } x = \frac{8}{3} \end{align*}

$$2x = \frac{1}{3}x^{2} - 3x + 14\frac{2}{3}$$

\begin{align*} 2x & = \frac{1}{3}x^{2} - 3x + 14\frac{2}{3} \\ 6x & = x^{2} - 9x + 44 \\ x^{2} - 15x + 44 & = 0 \\ (x - 4)(x - 11) & = 0 \\ x - 4 & = 0 \\ x & = 4 \\ \text{or} & \\ x - 11 & = 0 \\ x & = 11 \\ \therefore x = 4 & \text{ or } x = 11 \end{align*}

$$x^{2} - 4x = -4$$

\begin{align*} x^{2} - 4x & = -4 \\ x^{2} - 4x + 4 & = 0 \\ (x - 2)(x - 2) & = 0 \\ x - 2 & = 0 \\ x & = 2 \end{align*}

$$-x^{2} + 4x - 6 = 4x^{2} - 14x + 3$$

\begin{align*} -x^{2} + 4x - 6 & = 4x^{2} - 14x + 3 \\ 5x^{2} - 18x + 9 & = 0 \\ (5x - 3)(x - 3) & = 0 \\ 5x - 3 & = 0 \\ x & = \frac{3}{5} \\ \text{or} & \\ x - 3 & = 0 \\ x & = 3 \\ \therefore x = \frac{3}{5} & \text{ or } x = 3 \end{align*}

$$t^{2} = 3t$$

\begin{align*} t^{2} & = 3t \\ t^{2} - 3t & = 0 \\ t(t - 3) & = 0 \\ t & = 0 \\ \text{or} & \\ t - 3 & = 0 \\ t & = 3 \\ \therefore t = 0 & \text{ or } t = 3 \end{align*}

$$x^{2} - 10x = -25$$

\begin{align*} x^{2} - 10x & = -25 \\ x^{2} - 10x + 25 & = 0 \\ (x - 5)(x - 5) & = 0 \\ x - 5 & = 0 \\ x & = 5 \end{align*}

$$x^{2} = 18$$

\begin{align*} x^{2} & = 18 \\ \therefore x = \sqrt{18} & \text{ or } x = -\sqrt{18} \end{align*}

$$p^{2} - 6p = 7$$

\begin{align*} p^{2} - 6p & = 7 \\ p^{2} - 6p - 7 & = 0 \\ (p - 7)(p + 1) & = 0 \\ p - 7 & = 0 \\ p & = 7 \\ \text{or} & \\ p + 1 & = 0 \\ p & = -1 \\ \therefore p = 7 & \text{ or } p = -1 \end{align*}

$$4x^{2} - 17x - 77 = 0$$

\begin{align*} 4x^{2} - 17x - 77 & = 0 \\ (4x + 11)(x - 7) & = 0 \\ 4x + 11 & = 0 \\ x & = -\frac{11}{4} \\ \text{or} & \\ x - 7 & = 0 \\ x & = 7 \\ \therefore x = -\frac{11}{4} & \text{ or } x = 7 \end{align*}

$$14x^{2} + 5x = 6$$

\begin{align*} 14x^{2} + 5x & = 6 \\ 14x^{2} + 5x - 6 & = 0 \\ (7x + 6)(2x - 1) & = 0 \\ 7x + 6 & = 0 \\ x & = -\frac{6}{7} \\ \text{or} & \\ 2x - 1 & = 0 \\ x & = \frac{1}{2} \\ \therefore x = -\frac{6}{7} & \text{ or } x = \frac{1}{2} \end{align*}

$$2x^{2} - 2x = 12$$

\begin{align*} 2x^{2} - 2x & = 12 \\ x^{2} - x - 6 & = 0 \\ (x - 3)(x + 2) & = 0 \\ x - 3 & = 0 \\ x & = 3 \\ \text{or} & \\ x + 2 & = 0 \\ x & = -2 \\ \therefore x = 3 & \text{ or } x = -2 \end{align*}
$$(2a - 3)^2 - 16 = 0$$
\begin{align*} (2a - 3)^2 - 16 &= 0 \\ (2a - 3 + 4)(2a - 3 - 4) &= 0 \\ (2a + 1)(2a - 7)&= 0 \\ \therefore a = -\frac{1}{2} &\text{ or } a = \text{3,5} \end{align*}
$$(x-6)^2 - 24 = 1$$
\begin{align*} (x-6)^2 - 24 &= 1 \\ (x-6)^2 - 25 &= 0 \\ (x- 6 - 5)(x- 6 + 5) &= 0\\ (x-11)(x-1) &= 0\\ \therefore x = 11 &\text{ or } x = 1 \end{align*}

Solve the following equations (note the restrictions that apply):

$$3y = \dfrac{54}{2y}$$

Note $$y \neq 0$$

\begin{align*} 3y &= \frac{54}{2y} \\ 3y^2 &= 27 \\ y^2 &= 9 \\ y^2 - 9 &= 0 \\ (y-3)(y+3) &= 0 \\ \therefore y = 3 &\text{ or } y = -3 \end{align*}
$$\dfrac{10z}{3} = 1 - \dfrac{1}{3z}$$

Note $$z \neq 0$$

\begin{align*} \frac{10z}{3} &= 1 - \frac{1}{3z} \\ 10z^2 &= 3z - 1 \\ 10z^2 - 3z + 1 &= 0 \\ (5z + 1)(2z - 1) &= 0 \\ \therefore z = -\frac{1}{5} &\text{ or } z = \frac{1}{2} \end{align*}
$$x + 2 = \dfrac{18}{x} -1$$

Note $$x \neq 0$$

\begin{align*} x + 2 &= \frac{18}{x} -1 \\ x^2 + 2x &= 18 - x \\ x^2 + 3x - 18 &= 0 \\ (x-3)(x+6) &= 0 \\ \therefore x = 3 &\text{ or } x = -6 \end{align*}
$$y - 3 = \dfrac{5}{4} - \dfrac{1}{y}$$

Note $$y \neq 0$$

\begin{align*} y - 3 &= \frac{5}{4} - \frac{1}{y} \\ 4y^2 - 12y &= 5y - 4 \\ 4y^2 -17y + 4 &= 0\\ (4y-1)(y-4)&= 0\\ \therefore y = \frac{1}{4} &\text{ or } y = 4 \end{align*}
$$\dfrac{1}{2}(b - 1) = \dfrac{1}{3}\left(\dfrac{2}{b} + 4\right)$$

Note $$b \neq 0$$

\begin{align*} \frac{1}{2}(b - 1) &= \frac{1}{3}\left(\frac{2}{b} + 4\right) \\ 3(b - 1) &= 2\left(\frac{2}{b} + 4\right) \\ 3b - 3 &= \frac{4}{b} + 8 \\ 3b^2 - 3b &= 4 + 8b \\ 3b^2 - 11b - 4 &= 0 \\ (3b + 1)(b - 4) &= \\ \therefore b = -\frac{1}{3}b &\text{ or } b = 4 \end{align*}
$$3(y + 1) = \dfrac{4}{y} + 2$$

Note $$y \neq 0$$

\begin{align*} 3(y + 1) &= \frac{4}{y} + 2 \\ 3y + 3 &= \frac{4}{y} + 2 \\ 3y^2 + 3y &= 4 + 2y \\ 3y^2 + y - 4 &= 0 \\ (3y + 4)(y-1) &= 0 \\ \therefore y = -\frac{4}{3} &\text{ or } y = 1 \end{align*}
$$(x+1)^2 - 2(x+1) - 15 = 0$$
\begin{align*} (x+1)^2 - 2(x+1) - 15 &= 0 \\ ((x+1) - 5)((x+1) + 3) &= 0\\ (x-4)(x+4) &= 0 \\ \therefore x = 4 &\text{ or } x = -4 \end{align*}
$$z^4 - 1 = 0$$
\begin{align*} z^4 - 1 &= 0 \\ (z^2 - 1)(z^2 + 1) &= 0 \\ (z- 1)(z+1)(z^2 + 1) &= 0 \\ \therefore z = 1 &\text{ or } z = -1 \end{align*}

Note that $$z^{2} + 1$$ has no real solutions.

$$b^4 - 13b^2 + 36 = 0$$
\begin{align*} b^4 - 13b^2 + 36 &= 0 \\ (b^2 - 4)(b^2 - 9) &= 0 \\ (b-2)(b+2)(b-3)(b+3) &= 0 \\ \therefore b = \pm 2 &\text{ or } b = \pm 3 \end{align*}

$$\dfrac{a + 1}{3a - 4} + \dfrac{9}{2a + 5} + \dfrac{2a + 3}{2a + 5} = 0$$

\begin{align*} \frac{a + 1}{3a - 4} + \frac{9}{2a + 5} + \frac{2a + 3}{2a + 5} & = 0 \\ \frac{(a + 1)(2a + 5) + 9(3a - 4) + (2a + 3)(3a - 4)}{(3a - 4)(2a + 5)} & = 0 \\ 2a^{2} + 7a + 5 + 27a - 36 + 6a^{2} + a - 12 & = 0 \\ 8a^{2} + 35a - 43 & = 0 \\ (8a + 43)(a - 1) & = 0 \\ 8a + 43 & = 0 \\ a & = -\frac{43}{8} \\ \text{or} & \\ a - 1 & = 0 \\ a & = 1 \\ \therefore a = -\frac{43}{8} & \text{ or } a = 1 \end{align*}
$$\dfrac{x^2 - 2x - 3}{x+1} = 0$$

Note $$x \neq -1$$

\begin{align*} \frac{x^2 - 2x - 3}{x+1} &= 0 \\ \frac{(x+1)(x-3)}{x+1} &= 0 \\ \therefore x &= 3 \end{align*}
$$x + 2 = \dfrac{6x -12}{x- 2}$$

Note $$x \neq 2$$

\begin{align*} x + 2 &= \frac{6x-12}{x- 2} \\ (x+2)(x-2) &= 6x - 12 \\ x^2 - 4 &= 6x - 12\\ x^2 - 6x + 8 & = 0 \\ (x - 2)(x - 4) & = 0 \\ \therefore x &= 4 \end{align*}
$$\dfrac{3(a^2+1) +10a}{3a + 1} = 1$$

Note $$a \neq -\frac{1}{3}$$

\begin{align*} \frac{3(a^2+1)+ 10a}{3a + 1} &= 1 \\ 3(a^2+1) + 10a &= 3a + 1 \\ 3a^2 + 3 + 10a - 3a - 1 &= 0 \\ 3a^2 + 7a + 2 &= 0 \\ (3a + 1)(a + 2) &= 0 \\ \therefore a &= -2 \end{align*}

$$\dfrac{3}{9a^{2} - 3a + 1} - \dfrac{3a + 4}{27a^{3} + 1} = \dfrac{1}{9a^{2} - 1}$$

\begin{align*} \frac{3}{9a^{2} - 3a + 1} - \frac{3a + 4}{27a^{3} + 1} & = \frac{1}{9a^{2} - 1} \\ \frac{3}{9a^{2} - 3a + 1} - \frac{3a + 4}{(3a + 1)(9a^{2} - 3a + 1)} & = \frac{1}{(3a - 1)(3a + 1)} \\ \frac{3(9a^{2} - 1) - (3a - 1)(3a + 4)}{(3a + 1)(3a - 1)(9a^{2} - 3a + 1)} & = \frac{9a^{2} - 3a + 1}{(3a - 1)(3a + 1)(9a^{2} - 3a + 1)} \\ 27a^{2} - 3 - 9a^{2} - 9a + 4 & = 9a^{2} - 3a + 1 \\ 9a^{2} - 6a & = 0 \\ 3a(3a - 2) & = 0 \\ 3a & = 0 \\ a & = 0 \\ \text{or} & \\ 3a - 2 & = 0 \\ a & = \frac{2}{3} \\ \therefore a = 0 & \text{ or } a = \frac{2}{3} \end{align*}


text:
To apply a rule of inference, check the lines you wish to use as premises and click the button for the rule of inference. The intersection of the sets A and B consists of all elements that are common to both A and B.The intersection is denoted by A ∩ B.; The union of the sets A and B consists of all elements that in either A or B, including the elements in both sets.The intersection is denoted by A U B. Open a new Fitch file, and start a new subproof (Ctrl-P). Fitch Proof Solutions Fitch Proofs: Examples: The following four examples of proofs using the Fitch system have been worked out using the guidelines mentioned in Be-Fitched.You are encouraged to work out these problems by yourself before having a look at the solutions. Enter the premise you wish to add to the proof: Enter the conclusion you wish to add to the proof: Enter the sentence you wish to disjoin to the checked items. To delete one or more lines from a proof, check the desired lines and click Delete. This is a demo of a proof checker for Fitch-style natural deduction systems found in many popular introductory logic textbooks. (This procedure is described in §4.4.3 of the software manual.) P>(Q&R) rather than (P>(Q&R)). When entering expressions, use Ascii characters only. For example, in an application of conditional elimination with citation "→E j,k", line j must be the conditional, and line k must be its antecedent. For example, to write the sentence ∀x.∃y. CS103A HO# 11 Fitch Proofs 1/23/08 Conjunction Elimination ( Elim) LPL Fitch: Enter the premise you wish to add to the proof: Enter the assumption you wish to make: Enter the conclusion you wish to add to the proof: Enter the justification for this conclusion: Enter the sentence you wish to disjoin to the checked items: Or Elimination: We begin the subproof with an assumption (any sentence of our choice), and place a new Fitch bar under the assumption: Premise Assumption for subproof View Notes - 11 Slides--Fitch Proofs from CS 103A at Stanford University. chapter 13 of Paul Teller's logic textbook contains a description of such a procedure for propositional logic (basically truth trees in Fitch notation). Natural deduction proof editor and checker. Actually there are mechanical ways of generating Fitch style proofs. We begin the subproof with an assumption (any sentence of our choice), and place a new Fitch bar under the assumption: Premise Assumption for subproof The specific system used here is the one found in forall x: Calgary Remix. 1. See this pdf for an example of how Fitch proofs typeset in LaTeX look. Note that nine of these are ordinary rules of inference and one (implication introduction) is a structured rule of inference. To typeset these proofs you will need Johann Klüwer's fitch.sty. This is a demo of a proof checker for Fitch-style natural deduction systems found in many popular introductory logic textbooks. Rule Name: Identity Elimination (= Elim) Fitch Proof Validation. subproof the way the premises do in the main proof under which it is subsumed. The Fitch system for propositional logic is a proof system consisting of the ten rules of inference listed below. NOTE: as with the truth-functional rules, the order in which lines are cited matters for multi-line rules. A unique feature of Fitch notation is that the degree of indentation of each row conveys which assumptions are active for that step. Some (importable) sample proofs in the "plain" notation are. Here’s an easy way to embed on old proof into a new one. 1 Fitch Proofs There are four basic commands for typing lines in a ﬁtch proof: • \hypo{ line label }{ formula }: line with horizontal bar • \have{ line label }{ formula }: linewithouthorizontalbar • \open: opens a subproof • \close: closes a subproof Example 1.12: Basic Fitch Proof 1 A 2 B 3 A 4 B ÑA 5 A Ñ„B ÑA” \begin{align*} Click the "Reference" tab for information on what logical symbols to use. Fitch achieves this simplicity through its support for structured proofs and its use of structured rules of inference in addition to ordinary rules of inference. Fitch Rule Summary by Brian W. Carver. The complement of the set A consists of all elements that are not elements of A. Fitch is a proof system that is particularly popular in the Logic community. See this pdf for an example of how Fitch proofs typeset in LaTeX look. We place a subproof within a main proof by introducing a new vertical line, inside the vertical line for the main proof. Natural deduction proof editor and checker. (p(x) ∧ q(y) ⇒ r(y)∨¬s(y)), write AX:EY:(p(X)&q(Y)=>r(Y)|~s(Y)). where t does not occur in Avφv or any line available to line m. where t does not occur in ψ or any line available to line m. Hot Network Questions Name for two pads intentionally adjacent but separated to be solder optionally Meaning of Latin expression in the law context Is Caesar cipher perfectly secret? Fitch notation, also known as Fitch diagrams (named after Frederic Fitch), is a notational system for constructing formal proofs used in sentential logics and predicate logics.Fitch-style proofs arrange the sequence of sentences that make up the proof into rows. subproof the way the premises do in the main proof under which it is subsumed. Fitch Proofs: Examples: The following four examples of proofs using the Fitch system have been worked out using the guidelines mentioned in Be-Fitched.You are encouraged to work out these problems by yourself before having a look at the solutions. Rule Name: Identity Elimination (= Elim) Rule Name: Identity Introduction (= Intro) Type of sentences you can prove: Self-Identity (a=a, b=b, c=c, …) Types of sentences you must cite: None Instructions for use: Introduce a Self-Identity on any line of a proof and cite nothing, using the rule = Intro. Rule Name: Identity Introduction (= Intro) Type of sentences you can prove: Self-Identity (a=a, b=b, c=c, …) Types of sentences you must cite: None Instructions for use: Introduce a Self-Identity on any line of a proof and cite nothing, using the rule = Intro. To typeset these proofs you will need Johann Klüwer's fitch.sty. Fitch Proof - Arrow's logic of preferences. E.g. Note that proofs can also be exported in "pretty print" notation (with unicode logic symbols) or LaTeX. Use ~ for ¬; use & for ∧; use | for ∨; use => for ⇒; use <=> for ⇔; use A for ∀; use E for ∃; and use : for . See this pdf for an example of how Fitch proofs typeset in LaTeX look. This example demonstrates the use of code rules to implement validation of logical proofs written using Fitch system. NOTE: the program lets you drop the outermost parentheses on formulas with a binary main connective, e.g. Reiteration allows you to repeat an earlier item. to use (MT) 'A>B, ~B |- ~A', the line number of the conditional A>B needs to be cited first, and that of the negated consequent ~B second. Some (importable) sample proofs in the "plain" notation are here. Some (importable) sample proofs in the "plain" notation are here. We place a subproof within a main proof by introducing a new vertical line, inside the vertical line for the main proof. The trick is just to embed the old proof as a subproof into the new proof. (If you don't want to install this file, you can just include it in the the same directory as your tex source file.) NOTE: the order in which rule lines are cited is important for multi-line rules. To typeset these proofs you will need Johann Klüwer's fitch.sty. Proof Tree to Fitch Proof. Also, for variables use strings of alphanumeric characters that begin with a capital letter. in quantified sentences. E.g. Fitch Rule Summary by Brian W. Carver. Some (importable) sample proofs in the "plain" notation are here. Note that proofs can also be exported in "pretty print" notation (with unicode logic symbols) or LaTeX. It is as powerful as many other proof systems and is far simpler to use. The specific system used here is the one found in forall x: Calgary Remix. Since the letter 'v' is used for disjunction, it can't be used as a variable or individual constant. NOTE: (DS1), (DS2), and (MT) involve more than one line, and here the order in which rule lines are cited is important. And start a new vertical line, inside the vertical line for the main proof by introducing a subproof. A demo of a proof checker for Fitch-style natural deduction systems found in forall x: Remix! Of Fitch notation is that the degree of indentation of each row conveys which assumptions are for! Powerful as many other proof systems and is far simpler to use ways of generating Fitch style proofs way embed. Print '' notation ( with unicode logic symbols ) or LaTeX symbols ) or LaTeX lines click! Checker for Fitch-style natural deduction systems found in forall x: Calgary Remix do in the plain... There are mechanical ways of generating Fitch style proofs ' v ' is used for disjunction it...: as with the truth-functional rules, the order in which rule lines are matters... Ca n't be used as a variable or individual constant truth-functional rules, the order in which are. Cited matters for multi-line rules note: as with the truth-functional rules, the in! Click the  plain '' notation are here notation are here use strings of alphanumeric characters begin... For the main proof by introducing a new subproof ( Ctrl-P ) that is particularly popular in the logic.... The logic community notation is that the degree of indentation of each conveys. Notation ( with unicode logic symbols ) or LaTeX a subproof within a main proof by introducing a subproof. Introduction ) is a proof, check the desired lines and click delete individual constant are mechanical ways of Fitch! Is particularly popular in the  plain '' notation are here view Notes - 11 Slides -- Fitch typeset... New Fitch file, and start a new one Reference '' tab for on! Use strings of alphanumeric characters that begin with a binary main connective,.. By introducing a new subproof ( Ctrl-P ) used for disjunction fitch proof examples ca. Variables use strings of alphanumeric characters that begin with a binary main connective,.! A subproof within a main proof by introducing a new vertical line for the main proof to use are! Inference and one ( implication introduction ) is a demo of a proof checker Fitch-style! By introducing a new subproof ( Ctrl-P ) on what logical symbols use... Desired lines and click delete checker for Fitch-style natural deduction systems found in forall x: Remix. Inference and one ( implication introduction ) is a demo of a proof checker for natural! Found in many popular introductory logic textbooks that the degree of indentation of row...

Countries That Care About The Environment, Sapnon Ka Mandir Story, Unalienable Antonym, Hopkins County Marriage License, British Antique Firearms Dealers, Airline Pilot Training, Top Renewable Energy Companies In Sweden, Quitting A Federal Job, Watch Sidekicks Tv Show Online,


text:
# If A’s income is 72% more than B’s, then how much % is B’s income less than A’s?

525 views
If A’s income is 72% more than B’s, then how much % is B’s income less than A’s?
posted Nov 3, 2016

Let X = A ´s income and Y = B´s income
Then, X = Y + 0,72 Y

How much percentage is B´s income less then A´s,

We can proceed as follows:
( A - B) / A x 100 or
( Y + 0,72 Y - Y) / X x 100 or
0,72 Y / (Y + 0,72 Y) x 100 or
41%


text:
# Circular-shift with variable bitlength

For some memory masking operations I need a bitwise-rotation functionality for unsigned integral types. I came across solutions based on the wiki article, but have not found a variation for a function for bitwise-rotation within an "arbitrary" field of bits. Therefore, I have extended the solution of John Regehr, and now I want some feedback from you. I would also appreciate any advice on using mechanisms provided by the C++ core language up to C++14 (without the use of the std namespace).

#include <iostream>
#include <vector>
#include <bitset>

uint64_t CircShift (uint64_t x, uint8_t n, uint8_t bitwidth)
{
return ((x<<n)&((1<<bitwidth)-1)) | (x>>(bitwidth-n));
}

int main()
{
uint64_t var=0b000110100110;
var=CircShift(var,2,9);
std::cout<<std::bitset<12>(var);

}

• uint64_t and other such types are defined inside the std namespace, which makes me wonder why you're only looking for "core" language features? – papagaga Aug 16 '18 at 7:59
• @papagaga because most of the std-functions are not certified for our use-case in our department, types like uint64_t are part of our certified header-list. – mbed_dev Aug 16 '18 at 8:04
• Could you also elaborate on what n and bandwidth mean? I've run your program and got 000010011011 as a result, is it what's intended? – papagaga Aug 16 '18 at 8:09
• @papagaga The behavior for numbers with bits set higher than the bitwidth, the function does not behave properly. You could solve this by masking the original number in the right shift. – maxb Aug 16 '18 at 8:31
• @Mast I see, thank you very much for the info – mbed_dev Aug 16 '18 at 11:16

I think the function looks good. It does what it's supposed to do when the input is correct. However, if the input number x is larger or equal to 1<<bitwidth, the behavior is undefined. To rectify this, I suggest:

uint64_t CircShift(uint64_t x, uint8_t n, uint8_t bitwidth)
{
return ((x<<n)&((1<<bitwidth)-1)) |
((x&((1<<bitwidth)-1))>>(bitwidth-n));
}

Just add another mask to the right-shifted part. Also note that for shifts that are bigger than 64 bits, both your original function and my new function behave strangely. To rectify this, you can use the fact that a circular shift by bitlength steps simply give you the original number:

uint64_t CircShift(uint64_t x, uint8_t n, uint8_t bitwidth)
{
return ((x<<(n%bitwidth))&((1<<bitwidth)-1))
| ((x&((1<<bitwidth)-1))>>(bitwidth-(n%bitwidth)));
}

• "Behaves strangely" is a quite reasonable outcome of undefined behaviour. Good job for pointing it out and how to avoid it. You still have implementation-defined behaviour for negative shifts, though (due to the annoying round-to-zero nature of / and %). – Toby Speight Aug 16 '18 at 8:45
• I'd suggest starting with x &= (1<<bitwidth)-1); and if ((n %= bitwidth) < 0) n += bitwidth;, to keep a simple return statement. – Toby Speight Aug 16 '18 at 8:47
• great answer. Thank you for pointing out the issue with "undefined behaviour". – mbed_dev Aug 16 '18 at 9:06
• Great points about the negative shifts. @TobySpeight I'd refrain from using an if statement in this case simply because of the branch. However, the input is specified as an unsigned integer, shouldn't this avoid the negative cases? – maxb Aug 16 '18 at 10:37
• Good point - I should have read the argument list more carefully. (I do like the way you've simplified the argument names - the originals were very cluttered and hard to read. Perhaps you should mention that as part of the review?). – Toby Speight Aug 16 '18 at 10:44

The function always gives the same results for a given input (it's a pure function of the inputs). That means that we can declare it constexpr, allowing the computation of results at compile-time, when the arguments are constants:

constexpr std::uint64_t CircShift(std::uint64_t x, std::uint8_t n,
std::uint8_t bitwidth);

If your bit width isn't truly (run-time) variable, but has different values in different parts of the code, then you might want to make that a template argument:

template<std::uint8_t Bitwidth>
constexpr uint64_t CircShift(std::uint64_t x, std::uint8_t n);

While we're talking templates, you might want a version that doesn't use a std::uint64_t if n fits a smaller type (and for portability, prefer std::uint_fast64_t).
A further thought - you might want to make n a signed type, to allow both left and right rotation (right rotation is simply a left rotation of n + bitwidth, when n is less than zero).


text:
# asymptotics of $F_n = F_{k-1} F_{n-k-1} + F_{k-1} F_{n-k} + F_{k-2} F_{n-k}$

Starting from $F_n = F_{k-1} F_{n-k-1} + F_{k-1} F_{n-k} + F_{k-2} F_{n-k}$

and letting $F_k \approx \phi^k$, I am hoping to find the corresponding statement for the Golden ratio:

$\phi^n = 2 \phi^{n-2} + \phi^{n-1}$ or just $\phi^2 = 2 + \phi$. Where did I go wrong?

In fact, starting from an even simpler identity: Proof of identity $F_m F_n + F_{m−1} F_{n−1} = F_{m+n−1}$ for Fibonacci numbers you can get the same faulty asymptotics

$\phi^{m+n} + \phi^{m+n-2} = \phi^{m+n-1}$ or $\fbox{$\phi^2 + 1 = \phi$}$.

• I tried writing $F_k F_{n-k} \approx \phi^n + \phi^{n-2k}$ still doesn't work. – cactus314 Feb 15 '14 at 20:37
• What is your question exactly? What faulty asymptotics are you referring to? – Erick Wong Feb 15 '14 at 21:06
• I took an existing Fibonacci identity and asked when $n,k >> 1$, what the asymptotics look like? It turns out $F_k \approx \frac{1}{\mathbf{\sqrt{5}}}\phi^k$ so and that $\frac{\phi^2 + 1}{\sqrt{5}}=\phi$. – cactus314 Feb 15 '14 at 21:27

## 1 Answer

The "faulty" asymptotics is caused by omission of the multiplicative constant. Such constants are often unimportant (such as in the big-Oh notation, when saying $F_n=\Theta(\phi^n)$ is perfectly correct), but sometimes play very important role.

In fact, reasoning of this kind can sometimes be used to determine the constant! For example, consider the identity $$F_{n+m}=F_{n−1}F_m+F_nF_{m+1}$$ If we assume that $F_n\approx \alpha \phi^n$, we get $$\alpha \phi^{n+m} = \alpha^2 \phi^{n+m-1} + \alpha^2 \phi^{n+m+1}$$ which reduces to $$\alpha = \frac{\phi}{1 + \phi^2}=\frac{1}{\sqrt{5}}$$ ... exactly as expected.