text:
# How to plot a function defined in considerable time with Plot3D

I'm trying to plot a function as follows:

In[1]:=Psi1[l1_,m1_,l2_,m2_]:=Sqrt[(2*l1+1)/(4*Pi)]*LegendreP[l1,m1,Cos[theta1]]*Sqrt[(2*l2+1)/(4*Pi)]*LegendreP[l2,m2,Cos[theta2]]-Sqrt[(2*l1+1)/(4*Pi)]*LegendreP[l1,m1,Cos[theta2]]*Sqrt[(2*l2+1)/(4*Pi)]*LegendreP[l2,m2,Cos[theta1]]

In[2]:=Den1[l1_,m1_,l2_,m2_]:=1/2*Psi1[l1,m1,l2,m2]^2

In[3]:=Fun1[l1_,m1_,l2_,m2_]:=Integrate[Den1[l1,m1,l2,m2]*Sin[theta1]*Sin[theta2],{theta1,x1,Pi},{phi1,0,2*Pi},{theta2,x2,Pi},{phi2,0,2*Pi}]

In[4]:=Plot3D[Fun1[2,0,1,0],{x1,0,Pi},{x2,0,Pi},PlotRange->All]

And:

In[5]:=CumDen1[l1_,m1_,l2_,m2_]:=Plot3D[Fun1[l1,m1,l2,m2],{x1,0,Pi},{x2,0,Pi},PlotRange->All]

In[6]:=CumDen1[2,0,1,0]

But I've noticed that Mathematica takes more than 60 minutes to plot the function that if it does it in parts:

In[7]:=Fun1[2,0,1,0]

In[8]:=Plot3D[%,{x1,0,Pi},{x2,0,Pi},PlotRange->All]

With this form, Mathematica graphs the function in less than 60 seconds.

Of course, everything gets too complicated when I want to plot the function for several values of l1 and l2 as follows:

In[9]:=Do[If[l1=!=l2,Print[{l1,l2,CumDen1[l1,m1,l2,m2]}]],{l1,0,5},{l2,0,5},{m1,0,0},{m2,0,0}]

Is there any way that Mathematica can plot these functions in a considerable time?

• In this case, you might wish to consider memoizing the integration so that it does not have to be done for every point in your plot: Fun1[l1_, m1_, l2_, m2_] := Fun1[l1, m1, l2, m2] = (* stuff *) – J. M.'s ennui Aug 24 '17 at 7:22
• Simply putting an Evaluate around the function in the plot should help a lot. – mmeent Aug 24 '17 at 7:27
• In your def of Fun1 you're integrating w.r.t. phi1 and phi2. But, as far as I can tell, they don't appear in the integrand. Also, for clarity if nothing else, I would probably write Psi1 and Den1 etc. explicitly as functions of the terms you later integrate over (ie. theta1, theta2, x1, x2, etc). – aardvark2012 Aug 24 '17 at 10:46

# TL;DR;

Define

int[a_ + b_] = int[a] + int[b]
int[a_] = int[int[a, 1], 2]
int[f_ a_, i_] := f int[a, i] /; FreeQ[f, Indexed[_, i]]
int[f_, i_] := 2 Pi (Pi - Indexed[x, i]) f /; FreeQ[f, Indexed[_, i]]
int[exp[a_?(FreeQ@Indexed[_, i_]) Indexed[\[Theta], i_]], i_] =
Integrate[
Exp[a Indexed[\[Theta], i]], {Indexed[\[Theta], i], Indexed[x, i],
Pi}, {Indexed[\[Phi], i], 0, 2*Pi}]

and

Psi1[l1_, m1_, l2_, m2_] :=
Sqrt[(2*l1 + 1)/(4*Pi)]*LegendreP[l1, m1, Cos[Indexed[\[Theta], 1]]]*
Sqrt[(2*l2 + 1)/(4*Pi)]*
LegendreP[l2, m2, Cos[Indexed[\[Theta], 2]]] -
Sqrt[(2*l1 + 1)/(4*Pi)]*
LegendreP[l1, m1, Cos[Indexed[\[Theta], 2]]]*
Sqrt[(2*l2 + 1)/(4*Pi)]*
LegendreP[l2, m2, Cos[Indexed[\[Theta], 1]]]

Den1[l1_, m1_, l2_, m2_] := 1/2*Psi1[l1, m1, l2, m2]^2

Fun1[l1_, m1_, l2_, m2_] :=
Fun1[l1, m1, l2, m2] =
Simplify@ExpToTrig[
int[Expand@
TrigToExp[
Den1[l1, m2, l2, m2]*Sin[Indexed[\[Theta], 1]]*
Sin[Indexed[\[Theta], 2]] /.
Sqrt[1 - Cos[Indexed[\[Theta], i_]]^2] :>
Sin[Indexed[\[Theta], i]]] /.
E^(a_ + b_: 0) :> exp[a] exp[b]] /. exp -> Exp]

Fun1P[l1_, m1_, l2_, m2_] :=
Fun1[l1, m1, l2, m2] /. {Indexed[x, 1] -> x1, Indexed[x, 2] -> x2}

Now plot with:

Plot3D[Fun1P[2, 0, 1, 0], {x1, 0, Pi}, {x2, 0, Pi}, PlotRange -> All]

# Explanation

Apart from memoization/Evaluate, we can do a little bit more to speed up this specific function:

First, we look at some typical outputs from Den1 - you'll notice that the output only consists of products of trigonometric functions and occasionally $\sqrt{1-\cos^2\theta_i}$ (which we can simply replace with $\sin\theta_i$ since $0<\theta_i<\pi$). Now we can make our own integration function that is specialized for this type of functions:

To make things a bit easier later, we redefine Psi1 to use Indexed expressions instead of hardcoded names:

Psi1[l1_, m1_, l2_, m2_] :=
Sqrt[(2*l1 + 1)/(4*Pi)]*LegendreP[l1, m1, Cos[Indexed[\[Theta], 1]]]*
Sqrt[(2*l2 + 1)/(4*Pi)]*
LegendreP[l2, m2, Cos[Indexed[\[Theta], 2]]] -
Sqrt[(2*l1 + 1)/(4*Pi)]*
LegendreP[l1, m1, Cos[Indexed[\[Theta], 2]]]*
Sqrt[(2*l2 + 1)/(4*Pi)]*
LegendreP[l2, m2, Cos[Indexed[\[Theta], 1]]]

Next, we define our specialized integral, int. First, we make it transparent to addition:

int[a_ + b_] = int[a] + int[b]

Next, we separate integrals into ones over $\theta_1$ and $\theta_2$:

int[a_] = int[int[a, 1], 2]

where we take int[f,i] to mean "integrate f over $\theta_1,\phi_1$". Now, we need to pull out constant factors:

int[f_ a_, i_] := f int[a, i] /; FreeQ[f, Indexed[_, i]]

The Condition (/; for short) ensures that the factor we want to pull out does indeed not contain any variable indexed with i. Integrals over constants are handled by

int[f_, i_] := 2 Pi (Pi - Indexed[x, i]) f /; FreeQ[f, Indexed[_, i]]

where the Condition ensures once again that we really have a constant. To check how far we got, we can apply it to e.g. Den1[2, 1, 1, 0]*Sin[Indexed[\[Theta], 1]]*Sin[Indexed[\[Theta], 2]]:

int[Expand@
TrigToExp[
Den1[2, 1, 1, 0]*Sin[Indexed[\[Theta], 1]]*
Sin[Indexed[\[Theta], 2]]]]

We apply Expand and TrigToExp to get terms that are as simple as possible. There are still some square roots left. As mentioned above, we can deal with them using Sqrt[1 - Cos[Indexed[\[Theta], i_]]^2] :> Sin[Indexed[\[Theta], i]]:

int[Expand@
TrigToExp[
Den1[2, 1, 1, 0]*Sin[Indexed[\[Theta], 1]]*
Sin[Indexed[\[Theta], 2]] /.
Sqrt[1 - Cos[Indexed[\[Theta], i_]]^2] :>
Sin[Indexed[\[Theta], i]]]]

We need some way of separating the exponentials, and since they're automatically combined every time you have a product, we replace them with exp[x]: /. E^(a_ + b_: 0) :> exp[a] exp[b]. Now we're nearly there:

int[Expand@
TrigToExp[
Den1[2, 1, 1, 0]*Sin[Indexed[\[Theta], 1]]*
Sin[Indexed[\[Theta], 2]] /.
Sqrt[1 - Cos[Indexed[\[Theta], i_]]^2] :>
Sin[Indexed[\[Theta], i]]] /. E^(a_ + b_: 0) :> exp[a] exp[b]]

We just need to define int for exponential terms:

int[exp[a_?(FreeQ@Indexed[_, i_]) Indexed[\[Theta], i_]], i_] =
Integrate[
Exp[a Indexed[\[Theta], i]], {Indexed[\[Theta], i], Indexed[x, i],
Pi}, {Indexed[\[Phi], i], 0, 2*Pi}]

This applies to expressions of the form $e^{a\cdot\theta_i}$, where we're using our "custom" exponential exp. Cleaning up with Simplify and ExpToTrig, we arrive at our final result (we also replace exp with Exp again):

Simplify@ExpToTrig[
int[Expand@
TrigToExp[
Den1[2, 1, 1, 0]*Sin[Indexed[\[Theta], 1]]*
Sin[Indexed[\[Theta], 2]] /.
Sqrt[1 - Cos[Indexed[\[Theta], i_]]^2] :>
Sin[Indexed[\[Theta], i]]] /.
E^(a_ + b_: 0) :> exp[a] exp[b]] /. exp -> Exp]


text:
# Recovering a basis from an isomorphism with the dual space.

Let $V$ be a finite dimensional vector space, then given a basis for $V$ constructing an isomorphism $V \rightarrow V^*$ is easy, but how about the reverse direction? Given an explicit isomorphism $\phi : V \rightarrow V^*$ can we fully recover a basis for $V$?

Denoting $v \in V$ denote $\phi(v) = \phi_v$. Take the elements $e_i \in V$ satisfying $\phi_{e_i}(e_j) = \delta_{i,j}$. It's easy to check that these elements are linearly independent but do they form a basis?

• If $V$ has dimension $n$ then any $n$ independent vectors form a basis. This is the finite-dimensional-vector-spaces-are-magic theorem... – David C. Ullrich Aug 28 '15 at 14:23
• Yup, so the question becomes, for any isomorphism are there $n$ such vectors $e_i$ satisfying this condition. – Nostromo Aug 28 '15 at 14:31
• $\phi^{-1}$ is an isomorphism $V^* \to V$. Also $\phi^*$ is an isomorphism $V^* \to V^{**}$. So this really isn't even a different problem! – Excluded and Offended Aug 28 '15 at 14:34
• My last comment (deleted) didn't make sense. I don't see how this is the same problem in disguise, can you elaborate? – Nostromo Aug 28 '15 at 15:14
• The answer to my original question is no. The non-degenerate bilinear form corresponding to the isomorphism $\phi$ won't satisfy the frobenius axioms in general. It's known that bases of vector spaces correspond with special commutative frobenius algebras. – Nostromo Aug 28 '15 at 15:26

format: plain


text:
# Thread: evaluate limit

1. ## evaluate limit

use L'Hopitals Rule
as the limit x approaches 0 from the right side
tanxlnx

i got as far as this lnx/(1/tanx) and tried to differentiate but coudnt get anything that sounded right

2. Hello, fgkl8!

Use L'Hopital's Rule: . $\lim_{x\to0^+} \tan x\ln x$

Since the limit goes to: . $0\cdot(\text{-}\infty)$, we can apply L'Hopital.

We have: . $\tan x \ln x \:=\:\frac{\ln x}{\cot x}$

Apply L'Hopital: . $\frac{\frac{1}{x}}{-\csc^2\!x} \;=\;-\frac{\sin^2\!x}{x} \;=\;-\left(\frac{\sin x}{x}\right)\left(\frac{1}{x}\right)$

Therefore: . $\lim_{x\to0^+}\bigg[-\left(\frac{\sin x}{x}\right)\left(\frac{1}{x}\right)\bigg] \;=\;-(1)(\infty) \;=\;-\infty$

3. Originally Posted by Soroban
Hello, fgkl8!

Since the limit goes to: . $0\cdot(\text{-}\infty)$, we can apply L'Hopital.

We have: . $\tan x \ln x \:=\:\frac{\ln x}{\cot x}$

Apply L'Hopital: . $\frac{\frac{1}{x}}{-\csc^2\!x} \;=\;-\frac{\sin^2\!x}{x} \;=\;-\left(\frac{\sin x}{x}\right)\left(\frac{1}{x}\right)$

correction ...

Therefore: . $\lim_{x\to0^+}\textcolor{red}{\bigg[-\left(\frac{\sin x}{x}\right)\left(\frac{\sin{x}}{1}\right)\bigg] \;=\;-(1)(0) = 0 }$

...

4. Originally Posted by Soroban
Hello, fgkl8!

Since the limit goes to: . $0\cdot(\text{-}\infty)$, we can apply L'Hopital.

We have: . $\tan x \ln x \:=\:\frac{\ln x}{\cot x}$

Apply L'Hopital: . $\frac{\frac{1}{x}}{-\csc^2\!x} \;=\;-\frac{\sin^2\!x}{x} \;=\;-\left(\frac{\sin x}{x}\right)\left(\frac{1}{x}\right)$
EDIT: Was just a typo in. missed that a sin was missing just noticed the (sin/x)(1/x) bit.

Therefore: . $\lim_{x\to0^+}\bigg[-\left(\frac{\sin x}{x}\right)\left(\frac{1}{x}\right)\bigg] \;=\;-(1)(\infty) \;=\;-\infty$

i dont agree with the last line, lim(ab)=lim (a)lim(b) if both limits exist.
applying l'hopitals once again gives

lim 2sinxcosx/1 as x goes to 0

which is 0

5. for $x\ne0$ we have $\tan (x)\ln (x)=\frac{\tan x}{x}\cdot x\ln (x),$ and we can compute its limit.


text:
Step-by-step Solution

Go!
1
2
3
4
5
6
7
8
9
0
a
b
c
d
f
g
m
n
u
v
w
x
y
z
.
(◻)
+
-
×
◻/◻
/
÷
2

e
π
ln
log
log
lim
d/dx
Dx
|◻|
=
>
<
>=
<=
sin
cos
tan
cot
sec
csc

asin
acos
atan
acot
asec
acsc

sinh
cosh
tanh
coth
sech
csch

asinh
acosh
atanh
acoth
asech
acsch

Step-by-step explanation

Problem to solve:

$\int x^2\ln\left(x\right)dx$

Learn how to solve calculus problems step by step online.

$\displaystyle\int u\cdot dv=u\cdot v-\int v \cdot du$

Learn how to solve calculus problems step by step online. Calculate the integral of x^2ln(x). We can solve the integral \int x^2\ln\left(x\right)dx by applying integration by parts method to calculate the integral of the product of two functions, using the following formula. First, identify u and calculate du. Now, identify dv and calculate v. Solve the integral.

$\frac{x^{3}\ln\left(x\right)}{3}-\frac{1}{9}x^{3}+C_0$
$\int x^2\ln\left(x\right)dx$


text:
# How do you calculate the formal charge of O3?

Nov 7, 2015

The formal charge of the ozone molecule is zero. Its Lewis structures do present charge separation.

#### Explanation:

With simple VSEPR considerations, there are 18 valence electrons to distribute around the 3 oxygen atoms (24 electrons in total; 6 are inner core).

Typically, a Lewis structure of O=stackrel(ddot)O^(+)-O^(-), would be depicted. Going from left $O$ to right $O$ and including the 2 inner core electrons on each atom, there are 8, 7, and 9 electrons around each oxygen centre, resulting in formal charges of $0$, $+ 1$, and $- 1$, respectively. Of course, I can draw the other resonance structure, but the Lewis structure has the same electronic formulation. The $\angle O - O - O$ $\cong {117}^{\circ}$; this is slightly LESS than the normal $s {p}_{2}$ bond angle of ${120}^{\circ}$, due to disproportionate influence of the oxygen lone pair, which tends to compress $\angle O - O - O$.

Since the central oxygen has 3 regions of electron density, this molecule is bent.


text:
# Parallel Lines Notation

Parallel lines are denoted by the parallel symbol placed betwen the notation of the two lines. A line is denoted by the start and end letter with a line over top.


text:
# Term for weak head normal forms that cannot be reduced in any environment

In my understanding, a lambda expression is a normal form (NF) when it has no redexes. For instance, $\lambda x.x$ is a NF, but $(\lambda x.x)y$ is not. A lambda expression is a weak head normal form (WHNF) if the root expression is not a redex. For instance, $\lambda x.(\lambda y.y)x$ is a WHNF, but not a NF as it reduces to $\lambda x.x$.

When implementing functional programming languages we call the opposite of an expression in WHNF a thunk. Thus, taking Haskell as an example, const 1 2 is a thunk (it evaluates to 1), but const, const 1 and (1,const 1) are WHNFs (the first two are unsaturated applications; the last is a constructor).

I'm looking for term to distinguish const (1,2) and (1,const 1). They are both WHNFs, neither is in NF, however, the root constructor of the latter ((,)) will not change any more while that of the former (const) may still change, if it is applied to some other expression (to (,)). Are there terms that distinguish WHNFs of which the head can/cannot change in any environment?

• What you are calling "head normal form" is actually weak head normal form. See, e.g. page 5 of Demonstrating Lambda Calculus Reduction. – Derek Elkins left SE May 25 '18 at 21:39
• @DerekElkins thanks for clarifying that for me! I updated the question. – user23039 May 25 '18 at 21:58
• If you claim that "const 1 may change" because we could apply it to 2, then you also have to agree that const (1, 2) may change because we could apply fst to it. I do not understand your question. And the title of your question is odd, did you mean "evaluation context" instead of "environment"? An environment is a mapping of variables to their values, but you are talking about closed expressions which are completely independent of the environment. – Andrej Bauer May 26 '18 at 18:18
• @AndrejBauer yes, I agree, I didn't think of it that way. I suppose then what I'm looking for is "a WHNF that can be applied" vs. "a WHNF that cannot be applied". I suppose there are no terms for that? Perhaps you could add your comment as an answer. It doesn't answer the question directly, but does explain why it is a weird question. – user23039 May 28 '18 at 9:52
• If I understand you correctly, you want to make application special. So of all eliminator forms applying to a term is special. It would be helpful to know the motivation for this. Where are you going with this? – Andrej Bauer May 28 '18 at 12:24


text:
# Stata: ml versus nl

#### kungal

##### New Member
I need to estimate an equation using some iterative method to optimally choose the coefficients. I won't go into the reasons that I can't use a simpler methods like OLS, GLS or instrumental variables (it's a long, sad story).

My question is about weather I can expect equivalent results from ml and nl. Say I want to estimate

y_t = \alpha + \beta y_{t-1} + \gamma x_t + u_t

where I have autocorrelation in the error terms. Do I need to put in the effort to specify a likelihood function and ask Stata to maximize it, or will I get the same result if I ask Stata to minimize the sum of squares using nl?

#### skolenik

##### New Member
What is the distribution of the error terms u_t? If it i.i.d. Gaussian, then ML will be the same as NL. If not, they won't be the same, and ML will be more efficient when it is correct (but arguably NL will be robust when ML is misspecified, although you may have hard time getting Newey-West standard errors out of NL). If the distribution of the errors is Cauchy, then NL may not be defined/may not converge.


text:
## Finding integer vertices in an MILP

General discussion on polymake goes here.
Abbas Omidi
Posts: 7
Joined: 26 Sep 2021, 12:46

### Finding integer vertices in an MILP

Dear support team,

I am trying to implement a decomposition algorithm and I have to work with extreme points of the MILP. As I asked some questions about defining polyhedron, I have tried to use the same approach to find integer vertices, but I am failing to do that. Also, I am working on lattice and lattice points too. What I am looking for is, in an MILP problem (actually, the defined polyhedron) the integer vertices are $\{(0,0),(4,0),(2,1),(0,1)\}$ respectively. when I am solving the problem the Polymake shows vertices of the linear relaxation of the MILP and it is different from what I am looking for. The syntax I have used is:
***
* without upper bound
$p = new Polytope(INEQUALITIES=>[[18,-4,-9],[4,2,-4],[0,1,0],[0,0,1]]); *** *** * with upper bound$p = new Polytope(INEQUALITIES=>[[18,-4,-9],[4,2,-4],[0,1,0],[0,0,1],[-9,-1,0],[-9,0,-1]]);
***
In the first attempt, I got the linear relaxation vertices while, in the second, it seems, the Polymake waits for another argument.
I was wondering if, how can I define/find the integer vertices of the MILP polyhedron?

Regards
Abbas

paffenholz
Developer
Posts: 197
Joined: 24 Dec 2010, 13:47

### Re: Finding integer vertices in an MILP

Yor can compute the integer hull of a polyhedron with the function integer_hull and then ask for the vertices:

Code: Select all

$q=integer_hull($p); print $q->VERTICES; 1 0 0 1 0 1 1 2 1 1 4 0  Note however, that this internally computes a representation of all integer points in the polyhedron. There is no significantly more efficient algorithm to compute the integer hull of a polyhedron. Your second polytope is empty. The last two inequalities demand that all coordinates are less or equal to -9, but already the first polytope, which is a relaxation of the second, lives in the positive orthant. Abbas Omidi Posts: 7 Joined: 26 Sep 2021, 12:46 ### Re: Finding integer vertices in an MILP Dear Dr. Paffenholz, Many thanks for your prompt reply. I am aware of, the finding all of the integer vertices of a MILP problem needs to consume a lot of time and effort, but for a trivial problem, it is very helpful for understanding the problem structure. W.r.t the above problem, As it has four vertices, indeed has eight integer extreme points. Is there any way to find all of the extreme points of the problem? Regards Abbas paffenholz Developer Posts: 197 Joined: 24 Dec 2010, 13:47 ### Re: Finding integer vertices in an MILP I am not sure what you mean by "extreme point". Can you please give a definition? There are eight integral points contained in the polytope, which you can compute via Code: Select all print$p->LATTICE_POINTS; 1 0 0 1 0 1 1 1 0 1 1 1 1 2 0 1 2 1 1 3 0 1 4 0
Six of them are on the boundary:

Code: Select all

print \$p->BOUNDARY_LATTICE_POINTS; 1 0 0 1 0 1 1 1 0 1 2 0 1 3 0 1 4 0

Abbas Omidi
Posts: 7
Joined: 26 Sep 2021, 12:46

### Re: Finding integer vertices in an MILP

Dear Dr. Paffenholz,


text:
# 1. Create the Tex source from a template¶

Open MIAU and unfold the checkin tree so that you can see the section where you want to create the new program problem. For this tutorial, we assume the section is content/test/problems, but you can choose a different one of course. The MIAU window should look like the following (click on the image to get a larger view):

Right-click on the section and select "New > Mumie Document or Course" in the popup menu:

In the wizard that opens, select "Building Blocks (TeX) > Problem > Programming problem" and enter a name for the new document. In the problem we delevelop in this tutorial the user has to calculate the minimum in an array of numbers, so we choose the name "minimum_in_array":

Click "Next". In the window that opens then, select a language:

Click "Next".:

Click "Finish". MIAU creates a skeleton for the Tex source and loads it in the editor:

The skeleton creates some placeholder items that we replace by the real entries. First, switch to the metainfo tab and provide a suitable name and description:

Return to the "Content Block" tab. Here is the code you should see:

\title{Enter title here}

Describe problem here...

public static int methodToImplement (int[] array) {  % <-- Change this
}

\prgwrapper{net.mumie.test.program.SampleWrapper}      % <-- Change this
\prgevaluator{net.mumie.test.program.SampleEvaluator}  % <-- Change this

We change the title, the text below the title, and the prganswer environment which creates the input field for the user:

\title{Minimum in array}

Write a Java method which computes and returns the minimum number of an array
of integer numbers. If the array is empty, the largest possible integer number
is to be returned. Complete the following code fragment:

public static int getInt (int[] array) {
}


text:
# Top 10 8th Grade FSA Math Practice Questions

Preparing for the 8th Grade FSA Math test? The best way to prepare for your 8th Grade FSA Math test is to work through as many 8th Grade FSA Math practice questions as possible. Here are the top 10 8th Grade FSA Math practice questions to help you review the most important 8th Grade FSA Math concepts. These 8th Grade FSA Math practice questions are designed to cover mathematics concepts and topics that are found on the actual test. The questions have been fully updated to reflect the latest 2022 8th Grade FSA guidelines. Answers and full explanations are provided at the end of the post.

Start your FSA Math test prep journey right now with these sample FSA Math questions.

## 8th Grade FSA Math Practice Questions

1- A rope weighs 600 grams per meter of length. What is the weight in kilograms of 12.2 meters of this rope? (1 kilograms = 1000 grams)

A. 0.0732

B. 0.732

C. 7.32

D. 7320

2- In a school, the ratio of the number of boys to girls is 3:7. If the number of boys is 180, what is the total number of students in the school?__________
Write your answer in the box below.

3- In two successive years, the population of a town is increased by $$15\%$$ and $$20\%$$. What percent of its population is increased after two years?

A. 32

B. 35

C. 38

D. 68

4- Which graph shows a non–proportional linear relationship between $$x$$ and $$y$$?

A.

B.

C.

D.

5- In the rectangle below if $$y>5$$ cm and the area of the rectangle is 50 cm$$^2$$ and the perimeter of the rectangle is 30 cm, what is the value of $$x$$ and $$y$$ respectively?

A. $$4, 11$$

B. $$5, 11$$

C. $$5, 10$$

D. $$4, 10$$

6- A football team had $40,000 to spend on supplies. The team spent$22,000 on new balls. New sports shoes cost $240 each. Which of the following inequalities represent how many new shoes the team can purchase. A. $$240x+22,000 ≤40,000$$ B. $$240x+22,000 ≥40,000$$ C. $$22,000x+240 ≤40,000$$ D. $$22,000x+240 ≥40,000$$ 7- Right triangle ABC has two legs of lengths 6 cm (AB) and 8 cm (AC). What is the length of the third side (BC)? A. 4 cm B. 6 cm C. 8 cm D. 10 cm 8- If $$3x-5=8.5$$, What is the value of $$5x+3$$? A. 13 B. 15.5 C. 20.5 D. 25.5 9- A bank is offering $$4.5\%$$ simple interest on a savings account. If you deposit$8,000, how much interest will you earn in five years?

A. $360 B.$720

C. $1800 D.$3600

10- In a party, 10 soft drinks are required for every 12 guests. If there are 252 guests, how many soft drinks is required?

A. 21

B. 105

C. 210

D. 2510

$13.99 Satisfied 48 Students ## Answers: 1- C The weight of 12.2 meters of this rope is: $$12.2 × 600 g = 7320 g$$ $$1 kg = 1000 g$$ therefore, $$7320 g ÷ 1000 = 7.32 kg$$ 2- 600 The ratio of boys to girls is $$3:7$$. Therefore, there are 3 boys out of 10 students. To find the answer, first, divide the number of boys by 3, then multiply the result by 10. $$180 ÷ 3 = 60 ⇒ 60 × 10 = 600$$ 3- C the population is increased by $$15\%$$ and $$20\%$$. $$15\%$$ increase changes the population to $$115\%$$ of the original population. For the second increase, multiply the result by $$120\%$$. $$(1.15) × (1.20) = 1.38 = 138\%$$ 38 percent of the population is increased after two years. 4- B A linear equation is a relationship between two variables, $$x$$ and $$y$$, that can be put in the form $$y = mx + b$$. A non-proportional linear relationship takes on the form $$y=mx + b$$, where $$b ≠ 0$$ and its graph is a line that does not cross through the origin. 5- C The perimeter of the rectangle is: $$2x+2y=30→x+y=15→x=15-y$$ The area of the rectangle is: $$x×y=50→(15-y)(y)=50→y^2-15y+50=0$$ Solve the quadratic equation by factoring method. $$(y-5)(y-10)=0→y=5$$ (Unacceptable, because y must be greater than 5) or $$y=10$$ If $$y=10 →x×y=50→x×10=50→x=5$$ 6- A Let $$x$$ be the number of new shoes the team can purchase. Therefore, the team can purchase 240 $$x$$. The team had$40,000 and spent $22,000. Now the team can spend on new shoes$18,000 at most.
Now, write the inequality: $$120x+22.000 ≤40.000$$

7- D
Use Pythagorean Theorem:
$$a^2 + b^2 = c^2$$
$$6^2 + 8^2 = c^2 ⇒ 100 = c^2 ⇒ c = 10$$

8- D
$$3x-5=8.5→3x=8.5 + 5=13.5→x = \frac{13.5}{3}= 4.5$$
Then;
$$5x+3=5 (4.5)+3=22.5+3=25.5$$

9- C
Use simple interest formula:
I=prt
(I = interest, p = principal, r = rate, t = time)
I$$=(8000)(0.045)(5)=1800$$

10- C
Let $$x$$ be the number of soft drinks for 252 guests. Write the proportion and solve for $$x$$.
$$\frac{10 soft drinks}{12 guests}=\frac{x}{252 guests}$$
$$x = \frac{252×10}{12}⇒x=210$$

Looking for the best resource to help you succeed on the 8th Grade FSA Math test?

## The Best Books to Ace 8th Grade FSA Math Test

### What people say about "Top 10 8th Grade FSA Math Practice Questions"?

No one replied yet.

X
27% OFF

Limited time only!

Save Over 27%

SAVE $5 It was$18.99 now it is \$13.99


text:
# CPhaseGate¶

class CPhaseGate(theta, label=None, ctrl_state=None)[source]

Bases : ControlledGate

Controlled-Phase gate.

This is a diagonal and symmetric gate that induces a phase on the state of the target qubit, depending on the control state.

Can be applied to a QuantumCircuit with the cp() method.

Circuit symbol:

q_0: ─■──
│λ
q_1: ─■──

Matrix representation:

$\begin{split}CPhase = I \otimes |0\rangle\langle 0| + P \otimes |1\rangle\langle 1| = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & e^{i\lambda} \end{pmatrix}\end{split}$

Voir aussi

CRZGate: Due to the global phase difference in the matrix definitions of Phase and RZ, CPhase and CRZ are different gates with a relative phase difference.

Create new CPhase gate.

Methods Defined Here

 control Controlled version of this gate. inverse Return inverted CPhase gate ($$CPhase(\lambda){\dagger} = CPhase(-\lambda)$$) power Raise gate to a power.

Attributes

condition_bits

Get Clbits in condition.

Type renvoyé

List[Clbit]

ctrl_state

Return the control state of the gate as a decimal integer.

Type renvoyé

int

decompositions

Get the decompositions of the instruction from the SessionEquivalenceLibrary.

definition

Return definition in terms of other basic gates. If the gate has open controls, as determined from self.ctrl_state, the returned definition is conjugated with X without changing the internal _definition.

Type renvoyé

List

duration

Get the duration.

label

Return instruction label

Type renvoyé

str

name

Get name of gate. If the gate has open controls the gate name will become:

<original_name_o<ctrl_state>

where <original_name> is the gate name for the default case of closed control qubits and <ctrl_state> is the integer value of the control state for the gate.

Type renvoyé

str

num_clbits

Return the number of clbits.

num_ctrl_qubits

Get number of control qubits.

Renvoie

The number of control qubits for the gate.

Type renvoyé

int

num_qubits

Return the number of qubits.

params

Get parameters from base_gate.

Renvoie

List of gate parameters.

Type renvoyé

list

Lève

CircuitError – Controlled gate does not define a base gate

unit

Get the time unit of duration.


text:
# What colors are good to use for graphs and figures in scientific publications that print well in black and white?

This question is not TeX specific. When creating scientific documents with graphs and figures, what colors are good to use such that they help the reader understand the figure but will also print well on a black and white printer? For example, I would assume that yellow is a poor choice since it is difficult to read on the screen and it prints very light on the page.

-
I would think that that would depend on the colors in the figure/graph? I tend to use thick lines and so far have been using a white background so will be interesting to see what others think. –  Peter Grill Jan 24 '12 at 0:03
This might depend on the printer, I think. By the way, if you're using something like TikZ, with a little work you should be able to set up two color schemes, one for black-and-white printing and one for color printing, that you can just switch between by changing a line in the preamble. –  JohnJamesSmith Jan 24 '12 at 1:29
Unfortunately the scientific journals require a single PDF. –  Nathan Farrington Jan 24 '12 at 2:13
Do you have a specific kind of graph in mind (bar chart with three different series, line graph with a single series, chloropleth map)? –  Jake Jan 24 '12 at 3:56
Here is an example paper. –  Nathan Farrington Jan 24 '12 at 7:17

In general using patterns is preferable than colour, especially for scientific papers. If you need to use colours though, I suggest you use a combination of high contrast colour values and limit them to two or three colours. For example in the figure below, I wanted to emphasize delayed activities for a Project. I used orange to highlight these values and shades of gray for the rest.

Shades of gray, come out well in print as well as photocopying. For screen viewing, black colours don't look attractive. If you expect people to view your paper on the screen (if for example you posting it on a web page) rather use colours and control the screen version via a boolean, but best option of course is to choose colors that look well both in print as well as on a screen.

-
I hope this is not a new question, but how can I get the contrast of a specific color, such as the orange color in your graph, to find out what gray level it will print with? Photoshop tells me that your dark gray is RGB 128,128,128, your medium gray is RGB 159,159,159, your light gray is 191,191,191, and your orange is 255,140,25. –  Nathan Farrington Jan 24 '12 at 17:03
@NathanFarrington If you convert to grayscale you will see immediately, either with photoshop or gimp. The gimp manual is a good read gimp-savvy.com/BOOK/index.html?node54.html for this sort of problem. Personally I just experiment and when I see something good I tend to save it and try it later on. The highest contrast is black and white, the further the delta between the channel values the better. –  Yiannis Lazarides Jan 24 '12 at 17:19
Hmmm, is there a "color scheme" I could use for my papers? For example, product literature such as data sheets often use the colors of the corporation, possibly as a branding mechanism since the primary interface to these companies is through their data sheets. It would be nice to write down some where the RGB values of say up to 5 different colors to use for every figure. This way I wouldn't have to hunt and experiment each time. Perhaps I could choose an "orange" color scheme and write down 5 shades of orange that also convert well to grayscale? –  Nathan Farrington Jan 24 '12 at 21:30
@NathanFarrington You can check the colourlovers.com for some inspiration. Note that the xcolor package provides a number of testing routines and environments and is a good read. –  Yiannis Lazarides Jan 25 '12 at 3:01
@NathanFarrington: have a look at the ConTeXt default colorgroups and palettes –  morbusg Mar 12 '12 at 10:17

I'd take a look at http://colorbrewer2.org/. It is a site designed to help pick color schemes for cartography, but I've used it to pick schemes for regular scientific plots as well.

There is an optional button that will only show color schemes that are photocopy-able. If you click on learn more it says:

Photocopy Friendly: This indicates that a given color scheme will withstand black and white photocopying. Diverging schemes can not be photocopied successfully. Differences in lightness should be preserved with sequential schemes.

-

An easy way to check whether the black-and-white version of a coloured document will be usable is:

\usepackage{xcolor}
\selectcolormodel{gray}

-
I don't expect this will do anything to figures that aren't drawn with TikZ or such? –  Christian Jul 2 '12 at 15:28
@Christian: Yes, external graphics included with \includegraphics are not affected. –  mhp Jul 2 '12 at 15:41


text:
dim1_fin_bad is a general purpose integrator which calculates an approximation to the integral of a function over a finite interval :

For full information please refer to the NAG Library document for d01aj

https://www.nag.com/numeric/nl/nagdoc_28.5/flhtml/d01/d01ajf.html

Parameters
fcallable retval = f(x, data=None)

must return the value of the integrand at a given point.

Parameters
xfloat

The point at which the integrand must be evaluated.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
retvalfloat

The value of the integrand at .

afloat

, the lower limit of integration.

bfloat

, the upper limit of integration. It is not necessary that .

epsabsfloat

The absolute accuracy required. If is negative, the absolute value is used. See Accuracy.

epsrelfloat

The relative accuracy required. If is negative, the absolute value is used. See Accuracy.

lwint, optional

The value of (together with that of ) imposes a bound on the number of sub-intervals into which the interval of integration may be divided by the function. The number of sub-intervals cannot exceed . The more difficult the integrand, the larger should be.

liwNone or int, optional

Note: if this argument is None then a default value will be used, determined as follows: .

The number of sub-intervals into which the interval of integration may be divided cannot exceed .

dataarbitrary, optional

User-communication data for callback functions.

Returns
resultfloat

The approximation to the integral .

abserrfloat

An estimate of the modulus of the absolute error, which should be an upper bound for .

wfloat, ndarray, shape

iwint, ndarray, shape

contains the actual number of sub-intervals used. The rest of the array is used as workspace.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )

The maximum number of subdivisions () has been reached: , and .

(errno )

Round-off error prevents the requested tolerance from being achieved: and .

(errno )

Extremely bad integrand behaviour occurs around the sub-interval .

(errno )

Round-off error is detected in the extrapolation table.

(errno )

The integral is probably divergent or slowly convergent.

Notes

dim1_fin_bad is based on the QUADPACK routine QAGS (see Piessens et al. (1983)). It is an adaptive function, using the Gauss -point and Kronrod -point rules. The algorithm, described in de Doncker (1978), incorporates a global acceptance criterion (as defined by Malcolm and Simpson (1976)) together with the -algorithm (see Wynn (1956)) to perform extrapolation. The local error estimation is described in Piessens et al. (1983).

The function is suitable as a general purpose integrator, and can be used when the integrand has singularities, especially when these are of algebraic or logarithmic type.

dim1_fin_bad requires you to supply a function to evaluate the integrand at a single point.

The function dim1_fin_bad_vec() uses an identical algorithm but requires you to supply a function to evaluate the integrand at an array of points. Therefore, dim1_fin_bad_vec() may be more efficient for some problem types and some machine architectures.

References

de Doncker, E, 1978, An adaptive extrapolation algorithm for automatic integration, ACM SIGNUM Newsl. (13(2)), 12–18

Malcolm, M A and Simpson, R B, 1976, Local versus global strategies for adaptive quadrature, ACM Trans. Math. Software (1), 129–146

Piessens, R, de Doncker–Kapenga, E, Überhuber, C and Kahaner, D, 1983, QUADPACK, A Subroutine Package for Automatic Integration, Springer–Verlag

Wynn, P, 1956, On a device for computing the transformation, Math. Tables Aids Comput. (10), 91–96


text:
TL;DR

Add "python.terminal.activateEnvironment": false, to your vscode settings, and the integrated terminal will work as expected in vscode.

Symptom

I just set up zsh for my mac, but it did not work well in the integrated terminal of vscode. When I started a new terminal, it looks like this:

source /Users/hanezu/.pyenv/versions/my-virtualenv/bin/activate

# hanezu@Hanezu-mbp.local:~/my-project-dir on git:master
 source /Users/hanezu/.pyenv/versions/my-virtualenv/bin/activate
(my-virtualenv) \h:\W \u\$

Analysis

However, when I open a JavaScript project in vscode, everything worked out well. Like this:

# hanezu@Hanezu-mbp.local:~/my-js-project-dir on git:master


So this must be caused by my pyenv-virtualenv settings.

If you look carefully at the wrong terminal output again, you will find out that vscode actually activate the python environment for you twice: before and after zsh is ready.

Solution

Therefore, by adding "python.terminal.activateEnvironment": false, in vscode settings, the terminal will work as expected in vscode.

By the way, this setting does not stop the terminal from activating your virtualenv, as long as you have set your virtualenv via pyenv local my-virtualenv.


text:
# Thread: A liar says he tells truth. So he is a liar. But he just told he tells truth.Solution

1. ## A liar says he tells truth. So he is a liar. But he just told he tells truth.Solution

A liar says I am a truthteller. But he is a liar. He can't be a truthteller. He is a liar. But the liar said he is a truth teller. We have reached a contradiction.

What is the solution?

2. ## Re: A liar says he tells truth. So he is a liar. But he just told he tells truth.Solu

Why is a liar saying he is a truth-teller a paradox? Since he is a liar what he is in NOT true- he is not a truth-teller.

IF "liar" and "truth-teller" are the only options then it would be a "paradox" for a liar to say "I am NOT a truth-teller" or for a truth-teller to say "I am a liar".

3. ## Re: A liar says he tells truth. So he is a liar. But he just told he tells truth.Solu

How have you reached a contradiction. You already pointed out that he lied. His statement was a lie. There is no contradiction. And what sort of "solution" are you seeking?

4. ## Re: A liar says he tells truth. So he is a liar. But he just told he tells truth.Solu

Originally Posted by SlipEternal
How have you reached a contradiction. You already pointed out that he lied. His statement was a lie. There is no contradiction. And what sort of "solution" are you seeking?
Let me rephrase it how I reached a contradiction. It is called Liar paradox.

"'I said in my alarm, Every man is a liar!' Is David telling the truth or is he lying? If it is true that every man is a liar, and David's statement, "Every man is a liar" is true, then David also is lying; he, too, is a man. But if he, too, is lying, his statement: "Every man is a liar," consequently is not true. Whatever way you turn the proposition, the conclusion is a contradiction. Since David himself is a man, it follows that he also is lying; but if he is lying because every man is a liar, his lying is of a different sort."

5. ## Re: A liar says he tells truth. So he is a liar. But he just told he tells truth.Solu

Originally Posted by x3bnm
Let me rephrase it how I reached a contradiction. It is called Liar paradox.
That is very different from what you stated. The Liar's Paradox is another well known example of paradox through self reference.

6. ## Re: A liar says he tells truth. So he is a liar. But he just told he tells truth.Solu

Originally Posted by x3bnm
> > > A liar says I am a truthteller. < < < But he is a liar. He can't be a truthteller. He is a liar. But the liar said he is a truth teller. We have reached a contradiction.

What is the solution?
x3bnm, your English did not communicate what you intended. What I emphasized above means that a liar said that you, x3bnm, are a truthteller. That is not what you meant.
You needed to have put what the liar said in quotes. (I did not realize this until I read your post to the end.)

Here is what you should have posted:

A liar says, "I am a truthteller."

7. ## Re: A liar says he tells truth. So he is a liar. But he just told he tells truth.Solu

Originally Posted by greg1313
x3bnm, your English did not communicate what you intended. What I emphasized above means that a liar said that you, x3bnm, are a truthteller. That is not what you meant.
You needed to have put what the liar said in quotes. (I did not realize this until I read your post to the end.)

Here is what you should have posted:

A liar says, "I am a truthteller."
Sorry for the miscommunication from my part.

8. ## Re: A liar says he tells truth. So he is a liar. But he just told he tells truth.Solu

A and B always lie. They are chatting between themselves.
A says, 'You are a truth-teller.'
B replies, 'I'm not a liar.'

Is there a word for such situations?


text:
How 9 Cheenta students ranked in top 100 in ISI and CMI Entrances?

# TIFR 2013 problem 13 | Riemann integrable functions

Try this true/false problem from TIFR 2013 Problem 13 based on composite of Riemann integrable functions.

Question: TIFR 2013 problem 13

True/False?

Let $f:[a,b]\to[c,d]$ and $g:[c,d]\to\mathbb{R}$ be Riemann integrable  functions. Then the composite $gof$ is also Riemann integrable.

Hint: Can the Thomae function(which is known to be integrable) be composed with some function to give the characteristic function of rational numbers (which is known to be not integrable in the Riemann sense)?

Discussion:

Let $f:[0,1]\to[0,1]$ be the Thomae function, $f(x)=\begin{cases} 1/q & \text{ for }x=p/q & \text{where}& gcd(p,q)=1 \\ 0 & \text{ for } x \notin \mathbb{Q} \end{cases}$.

$f$ is known to be Riemann integrable over [0,1] (it is continuous at all irrationals and therefore set of discontinuity is countable).

We want a function $g:[0,1]\to\mathbb{R}$ such that, for $1/q$ it gives value $1$ and for $0$ it gives value $0$. Then we will end up with the $h(x)=\begin{cases} 0 & \text{ for }x\in\mathbb{Q} \\ 1 & \text{ for } x \notin \mathbb{Q} \end{cases}$. Moreover, g should be Riemann integrable.

Let $g(x) = \begin{cases} 1 & \text{ for }x \ne 0 \\ 0 & \text{ for } x = 0 \end{cases}$

Then g is Riemann integrable since it is discontinuous at only 1 point. And as desired, $gof=h$. $h$ is well known to be not Riemann integrable. This proves the fact that the statement is False.


text:
# Homework Help: Integral proofs

1. Jun 8, 2009

### nameVoid

looking for proofs of the following integrals

integral ( e^(au)sin(bu)du ) and integral(e^(au)cos(bu)du) and integral (sec^3u du)

2. Jun 8, 2009

### Staff: Mentor

The first two can be done by integrating by parts twice. After the second integration, you end up with the integral you started with, and you can solve algebraically for the integral. In both problems, start with u = e^(au) and dv = sin(bu)du or cos(bu)du. After integrating the first time, do it again, with u = e^(au) again, and dv being whatever is left.

The third one can also be done by integration by parts, I believe. Try u = sec u and dv = sec^2(u) du.

3. Jun 8, 2009

### Physics_Math

d/dx(secx)=tanxsecx and
d/dx(tanx)=sec2x

4. Jun 8, 2009

### Count Iblis

$$\int \exp(p x) dx = \frac{1}{p}\exp(px) + c$$

Take p = a + b i and equate the real and imaginary parts of both sides. You should be able do this mentally in your head (multiplying the numerator and denominator by the complex conjugate of p isn't that difficult).

5. Jun 8, 2009

### nameVoid

im looking for somthing along the lines of integration by parts a link to proofs would be nice

6. Jun 9, 2009

### Staff: Mentor

Your problem isn't a proof. All you need to do is carry out the integration, and I have given you a start on how to do that.

7. Jun 9, 2009

### Physics_Math

Do you mean that you want a proof of the actual method of integration by parts? If so, then consider the product rule of differentiation:

d/dx(f*g)=f'*g + f*g'

Now integrate both sides of the equation and you get you proof.

Is that what you were looking for?


text:
# Prime congruence series formula

1. Jun 17, 2010

### b1029384756

I'm trying to help a friend solve a problem but as I've never studied number theory, I'm having a bit of trouble myself figuring out how to do it.

We need to find the sum of 1$$^{k}$$+2$$^{k}$$+...+(p-1)$$^{k}$$ (mod p), where p is prime. By writing a program that created a table from test cases 2$$\leq$$p$$\leq$$47 and 1$$\leq$$k$$\leq$$100, I've conjectured that if p-1 divides k, the sum is p-1 mod p, and if p-1 does not divide k, the sum is 0 mod p. I need to be able to prove this but am not sure how. For the first case, if 1$$\leq$$a$$\leq$$p-1, then a$$^{k}$$=(a$$^{p-1}$$)$$^{n}$$ for some n, which is congruent to 1$$^{n}$$ by Fermat's little theorem, so then it is congruent to 1. Since there are p-1 such terms congruent to 1, their sum is p-1. Let me know if I've done something incorrectly.

As for the second case where p-1 does not divide k, I have no idea how to show that the sum is congruent to 0. Any information is appreciated.

2. Jun 18, 2010

### Petek

Your conjecture is correct, as is your proof of the case in which (p - 1) divides k. For the case in which (p - 1) does not divide k, can you show that the values 1$$^{k}$$, 2$$^{k}$$, ..., (p - 1)$$^{k}$$ are distinct mod p? If so, what then can you say about the sum?

HTH

Petek

3. Jun 18, 2010

### b1029384756

If the values are distinct, then each of 1, 2, ..., p-1 appears once, so their sum is (p$$^{2}$$-p)/2. If p = 2, then p - 1 = 1 which divides p, so the first case applies. So, p$$\geq$$3. Then, p must be odd, so p-1 is even, and (p-1)/2 is an integer. Therefore, (p$$^{2}$$-p)/2 = p(p-1)/2 = p*n for some n. This tell us that the sum is zero mod p.

Okay, that part is easy, but I still don't see how to use the fact that p-1 does not divide k to show that the values of each term are distinct. Thanks for the post, let me know what else I'm missing.

4. Jun 18, 2010

### Petek

Suppose that (p - 1) does not divide k. Use the Eucidean algorithm to write

k = q(p - 1) + r

where 0 < r < p-1

(r > 0 by hypothesis).

Consider n^k. Can you take it from there?

5. Jun 18, 2010

### b1029384756

The problem I have understanding how to do that is...suppose I consider n^k and m^k for distinct m and n. We know that mm$$^{k}$$ is congruent to m$$^{r}$$ by using Fermat's little theorem again. I'm trying to show that then m$$^{r}$$$$\neq$$n$$^{r}$$, correct? But, that's not always the case. Suppose we have p = 29, k = 14, m = 4, n = 16, p - 1 clearly does not divide k, but 4m$$^{14}$$ is congruent to 16$$^{14}$$, which are both congruent to 1. What am I missing?

6. Jun 19, 2010

### Petek

Sorry, I was wrong. Consider p = 5, k = 2. Then 1 ^2 + 2^2 + 3^2 + 4^4 == 0 (mod 5), but the individual summands aren't distinct mod 5.

7. Jun 19, 2010

### b1029384756

So any ideas how else I can prove that the sum will be 0 mod p? I appreciate the attempt, it seemed like a good approach to it.

8. Jun 19, 2010

### b1029384756

Okay, I have a step in the right direction. If p - 1 does not divide k, use the argument above to show that p is odd and p - 1 is even. So, there are an even number of terms in the sum.

Suppose k is odd. Then, consider a$$^{k}$$, where a$$\leq$$(p-1)/2. Consider its additive inverse, (p-a)$$^{k}$$. Using the binomial formula, we can show the expanded polynomial is congruent to -a$$^{k}$$, because k is odd. So, for each of the first (p-1)/2 terms, there is a corresponding term in the second (p-1)/2 terms to cancel it from the sum, leaving a resulting sum of 0.

Now, how do I show that the sum is 0 when p - 1 does not divide k, and k is even? If this is the case, again consider a$$^{k}$$, where a$$\leq$$(p-1)/2. Since p - 1 does not divide k, k is not congruent to 0. This time, (p-a)$$^{k}$$ is congruent to a$$^{k}$$. So, upon combining like terms, we have the 2*$$\sum$$a$$^{k}$$ for 1$$\leq$$a$$\leq$$(p-1)/2. I don't know if this is helpful or what to do with it. Let me know what to do.

9. Jun 19, 2010

### Petek

I think I now have a valid solution for the case p - 1 doesn't divide k:

Let g be a primitive root mod p. That is, g generates the multiplicative subgroup that consists of the non-zero elements of Z/pZ. See this Wikipedia article if you're not familiar with primitive roots. Thus, each of the numbers 1, 2, ..., p-1 is congruent to a power of g, mod p. We can then write

$$1^{k} + 2^{k} + ... + (p - 1)^{k} \equiv 1^{k} + g^{k} + g^{2k} + ... +g^{(p-2)k} \ (mod\ p)$$

The RHS of this equation is a geometric series that equals

$$\frac{1 - g^{(p-1)k}}{1 - g^{k}}$$

where

$$\frac{1}{1 - g^{k}}$$

is the multiplicative inverse of $1 - g^{k}$ in Z/pZ. Such an inverse exists because (p - 1) doesn't divide k, and so $g^{k} \not \equiv 1\ (mod\ p)$.

It's easy to see that $g^{(p-1)k} \equiv 1\ (mod\ p)$ and so the sum is divisible by p, as required.

Hope this is correct.

Petek

10. Jun 19, 2010

### b1029384756

Thanks, I looked at the article as well as a proof that all primes have at least one primitive root, so now it makes perfect sense. I don't think I would have been able to come up with that on my own without more of a background in number theory, so it's definitely appreciated. I'll explain it to my friend when I see her.


text:
CONTINUITY OF BANACH ALGEBRA VALUED FUNCTIONS

Title & Authors
CONTINUITY OF BANACH ALGEBRA VALUED FUNCTIONS
Rakbud, Jittisak;

Abstract
Let K be a compact Hausdorff space, $\small{\mathfrak{A}}$ a commutative complex Banach algebra with identity and $\small{\mathfrak{C}(\mathfrak{A})}$ the set of characters of $\small{\mathfrak{A}}$. In this note, we study the class of functions $\small{f:K{\rightarrow}\mathfrak{A}}$ such that $\small{{\Omega}_{\mathfrak{A}}{\circ}f}$ is continuous, where $\small{{\Omega}_{\mathfrak{A}}}$ denotes the Gelfand representation of $\small{\mathfrak{A}}$. The inclusion relations between this class, the class of continuous functions, the class of bounded functions and the class of weakly continuous functions relative to the weak topology $\small{{\sigma}(\mathfrak{A},\mathfrak{C}(\mathfrak{A}))}$, are discussed. We also provide some results on its completeness under the norm defined by \${\mid}{\parallel}f{\parallel}{\mid}
Keywords
Banach algebra;Gelfand representation;character;
Language
English
Cited by
References
1.
R. G. Douglas, Banach Algebra Techniques in Operator Theory, Academic Press, New York, 1972.

2.
W. Fupinwong and S. Dhompongsa, The fixed point property of unital abelian Banach algebras, Fixed Point Theory Appl. 2010 (2010), Artical ID 362829, 13 pp.

3.
R. V. Kadison and J. R. Ringrose, Fundamentals of the Theory of Operator Algebras. Vol. I, Academic Press, New York, 1983.

4.
R. V. Kadison and J. R. Ringrose, Fundamentals of the Theory of Operator Algebras. Vol. II, Academic Press, New York, 1986.


text:
# MOV attack when $E(\mathbb{F}_q)$ is cyclic

Suppose $$P\in E(\mathbb{F}_q)$$ and $$R=dP$$.

In the MOV attack, we compute $$\alpha=e(P,T)$$ and $$\beta=e(R,T)$$ and try to solve the discrete logarithm problem for $$\alpha$$ and $$\beta$$ in the finite field $$\mathbb{F}_{q^k}$$ where $$k$$ is the embedding degree.

But if $$E(\mathbb{F}_q)$$ is cyclic (which it can be even in the supersingular case), $$\alpha,\beta$$ are doomed to be $$1$$.

So what am I missing here?

• Why are they doomed to be 1? You would have $\alpha=\beta=1_{T}$ iff. $P=R=G_{1}$ and $T=G_2$, where $G_1$ and $G_2$ are the generators of the first group and second group respectively, which I suppose, is not the case. In the target group you have that $\beta=d\alpha$. Thus we have reduced the discrete logarithm problem on the group of points on an elliptic curve to the discrete logarithm on finite fields, where subexponential attacks are known. May 9 '20 at 7:54

For the purposes of the MOV attack you choose $$T$$ to be a point in $$E(\mathbb{F}_{q^k})$$.


text:
# What is the period of f(t)=cos ( ( 7 t ) / 2 ) ?

May 16, 2016

$\frac{4 \pi}{7}$.

#### Explanation:

The period for both sin kt and cos kt is (2pi)/k.

Here, k = = $\frac{7}{2}$. So, the period is 4pi)/7..

See below how it works

$\cos \left(\left(\frac{7}{2}\right) \left(t + \frac{4 \pi}{7}\right)\right) = \cos \left(\frac{7 t}{2} + 2 \pi\right) = \cos \left(\frac{7 t}{2}\right)$

May 16, 2016

$T = \frac{4 \pi}{7}$

#### Explanation:

$y = A \cdot \cos \left(\omega \cdot t + \phi\right) \text{ general equation}$

$\text{A:Amplitude}$

$\omega : \text{Angular velocity}$

$\phi = \text{phase angle}$

$\text{your equation:} f \left(t\right) = \cos \left(\frac{7 t}{2}\right)$

$A = 1$

$\omega = \frac{7}{2}$

$\phi = 0$

$\omega = \frac{2 \pi}{T} \text{ T:Period}$

$\frac{7}{2} = \frac{2 \pi}{T}$

$T = \frac{4 \pi}{7}$


text:
# Solving a simple QUBO with QAOA¶

This section shows how QAOA can be used to solve a simple quadratic unconstrained binary optimisation (QUBO) problem. QUBOs have received significant interest in recent years as a way of tackling discrete combinatorial optimisation tasks, which are widespread in the logistics industry, amongst others. They have also attracted attention for their apparent amenability to implementation on near-term quantum hardware. For a good review of QUBOs and how to formulate them, see Ref 1.

import numpy as np
import matplotlib.pyplot as plt

from pyquil.paulis import PauliSum
from pyquil.api import WavefunctionSimulator
from pyquil.unitary_tools import lifted_pauli

from entropica_qaoa.qaoa.parameters import StandardParams
from entropica_qaoa.qaoa.cost_function import QAOACostFunctionOnWFSim

from scipy.optimize import minimize

## Defining the problem¶

Here we will tackle the simple problem given in Section 2 of Ref 1. We seek the minimum function value, and corresponding configuration of variables, of

$y = -5x_1 -3x_2 -8x_3 -6x_4 + 4x_1x_2 + 8x_1x_3 + 2x_2x_3 + 10x_3x_4$

Here the variables $$x_i$$, $$i = 1,...,4$$ are binary. i.e. they can take the value 0 or 1. Observe that in the linear part (the first 4 terms), all of the variables would ideally be equal to 1 in order to minimise the function. However, the quadratic part (the second 4 terms) encodes penalties for having different pairs of variables equal to 1.

Note that in the linear part, we can simply square all of the variables, since $$x_i = x_i^2$$ for binary variables. We then transform the problem to minimisation of

$\begin{split}y^{\prime} = -5x_1^2 -3x_2^2 -8x_3^2 -6x_4^2 + 4x_1x_2 + 8x_1x_3 + 2x_2x_3 + 10x_3x_4 \\ = \left(\begin{matrix} x_4 & x_3 & x_2 & x_1\end{matrix}\right) \left(\begin{matrix} -6 & 5 & 0 & 0 \\ 5 & -8 & 1 & 4 \\ 0 & 1 & -3 & 2 \\ 0 & 4 & 2 & -5 \end{matrix} \right) \left(\begin{matrix} x_4\\ x_3 \\ x_2 \\ x_1 \end{matrix}\right)\end{split}$

We have ordered the variables in the binary strings such that $$x_1$$ appears as the least significant bit (i.e. on the right of the register), which corresponds to a common convention in the quantum computing community, and in particular for Rigetti’s Pyquil: see here for more information. Let’s plot the function to see what the energy landscape looks like.

def func_y(config):

matr = np.array([[-6, 5, 0, 0], [5, -8, 1, 4], [0, 1, -3, 2], [0, 4, 2, -5]])

return config @ matr @ config

def num_2_bin(num):

bin_str = np.binary_repr(num, width=4)
bin_arr = np.array([int(x) for x in bin_str])

return bin_arr

y_vals = [func_y(num_2_bin(i)) for i in range(16)]
bin_strings = ['{0:04b}'.format(i) for i in range(16)]

plt.plot(y_vals,'o-')
plt.xticks(range(16), bin_strings, rotation=70);
plt.ylabel('y')
plt.show()

The optimal solution is $$x_1 = x_4 = 1$$, $$x_2 = x_3 = 0$$, i.e. the bitstring 1001 (the binary representation of the number 9). Its corresponding function value is $$y =-11$$.

## Mapping to QAOA¶

To solve the problem using QAOA, we can associate the variable $$x_i$$ with the $$i^{th}$$ qubit of our quantum register. If the variable takes value 0, this corresponds to the qubit state being in state $$|0\rangle$$; likewise, the value 1 corresponds to the qubit being in state $$|1\rangle$$.

On a quantum computer we measure the state of a qubit in the $$\{|0\rangle, |1\rangle\}$$ basis by applying the $$Z$$ operator. However, the eigenvalues of this operator are $$+1$$ for the state $$|0\rangle$$, and $$-1$$ for the state $$|1\rangle$$. In order to map this to the 0,1 values of binary variables, we need to modify the measurement operator to be

$x_i \leftrightarrow \frac{\mathbb{I} - Z_i}{2}$

where $$\mathbb{I}$$ is the identity operator. With these considerations, the Hamiltonian $$H_y$$ encoding our objective function $$y$$ is:

$\begin{split}H_y = -\frac{1}{4}\left[5(\mathbb{I} - Z_1)^2 + 3(\mathbb{I} - Z_2)^2 + 8(\mathbb{I} - Z_3)^2 + 6(\mathbb{I} - Z_4)^2\right] \\ + \frac{1}{4}\left[4(\mathbb{I} - Z_1)(\mathbb{I} - Z_2) + 8(\mathbb{I} - Z_1)(\mathbb{I} - Z_3) + 2(\mathbb{I} - Z_2)(\mathbb{I} - Z_3) + 10(\mathbb{I} - Z_3)(\mathbb{I} - Z_4)\right]\end{split}$

Let’s now set the problem up and proceed to solve it using QAOA.

# Linear part of the Hamiltonian
# For simplicity here we do not square each term, as this does not affect the outcome
ham_lin = -0.5*PauliSum.from_compact_str('(-5)*Z1 + (-3)*Z2 + (-8)*Z3 + (-6)*Z4 + 22*I')

# Quadratic part of the Hamiltonian
ham_poly = 0.25*PauliSum.from_compact_str('4*Z1*Z2 + 4*I + (-4)*Z1 + (-4)*Z2 + 8*Z1*Z3 + 8*I + (-8)*Z1 + (-8)*Z3')
ham_poly += 0.25*PauliSum.from_compact_str('2*Z2*Z3 + 2*I + (-2)*Z2 + (-2)*Z3 + 10*Z3*Z4 + 10*I + (-10)*Z3 + (-10)*Z4')

ham = ham_lin + ham_poly

We can check that the eigenvalues of the Hamiltonian ham correspond to the function values we plotted above:

ham_matrix = lifted_pauli(ham, ham.get_qubits())
print('Eigenvalues: ', np.diag(ham_matrix)) # NB: ham is diagonal in the Z basis
print('')
print('Function values: ', y_vals)

Eigenvalues:  [  0.+0.j  -5.+0.j  -3.+0.j  -4.+0.j  -8.+0.j  -5.+0.j  -9.+0.j  -2.+0.j
-6.+0.j -11.+0.j  -9.+0.j -10.+0.j  -4.+0.j  -1.+0.j  -5.+0.j   2.+0.j]

Function values:  [0, -5, -3, -4, -8, -5, -9, -2, -6, -11, -9, -10, -4, -1, -5, 2]

## Solution with StandardParams¶

Let’s tackle the problem using the StandardParams parametrisation. We’ll see how we do with $$p=3$$ timesteps, using Cobyla as our optimiser, and the linear_ramp_from_hamiltonian function to set up our inital parameters.

p = 3
standard_params = StandardParams.linear_ramp_from_hamiltonian(ham,p)

# Set up cost function and run optimisation
cost_std = QAOACostFunctionOnWFSim(ham,standard_params)
res_std = minimize(cost_std, standard_params.raw(), method = 'Cobyla')

# Print the output
res_std

    fun: -9.481743378102294
maxcv: 0.0
message: 'Optimization terminated successfully.'
nfev: 229
status: 1
success: True
x: array([0.57705579, 0.36725195, 0.17168154, 0.13192841, 0.27705965,
0.31679062])

The expectation value of the cost Hamiltonian ham is -9.48, however we know the true solution to have cost -11. Evidently, our QAOA circuit has not returned the correct solution, however we can examine the probability distribution of the output quantum state:

state = cost_std.get_wavefunction(res_std.x)
probs = state.probabilities()
labels = [r'$\left|{0:04b}\right>$'.format(i) for i in range(16)]
plt.bar(range(16),probs)
plt.xticks(range(16), labels, rotation=70);

Observe that the most probable state is $$|1001\rangle$$, which does indeed correspond to the minimum energy configuration of the variables. However, if we were to sample from a quantum computer, the above distribution would not allow us to conclude with high confidence that we have found the solution: there are several other bit strings with relatively high probabilities too.

Let’s try increasing the parameter $$p$$ (the circuit depth) to see how more likely we are to obtain the optimal solution. To do this, we’ll define a simple convenience function.

def state_prob_p(p):

"""
Applies the QAOA circuit and returns the probability of measuring the bitstring 1001
"""

params_std = StandardParams.linear_ramp_from_hamiltonian(ham,p)
cost_std = QAOACostFunctionOnWFSim(ham,params_std)
res_std = minimize(cost_std, params_std.raw(), method = 'Cobyla')
state = cost_std.get_wavefunction(res_std.x)
probs = state.probabilities()

return probs[9] # The bitstring 1001 is the 9th entry of the vector of probabilities

We will run the above function for different values of $$p$$, and see how the probability of the optimal bistring 1001 increases.

# Running this cell should take 2 or 3 minutes.
p_vals = np.arange(1,13)
probability_opt_state = [state_prob_p(i) for i in p_vals]

# Plot the probabilities
plt.plot(p_vals,probability_opt_state,'o-')
plt.xlabel('p')
plt.ylabel('Prob. of ' + r'$|1001\rangle$')
plt.show()

Clearly the optimal bit string probability approaches unity with increasing $$p$$.

## References¶

1. F. Glover et al, A Tutorial on Formulating and Using QUBO Models.


text:
# 3DTouch: G-code to temporarily change probe points and Z home?

I am using a BLTouch clone (3DTouch), and with G28 and G29 in Simplify3D it auto-detects Z home right in the center of the bed and afterward it measures 9 grid points. For most of my printings, this is great, except for a special one.

This special one consists of one first print with a thin drawing and a second print on top of that drawing (obviously with the gap matching the drawing). G28 and G29 are not an issue for the drawing print, but for the second print where the nozzle must not touch the center (since it would ruin the drawing and would measure a wrong Z home and a wrong Z probe point there).

So is there a G-code that indicates the printer to select Z home on a different position (determined by X and Y coordinates, outside the drawing) and to eliminate the central point of the grid (leaving the remaining 8 points)?

Obviously, I can't change the firmware every time that I print that special figure, so it must be through a script.

EDIT:

This is an example of the print, the very first layer:

Print 1: 0,4 mm layer of blue

Print 2: 0,4 mm layer of green

Print 3: Much thicker and bigger print of white filament that prints around the previous prints during the first 2 layers and start covering all by the third layer.

Imagine a box cover with a drawing on top. The first layers of each print must be as smooth and nice as possible as is it the visible one. I was doing this manually before installing the BLTouch with very good results, the drawing gets embedded in the final printing.

• You're printing the same thing right in top of a previous print? Are you changing filament or something? Why not just have it print extra layers during the same print? – Rykara Mar 26 at 5:59
• As there is already a layer laid out on the build plate you should not use G29 to scan the plate again. As said in a previous comment, can't you join the 2 files? Alternatively, don't use G29, instead load a saved mesh and raise the Z height after your G28 command. – 0scar Mar 26 at 11:09
• I can't join the files, I am going to edit the first post and add an example image of what I mean. – edea Mar 26 at 11:28
• I could indeed load a saved mesh, that would solve the second time that the nozzle goes to the middle before printing. Now I would just need to know how to tell the BLTouch to measure Z home in the coordinates I want. – edea Mar 26 at 13:09


text:
Opened 10 years ago

# Upgrade t-h.o to Trac 1.0 — at Version 83

Reported by: Owned by: Ryan J Ollos Ryan J Ollos normal TracHacks normal upgrade Steffen Hoffmann, falkb, osimons, Dirk Stöcker, Mitar, Jun Omae 1.0

The following plugins needed to be upgraded, tested and possibly fixed to work with the upgraded version of Trac.

 Plugin Status AccountManagerPlugin WiP - Version 0.4dev, for new user registration see #10092 AcronymsPlugin ✓ AutoWikifyPlugin ✓ Version 0.2 has been tested with Trac 1.0dev ChangeLogMacro EmailProcessorMacro FootNoteMacro IncludeMacro ✓ IniAdminPlugin ✓ NewHackMacro Replaced by NewHackPlugin NewsFlashMacro PollMacro ✓ RefMacro Integrated into core with Trac 0.10, see t:TracLinks#Linkanchors SpamFilterPlugin SvnAuthzAdminPlugin TagsPlugin TicketChangePlugin Integrated into core with Trac 0.12 (permission TICKET_EDIT_COMMENT) TicketDeletePlugin Integrated into core as option component with Trac 0.12 (tracopt.ticket.deleter) TocMacro Replace macro calls with native PageOutline wiki macro from Trac core. WikiReplacePlugin can help with quick replacement, but the plugin may need to be further developed first (better regex support and preview function). TracBlogPlugin deprecated, use FullBlogPlugin FullBlogPlugin ✓, even combined with FullBlogNotificationPlugin TracHacksPlugin TracPygmentsPlugin Integrated into core with Trac 0.11. Make sure to install Pygment 1.5 TracRedirect -> ServerSideRedirectPlugin ✓ Version 0.4 has been tested with Trac 1.0dev WebAdminPlugin Integrated into core with Trac 0.11 XmlRpcPlugin WikiReplacePlugin Not currently used on t-h.o, but may be added.

### comment:1 Changed 10 years ago by Ryan J Ollos

Description: modified (diff)

### comment:2 Changed 10 years ago by Ryan J Ollos

Description: modified (diff)

### comment:3 Changed 10 years ago by Ryan J Ollos

Description: modified (diff)

Fixed-up the AutoWikifyPlugin. It should be good to go, but I'll add some unit tests this evening for good measure.

### comment:4 Changed 10 years ago by Ryan J Ollos

Description: modified (diff) changed from Michael Renzmann to Ryan J Ollos

RefMacro is no longer needed.

### comment:5 Changed 10 years ago by Ryan J Ollos

Description: modified (diff)

Let's plan to replace all calls to TOC macro with [[PageOutline(2-5,Contents,pullout)]] unless:

1. Someone steps up with reasonable objections.
2. Someone steps up to maintain the macro.

Even better than (2), if someone wishes to step-up and maintain TocMacro, why not see if you can get those features pushed to the Trac core? In the future, we can certainly plan to upgrade t-h.o on the release cycle of Trac, so any features pushes to the Trac core will make their way to t-h.o before too long.

### comment:6 Changed 10 years ago by Ryan J Ollos

Description: modified (diff)

### comment:7 Changed 10 years ago by Ryan J Ollos

Summary: Upgrade t--h.o to Trac 1.0 → Upgrade t-h.o to Trac 1.0

### comment:8 Changed 10 years ago by Ryan J Ollos

Description: modified (diff)

Pushed a patch for ServerSideRedirectPlugin this evening in [11890] and did some quick testing with Trac 1.0dev. Seems to be good to go.

### comment:9 follow-up:  10 Changed 10 years ago by falkb

What is the news? What are you doing at present?

### comment:10 in reply to:  9 Changed 10 years ago by Ryan J Ollos

What is the news? What are you doing at present?

We should have some news in the near future. Everything seems to be moving towards an upgrade and server move, but the details must be working out in the coming days.

### comment:11 Changed 10 years ago by falkb

work for me with 1.0.

I just called  python setup.py clean bdist_egg  on the current SVN checkout and reloaded Trac with the new plugin egg files, used it for a while, checked the logging.

### comment:12 follow-up:  13 Changed 10 years ago by falkb

• IncludeMacro works as well with 1.0
• AcronymsPlugin works only if [acronym] page = AcronymDefinitions is explicitly set in trac.ini, the default hasn't worked, although I'm not sure if this maybe is a general problem.
Last edited 8 years ago by Ryan J Ollos (previous) (diff)

### comment:13 in reply to:  12 Changed 10 years ago by anonymous

No, I think that was just a caching problem, fully works now after Browser restart and Apache reload. I tag it for 1.0, too.

### comment:14 Changed 10 years ago by Steffen Hoffmann

description update according to falkb's comments, added my own work on AccountManagerPlugin

### comment:16 in reply to:  15 Changed 10 years ago by Steffen Hoffmann

Description: modified (diff)

You meant IniAdminPlugin, right? Done so now.

### comment:17 Changed 10 years ago by falkb

What is going on with the TH upgrade?

### comment:18 follow-up:  19 Changed 10 years ago by Ryan J Ollos

We all have one or more jobs each and also maintain several plugins. I don't see myself having time to commit to getting the upgrade off the ground until at least the second week of Feb.

### comment:19 in reply to:  18 Changed 10 years ago by falkb

... until at least the second week of Feb.

I'll try to get some more plugins from the list above tested until then

### comment:20 Changed 10 years ago by Ryan J Ollos

Thanks, that would be great. I'll be looking for when I have most of a weekend clear before embarking on the initial stage of the upgrade, which is to setup a Trac 1.0 version running on a different port, as Michael had done previously for the Trac 0.11 instance. I'll keep you posted as to when I think that might happen. I had hoped to find time over the holidays, but managed to consume myself with other coding tasks.

### comment:21 Changed 10 years ago by falkb

I'd go for the Bitnami version which is an all-in-one package and easy to install, and as second step replace its Trac sources with the SVN trunk of Trac. And I hope we get rid of that nasty "TimeoutError: Unable to get database connection within 20 seconds" that is getting worse over the last months.

### comment:22 Changed 9 years ago by Ryan J Ollos

#10939 closed as a duplicate, requesting a Back to Report or Back to Query link after navigating from a report/query to a ticket. I think we get that for free with the Trac 1.0 upgrade.

### comment:23 Changed 9 years ago by Ryan J Ollos

#10986 closed as a duplicate.

### comment:24 follow-up:  32 Changed 9 years ago by Ryan J Ollos

I'm dedicating the entire day of Sat April 6th to getting an instance of trac-hacks running Trac 1.0 on port 8080. Since we have several people offering to help test and fix plugin issues, I'll try to coordinate the effort so that we can get the site deployed asap after that.

Last edited 8 years ago by Ryan J Ollos (previous) (diff)

### comment:25 Changed 9 years ago by Ryan J Ollos

Status: new → assigned

### comment:26 follow-up:  27 Changed 9 years ago by Dirk Stöcker

Some macro notes:

### comment:27 in reply to:  26 Changed 9 years ago by Ryan J Ollos

• TocMacro works with 1.0, so replace is not required for update.

True, replacing it is not required, but it seemed to be a good opportunity to get rid of the macro. Of course, we can get rid of it later on too, if it still works with Trac 1.0.

I'm open to keeping the TocMacro if it will be maintained, and someone can describe reasons we need to have it on trac-hacks. However, the last commit was in 2008 and I don't think anyone is giving it attention anymore.

### comment:28 follow-up:  29 Changed 9 years ago by osimons

I'm maintaining TocMacro in the sense that I use it in production and will fix serious bugs if found. However, it is definitely in maintenance-mode as I don't spend time adding features or fixing trivial bugs.

My main use for [[TOC]] is that it can build a combined TOC for any number of pages at the same time, typically used for plugins that split information into subpages. [[PageOutline]] macro will of course be a fine option for single-page input.

### comment:29 in reply to:  28 Changed 9 years ago by Ryan J Ollos

My main use for [[TOC]] is that it can build a combined TOC for any number of pages at the same time, typically used for plugins that split information into subpages.

That sounds like a good enough use case to keep it around then. The AccountManagerPlugin has a few subpages, and might benefit from using TOC.

### comment:30 follow-up:  31 Changed 9 years ago by anonymous

Maybe providing a patch for core, so that this feature gets added as well?

### comment:31 in reply to:  30 Changed 9 years ago by Ryan J Ollos

Maybe providing a patch for core, so that this feature gets added as well?

I had similar thoughts, and I think that enhancing the PageOutline macro in the Trac core is a good idea. I have numerous other issues I'm working on in the Trac core though, so I'm unlikely to get to it soon. Hopefully someone else will :)

### comment:32 in reply to:  24 ; follow-up:  34 Changed 9 years ago by Ryan J Ollos

I'm dedicating the entire day of Sat April 6th to getting an instance of trac-hacks running Trac 1.0 on port 8080.

I made a little bit of progress over the weekend, but had some thing come up so didn't get as far as I'd hoped. I will try to make progress during the week. Stay tuned!

### comment:33 Changed 9 years ago by Mitar

Joining in a bit. I don't know how much time I can have for this but in general I am interested in how to make collaboration on the Internet better. So let's see what we can do here.

### comment:34 in reply to:  32 Changed 9 years ago by falkb

I made a little bit of progress over the weekend, but had some thing come up so didn't get as far as I'd hoped.

What is exactly meant with progress and which things came up? What is the news? :)

### comment:35 Changed 9 years ago by Ryan J Ollos

Life things came up, and the demands of people that pay my mortgage :)

I have a holiday coming up, so hope to keep that clear to work on the upgrade.

### comment:36 Changed 9 years ago by Ryan J Ollos

#11078 discusses a workaround for attachments that fail to display, and was closed as a duplicate of this ticket.

### comment:37 Changed 9 years ago by falkb

Wow! The new version is much faster and looks good :-)

### comment:38 follow-ups:  39  64  69 Changed 9 years ago by Dirk Stöcker

Wow. Finally. Thanks.

After login I get that everywhere.

AttributeError: 'TracHacksHtPasswdStore' object has no attribute 'user_email_verification_requested'

### comment:39 in reply to:  38 Changed 9 years ago by Ryan J Ollos

Wow. Finally. Thanks.

It hasn't come about the way I intended; I had hoped for a smoother process, but I made some mistakes and here we are. At least it's moving along, is my feeling at the end of a long day.

After login I get that everywhere.

AttributeError: 'TracHacksHtPasswdStore' object has no attribute 'user_email_verification_requested'

Thanks. Steffen is going to take a look at the AccountManagerPlugin configuration tomorrow. It was major upgrade, and I'm sure I don't have the configuration right yet.

I grabbed a bunch of entries from the logs and one of them seemed related to the SpamFilter (comment:1:ticket:11149). It looked pretty minor, if even a problem at all. We are running 0.8.0dev-r11796 (latest from the 1.0 branch as of earlier today).

I'm sure I'll have lots of questions for you regarding the configuration of the SpamFilterPlugin soon.

### comment:40 follow-up:  41 Changed 9 years ago by falkb

Is it policy or a configuration issue that commenting a blog entry is not permitted, even logged in?

### comment:41 in reply to:  40 ; follow-up:  42 Changed 9 years ago by osimons

Is it policy or a configuration issue that commenting a blog entry is not permitted, even logged in?

It is a new permission. Just haven't gotten around to adding it before now. Could you please check again and verify?

BTW, I have added it to authenticated users only. I see no particular good reason why we would want anonymous feedback to site issues.

### comment:42 in reply to:  41 ; follow-up:  48 Changed 9 years ago by falkb

Could you please check again and verify?

Works well

BTW, I have added it to authenticated users only. I see no particular good reason why we would want anonymous feedback to site issues.

This would just result in spam. BTW: I'd suggest to protect it with reCAPTCHA even for authenticated users because a spam robot may simply create a TH user first.

### comment:43 follow-up:  46 Changed 9 years ago by osimons

I've also enabled the blog spamfilter support, so all comments should also go through the same verification process as ticket and wiki updates.

Let's hope it works - been a while since I've looked at that particular code. Perhaps stoecker can verify the current implementation? See source:fullblogplugin/0.11/tracfullblog/spamfilter.py

### comment:44 follow-up:  45 Changed 9 years ago by Ryan J Ollos

One other small thing is that we seem to have lost the background with the trac-hacks wording. I'll worry about that when I stop spotting broken features and exceptions!

### comment:45 in reply to:  44 Changed 9 years ago by osimons

One other small thing is that we seem to have lost the background with the trac-hacks wording. I'll worry about that when I stop spotting broken features and exceptions!

Many small things we've lost here, but all is found in the old customization templates - see trac/templates/site_css.cs, site_footer.cs, site_header.cs and friends. I've started a site.html to get this going, and have so far converted site_newticket.cs and site_css.cs into new format. Particularly styles may need to be reviewed with all visual and layout changes since 0.10... At least it loads, so let's tweak it from here.

### comment:46 in reply to:  43 ; follow-up:  47 Changed 9 years ago by osimons

Let's hope it works - been a while since I've looked at that particular code. Perhaps stoecker can verify the current implementation? See source:fullblogplugin/0.11/tracfullblog/spamfilter.py

### comment:47 in reply to:  46 Changed 9 years ago by Dirk Stöcker

Let's hope it works - been a while since I've looked at that particular code. Perhaps stoecker can verify the current implementation? See source:fullblogplugin/0.11/tracfullblog/spamfilter.py

Hmm, depends on the fact if authenticated users are auto-trusted or not. Default is to trust them fully. Code looks good on first inspection.

### comment:48 in reply to:  42 Changed 9 years ago by Dirk Stöcker

BTW, I have added it to authenticated users only. I see no particular good reason why we would want anonymous feedback to site issues.

This would just result in spam. BTW: I'd suggest to protect it with reCAPTCHA even for authenticated users because a spam robot may simply create a TH user first.

With a fine trained filter there is no need for a standard captcha anymore. Captcha only appears if submissions have been detected as SPAM and users get a chance to override it. T.E.O. and my josm site have approx. !one spam entry each 2-5000 spam submissions. Usually hand-entered spam passing valid captchas or stuff which is human-mad crap, but not really spam. Both sites allow unregistered edits.

### comment:49 Changed 9 years ago by Ryan J Ollos

I moved the repository configuration from trac.ini to the database, and resynced the repository. The configuration is such that the SVN repository URL is now shown in the contextual navigation of the repository browser.

One odd thing is that the resync kept halting, showing no error. Here is the last bit of my shell session:

rjollos@hacks:~$sudo /srv/trac-hacks.org/pve/bin/trac-admin /srv/trac-hacks.org/trac repository sync "" Resyncing repository history for (default)... 6072 revisions cached. Done. rjollos@hacks:~$ sudo /srv/trac-hacks.org/pve/bin/trac-admin /srv/trac-hacks.org/trac repository sync ""
Resyncing repository history for (default)...
6213 revisions cached.
Done.
rjollos@hacks:~$sudo /srv/trac-hacks.org/pve/bin/trac-admin /srv/trac-hacks.org/trac repository sync "" Resyncing repository history for (default)... 6699 revisions cached. Done. rjollos@hacks:~$ sudo /srv/trac-hacks.org/pve/bin/trac-admin /srv/trac-hacks.org/trac repository sync ""
Resyncing repository history for (default)...
6762 revisions cached.
Done.
rjollos@hacks:~$sudo /srv/trac-hacks.org/pve/bin/trac-admin /srv/trac-hacks.org/trac repository sync "" Resyncing repository history for (default)... 6993 revisions cached. Done. rjollos@hacks:~$ sudo /srv/trac-hacks.org/pve/bin/trac-admin /srv/trac-hacks.org/trac repository sync ""
Resyncing repository history for (default)...
7529 revisions cached.
Done.
rjollos@hacks:~$sudo /srv/trac-hacks.org/pve/bin/trac-admin /srv/trac-hacks.org/trac repository sync "" Resyncing repository history for (default)... 10111 revisions cached. Done. rjollos@hacks:~$ sudo /srv/trac-hacks.org/pve/bin/trac-admin /srv/trac-hacks.org/trac repository sync ""
Resyncing repository history for (default)...
13267 revisions cached.
Done.
rjollos@hacks:~\$ sudo /srv/trac-hacks.org/pve/bin/trac-admin /srv/trac-hacks.org/trac repository sync ""
Resyncing repository history for (default)...
13267 revisions cached.
Done.

In the logs, many entries like the following:

2013-06-07 02:04:10,772 Trac[cache] WARNING: Revision 13089 already cached: IntegrityError('duplicate key value violates unique constraint "revision_pk"\n',)
2013-06-07 02:04:13,460 Trac[cache] WARNING: Revision 13204 already cached: IntegrityError('duplicate key value violates unique constraint "revision_pk"\n',)
2013-06-07 02:04:14,328 Trac[cache] WARNING: Revision 13240 already cached: IntegrityError('duplicate key value violates unique constraint "revision_pk"\n',)
2013-06-07 02:04:14,640 Trac[cache] WARNING: Revision 13253 already cached: IntegrityError('duplicate key value violates unique constraint "revision_pk"\n',)

### comment:50 follow-ups:  51  52 Changed 9 years ago by Ryan J Ollos

The hacks are back on WikiStart now, and the styling looks quite a bit better. I haven't looked closely at the code, but I imagine it is due to a combination of the Trac 1.0 theme and the work of otaku42 on the TracHacksPlugin.

### comment:51 in reply to:  50 Changed 9 years ago by Steffen Hoffmann

The hacks are back on WikiStart now, and the styling looks quite a bit better. I haven't looked closely at the code, but I imagine it is due to a combination of the Trac 1.0 theme and the work of otaku42 on the TracHacksPlugin.

Great. OTOH, this slows down the front-page to previous lag-times.

This will finally drive me to look at TracHacksPlugin code. Best possible outcome would be a sub-optimal use of TagsPlugin, so that I could redirect calls towards a faster method for retrieving tagged (wiki) resources too. Using a cached list would be another strong option IMHO. We should really push computing effort and resulting response times towards what we had with the listing disabled, and I'm sure, this is possible.

### comment:52 in reply to:  50 ; follow-up:  53 Changed 9 years ago by falkb

The hacks are back on WikiStart now, and the styling looks quite a bit better. I haven't looked closely at the code, but I imagine it is due to a combination of the Trac 1.0 theme and the work of otaku42 on the TracHacksPlugin.

Currently, I don't see that table of hacks (both cases, logged in and out). Just "Show hacks for releases:" with an "Update" button appears but nothing happens when I click it.

### comment:53 in reply to:  52 ; follow-up:  63 Changed 9 years ago by Ryan J Ollos

Currently, I don't see that table of hacks (both cases, logged in and out). Just "Show hacks for releases:" with an "Update" button appears but nothing happens when I click it.

I hadn't granted TAGS_VIEW. Sorry about that. You should see it now.

### comment:54 Changed 9 years ago by falkb

Wow! Even the main menu item "Tags" suddenly appeared. Thanks.

### comment:55 follow-up:  57 Changed 9 years ago by falkb

The tag cloud doesn't contain plugin names. Correct or not?

### comment:56 follow-up:  58 Changed 9 years ago by falkb

Now the main menu offers "Wiki", "Timeline", "Browse Source", "View Tickets", "New Ticket", "Search", "Tags", "Blog". Everything on board now or do we still miss some other VIEW permissions?

"Roadmap" for instance is not shown, maybe it's a good idea to create milestones there for tickets regarding to the improvements of trac-hacks.org itself or related tickets (e.g. TracHacksPlugin). This would likely increase the transparency of the TH project.

### comment:57 in reply to:  55 ; follow-ups:  59  60 Changed 9 years ago by Steffen Hoffmann

The tag cloud doesn't contain plugin names. Correct or not?

How could that be? Hack names are Components here (that cannot be tagged directly by now - pending enhancement), and tags named after plugins are possible but not planned as a general rule yet. Tagging if wiki pages will have to be converted from TagIt macro (old way).

### comment:58 in reply to:  56 ; follow-up:  61 Changed 9 years ago by Steffen Hoffmann

Now the main menu offers "Wiki", "Timeline", "Browse Source", "View Tickets", "New Ticket", "Search", "Tags", "Blog". Everything on board now or do we still miss some other VIEW permissions?

Looks ok, so far. Probably we'll want to hide the /newticket direct link in favor of the per-hack default link in each hack's wiki page, or at least change the link to /newticket?component=TracHacksPlugin as a sensible default for issues not coming from specific plugins.

"Roadmap" for instance is not shown, maybe it's a good idea to create milestones there for tickets regarding to the improvements of trac-hacks.org itself or related tickets (e.g. TracHacksPlugin). This would likely increase the transparency of the TH project.

Doing it just because it could be done is not a hot idea. We have missed something like the roadmap to triage tickets for some plugins, sure. But we've not decided on how to approach it now. I.e. we can't do it without a having real per-hack-milestones and a per-hack-milestone admin interface. Let's go further on that road only after carefully examining the real benefit and after having prepared the required infrastructure.

Please note, that progress bars are no longer tied to the roadmap, and could be embedded in every text-area supporting WikiFormatting:

[[TicketQuery(component=TracHacksPlugin,format=progress)]]

renders as

79%

Many possibilities with Trac 1.0, you see?

### comment:59 in reply to:  57 Changed 9 years ago by Ryan J Ollos

Hack names are Components here (that cannot be tagged directly by now - pending enhancement),

Did you have in mind the ability to add tags to Components, or to use the component table as a tag provider with the name column providing the tags? The latter would be somewhat similar to the [tags] ticket_fields option, except that the component table would be the direct source of tags rather than the component field of each ticket.

### comment:60 in reply to:  57 ; follow-up:  62 Changed 9 years ago by anonymous

The tag cloud doesn't contain plugin names. Correct or not?

How could that be? Hack names are Components here (that cannot be tagged directly by now - pending enhancement), and tags named after plugins are possible but not planned as a general rule yet. Tagging if wiki pages will have to be converted from TagIt macro (old way).

Sorry, I was not clear enough. I just remembered, with the old Trac version, I've seen e.g. TracJsGanttPlugin with a certain font size on the tag cloud page, but now it's vanished there. I just thought it might be due a permission problem.

### comment:61 in reply to:  58 ; follow-up:  65 Changed 9 years ago by Ryan J Ollos

Please note, that progress bars are no longer tied to the roadmap, and could be embedded in every text-area supporting WikiFormatting:

[[TicketQuery(component=TracHacksPlugin,format=progress)]]

renders as

79%

That might be a good modification to make to the NewHack template.

How does this look?: BookmarkPlugin#BugsFeatureRequests. The change makes the link to all tickets, including closed ticket, immediately available to the user, so hopefully more users will take advantage of this to read closed tickets as well before opening a new ticket. As part of the change in #10510, I'll make report {10} group tickets by status, though we might be better off using a custom query rather than a report so that a user can easily do further filtering.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

### comment:62 in reply to:  60 Changed 9 years ago by Ryan J Ollos

Sorry, I was not clear enough. I just remembered, with the old Trac version, I've seen e.g. TracJsGanttPlugin with a certain font size on the tag cloud page, but now it's vanished there. I just thought it might be due a permission problem.

I'm not sure what would cause it to appear on the tag cloud page. The first guess I had was that some tickets had TracJsGanttPlugin as a keyword, but a query yields no results.

### comment:63 in reply to:  53 Changed 9 years ago by Ryan J Ollos

I hadn't granted TAGS_VIEW. Sorry about that. You should see it now.

Note that I also granted TAGS_MODIFY at that time.

### comment:64 in reply to:  38 Changed 9 years ago by Ryan J Ollos

After login I get that everywhere.

AttributeError: 'TracHacksHtPasswdStore' object has no attribute 'user_email_verification_requested'

I think we've fixed this now in #11154, but please let me know if you find that's not the case.

### comment:65 in reply to:  61 ; follow-up:  66 Changed 9 years ago by Steffen Hoffmann

That might be a good modification to make to the NewHack template.

How does this look?

+1, looks great, provides intuitive links to resolved as well as open issues, and an overall impression on plugin status even before looking at a ticket listings.

Minor nit-pick: For some plugin's I'd like to have a miniature representation to be able to show a bundle of progress bars - on bar per ticket type. When there are 10 issues, it matters if 8 of them are bugs ore enhancement requests.

### comment:66 in reply to:  65 ; follow-up:  67 Changed 9 years ago by Ryan J Ollos

Minor nit-pick: For some plugin's I'd like to have a miniature representation to be able to show a bundle of progress bars - on bar per ticket type. When there are 10 issues, it matters if 8 of them are bugs ore enhancement requests.

It might be possible to even show all the different ticket types in one bar (probably an enhancement to Trac is needed), similar to TracIni#milestone-groups-section, and have closed / defects / enhancements / tasks as colored segments of the bar and query links below the bar. That would provide all the information I need, because like you I care to see how many open defects vs enhancements vs tasks there are, but I don't really need to see the closed tickets categorized by ticket type.

Your edits to AccountManagerPlugin#BugsFeatureRequests look good though. The bars are only lacking a title, which is another possible enhancement to the TicketQuery macro, though we can probably just add it through wiki markup, or even WikiHtml if we want it to look really nice (e.g. adjust the font and font size) (see also #11045).

### comment:67 in reply to:  66 Changed 9 years ago by Steffen Hoffmann

It might be possible to even show all the different ticket types in one bar (probably an enhancement to Trac is needed), similar to TracIni#milestone-groups-section, and have closed / defects / enhancements / tasks as colored segments of the bar and query links below the bar. That would provide all the information I need, because like you I care to see how many open defects vs enhancements vs tasks there are, but I don't really need to see the closed tickets categorized by ticket type.

Agreed, feeling the same. It will definitely need an enhancement to get ticket grouped by status and - at the same time - open tickets by type. Because there are so many possible use-cases, that having closes/defects/enhancements/tasks would be not enough. I know of some instances with more than 20 ticket types.

IMHO it would be valuable to just switch the criterion for grouping from ticket status to type and have two bars: an overall status + open ones grouped by type. An have a scaling attribute for miniature progress bar image, probably auto-popup-n-grow to 100% onMouseOver and go back to miniature when the pointer is dragged away from the image?

Last edited 9 years ago by Steffen Hoffmann (previous) (diff)

### comment:68 Changed 9 years ago by falkb

Still something deep in my mind warns me the progress thingy is a bit odd here. For a while I was thinking why and I think I detected the reason now: It's the percent number. That makes it more look like you're aiming a certain date (on a roadmap), but it is not. What you want to display is just a coloured ticket type overview chart not chained to an aim. Maybe this is a bit captious but I bet some users will accociate it with the state until the next plugin version... probably it helps to mask out the percent value.

### comment:69 in reply to:  38 Changed 9 years ago by Ryan J Ollos

I would like to take you up on this offer as much as possible. I'll contact you by email.

In 13283:

### comment:71 follow-up:  72 Changed 9 years ago by falkb

Uhmm... I can't vote tickets and wiki anymore (?).

### comment:72 in reply to:  71 Changed 9 years ago by Ryan J Ollos

Uhmm... I can't vote tickets and wiki anymore (?).

Removed to avoid an error that resulted in a traceback. Maybe one of the errors documented in #11149, but I don't remember. It will be reinstalled once we have sorted out what the problem is.

Installation of VotePlugin is being tracked in #8717.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

### comment:73 follow-up:  74 Changed 9 years ago by anonymous

stoecker has pointed out that TracIniAdminPanelPlugin needs to be reinstalled because i18n translations aren't enabled.

### comment:74 in reply to:  73 Changed 9 years ago by Steffen Hoffmann

stoecker has pointed out that TracIniAdminPanelPlugin needs to be reinstalled because i18n translations aren't enabled.

Right, but this is true for every plugin packaged in the virtual environment before we installed Babel. I noticed this for AcctMgr and TagsPlugin too, but no need to hurry from my point of view. It will come with next update automatically, and I hope to roll a lot of improvements in due time.

### comment:75 Changed 9 years ago by Steffen Hoffmann

Been bitten by genshi:ticket:566 same way as mentioned in t:#11184 - another Genshi issue for the 0.7 release.

I wonder, if we should roll-back to 0.6 for a while, because I can't see much pushing to get Genshi issues fixed in a timely manner, and I cannot do it myself. Another option would be to maintain a version with published patches meanwhile, what might actually encourage fixing it upstream a bit more. Thoughts?

### comment:76 follow-up:  77 Changed 9 years ago by falkb

Realizing blog and news ticker at wiki start page is not sync'ed I wonder if it's a good idea to use

{{{
#!div class=blogflash
}}}

### comment:77 in reply to:  76 Changed 9 years ago by Steffen Hoffmann

Realizing blog and news ticker at wiki start page is not sync'ed

This is on purpose. We use tagging to mark blog posts for WikiStart, and I decided to not add the German developer meeting post, but announce it at out mailing-list instead.

### comment:78 Changed 9 years ago by Jun Omae

Hi, it seems NewHack page currently doesn't work. I have a new hack....

### comment:79 Changed 9 years ago by Ryan J Ollos

I've been feeling a bit guilty about not getting that working yet. The TracHacksPlugin seems to need a bit of work still. I'll take a look tomorrow and try to figure out what needs to be done still, and report back.

### comment:80 Changed 9 years ago by Ryan J Ollos

I've installed the ServerSideRedirectPlugin as a replacement for TracRedirect. The latter hadn't been reinstalled after the upgrade, so pages such as GoogleAnalyticsPlugin and AccountManager weren't redirecting.

Sorry the progress on the upgrade is moving so slow lately. I'll try to find time this week to finish up the major issues.

### comment:81 Changed 9 years ago by Ryan J Ollos

After this mailing list post, I searched for ?format=raw strings and made the following changes to each URL to fix the links:

• removed ?format=raw
• replaced attachment with raw-attachment`

Please fix or let me know if you spot any I missed.

Last edited 9 years ago by Ryan J Ollos (previous) (diff)

### comment:82 Changed 9 years ago by Matthew Carlson

I also have a new hack, but the NewHack page doesn't work, presumably related to the NewHackMacro not being checked off in this ticket. I'm not in any hurry to upload, but thought I'd share a small LDAP Sync plugin I wrote to fill a gap between SSPI authentication and email notifications.

### comment:83 Changed 9 years ago by Ryan J Ollos

Description: modified (diff)

Sorry for the continued delay on resurrecting the New Hack form. I will try to find some time to work on it this coming weekend.

If anyone is interested in contributing to that effort, the TracHacksPlugin provides the New Hack form now, and if I remember correctly there are some major issues that will quickly be discovered once you start testing. The NewHackMacro is deprecated.

Note: See TracTickets for help on using tickets.