text:
## One forms: link between stochastic integral d and Riemann-Stieltjes d and one form d.

In differential geometry we learn about the "one forms," $dx_{i}$ and its dual $\frac{\partial}{\partial x_{i}}$

I don't see in the literature anything concerning a "one form" of Stieltjes type $df\left(x\right)$.

Is it appropriate to call it a one form? Furthermore is the dual still $\frac{\partial}{\partial f\left( x\right)}$? I would assume the answer is yes.

Next in stochastic integration, the integral is with respect to Brownian motion, $B\left(t, x,\omega\right)$, usually written $B_{t}\left(x,\omega\right)$.

Brownian motion is a process that doesn't have bounded variation, but instead has quadratic variation $t$, so the integral needs a special definition, which is typically written $\displaystyle \int f\left(x\right) dB_{t}\left(x\right)$. Note the $d$ is with respect to time. Is it appropriate to call $dB_{t}\left(x,\omega\right)$ a "one form"? And is there a notation for taking the one form d of one variable and holding the other one fixed in the case of functions of multiple variables. For example: If I write $d_{t}B\left(t, x,\omega\right)$ vs. $\partial_{t}B\left(t, x,\omega\right)$ I've never seen $d_{t}$, but I'm not sure that the partial notation gives the feel of it being a "one form" even though it would seem to be more correct to me?

-

format: plain


text:
# Difference between the two regular expression

I came across a question to create a regular expression to check whether there are even number of b's in a string of language {a,b}. The expression I came up with is (a+ba*b)*. However I found the solution online to be a*(ba*ba*). Is there any difference? If any where?

Also I know that (a+b)* is equivalent to (a*b*)*. So my solution comes out to be (a*(ba*b))*. So why that extra a*?

• I think you'll need to edit the question, as I can't tell what you are asking. 1. (a+b)* is not equivalent to (a*b*). Please double-check all your statements. Proof-read the formatted output, and consider using Markdown to typeset your notation more clearly. 2. What have you tried? Have you tried to look for a string that is accepted by your expression but not by the other one, or vice versa? Have you taken a look at closure properties, to see how to compute the set difference between two regexps? (continued) – D.W. Sep 3 '15 at 21:33
• 3. Please use typesetting to reduce ambiguity. Does (a+ba*b)* mean (a+(ba*b))* or ((a+b)a*b)*? 4. I can't tell what "check whether for even number of b's in a language of {a,b}" means. Can you please edit to rewrite that? Thank you! – D.W. Sep 3 '15 at 21:33

• In fact $(a+ba^*b)^*$ does correctly represent an even number of $b$'s. The expression has a repeated alternative between a single $a$ and a sequence of two $b$'s with an arbitrary numbers of $a$'s in between. The star allows zero iterations. Also $a^*(ba^*b)^*$ is indeed wrong, but it will match $a$'s between $b$'s. The reason it is wrong is that we cannot end with the letter $a$ unless we only have $a$'s. – Hendrik Jan Sep 5 '15 at 22:53


text:
Welcome to ZOJ
 Problem Sets Information Select Problem Runs Ranklist
ZOJ Problem Set - 4121
Connected Intervals

Time Limit: 2 Seconds      Memory Limit: 131072 KB

DreamGrid has just found a tree of $n$ vertices in his backyard. As DreamGrid loves connected components, he defines an interval $[l, r]$ ($1 \le l \le r \le n$) as a "connected interval" if the induced subgraph formed from the set $\mathbb{V} = \{v_i | i \in [l, r]\}$ consists of exactly one connected component, where $v_i$ indicates the vertex whose index is $i$.

Given the tree in DreamGrid's backyard, your task is to help DreamGrid count the number of connected intervals.

Recall that an induced subgraph $G'$ of a graph $G$ is another graph, formed from a subset $\mathbb{V}$ of the vertices of the graph $G$ and all of the edges in graph $G$ connecting pairs of vertices in $\mathbb{V}$.

#### Input

There are multiple test cases. The first line of the input contains an integer $T$ indicating the number of test cases. For each test case:

The first line contains an integer $n$ ($1 \le n \le 3 \times 10^5$) indicating the size of the tree.

For the following $(n-1)$ lines, the $i$-th line contains two integers $a_i$ and $b_i$ ($1 \le a_i, b_i \le n$) indicating that there is an edge connecting vertex $a_i$ and vertex $b_i$ in the tree.

It's guaranteed that the given graph is a tree and that the sum of $n$ in all test cases will not exceed $3 \times 10^5$.

#### Output

For each test case output one line containing one integer, indicating the number of connected intervals.

#### Sample Input

2
4
1 2
2 3
3 4
4
1 2
2 3
2 4

#### Sample Output

10
9

#### Hint

For the first sample test case, all intervals are connected intervals.

For the second sample test case, all intervals but [3, 4] are connected intervals.

Author: LIN, Xi
Source: The 10th Shandong Provincial Collegiate Programming Contest
Submit    Status


text:
## Introduction

In the past decade, neural networks have proven to be stunningly effective tools for a slew of machine learning tasks as diverse as classifying images, generating 3D graphics, and playing games. These incredible successes all stem from neural networks’ remarkable ability to perform a central task in machine intelligence: given complex data, find underlying patterns.

Boiled down to their core, neural networks are just a series of hierarchical nonlinear transformations. Each layer of the neural network is one layer in this hierarchy, transforming a feature vector and passing it to the next layer up, until it reaches the output. Each layer usually involves a step that mixes the elements of the feature vector according to a set of weights followed by a nonlinear function applied to each element of the vector. All types of neural networks use a series of these layers to do the basic information processing.

Within that hierarchical nonlinear structure, however, there are many variations. There are a vast array of different ways layers can be connected and parameterized, giving different architectures like convolutional nets, recurrent nets, and resnets specialized to certain types of task. However, there are also lower-level things that can be changed. One example is the nonlinear function, usually denoted $$\sigma$$. The field’s explored many options for $$\sigma$$ over the years, and the most popular choice has changed over time. The $$\tanh$$ function (and similar sigmoid) were once the leading choice, but the $$\text{ReLU}$$ (defined by $$\sigma(x) = \max(x, 0)$$) is now more popular. Choosing a different nonlinearity can improve performance slightly, but to me it is more striking that the choice of nonlinearity matters so little. On the face of it, the $$\text{ReLU}$$ and $$\tanh$$ functions are basically as different as they could be within reason. $$\tanh$$ is smooth, saturating, nonlinear on every finite set, and is symmetric about the origin. $$\text{ReLU}$$ has a kink, is unbounded, piecewise-linear, and never takes negative values, not to mention that it outputs zero on half of its domain. The fact that both of these functions could work reasonably well speaks to the fact that even though the hierarchical nonlinear structure is core to the effectiveness of neural nets, the exact choice of nonlinearity is, surprisingly, not crucial.

In fact, even the typical layer structure of matrix multiplication + elementwise nonlinearity isn’t crucial to performance. It has been shown that tensor networks, a completely different type of hierarchical nonlinear model commonly used in physics, can also learn machine learning tasks. This paper develops the idea and gets 1% test error on MNIST, which is pretty good for a totally new approach. Interestingly, neural networks have recently been used instead of tensor networks in computational physics problems and achieved good performance there. This raises a natural question: how do we know that the matrix multiplication + elementwise nonlinearity structure is really the best one? To my knowledge, there’s no known fundamental, theoretical reason why it would be better than other options.

## Multiplicative nets

Here’s an idea for a different type of nonlinear hierarchical model. What if we took a neural network and replaced the matrix multiplication step $$\sum_j w_{ij} x_j$$ with a product step $$\prod_j x_j ^ {w_{ij}}$$, with the weights as exponents in a product instead of coefficients in a sum? This would still mix together the elements of the feature vector $$x$$, just like a matrix operation, but in a different, nonlinear way. Given the way deep learning systems can sometimes be surprisingly invariant to details of implementation, maybe this new, different sort of model could still work well.

Architectures using this idea are called multiplicative neural networks. The idea was first proposed in 1989 by neuroscientists seeing multiplication as more biologically plausible and potentially more powerful than addition. They were tested experimentally on some very small problems in the next decade and once analyzed from a complexity standpoint in the decade after. The architectures these papers describe are a little more general - they consider combining additive and multiplicative neurons in the same net and using hybrid terms with more weights of the form $$v_1 \prod_j x_j ^ {w_{ij1}} + v_2 \prod_j x_j ^ {w_{ij2}} + ... + v_n \prod_j x_j ^ {w_{ijn}}$$ - but their key innovation is the multiplicative form. However, despite this research, multiplicative nets never broke through to practical use; we still use additive neural networks with normal matrix operations.

This is pretty understandable - at a first glance, multiplicative nets seem like they’d have some problems. One immediate question is what to do when $$x_i < 0$$ and $$w_{ij}$$ isn’t an integer, in which case $$x_i ^ {w_{ij}}$$ isn’t uniquely defined, but to avoid that problem let’s just set things up so that all the $$x_i$$ are positive, which I’ll show we can do with the right choice of data and nonlinearity. Even dealing with this, though, these nets have some pretty prolific potential practical problems. First, there’s been a lot of research and hardware development into making matrix operations faster, and this wouldn’t use them. Second, replacing simple matrix operations with something more complex could lead to weird gradients and failed optimization. Third, as a friend noted, even from a pure computational complexity standpoint, calculating $$x^y$$ is more expensive than calculating $$x*y$$, so this would be slow. Finally, the advantages of switching to this architecture are far from clear, so there’s no incentive to overcome these problems.

The purpose of this post is to explore something interesting that isn’t discussed in the above papers: the multiplicative nets you get by replacing $$\sum_j w_{ij} x_j$$ with $$\prod_j x_j ^ {w_{ij}}$$ are basically identical to normal, additive neural nets with a different choice of nonlinearity. The basic reason is that, as the 1989 paper did note, $$\prod_j x_j ^ {w_{ij}} = \exp \big( \sum_j w_{ij} \ln(x_j) \big)$$, so a multiplicative layer is the same as an additive layer where you take the logarithm before and an exponential after. The main trick we’ll use is the fact that you can then absorb the $$\ln$$ and $$\exp$$ into the nonlinearity to get a new nonlinearity $$\sigma'(x) = \exp\sigma(\ln(x)))$$, or, with compositional notation, $$\sigma' = \exp \circ \sigma \circ \ln$$.

My argument could easily be laid out with standard symbolic math. However, that’s not how I think about it, and I don’t think it’s the clearest way to explain it. Notation matters; different ways of writing the same thing inspire different kinds of manipulations, and cleaner notations are better to learn with. Instead of algebra, I’ll use diagrams.

Basic neural nets are built of a few basic pieces. There are input nodes, where input data vectors go into the net. There are output nodes, where the net’s output comes out. There are elementwise nonlinear functions, mapping real numbers to real numbers. There are additive or matrix operations, each with its own 2D array of parameters $$W$$, which in normal neural nets come between applications of nonlinear functions. Lastly, we’ll include multiplicative operations, which also each have their own 2D array array of parameters $$W$$ as discussed above. We’ll use color to differentiate between additive and multiplicative operations; additive will be black, multiplicative will be purple. Note that changing an operation from additive to multiplicative or vice versa doesn’t change its parameter matrix; the same numerical weights are just interpreted differently in a different operation. We could also add pieces like biases or specialized layers like softmax or maxpooling, but we’ll leave those out for now for simplicity. We could cast these pieces into diagrammatic form as follows:

We can now build neural nets out of these components. For example, the following is a standard additive neural net with 3-dimensional input, 3-dimensional output, two hidden layers with width 3, and a nonlinearity $$\sigma$$.

There are a few different ways we can manipulate these diagrams while still keeping the model the same. The first way is function composition. If there are two nonlinear functions in a row, we can just replace them with one new function. This is just saying that the double function application $$f(g(x))$$ is equivalent to the single function application $$h(x)$$, defining $$h = f \circ g$$. One special, familiar case is when the two functions are each other’s inverses, and the new function is simply the identity; for example, $$\ln(\exp(x)) = x$$. Instead of writing the identity function explicitly, we can just write a line. Note that in the notation $$f \circ g$$, functions are applied right to left, but in our diagramas, everything flows from left to right, so the ordering of the composed functions might seem backwards at first. There’s also the multiplicative-additive net identity we talked about earlier: $$\prod_j x_j ^ {w_{ij}} = \exp \big( \sum_j w_{ij} \ln(x_j) \big)$$. A multiplicative layer is the same as an additive layer with logarithms before and exponentials afterwards. We can write these rules like this:

These rules lay out ways we can manipulate diagrams. As a test of this notation, with just these simple rules we can derive a companion rule to the multiplicative-additive identity. Just as you can take a function of both sides of an algebraic equation, we’re allowed to modify a diagrammatic equation by attaching pieces to dangling ends of both diagrams in the same way. In this case, we’ll attach exponentials on all dangling ends on the left and logarithms on the right of both diagrams. This gives us a new diagrammatic equation. We can then use function composition to simplify the adjacent logarithms and exponentials to get a new, simple identity. This one tells us that $$\ln \big( \prod_j \exp(x_j)^{w_{ij}} \big) = \sum_j w_{ij} x_j$$, which you can algebraically check is true.

Now, let’s put together a multiplicative net and see what we can derive. Our starting point will be the same simple 3-3-3-3 net as before, but with multiplicative layers; it will be clear that our operations will generalize to different sizes. First, we use the multiplicative-additive identity to get an additive net. However, instead of just having one nonlinear function acting on each element of the feature vector, there are now three in succession. Using function composition, we can just group these into a new nonlinearity we define as $$\sigma' = \ln \circ \sigma \circ \exp$$. We now arrive at an additive net exactly equivalent to the multiplicative net. The only major oddity of the new additive net is elementwise logarithms at the start and exponentials at the end.

These logarithms and exponentials at the start and end aren’t surprising. We’re requiring that multiplicative nets need positive input and give positive output, so since logarithms of negative numbers aren’t real, these logarithms enforce the positivity of the input. The exponentials similarly enforce the positivity of the output. Also, as long as $$\sigma$$ maps positive numbers to positive numbers, the net only operates on positive numbers intermediately, and we don’t have the undefined power problem. We can make our diagram even simpler by absorbing the logarithms and exponentials into the inputs as follows:

It turns out that a multiplicative net is basically the same as an additive net with the same weights! Our choice of notation emphasizes the similarity of form. However, is this really a meaningful, useful correspondence? The main question is this: what’s the nonlinearity $$\sigma'$$ like? It’s possible that $$\sigma' = \ln \circ \sigma \circ \exp$$ is some bizarre function that’d be totally nonfunctional in an additive net, which would bode badly for our multiplicative net. To answer this, a few examples are plotted below. The blue curves show different choices of nonlinearity for multiplicative nets, defined only for positive inputs, and the orange curves show the corresponding additive nonlinearities.

As shown in (a), when $$\sigma$$ is the $$\tanh$$ function, $$\sigma'$$ looks a lot like a smoothed $$\text{ReLU}$$, also called a softplus! It’s flipped across the x- and y-axes, but that doesn’t change the usefulness of a nonlinearity in an additive neural net. This would definitely work as an activation function. Surprisingly, (b) shows that when $$\sigma$$ is a sigmoid, $$\sigma'$$ is also roughly a sigmoid (but again flipped across both axes), which also works as a nonlinearity. Shown in (c) is the case when the multiplicative net uses a $$\text{ReLU}$$ nonlinearity. This is a distinctly horrendous choice for only positive inputs, since it’s the same as the identity on positive input, which is reflected in the fact that $$\sigma'(x) = x$$. A multiplicative neural net with $$\text{ReLU}$$ nonlinearities is basically linear; adding extra layers doesn’t give it any power since, for additive networks, a multilayer linear net is reducible to a linear model. With a slight modification, however, we get a very useful nonlinearity. As shown in (d), if the nonlinear net uses a modified $$\text{ReLU}$$ - specifically, $$\sigma(x) = \max(x, 1)$$ - the corresponding linear net has exactly $$\text{ReLU}$$ activations.

It might not be clear what, exactly, this means for multiplicative nets. Let’s suppose that we’re using a multiplicative neural net to do a task - say, classifying images - and we operate it by exponentiating the pixel values at input and taking the log of the output. We have shown that, for a reasonable nonlinearity, the function the multiplicative net computes as a function of weights and data - say, $$f(X ; W)$$ - is exactly the same as for a reasonable additive net. That means that the loss surface is the same. That means that the gradients are the same, and that means that the trainability is the same, and all this means that the theoretical usefulness of multiplicative neural nets, including their representational power and optimization behavior, are the same as the standard additive neural nets that have been the focus of such intense study. Multiplicative nets are just as effective, there’s a correspondence to additive nets, and we have the conversion algorithm.

This fact is intriguing, but what does it mean in a broader sense? This doesn’t make multiplicative nets practically useful; it’s still faster to perform a matrix multiplication than a multiplicative step, and since they amount to the same thing there’s no reason to prefer the latter. To me, the reason this fact bears consideration is the hint it might be towards what truly gives deep learning its unreasonable effectiveness. Multiplicative and additive nets have starkly different functional forms, and at a first glance I’d guess they have wholly different behavior as models. The fact that they actually have equivalent power and utility seems like a hint that the fundamental magic of deep learning doesn’t lie in the details of implementation, like the choice of activation function or even the choice of matrix multiplication for mixing; the latter’s just preferred for convenience. It seems likely that the key to deep learning’s success is something more deep and general about hierarchical nonlinear structures, and wildly disparate hierarchical models, from standard neural nets to multiplicative nets to tensor networks, all succeed because in some deep way they all fit this broad category. Perhaps efforts to understand deep learning will eventually uncover a mathematical understanding of something like this.

## Extras

• “Wait,” you might say, “there’s no clean correspondence to an additive net if the multiplicative net has a more complicated form, like involving a sum of product terms. This analysis only works in one case when it happens to be trivial!” It’s true that the exact correspondence is easy to break by adding a bell or a whistle to the multiplicative net. The question, however, is whether these modifications add anything fundamentally different, or whether they’d be incremental changes at most. I can only conjecture for now - maybe I’ll do experiments if this becomes a paper - but I’d guess it’s likely that there are many ways to superficially change the form of multiplicative nets without fundamentally changing their behavior because the same is true of additive nets. For example, you can add extra parameters to neural nets by parameterizing the activation functions themselves; this paper not only tried that, but ran an evolutionary algorithm to build complicated activation functions, and their error rates were only a few percent lower than with simple $$\text{ReLU}$$s. Many such engineering intricacies lead to no big change in performance. For that reason, I think it’s a decent hypothesis that multiplicative nets behave similarly to additive nets even when there’s no exact correspondence.

• In the diagrams I drew, the nets have only weights, not biases. Since $$\exp \big( \sum_j w_{ij} \ln( x_j ) + b_j \big) = e^{b_j} \prod_j x_j ^ {w_{ij}}$$, we can add them by multiplying the product by $$e^{b_j}$$, where $$b_j$$ is a new bias parameter.
• The choice of base $$e$$ (i.e. $$\exp$$ and $$\ln$$) in this article was arbitrary, and any other base would’ve worked.
• Many types of specialized neural net layer can also be translated into multiplicative nets. For example, a softmax is similar, but it doesn’t even require taking the exponentals. $$\exp$$ and $$\ln$$ are monotonic, so they commute through max operations, so maxpool layers are the same for multiplicate nets.
• Are there other choices for the mixing operation besides the matrices of additive nets and the multiplication operation shown here? One way to generalize the concept to include both is to make the mixing transform $$f \big( \sum_j w_{ij} f^{-1}(x_j) \big)$$, with $$f$$ an invertible function mapping reals to reals. In the case of $$f = \text{identity}$$, this gives additive nets. In the case of $$f = \exp$$, this gives multiplicative nets. In a case like $$f(x) = x^3$$, though, it would give something new, but still equivalent to an additive net by the same sort of proof.
• The most recent paper I’ve found on these nets, which was mentioned above, argues that multiplicative neurons perform operations that need large numbers of summing units, stating that “networks of summing units do not seem to be an adequate substitute for genuine multiplicative units.” This post basically disproves that!


text:
# Thread: cant uderstand certain parts this another problem..

1. ## cant uderstand certain parts this another problem..

here is the problem and solution:
http://i30.tinypic.com/2w2mnap.jpg

why they divide into two cases?

then they find a magnetic field

but we dont have any electricity flowing??

the i recognized the formula for a magnetic field from a wire
but when we find a the formula from the biotsavart law
the oly direction is dlX $\hat{r}$

2. It goes without saying that there is a current flowing through the wire.


text:
+0

# Simple Proofs (Hopefully)

+2
313
3
+2190

Can someone please prove the properties of exponents? Doing this will allow me to understand it better. Thanks.

TheXSquaredFactor  Dec 20, 2017

#1
+2190
+3

Sure, I think I can give you a fairly simple proof for you. There are a few property of exponents that you have learned. I have listed all of them for you and what each says. To understand these proofs, you should understand that for whole numbers of a, $$x^a=\underbrace{x*x*x*...*x}\\ \quad\quad\quad\quad\text{a times}$$. This is the basis of the notation. The proofs are based on the notation. Sometimes, some rules will assume that a previous one was already proven.

 Property of Exponent Definition 1. Product of Powers $$x^{\textcolor{red}{a}}*x^{\textcolor{blue}{b}}=x^{\textcolor{red}{a}+\textcolor{blue}{b}}$$ 2. Quotient of Powers $$\frac{x^{\textcolor{red}{a}}}{x^{\textcolor{blue}{b}}}=x^{\textcolor{red}{a}-\textcolor{blue}{b}}$$ 3. Negative Exponents $$x^{\textcolor{blue}{-b}}=\frac{1}{x^\textcolor{blue}{b}}\\ \frac{1}{x^\textcolor{blue}{-b}}=x^{\textcolor{blue}{b}}$$ 4. Power of a Power $$\left(x^{\textcolor{red}{a}}\right)^{\textcolor{blue}{b}}=x^{{\textcolor{red}{a}}\textcolor{blue}{b}}$$ 5. Power of a Product $$(xy)^\textcolor{red}{a}=x^\textcolor{red}{a}y^\textcolor{red}{a}$$ 6. Power of a Quotient $$\left(\frac{x}{y}\right)^\textcolor{red}{a}=\frac{x^\textcolor{red}{a}}{y^\textcolor{red}{a}}\\ \left(\frac{x}{y}\right)^\textcolor{red}{-a}=\frac{y^\textcolor{red}{a}}{x^\textcolor{red}{a}}$$

I will write the proofs in order.

1) $$x^{\textcolor{red}{a}}*x^{\textcolor{blue}{b}}=\underbrace{\underbrace{x*x*x*...*x}*\underbrace{x*x*x..*x}\\ \hspace{7mm}\text{a times}\hspace{18mm}\text{b times}}\\ \hspace{40mm}\text{a+b times}\\$$, so $$x^{\textcolor{red}{a}}*x^{\textcolor{blue}{b}}=x^{{\textcolor{red}{a}}+{\textcolor{blue}{b}}}$$

2) $$\frac{x^{\textcolor{red}{a}}}{x^{\textcolor{blue}{b}}}=\frac{\underbrace{x*x*x*...*x}\\ \hspace{2mm}\text{a times}}{\underbrace{x*x*x*...*x}\\ \hspace{2mm}\text{b times}}$$. Here, the x in the numerator will cancel out the x in the denominator a-b times, so $$\frac{x^{\textcolor{red}{a}}}{x^{\textcolor{blue}{b}}}=x^{\textcolor{red}{a}-\textcolor{blue}{b}}$$

3a)

 $$\frac{x^{\textcolor{red}{a}}}{x^{\textcolor{blue}{b}}}=x^{\textcolor{red}{a}-\textcolor{blue}{b}}$$ This was established in the second proof. Set a=0 to get the case of x to the power of -b. $$\frac{x^0}{x^{\textcolor{blue}{b}}}=x^{0{\textcolor{blue}{-b}}}$$ x^0=1, except when x=0. $$\frac{1}{x^{\textcolor{blue}{b}}}=x^{{\textcolor{blue}{-b}}}$$

3b)

 $$\frac{1}{x^\textcolor{blue}{-b}}$$ As we established in the previous proof, we can replace x^(-b) with 1/[x^(-b)] $$\frac{1}{\frac{1}{x^\textcolor{blue}{b}}}*\frac{x^\textcolor{blue}{b}}{x^\textcolor{blue}{b}}$$ Now, simplify this complex fraction. Notice how the denominators cancel out here. $$x^\textcolor{blue}{b}$$

4) $$\left(x^{\textcolor{red}{a}}\right)^{\textcolor{blue}{b}}=\underbrace{x^{\textcolor{red}{a}}*x^{\textcolor{red}{a}}*x^{\textcolor{red}{a}}*...*x^{\textcolor{red}{a}}}= x^{\underbrace{{\textcolor{red}{a}}+{\textcolor{red}{a}}+{\textcolor{red}{a}}+...+{\textcolor{red}{a}}}}\\ \hspace{27mm}\text{b times}\hspace{23mm}\text{b times}$$

If there are b lots of a, this is equivalent to multiplication, so $$\left(x^{\textcolor{red}{a}}\right)^{\textcolor{blue}{b}}=x^{{\textcolor{red}{a}}\textcolor{blue}{b}}$$

5) $$(xy)^\textcolor{red}{a}=\underbrace{xy*xy*xy*...*xy}=\underbrace{(x*x*x*...*x)}*\underbrace{(y*y*y...*y)}=x^\textcolor{red}{a}y^\textcolor{red}{a}\\ \hspace{27mm}\text{a times}\hspace{27mm}\text{a times}\hspace{22mm}\text{a times}$$

If we multiply lots of x and y a times, then we can convert this back to an exponent.

6a) $$\left(\frac{x}{y}\right)^\textcolor{red}{a}=\underbrace{\frac{x}{y}*\frac{x}{y}*\frac{x}{y}*...*\frac{x}{y}} =\underbrace{(x*x*x*...*x)}*\underbrace{\left(\frac{1}{y}*\frac{1}{y}*\frac{1}{y}*...*\frac{1}{y}\right)} =\frac{x^\textcolor{red}{a}}{1}*\frac{1}{y^\textcolor{red}{a}}=\frac{x^\textcolor{red}{a}}{y^\textcolor{red}{a}}\\ \hspace{27mm}\text{a times}\hspace{22mm}\text{a times}\hspace{25mm}\text{a times}$$

6b)

 $$\left(\frac{x}{y}\right)^\textcolor{red}{-a}$$ Use the negative exponents rule that we already proved. $$\frac{1}{\left(\frac{x}{y}\right)^\textcolor{red}{a}}$$ Use the rule we used in 6a. $$\frac{1}{\frac{x^\textcolor{red}{a}}{y^\textcolor{red}{a}}}*\frac{\frac{y^\textcolor{red}{a}}{x^\textcolor{red}{a}}}{\frac{y^\textcolor{red}{a}}{x^\textcolor{red}{a}}}$$ Of course, we are only multiplying the fraction by one, which does not actually change the value at all. Now, a lot of canceling occurs in the denominator. $$\frac{y^\textcolor{red}{a}}{x^\textcolor{red}{a}}$$

Hopefully, these proofs will aide you in your math journey. Always question why something is and don't accept them as fact!

TheXSquaredFactor  Dec 21, 2017
#1
+2190
+3

Sure, I think I can give you a fairly simple proof for you. There are a few property of exponents that you have learned. I have listed all of them for you and what each says. To understand these proofs, you should understand that for whole numbers of a, $$x^a=\underbrace{x*x*x*...*x}\\ \quad\quad\quad\quad\text{a times}$$. This is the basis of the notation. The proofs are based on the notation. Sometimes, some rules will assume that a previous one was already proven.

 Property of Exponent Definition 1. Product of Powers $$x^{\textcolor{red}{a}}*x^{\textcolor{blue}{b}}=x^{\textcolor{red}{a}+\textcolor{blue}{b}}$$ 2. Quotient of Powers $$\frac{x^{\textcolor{red}{a}}}{x^{\textcolor{blue}{b}}}=x^{\textcolor{red}{a}-\textcolor{blue}{b}}$$ 3. Negative Exponents $$x^{\textcolor{blue}{-b}}=\frac{1}{x^\textcolor{blue}{b}}\\ \frac{1}{x^\textcolor{blue}{-b}}=x^{\textcolor{blue}{b}}$$ 4. Power of a Power $$\left(x^{\textcolor{red}{a}}\right)^{\textcolor{blue}{b}}=x^{{\textcolor{red}{a}}\textcolor{blue}{b}}$$ 5. Power of a Product $$(xy)^\textcolor{red}{a}=x^\textcolor{red}{a}y^\textcolor{red}{a}$$ 6. Power of a Quotient $$\left(\frac{x}{y}\right)^\textcolor{red}{a}=\frac{x^\textcolor{red}{a}}{y^\textcolor{red}{a}}\\ \left(\frac{x}{y}\right)^\textcolor{red}{-a}=\frac{y^\textcolor{red}{a}}{x^\textcolor{red}{a}}$$

I will write the proofs in order.

1) $$x^{\textcolor{red}{a}}*x^{\textcolor{blue}{b}}=\underbrace{\underbrace{x*x*x*...*x}*\underbrace{x*x*x..*x}\\ \hspace{7mm}\text{a times}\hspace{18mm}\text{b times}}\\ \hspace{40mm}\text{a+b times}\\$$, so $$x^{\textcolor{red}{a}}*x^{\textcolor{blue}{b}}=x^{{\textcolor{red}{a}}+{\textcolor{blue}{b}}}$$

2) $$\frac{x^{\textcolor{red}{a}}}{x^{\textcolor{blue}{b}}}=\frac{\underbrace{x*x*x*...*x}\\ \hspace{2mm}\text{a times}}{\underbrace{x*x*x*...*x}\\ \hspace{2mm}\text{b times}}$$. Here, the x in the numerator will cancel out the x in the denominator a-b times, so $$\frac{x^{\textcolor{red}{a}}}{x^{\textcolor{blue}{b}}}=x^{\textcolor{red}{a}-\textcolor{blue}{b}}$$

3a)

 $$\frac{x^{\textcolor{red}{a}}}{x^{\textcolor{blue}{b}}}=x^{\textcolor{red}{a}-\textcolor{blue}{b}}$$ This was established in the second proof. Set a=0 to get the case of x to the power of -b. $$\frac{x^0}{x^{\textcolor{blue}{b}}}=x^{0{\textcolor{blue}{-b}}}$$ x^0=1, except when x=0. $$\frac{1}{x^{\textcolor{blue}{b}}}=x^{{\textcolor{blue}{-b}}}$$

3b)

 $$\frac{1}{x^\textcolor{blue}{-b}}$$ As we established in the previous proof, we can replace x^(-b) with 1/[x^(-b)] $$\frac{1}{\frac{1}{x^\textcolor{blue}{b}}}*\frac{x^\textcolor{blue}{b}}{x^\textcolor{blue}{b}}$$ Now, simplify this complex fraction. Notice how the denominators cancel out here. $$x^\textcolor{blue}{b}$$

4) $$\left(x^{\textcolor{red}{a}}\right)^{\textcolor{blue}{b}}=\underbrace{x^{\textcolor{red}{a}}*x^{\textcolor{red}{a}}*x^{\textcolor{red}{a}}*...*x^{\textcolor{red}{a}}}= x^{\underbrace{{\textcolor{red}{a}}+{\textcolor{red}{a}}+{\textcolor{red}{a}}+...+{\textcolor{red}{a}}}}\\ \hspace{27mm}\text{b times}\hspace{23mm}\text{b times}$$

If there are b lots of a, this is equivalent to multiplication, so $$\left(x^{\textcolor{red}{a}}\right)^{\textcolor{blue}{b}}=x^{{\textcolor{red}{a}}\textcolor{blue}{b}}$$

5) $$(xy)^\textcolor{red}{a}=\underbrace{xy*xy*xy*...*xy}=\underbrace{(x*x*x*...*x)}*\underbrace{(y*y*y...*y)}=x^\textcolor{red}{a}y^\textcolor{red}{a}\\ \hspace{27mm}\text{a times}\hspace{27mm}\text{a times}\hspace{22mm}\text{a times}$$

If we multiply lots of x and y a times, then we can convert this back to an exponent.

6a) $$\left(\frac{x}{y}\right)^\textcolor{red}{a}=\underbrace{\frac{x}{y}*\frac{x}{y}*\frac{x}{y}*...*\frac{x}{y}} =\underbrace{(x*x*x*...*x)}*\underbrace{\left(\frac{1}{y}*\frac{1}{y}*\frac{1}{y}*...*\frac{1}{y}\right)} =\frac{x^\textcolor{red}{a}}{1}*\frac{1}{y^\textcolor{red}{a}}=\frac{x^\textcolor{red}{a}}{y^\textcolor{red}{a}}\\ \hspace{27mm}\text{a times}\hspace{22mm}\text{a times}\hspace{25mm}\text{a times}$$

6b)

 $$\left(\frac{x}{y}\right)^\textcolor{red}{-a}$$ Use the negative exponents rule that we already proved. $$\frac{1}{\left(\frac{x}{y}\right)^\textcolor{red}{a}}$$ Use the rule we used in 6a. $$\frac{1}{\frac{x^\textcolor{red}{a}}{y^\textcolor{red}{a}}}*\frac{\frac{y^\textcolor{red}{a}}{x^\textcolor{red}{a}}}{\frac{y^\textcolor{red}{a}}{x^\textcolor{red}{a}}}$$ Of course, we are only multiplying the fraction by one, which does not actually change the value at all. Now, a lot of canceling occurs in the denominator. $$\frac{y^\textcolor{red}{a}}{x^\textcolor{red}{a}}$$

Hopefully, these proofs will aide you in your math journey. Always question why something is and don't accept them as fact!

TheXSquaredFactor  Dec 21, 2017
#2
+3

X^2: You would make a great Math teacher if you aren't or weren't one already!!. Congrats on a very thorough job.

Guest Dec 21, 2017
#3
+2190
+1

Well, thank you!

TheXSquaredFactor  Dec 22, 2017


text:
# 루덴스코드 Blog

## USB 를 이용한 제어 실험 - 첫번째, 자료모음

[START]

USB 를 이용한 기본 실험환경를 만들어 본다.

PC 에서 USB 를 사용해 외부 소형 보드에 연결하고, 보드에 붙어있는 LED 를 켜고 끄는 작업을 진행한다.

[참고사이트]

1. FTDI 사이트
1. http://www.ftdichip.com/
2. USB 사용할 수 있는 칩제조사
3. Evaluation Board 자료가 있다.
4. FT245R, FT245BM 에 대한 자료
5. http://www.ftdichip.com/Drivers/VCP.htm
6. VCP (Virtual Com Port) Driver URL, D2XX Drivers URL,
2. DLP Design
1. http://www.dlpdesign.com/
2. Visual C++ 사용한 소스코드제공
3. http://www.dlpdesign.com/usb/usb245.shtml
3. M2CV (국내회사)
1. http://www.m2cv.co.kr/
2. FT245 USB Module
3. DLP Design 의 DLP-USB232M-G 과 동일
4. 디바이스마트
1. http://www.devicemart.co.kr/
2. FT245 로 검색하면 관련 칩과 모듈이 검색됨

결론 : (잠정적)

회로도와 부품들을 살펴보고 PCB를 제작, 직접 모듈을 제작할 수도 있으나 부품을 구하기가 번거롭고, 제작시 칩형 부품들의 납땜에 에러가 발생할 것이 우려되어 모듈을 직접 구입하여 동작시켜 보기로 한다.

USB 를 이용한 제어 실험 - 첫번째
http://electoy.tistory.com/132
JelicleLim(2008.10.10)

# Comment +0

## Ball & Beam Control - Digital PID

Ball and Beam problem using PID Control

In this digital control version of the ball and beam experiment, we are going to use the PID control method to design the digital controller. If you refer to the Ball and Beam Modeling page, the open-loop transfer function was derived as
.....m........mass of the ball...............0.11 kg
.....g........gravitational acceleration.....9.8 m/s^2
.....d........lever arm offset...............0.03 m
.....L........length of the beam.............1.0 m
.....J........ball's moment of inertia.......9.99e-6 kgm^2
.....R(s).....ball position coordinate (m)

The design criteria for this problem are:
• Settling time less than 3 seconds
• Overshoot less than 5%
Digital PID controller
If you refer to any of the PID control problem for continuous systems, the PID transfer function was expressed as
As you noticed the above transfer function was written in terms of s. For the digital PID control, we use the following transfer function in terms of z.
Discrete transfer function
The first thing to do here is to convert the above continuous system transfer function to discrete transfer function. To do this, we are going to use the Matlab function called c2dm. To use this c2dm, we need to specify four arguments: numerator and denominator matrices, sampling time (Ts), and the 'method'. You should already be familiar with how to enter numerator and denominator matrices. The sampling time should be smaller than 1/(30*BW) sec, where BW is the closed-loop bandwidth frequency. The method we will use is the zero-order hold ('zoh'). Assuming that the closed-loop bandwidth frequency is around 1 rad/sec, let the sampling time be 1/50 sec/sample. Now we are ready to use c2dm. Enter the following commands to an m-file.

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....Ts = 1/50;

.....[numDz,denDz]= c2dm (num,den,Ts,'zoh')

Running this m-file in the Matlab command window gives you the following matrices.

.....numDz =
..........1.0e-0.4 *
..........0    0.4200    0.4200

.....denDz =
..........1    -2    1

From these matrices, the discrete transfer function can be written as
Open-loop response
Now we will observe the ball's response to a step input of 0.25 m. To do this, enter the following commands to an new m-file and run it in the command window. You should see the following response.

.....numDz = 0.0001*[0.42 0.42];
.....denDz = [1 -2 1];

.....[x] = dstep(0.25*numDz,denDz,251);
.....t=0:0.02:5;
.....stairs(t,x)
From this plot, it is clear that the open-loop system is unstable causing the ball to roll off from the end of the beam.

Proportianal Control
Now we will add the proportional control (Kp) to the system and obtain the closed-loop system response. For now let Kp equal to 100 and see what happens to the response. Enter the following commands to an new m-file and run it in the command window.

.....numDz = 0.0001*[0.42 0.42];
.....denDz = [1 -2 1];

.....Kp=100;
.....[numDzC,denDzC]=cloop (Kp*numDz,denDz);

.....[x] = dstep(0.25*numDzC,denDzC,251);
.....t=0:0.02:5;
.....stairs(t,x)
As you can see, the addition of proportional control does not make the system stable. You may try to increase the proportional gain (Kp) and confirm that the system remains unstable.

Proportional-Derivative control
Now we will add a derivative term to the controller. Keep the proportional gain (Kp) equal to 100, and let the derivative gain (Kd) equal to 10. Copy the following code to an new m-file and run it to view the system response.

.....numDz = 0.0001*[0.42 0.42];
.....denDz = [1 -2 1];
.....Kp=100;
.....Kd=10;
.....numpd = [Kp+Kd -(Kp+2*Kd) Kd];
.....denpd = [1 1 0];
.....numDnew = conv(numDz,numpd);
.....denDnew = conv(denDz,denpd);
.....[numDnewC,denDnewC] = cloop(numDnew,denDnew);
.....[x] = dstep(0.25*numDnewC,denDnewC,251);
.....t=0:0.02:5;
.....stairs(t,x)
Now the system is stable, but the rise time is too long. From the PID Tutorial page, we see that the increasing the proportional gain (Kp) will decrease the rise time. Let's increase the proportional gain (Kp) to 1000 and see what happens. Change Kp in the above m-file from 100 to 1000 and rerun it in the command window. You should see the following step response.
As you can see, all of the design requirements are satisfied. For this particular problem, no implementation of an integral control was needed. But remember there is more than one solution for a control problem. For practice, you may try different P, I and D combinations to obtain a satisfactory response.

# Comment +0

## Ball & Beam Control - State space

Ball & Beam Problem Using the State-space Design Method

The state-space representation of the ball and beam example is given below:
Remember, unlike the previous examples where we controlled the gear's angle to control the beam and ball, here we are controlling alpha-doubledot. By doing this we are essentially controlling a torque applied at the center of the beam by a motor. Therefore, we do not need a gear and lever system.

The design criteria for this problem are:
• Settling time less than 3 seconds
• Overshoot less than 5%
To see the derivation of the state-space equations for this problem refer to the ball and beam modeling page.

If you are interested in running an animation of this example based on the control techniques used in the state-space tutorial please go to the Ball & Beam Animation Page after completing this tutorial.

Full-State Feedback Controller

We will design a controller for this physical system that utilizes full-state feedback control. A schematic of this type of system is shown below:
Recall, that the characteristic polynomial for this closed-loop system is the determinant of (sI-(A-BK)), where s is the Laplace variable. For our system the A and B*K matrices are both 4x4. Hence, there should be four poles for our system. In designing our full-state feedback controller we can move these poles anywhere we want.

For our design we desire an overshoot of less than 5% which corresponds to a zeta of 0.7 (please refer to your textbook for the relationship between overshoot and damping ratio). On a root locus this criterion is represented as a 45 degree line emanating from the origin and extending out into the left-half plane. We want to place our poles on or beneath this line. Our next criterion is a settling time less than 3 seconds, which corresponds to a sigma = 4.6/Ts = 4.6/3 = 1.53, represented by a vertical line at -1.53 on the root locus. Anything beyond this line in the left-half plane is a suitable place for our poles. Therefore we will place our poles at -2+2i and -2-2i. We will place the other poles far to the left for now, so that they will not affect the response too much. To start with place them at -20 and -80. Now that we have our poles we can use Matlab to find the controller (K matrix) by using the place command. Copy the following code to an m-file to model the system and find the K matrix:

NOTE: Matlab commands from the control system toolbox are highlighted in red.

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....J = 9.99e-6;

.....H = -m*g/(J/(R^2)+m);

.....A=[0 1 0 0
........0 0 H 0
........0 0 0 1
........0 0 0 0];
.....B=[0;0;0;1];
.....C=[1 0 0 0];
.....D=[0];

.....p1=-2+2i;
.....p2=-2-2i;
.....p3=-20;
.....p4=-80;

.....K=place(A,B,[p1,p2,p3,p4])

Run your m-file and you should get the following output for the K matrix:

.....place: ndigits= 15

.....K =
..........1.0e+03 *
..........1.8286    1.0286    2.0080    0.1040

After adding the K matrix, the state space equations now become:
We can now simulate the closed-loop response to a 0.25m step input by using the lsim command. Add the following to your m-file:

.....T = 0:0.01:5;
.....U = 0.25*ones(size(T));
.....[Y,X]=lsim(A-B*K,B,C,D,U,T);
.....plot(T,Y)

Run your m-file and you should get the following plot:
From this plot we see that there is a large steady state error for which we will need to add reference input (explained in next section). However, the overshoot and settling time criteria are met. If we wanted to reduce the overshoot further than we would make the imaginary part of the pole smaller than the real part. Also, if we wanted a faster settling time we would move the poles further in the left-half plane. Feel free to experiment with the pole positions to see these trends.

Reference Input
Now we want to get rid of the steady-state error. In contrast to the other design methods, where we feedback the output and compare it to the reference input to compute an error, with a full-state feedback controller we are feeding back both states. We need to compute what the steady-state value of the states should be, multiply that by the chosen gain K, and use a new value as our reference for computing the input. This can be done by adding a constant gain Nbar after the reference. The schematic below shows this relationship:
Nbar can be found using the user-defined function rscale (copy it to the directory that your m-file is in). Copy the following to your m-file and run it to view the step response with Nbar added.

.....Nbar=rscale(A,B,C,D,K)

.....T = 0:0.01:5;
.....U = 0.25*ones(size(T));
.....[Y,X]=lsim(A-B*K,B*Nbar,C,D,U,T);
.....plot(T,Y)

Note: Non-standard Matlab commands used in this example are highlighted in green.

.....place: ndigits= 15
.....Nbar =
..........1.8286e+03
Now the steady-state error is gone and all the design criteria are satisfied.

Note: A design problem does not necessarily have a unique answer. Using this method (or any other) may result in many different compensators. For practice you may want to go back and try to change the pole positions to see how the system responds.

# Comment +0

## Ball & Beam Control - Frequency Response

Ball & Beam Problem Using Frequency Response Method

The open-loop transfer function of the plant for the ball and beam experiment is given below:
The design criteria for this problem are:
• Settling time less than 3 seconds
• Overshoot less than 5%
To see the derivation of the equations for this problem refer to the ball and beam modeling page. A schematic of the closed loop system with a controller is given below:

Open-loop Bode Plot
The main idea of frequency based design is to use the Bode plot of the open-loop transfer function to estimate the closed-loop response. Adding a controller to the system changes the open-loop Bode plot, therefore changing the closed-loop response. Let's first draw the bode plot for the original open-loop transfer function. Create an m-file with the following code and then run it in the Matlab command window:

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....bode(num,den)

NOTE: Matlab commands from the control system toolbox are highlighted in red.

You should get the following Bode plot:
From this plot we see that the phase margin is zero. Since the phase margin is defined as the change in open-loop phase shift necessary to make a closed-loop system stable this means that our zero phase margin indicates our system is unstable. We want to increase the phase margin and we can use a lead compensator controller to do this. For more information on Phase and Gain margins please refer to the Frequency Response Tutorial.

A first order phase-lead compensator has the form given below:

The phase-lead compensator will add positive phase to our system over the frequency range 1/aT and 1/T, which are called the corner frequencies. The maximum added phase for one lead compensator is 90 degrees. For our controller design we need a percent overshoot of 5, which corresponds to a zeta of 0.7. Generally zeta * 100 will give you the minimum phase margin needed to obtain your desired overshoot. Therefore we require a phase margin greater than 70 degrees.

To obtain "T" and "a", the following steps can be used.

1. Determine the positive phase needed:

We need at least 70 degrees from our controller.

2. Determine the frequency where the phase should be added (center frequency):

In our case this is difficult to determine because the phase vs. frequency graph in the bode plot is a flat line. However, we have a relation between bandwidth frequency (wbw) and settling time (refer to the Bandwidth Frequency page for this equation) which tells us that wbw is approximately 1.92 rad/s. Therefore we want a center frequency just before this. For now we will choose 1.

3. Determine the constant "a" from the equation below, this determines the required space between the zero and the pole for the maximum phase added.
.....where phi refers to the desired phase margin. For 70 degrees, a = 0.0311.

4. Determine "T" and "aT" from the following equations:
..... For 70 degrees and center frequency (w) = 1, aT = 0.176 and T = 5.67

Now, we can add our lead controller to the system and view the bode plot. Remove the bode command from your m-file and add the following:

.....k=1;

.....bode(numl,denl)

You should get the following bode plot:

You can see that our phase margin is now 70 degrees. Let's check the closed-loop response to a step input of 0.25m. Add the following to your m-file:

.....[numcl,dencl] = cloop(numl,denl);
.....t=0:0.01:5;
.....step(0.25*numcl,dencl,t)

You should get the following plot:
Although the system is now stable and the overshoot is only slightly over 5%, the settling time is not satisfactory. Increasing the gain will increase the crossover frequency and make the response faster. Make k = 5, your response should look like:
The response is faster, however, the overshoot is much too high. Increasing the gain further will just make the overshoot worse.

We can increase our phase-lead compensator to decrease the overshoot. In order to make the iterative process easier use the following program. Create an m-file and copy the function from your web-browser into it (make sure the function command starts in the first column of the m-file).

.....function[ ] = phaseball()

.....%define TF
.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....pm = input('Phase Margin?.......');
.....w  = input('Center Frequency?...');
.....k  = input('Gain?...............');

.....%view compensated system bode plot
.....pmr = pm*pi/180;
.....a = (1 - sin(pmr))/(1+sin(pmr));
.....T = sqrt(a)/w;
.....aT = 1/(w*sqrt(a));

.....figure
.....bode(numl,denl)

.....%view step response
.....[numcl,dencl]=cloop(numl,denl);
.....t=0:0.01:5;
.....figure
.....step(0.25*numcl,dencl,t)

With this m-file you can choose the phase margin, center frequency, and gain. Run your m-file with the following values and you should see the plots below on your screen.

.....Phase Margin?.......80
.....Center Frequency?...1
.....Gain?...............1
The overshoot is fine but the settling time is just a bit long. Try different numbers and see what happens.

Using the following values the design criteria was met.

.....Phase Margin?.......85
.....Center Frequency?...1.9
.....Gain?...............2
Note: A design problem does not necessarily have a unique answer. Using this method (or any other) may result in many different compensators. For practice you may want to go back and change the added phase, gain, or center frequency.

# Comment +0

## Ball & Beam Control - Root Locus

Solution to the Ball & Beam Problem Using Root Locus Method

The open-loop transfer function of the plant for the ball and beam experiment is given below:

The design criteria for this problem are:
• Settling time less than 3 seconds
• Overshoot less than 5%

To see the derivation of the equations for this problem refer to the ball and beam modeling page. A schematic of the closed loop system with a controller is given below:

Open-loop Root Locus

The main idea of the root locus design is to estimate the closed-loop response from the open-loop root locus plot. By adding zeroes and/or poles to the original system (adding a compensator), the root locus and thus the closed-loop response will be modified. Let us first view the root locus for the plant in open loop. Create an m-file with the following Matlab code in order to model the plant and plot the root locus.

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....rlocus(num,den)

NOTE: Matlab commands from the control system toolbox are highlighted in red.

Now, run the m-file and you should see the following root locus plot:

As you can see the system has two poles at the origin which go off to infinity along the imaginary axes.

The design criteria can also be plotted onto the root locus using the sgrid command. This command generates a grid of constant damping ratio and natural frequency. The damping ratio and natural frequency were found using the following equation, which relates the them to our percent overshoot (PO) and settling time (Ts) requirements:

Note, that the equation with Ts is found by assuming settled is when the response remains within 2% of it's final value. From these equation damping ratio and natural frequency were found to be 0.7 and 1.9 respectively.

.....sgrid(0.70, 1.9)
.....axis([-5 5 -2 2])

The area between the two dotted diagnol lines represents locations where the percent overshoot is less than 5%. The area outside the curved line represents locations where the setttling time is less than 3 seconds. Note that no region of the plot falls within the design criteria shown be these lines. To remedy this and bring the root locus into the left-hand plane for stability we will try adding a lead-compensator to the system.

A first order lead compensator tends to shift the root locus into the left-hand plane. For a more detailed description of lead compensators refer to the Lead & Lag Compensator Design page. A lead compensator has the form given below:

where, the magnitude of zo is less than the magnitude of po.

Now, let us add the controller to the plant and view the root locus. We will position the zero near the origin to cancel out one of the poles. The pole of our compensator will be placed to the left of the origin to pull the root locus further into the left-hand plane. Add the following lines of Matlab code to your m-file.

.....zo = 0.01;
.....po = 5;

.....rlocus(numl,denl)
.....sgrid(0.70, 1.9)

Run your m-file in the Matlab command window and you should see the following:

Now, the branches of the root locus are within our design criteria.

Selecting a Gain
Now that we have moved the root locus into the left-hand plane, we may select a gain that will satisfy our design requirements. We can use the rlocfind command to help us do this. Add the following onto the end of your m-file.

.....[kc,poles]=rlocfind(numl,denl)

Go to the plot and select a point near those indicated by the cross mark on the plot below:

You should see in the Matlab command window something similar to the following (your numbers will be slightly different):

.....selected_point =
.....  -2.4988+ 1.2493i

.....kc =
.....   37.3131

.....poles =
.....  -2.4950+ 1.2493i
.....  -2.4950- 1.2493i
.....  -0.0101

Now, we can plot the response with this gain.

Plotting the Closed-loop Response
This value of kc can be put into the system and the closed-loop response to a step input of 0.25 m can be obtained. Add the following lines to your m-file to perform this analysis.

.....numl2 = kc*numl;
.....[numcl,dencl] = cloop(numl2,denl);
.....t=0:0.01:5;
.....figure
.....step(0.25*numcl,dencl,t)

Run your m-file and you select a point on the root locus similar to the selected point above. The step response should look like the following:

From this plot we see that when a 0.25m step input is given to the system both the settling time and percent overshoot design criteria are met.
Note: A design problem does not necessarily have a unique answer. Using this method (or any other) may result in many different compensators. Try running your m-file several more times selecting a different point each time and study the effect this has on the step response. For practice you may also want to go back to the original open-loop root locus and try to find other ways to add zeros and poles to get a better response.

# Comment +0

## Ball & Beam Control - PID

Solution to the Ball & Beam Problem Using PID Control

The open-loop transfer function of the plant for the ball and beam experiment is given below:

The design criteria for this problem are:
• Settling time less than 3 seconds
• Overshoot less than 5%

To see the derivation of the equations for this problem refer to the ball and beam modeling page.

Closed-loop Representation
The block diagram for this example with a controller and unity feedback of the ball's position is shown below:

First, we will study the response of the system shown above when a proportional controller is used. Then, derivative and/or integral control will be added if necessary.

Recall, that the transfer function for a PID controller is:

Proportional Control
The closed-loop transfer function for proportional control with a proportional gain (kp) equal to 100, can be modeled by copying the following lines of Matlab code into an m-file (or a '.m' file located in the same directory as Matlab)

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....kp = 1;
.....numP = kp*num;

.....[numc, denc] = cloop(numP, den)

NOTE: Matlab commands from the control system toolbox are highlighted in red.

You numerator and denominator should be:

.....numc =.....
.....         0         0    0.2100

.....denc =
.....    1.0000         0    0.2100

Now, we can model the system's response to a step input of 0.25 m. Add the following line of code to your m-file and run it:

.....step(0.25*numc,denc)

You should get the following output:

As, you can see the addition of proportional gain does not make the system stable. Try changing the value of kp and note that the system remains unstable.

Proportional-Derivative Control
Now, we will add a derivative term to the controller. Copy the following lines of code to an m-file and run it to view the system's response to this control method.

.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;

.....K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.....num = [-K];
.....den = [1 0 0];

.....kp = 10;
.....kd = 10;
.....numPD = [kd kp];

.....numh = conv(num, numPD);
.....[numc, denc] = cloop(numh, den);
.....t=0:0.01:5;
.....step(0.25*numc,denc,t)

Your plot should be similar to the following:

Now the system is stable but the overshoot is much too high and the settling time needs to go down a bit. From the PID tutorial page in the section on characteristics of P, I, and D controllers, we see that by increasing kd we can lower overshoot and decrease the settling time slightly. Therefore, make kd = 20 in your m-file and run it again. Your output should be:
The overshoot criterion is met but the settling time needs to come down a bit. To decrease the settling time we may try increasing the kp slightly to increase the rise time. The derivative gain (kd) can also be increased to take off some of the overshoot that increasing kp will cause. After playing with the gains a bit, the following step response plot can be achieved with kp = 15 and kd = 40:
As you can see from the above plot all the control objectives have been met without the use of an integral controller (settling time for this example is considered achieved when the response is less than 2% of it's final value). Remember, that for a control problem there is more than one solution for the problem.

# Comment +0

## Ball & Beam Control - Modeling

VIA[CTM]

Modeling the Ball and Beam Experiment

Problem Setup

A ball is placed on a beam, see figure below, where it is allowed to roll with 1 degree of freedom along the length of the beam. A lever arm is attached to the beam at one end and a servo gear at the other. As the servo gear turns by an angle theta, the lever changes the angle of the beam by alpha. When the angle is changed from the vertical position, gravity causes the ball to roll along the beam. A controller will be designed for this system so that the ball's position can be manipulated.

For this problem, we will assume that the ball rolls without slipping and friction between the beam and ball is negligible. The constants and variables for this example are defined as follows:

• M.........mass of the ball  0.11 kg
• R.........radius of the ball  0.015 m
• d.........lever arm offset  0.03 m
• g.........gravitational acceleration  9.8 m/s^2
• L.........length of the beam  1.0 m
• J.........ball's moment of inertia  9.99e-6 kgm^2
• r.........ball position coordinate
• alpha.....beam angle coordinate
• theta.....servo gear angle

The design criteria for this problem are:

• Settling time less than 3 seconds
• Overshoot less than 5%

System Equations

The Lagrangian equation of motion for the ball is given by the following:

Linearization of this equation about the beam angle, alpha = 0, gives us the following linear approximation of the system:
The equation which relates the beam angle to the angle of the gear can be approximated as linear by the equation below:

Substituting this into the previous equation, we get:

1. Transfer Function
Taking the Laplace transform of the equation above, the following equation is found:

NOTE: When taking the Laplace transform to find the transfer function initial conditions are assumed to be zero.

Rearranging we find the transfer function from the gear angle (theta(s)) to the ball position (R(s)).

It should be noted that the above plant transfer function is a double integrator. As such it is marginally stable and will provide a challenging control problem.

2. State-Space
The linearized system equations can also be represented in state-space form. This can be done by selecting the ball's position (r) and velocity (rdot) as the state variables and the gear angle (theta) as the input. The state-space representation is shown below:

However, for our state-space example we will be using a slightly different model. The same equation for the ball still applies but instead of controlling the position through the gear angle, theta, we will control alpha-doubledot. This is essentially controlling the torque of the beam. Below is the representation of this system:
Note: For this system the gear and lever arm would not be used, instead a motor at the center of the beam will apply torque to the beam, to control the ball's position.

Matlab Representation and Open-Loop Response

1. Transfer Function

The transfer function found from the Laplace transform can be implemented in Matlab by inputting the numerator and denominator as vectors. To do this we must create an m-file and copy the following text into it:

.......m = 0.111;
.......R = 0.015;
.......g = -9.8;
.......L = 1.0;
.......d = 0.03;
.......J = 9.99e-6;

.......K = (m*g*d)/(L*(J/R^2+m));   %simplifies input

.......num = [-K];
.......den = [1 0 0];
.......printsys(num,den)

.......num/den =   0.21 / ( s^2 )

Now, we would like to observe the ball's response to a step input of 0.25 m. To do this you will need to add the following line to your m-file:

.......step(0.25*num,den)

NOTE: Matlab commands from the control system toolbox are highlighted in red.

You should see the following plot showing the balls position as a function of time:

From this plot it is clear that the system is unstable in open-loop causing the ball to roll right off the end of the beam. Therefore, some method of controlling the ball's position in this system is required. Three examples of controller design are listed below for the transfer function problem. You may select from PID, Root Locus, and Frequency Response.

2. State-Space
The state-space equations can be represented in Matlab with the following commands (these equations are for the torque control model).

.......m = 0.111;
.......R = 0.015;
.......g = -9.8;
.......J = 9.99e-6;

.......H = -m*g/(J/(R^2)+m);

.......A=[0 1 0 0
.......   0 0 H 0
.......   0 0 0 1
.......   0 0 0 0];
.......B=[0;0;0;1];
.......C=[1 0 0 0];
.......D=[0];

The step response to a 0.25m desired position can be viewed by running the command below:

.......step(A,B*.25,C,D)

Your output should look like the following:

Like the plot for the transfer function this plot shows that the system is unstable and the ball will roll right off the end of the beam. Therefore, we will require some method of controlling the ball's position in this system. The State-Space example below shows how to implement a controller for this type of system.

# Comment +0

## 라플라스 역변환 풀이

기본적인 문제 중 하나다.
F(s)가 주어졌을때 어떻게 시간함수인 f(t)를 구할것인지에 대한 한 예제의 풀이과정이다.

개별근을 가질 경우는 풀이가 쉽다. 중근을 가질 경우 풀이가 어렵다기 보다는 한번 더 생각하면 된다. 보통 미분을 이용해서 풀이하지만 여기서는 문제의 특성상 간단한 대입으로 K1, K2, K3 를 구할 수 있다.

K1, K2, K3 를 구했으면 그것으로 F(s)를 위와 같은 모습으로 재구성하고 각각에 대해서 라플라스 역변환을 한다. 역변환의 기본 공식은 위의 공식을 참조하면 된다. 선형성을 가지므로 각각에 대한 라플라스 역변환을 거친 후 다시 더하면 최종적으로 구하고자 하는 값이 된다.

F(s) 의 라플라스 역변환 된 시간 함수 f(t)는 위와 같이 정해진다.

라플라스 역변환 풀이
http://electoy.tistory.com/108
JelicleLim(2008.7.19)

# Comment +2

• 감사합니다 2013.05.09 22:49 신고

참고하겠습니다!

• 감사합니다! 2018.04.18 11:25 신고

감사합니다너무ㅜㅜ

## 라플라스 변환에 관한 이해

라플라스변환은 시간영역에서 해를 구하기 어려운 미분방정식의 경우 보다 간단한 대수방정식으로 그 해를 구할 수 있게 해주는 특징을 가진다. 즉 복잡한 미분방정식의 해를 직접 구하기보다는 그 방정식을 라플라스 트랜스폼으로 변환시켜 주파수 영역에서 대수방정식으로 만들어 해를 구하고 그것의 역변환을 취해 최종적인 시간영역에서의 해를 구하게 된다.

함수 f(t)의 라플라스 변환은 모든 실수 t ≥ 0 에 대해, 다음과 같은 함수 F(s)로 정의된다.

F(s) = amath L { f } (s) = \int_{0^-}^\infty e^(-s*t) f(t) dt endamath

이때 amath  0^- 는 lim_{epsi->+0} -epsi endamath 의 약자이다. 실제 사용시에는 엄밀히 정확하지는 않은 다음의 표기를 사용하기도 한다.

F(s) = amath L { f(t) }  = \int_{0^-}^\infty e^(-s*t) f(t) dt endamath

보통은 Lapalece 변환의 정의를 다음과 같이 사용한다.

...L[f(t)] = F(s) = \int_0^\infty f(t) e^(-st) dt

...s = sigma + j omega

Laplace 역변환은 다음과 같이 사용한다.

...L^(-1) F(s) = f(t) = 1 / {j 2 pi } \int_{c-j omega}^\{c+j omega} F(s) e^(st) dt

시간함수 f(t)에 대한 라플라스변환 함수 F(S) 를 표로 나타낸 것은 다음과 같다.

이울러 f(t) 의 미분, 적분, t 와의 곱 등으로 변형된 형태의 라플라스 변환은 다음과 같다.

참고자료 : 제어시스템과 라플라스변환 공식

라플라스 변환에 관한 이해
http://electoy.tistory.com/101
JelicleLim(2008.7.12)

# Comment +0

## 제어 03 : 제어시스템과 라플라스변환 공식

기본적인 시스템의 모양은 위와 같다. 입력이 있고 그에 따른 출력이 있다.
입력을 r(t) 라고 하고 출력은 c(t)로 표현한다. 물론 위에서 출력부분에 되먹임(feedback)을 넣어서 다시 입력 부분으로 돌리는 것은 closed loop system 이라고 부른다. 일반적으로 위의 다이어그램은 신호처리(signal system)을 의미하고 feedback 이 들어간 시스템을 control system 이라고 부른다.

라플라스변환에 관한 기본 공식이다. 라플라스 변환은 일반 대수함수를 라플라스함수로 바꾸는 것을 말한다.

기본함수들에 대한 라플라스 변환식이다.
라플라스변환을 사용하는 이유는 식의 간편성때문이다. 일반 대수함수, 특히 미방의 경우 그 풀이가 상당히 어렵다. 반면에 라플라스로 변환된 식은 간단하고 명료하게 풀이 된다. 이런 점에서 라플라스변환은 제어쪽에서 주로 사용된다.
일반식을 라플라스변환으로 S 도메인 상의 공식으로 만들고 그것을 푼다. 풀이는 미방이 아닌 선형방정식이 된다. 그렇게 풀어진 최종값을 다시 역변환을 거쳐 최종식을 만들어낸다. 라플라스변환에 주로 사용되는 식은 위 테이블에 제공된다.

# Comment +0

## 홈페이지에서 수식사용하는 법

메이커활동/HW&SW2008.07.11 22:16
ASCIImathML.js 을 사용 tistory에서 수식을 사용 하는 방법이다.

1. ASCIImathML.js 파일을 다운 받는다. [LINK]

2. 다운받은 파일을 홈페이지나 블로그에 올린다. 티스토리의 경우 [admin]으로 들어가서 [스킨]->[직접올리기] 를 통해 파일을 올리면 된다. 그 경우 image/ 라는 폴더에 ASCIImathML.js 가 올라간다.

3. 스킨에서 html/css 를 직접 코드로 수정한다. skin.html 을 수정할 때 <body> 윗부분에 있는 <head> </head> 사이에 다음의 코드를 삽입한다.

<script type="text/javascript" src=" ./images/ASCIIMathML.js"></script>

이때 src="파일의 경로" 에서 ./images/ASCIIMathML.js 이 부분이 ASCIImathML.js 파일의 경로를 포함한 전체 이름이 된다.

4. 사용시 앞과 뒤에 amath endamath 를 넣으면 된다.
즉,
amath y = 1/2a x^2 + 1/3  endamath
위 수식은 이렇게 보여진다.
amath y = 1/2a x^2 + 1/3 endamath
더 자세한 수식표현법은 다음 사이트의 주소를 참고해서 보면 된다.

http://www1.chapman.edu/~jipsen/mathml/asciimath.html
http://www1.chapman.edu/~jipsen/mathml/asciimathsyntax.html

홈페이지에서 수식사용하는 법
http://electoy.tistory.com/99
JelicleLim(2008.7.11)

# Comment +0

## 제어 01 : 제어공학과 기본 다이어그램

제어에 관한 기본적인 다이어그램이다. 제어에서 필요한 것은 나온 결과를 다시 일정한 양만큼 입력으로 넣는 것이다. 이를테면 자동차의 제어를 위해서 출력(속도)를 측정하고, 그것을 다시 제어를 위한 입력으로 하는 것이다.

물론 위 그림에서 보듯이 입력과 그에 따른 수학적, 정량적 계산결과만이 있는 것이 아니라 외부 노이즈가 존재한다. 이를테면 동일한 가솔린을 사용하더라도 바람이 뒤에서 부는지 앞에서 부는지에 따라 차의 속도는 달라지는 것 따위다. 다양한 종류의 노이즈를 완벽히 계산할 수 없기 때문에 그것은 그냥 들어오는 것으로 처리한다. 결과값, 즉 RPM 을 측정하여 그것을 다시 입력으로 처리하는 것이다.

위 [Controller] 박스의 Gain 을 어떻게 처리하느냐에 따라서 위와 같은 결과 곡선이 만들어진다. Gain 을 크게 잡으로 반응은 매우 빠르게 나타난다. 즉시 결과값에 가까운 값으로 가고, 넘어가고, 다시 줄어드는 식으로 일정한 값을 찾아가게 된다. 반면 Gain 값을 작게 잡으면 서서히 증가하여 최종값이 수렴하는 식의 그래프가 그려진다.

제어에서 Gain 을 어떻게 잡는지가 제어기의 성능을 결정한다. 최종결과치에 가능한 짧은 시간에 도달하게 하는 것이 좋은 제어기이기도 하다. 동시에 특정한 제어기의 경우 Overshoot 을 허용하지 않기도 한다. 이를테면 벽면에 붙어 있는 스위치를 켜고 끄는 로봇팔 같은 경우 Overshoot 이 일어난다는 것은 로봇팔의 망가뜨릴수 있는 치명적인 결점이 된다.

제어 01 : 제어공학과 기본 다이어그램
http://electoy.tistory.com/97
JelicleLim(2008.7.11)


text:
# Is there another explanation than an asteroid/volcano for the extinction event on Earth millions of years ago?

This idea keeps on appearing in my mind, once in a million years the Sun's gravity will pull Earth near and eliminate every living in the earth due to the increased heat, and in another million years it pushes Earth far away and creates a frozen age due to lack of heat?

My Theory 1 I know that earth orbit around the sun is because of sun gravity, but gravity is randomly based on unknow mechanic, it might strong today, and might be weak after few years.

If I say that Ice age form is because the earth slowly move away from the sun million years ago(unexplainable weak sun gravity), lack of sunlight to the earth make earth cold, And now the ice at north pole is melting, it means that we might actually getting closer to the sun. And the event will keep on repeat each hundred million years, so we in the middle of extinction process, but that will take hundred million years to reach a level where the sun ray can destroy everything I know is kinda bluff without any proof, but this might be one of the possibility

-

## migrated from astronomy.stackexchange.comMay 8 at 12:18

This question came from our site for astronomers and astrophysicists.

A major problem with this premise: you say gravity is randomly based on an unknown premise. It is actually known to an amazing degree of accuracy. –  Rory Alsop May 6 at 6:58
gravity is randomly based on unknow mechanic is among the worse things ever you can say about science... –  Py-ser May 7 at 5:03
I have migrated this question from our Astronomy site. There has been some discussion in the Earth Science chat as to the difficulty of this question, but I have decided to go ahead and migrate it and let the Earth Science community round it out (or even eventually close it if need be), so that the community gets the opportunity to handle this type of question and decide what to do with it. –  called2voyage May 8 at 12:20
It sounds to me like the scenario being proposed is a bit like Jupiter's Grand Tack during the early-ish solar system. If considered helpful I can write up an answer about why that scenario isn't really relevant to recent Earth? –  kaberett May 8 at 12:52

Look at Earth's orbit around the Sun. The orbit is an ellipse, but Earth never gets close enough for the Sun to cause any mass extinction. The Earth orbits the Sun every year, and because the orbit is stable, on average we are about 8 light minutes from the Sun.

One way the Earth's orbit might change is if the Sun has a sister companion, that is, a binary star; thus far no evidence suggests the existence of another star in our solar system, but a binary star could alter the orbit of a planet. You could become an Astronomer and try to prove your hypothesis and it would not be a wasted journey.

I see you edited your question. Now you have included some aspects about gravity which contradict current knowledge of gravity. I highly recommend reading about gravity. To start you off I will share with you a known fact about gravity. The Earth exerts the same gravitational force on the Sun that the Sun exerts on the Earth. $$F_1=F_2 = G *m_1*m_2/r^2$$

That is, both these objects attract each other with the same amount of force. Moreover, gravity is related to an objects mass, so unless the Sun or the Earth lost mass there would be no change.

-
Nothing more than a footnote: "...unless the Sun or the Earth lost mass there would be no change [in the gravitational force between Earth and Sun]" — well, you could vary G or r. G is probably constant, but r does vary, e.g. in Milankovitch cycles, which certainly affect life on earth, and the orbital expansion @Keith_Thompson mentions. –  kwinkunks May 8 at 12:29

There have been numerous mass extinctions in Earth's history. The most famous one took place about 66 million years ago; see the linked article for others. Different events likely had different causes.

You suggest that the Sun's gravity periodically pulls the Earth closer, and then pushes it away. As far as I know, there is no evidence that this could have happened. The Sun's mass slowly diminishes over billions of years, due to direct loss of mass via solar wind and conversion of mass to energy; this should cause the Earth's orbit to expand very slowly. There is no known mechanism by which a change in the Sun's mass could draw the Earth closer and then "push" it away -- nor is there any need to postulate such a mechanism, since there are no observed phenomena that need it as an explanation.

Do you have some specific reason to think your idea is plausible?

-


text:
1072. Flip Columns For Maximum Number of Equal Rows

# 1072. Flip Columns For Maximum Number of Equal Rows

## 刷题内容

Given a matrix consisting of 0s and 1s, we may choose any number of columns in the matrix and flip every cell in that column.  Flipping a cell changes the value of that cell from 0 to 1 or from 1 to 0.

Return the maximum number of rows that have all values equal after some number of flips.

Example 1:

Input: [[0,1],[1,1]]
Output: 1
Explanation: After flipping no values, 1 row has all values equal.
Example 2:

Input: [[0,1],[1,0]]
Output: 2
Explanation: After flipping values in the first column, both rows have equal values.
Example 3:

Input: [[0,0,0],[0,0,1],[1,1,0]]
Output: 2
Explanation: After flipping values in the first two columns, the last two rows have equal values.

Note:

1 <= matrix.length <= 300
1 <= matrix[i].length <= 300
All matrix[i].length's are equal
matrix[i][j] is 0 or 1

*- 时间复杂度: O(m * n)- 空间复杂度: O(m)*

• 对于某一行，我们如果想让它那一行元素全部相等的话，我们要不全部变成1，要不全部变成0
• 对于任意两行，如果他们的某一列的cell相等，那么无论这列被翻转多少次，这两列都是一样的
• 对于任意两行，如果他们的某一列的cell不相等，那么无论这列被翻转多少次，这两列都不会一样

`python
class Solution:


text:
mersenneforum.org fond of a factor? Turn yourself in to become inane
 Register FAQ Search Today's Posts Mark Forums Read

2011-01-15, 16:33   #67
rajula

"Tapio Rajala"
Feb 2010
Finland

32×5×7 Posts

Quote:
 Originally Posted by drh M51443083 has a factor: 25320591696138535897675469195834877349466521
25320591696138535897675469195834877349466521 = 857285347808257713679 x 29535780310340488803799

Quote:
 I'm also assuming that this is composite since it is so large. I'm still very new at this, and learning. Can you tell me what you are doing, or using to tell if these numbers are composite or not?
One easy way is to use http://www.alpertron.com.ar/ECM.HTM.

2011-01-15, 23:39   #68
Mr. P-1

Jun 2003

7×167 Posts

Quote:
 Originally Posted by drh Can you tell me what you are doing, or using to tell if these numbers are composite or not?
A really neat trick is to use the P+1 method with the same bounds as the original P-1 test. This has a 50% chance per run of resolving the two factors, and will usually do so in a fraction of the processor time that other methods would take.

Code:
$echo "25320591696138535897675469195834877349466521" | ecm -c 0 -pp1 60000 GMP-ECM 6.2 [powered by GMP 4.2.2] [P+1] Input number is 25320591696138535897675469195834877349466521 (44 digits) Using B1=60000, B2=19419970, polynomial x^1, x0=2552205880 Step 1 took 88ms Step 2 took 96ms Run 2 out of 0: Using B1=60000, B2=19419970, polynomial x^1, x0=1936717407 Step 1 took 80ms [factor found by P-1] ********** Factor found in step 2: 857285347808257713679 Found probable prime factor of 21 digits: 857285347808257713679 Probable prime cofactor 29535780310340488803799 has 23 digits$
Not that other methods take much processor time, but I think this is a neat 'hack'.

 2011-01-16, 19:22 #69 drh     Jan 2011 Cincinnati, OH 22×52 Posts Just wanted to thank lorgix, Mr. P-1, and rajula for responding, and getting me started down the path of understanding, as I'm not a mathematician. I'm sure I'll have lots more questions. Doug
2011-01-16, 23:13   #70
Mr. P-1

Jun 2003

7×167 Posts

Quote:
 Originally Posted by drh Can you tell me what you are doing, or using to tell if these numbers are composite or not?
A simple heuristic is, if its size is more than double the TF limits, then it's almost certainly composite. P-1 (to the limits chosen by Prime95) rarely finds prime factors much more than about 100 bits, and rarely finds composite factors less than double the TF limits (since this would imply a missed TF-sized factor.)

The quickest way to prove these numbers composite would be a PrP test, which wouldn't tell us the prime factors. In practice, we don't bother, because we're interested in the prime factors anyway, and factoring them is so easy. Theoretically, if a large P-1 factor should resist factorisation for any length of time, we might begin to suspect it to be prime after all. To prove a number of that size prime, I'd use Pari/GP's isprime() function. There are several other tools capable of proving much larger numbers prime.

Last fiddled with by Mr. P-1 on 2011-01-16 at 23:13

 2011-01-17, 09:19 #71 lorgix     Sep 2010 Scandinavia 3×5×41 Posts Another find thanks to Suyama's extension; P-1 found a factor in stage #2, B1=85000, B2=1742500. M2294807 has a factor: 4743377217925125644071 k= 3^3*5*751*3851*2647063 --- You're welcome drh! I'm learning too, heck we all are. I usually use http://factordb.com/, that site stores the factor as well. But all the other suggestions are great too.
2011-01-17, 18:25   #72
Mr. P-1

Jun 2003

7×167 Posts

Quote:
 Originally Posted by lorgix Another find thanks to Suyama's extension;
E?

 2011-01-17, 18:31 #73 lorgix     Sep 2010 Scandinavia 3·5·41 Posts Actually the output doesn't say. But it always uses E=6 under similar (to the ones in question) circumstances.
 2011-01-17, 19:44 #74 drh     Jan 2011 Cincinnati, OH 6416 Posts From TF - M80307593 has a factor: 144625571114343550097
2011-01-17, 23:51   #75
Mr. P-1

Jun 2003

22218 Posts

Quote:
 Originally Posted by lorgix Actually the output doesn't say. But it always uses E=6 under similar (to the ones in question) circumstances.
That's curious. Normally it give the E value in the result.txt file, if it's higher than 2.

How many relative primes out of how many were you able to do per pass?

 2011-01-18, 08:07 #76 lorgix     Sep 2010 Scandinavia 26716 Posts All 480 in one pass. 498MB. I used to think the same. But it appears to me now that it doesn't do that if a factor is found. More recent find below, where Suyama's extension wasn't needed. Still used E=6, but doesn't show it here for some reason. P-1 found a factor in stage #2, B1=90000, B2=1755000. M2299571 has a factor: 103653914718894079697
 2011-01-18, 08:12 #77 lorgix     Sep 2010 Scandinavia 11478 Posts Close or what? P-1 found a factor in stage #2, B1=95000, B2=1947500. M2444359 has a factor: 1588994437060952149274017 k= 2^4*3*31*41*197*13901*1945487

 Similar Threads Thread Thread Starter Forum Replies Last Post ewmayer Programming 3 2016-09-30 07:15 jasong jasong 18 2013-11-15 22:54 Rafael Information & Answers 12 2012-01-02 19:38 rogue Lounge 10 2008-11-21 05:25 nngs Hardware 0 2005-05-20 01:31

All times are UTC. The time now is 13:24.

Sun Sep 20 13:24:56 UTC 2020 up 10 days, 10:35, 1 user, load averages: 1.76, 1.56, 1.48


text:
# Ex.14.3 Q2 Factorization - NCERT Maths Class 8

Go back to  'Ex.14.3'

## Question

Divide the given polynomial by the given monomial.

(i) \begin{align} \quad \left( {5{x^2} - 6x} \right) \div 3x\end{align}

(ii) \begin{align} \quad \left( {3{y^8} - 4{y^6} + 5{y^4}} \right) \div {y^4}\end{align}

(iii) \begin{align} \begin{Bmatrix} 8\left( {{x^3}{y^2}{z^2} + {x^2}{y^3}{z^2} + {x^2}{y^2}{z^3}} \right) \\ \div 4{x^2}{y^2}{z^2} \end{Bmatrix} \end{align}

(iv) \begin{align} \quad \left( {{x^3} + 2{x^2} + 3x} \right) \div 2x\end{align}

(v) \begin{align} \quad \left( {{p^3}{q^6} - {p^6}{q^3}} \right) \div {p^3}{q^3}\end{align}

## Text Solution

$${\rm{(i) }} \;\left( {5{x^2} - 6x} \right) \div 3x$$

What is known?

Algebraic expression.

What is unknown?

Division of the algebraic expression.

Reasoning:

Find out factor $$({5{x^2} - 6x})$$ and $$3{x}$$ then cancel out common factors of $$({5{x^2} - 6x})$$ and $$3{x}$$.

Steps:

$$5{x^2} - 6x$$ can be written as $$x(5x - 6)$$

Then,

\begin{align} \left( {5{x^2} - 6x} \right) \div 3x &= \frac{{x(5x - 6)}}{{3x}}\\&= \frac{1}{3}(5x - 6)\end{align}

$${\rm{(ii) }}\;( {3{y^8} - 4{y^6} + 5{y^4}}) \div {y^4}$$

What is known?

Algebraic expression.

What is unknown?

Division of the algebraic expression.

Reasoning:

Find out factor $$( {3{y^8} - 4{y^6} + 5{y^4}})$$ and $${y^4}$$ then cancel out common factors of $$( {3{y^8} - 4{y^6} + 5{y^4}})$$ and $${y^4}$$.

Steps:

$$3{y^8} - 4{y^6} + 5{y^4}$$ can be written as $${y^4}\left( {3{y^4} - 4{y^2} + 5} \right)$$

Then,

\begin{align} & \left( {3{y^8} - 4{y^6} + 5{y^4}} \right) \div {y^4} \\ & = \frac{{{y^4}\left( {3{y^4} - 4{y^2} + 5} \right)}}{{{y^4}}}\\&= 3{y^4} - 4{y^2} + 5\end{align}

(iii)

\ \begin{align} \begin{Bmatrix} 8\left( {{x^3}{y^2}{z^2} + {x^2}{y^3}{z^2} + {x^2}{y^2}{z^3}} \right) \\ \div 4{x^2}{y^2}{z^2} \end{Bmatrix} \end{align}

What is known?

Algebraic expression.

What is unknown?

Division of the algebraic expression.

Reasoning:

Find out factor $$8\left( {{x^3}{y^2}{z^2} + {x^2}{y^3}{z^2} + {x^2}{y^2}{z^3}} \right)$$ and $$4{x^2}{y^2}{z^2}$$ then cancel out common factors of $$8\left( {{x^3}{y^2}{z^2} + {x^2}{y^3}{z^2} + {x^2}{y^2}{z^3}} \right)$$ and $$4{x^2}{y^2}{z^2}$$.

Steps:

$$8\left( {{x^3}{y^2}{z^2} + {x^2}{y^3}{z^2} + {x^2}{y^2}{z^3}} \right)$$ can be written as $$8{x^2}{y^2}{z^2}(x + y + z)$$

Then,

\begin{align}& \begin{Bmatrix} 8\left( {{x^3}{y^2}{z^2} + {x^2}{y^3}{z^2} + {x^2}{y^2}{z^3}} \right) \\ \div 4{x^2}{y^2}{z^2}\end{Bmatrix} \\ \\ &= \frac{{8{x^2}{y^2}{z^2}(x + y + z)}}{{4{x^2}{y^2}{z^2}}}\\&= 2(x + y + z)\end{align}

$${\rm{(iv)}} \,({{x^3} + 2{x^2} + 3x}) \div 2x$$

What is known?

Algebraic expression.

What is unknown?

Division of the algebraic expression.

Reasoning:

Find out factor $$({{x^3} + 2{x^2} + 3x})$$ and $$2{x}$$ then cancel out common factors of $$({{x^3} + 2{x^2} + 3x})$$ and $$2{x}$$.

Steps:

$${x^3} + 2{x^2} + 3x$$ can be written as $$x\left( {{x^2} + 2x + 3} \right)$$

Then,

\begin{align} & \left( {{x^3} + 2{x^2} + 3x} \right) \div 2x\\ \\ &= \frac{{x\left( {{x^2} + 2x + 3} \right)}}{{2x}}\\&= \frac{1}{2}\left( {{x^2} + 2x + 3} \right)\end{align}

$$({\rm{v}})\;( {{p^3}{q^6} - {p^6}{q^3}}) \div {p^3}{q^3}$$

What is known?

Algebraic expression.

What is unknown?

Division of the algebraic expression.

Reasoning:

Find out factor $$({{p^3}{q^6} - {p^6}{q^3}})$$ and $${p^3}{q^3}$$ then cancel out common factors of $$( {{p^3}{q^6} - {p^6}{q^3}})$$ and $${p^3}{q^3}$$.

Steps:

$${p^3}{q^6} - {p^6}{q^3}$$ can be written as $${p^3}{q^3}\left( {{q^3} - {p^3}} \right)$$

Then,

\begin{align} & \left( {{p^3}{q^6} - {p^6}{q^3}} \right) \div {p^3}{q^3} \\ \\ &= \frac{{{p^3}{q^3}\left( {{q^3} - {p^3}} \right)}}{{{p^3}{q^3}}}\\&= {q^3} - {p^3}\end{align}

Learn from the best math teachers and top your exams

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


text:
# afw tests use the same name for a dummy file: test.fits

XMLWordPrintable

## Details

• Type: Story
• Status: Done
• Resolution: Done
• Fix Version/s: None
• Component/s:
• Labels:
• Story Points:
1
• Sprint:
Science Pipelines DM-W15-2
• Team:
Data Release Production

## Description

The afw package uses a file named: test.fits in multiple testers. If the user sets up the build to use multiple CPU (-j #), then there is the risk that the shared filename will be affected by more than one tester at a time.

In the case which provoked this Issue, the tester: testSimpleTable.py, reported that the file was missing. A simple rerun managed to get past the error.

I recommend that the different testers use uniquely named demo files.

## Activity

Hide
Robert Lupton added a comment -

git blame reveals that this is your doing. Could you fix it?

Show
Robert Lupton added a comment - git blame reveals that this is your doing. Could you fix it?
Hide
Robert Lupton added a comment -

I see that there's a similar problem in testWcsFitsTable.py that should be fixed at the same time. I didn't do an exhaustive audit, but there may be other cases too.

I also noticed that test.fits wasn't cleaned up if the tests failed. Is this deliberate? If so, there should probably be a comment or a note printed to stdout that tells the user that the file has been left behind for debugging.

Show
Robert Lupton added a comment - I see that there's a similar problem in testWcsFitsTable.py that should be fixed at the same time. I didn't do an exhaustive audit, but there may be other cases too. I also noticed that test.fits wasn't cleaned up if the tests failed. Is this deliberate? If so, there should probably be a comment or a note printed to stdout that tells the user that the file has been left behind for debugging.
Hide
Perry Gee added a comment -

This should be a simple review. Just some name changing to insure uniqueness. Not sure if you are setup yet to do a review, but I assume so, since you are on the list of reviewers.

The test framework (I am told) only runs an individual .py file in the test directory only once at any given time (never concurrently), so the name uniqueness just has to be good enough to not conflict with any other test. Since the files are generally stored beneath the package/tests directory (in this case afw/tests), only other tests in that directory have a potential to conflict.

Show
Perry Gee added a comment - This should be a simple review. Just some name changing to insure uniqueness. Not sure if you are setup yet to do a review, but I assume so, since you are on the list of reviewers. The test framework (I am told) only runs an individual .py file in the test directory only once at any given time (never concurrently), so the name uniqueness just has to be good enough to not conflict with any other test. Since the files are generally stored beneath the package/tests directory (in this case afw/tests), only other tests in that directory have a potential to conflict.
Hide
Jim Bosch added a comment -

Changes look fine to me; only comment would be that you should probably squash the two commits together using git rebase -i before merging, as there's no need for the second commit to be preserved in the history as separate from the first.

John Swinbank, the usual procedure for responding to a review would be to comment here, then transition the ticket to "Review Complete" when you're satisfied (either when the code is in all fixed, or when your comments were trivial enough that you don't feel you need to see it again after it's fixed). I'll let you do that here.

Show
Jim Bosch added a comment - Changes look fine to me; only comment would be that you should probably squash the two commits together using git rebase -i before merging, as there's no need for the second commit to be preserved in the history as separate from the first. John Swinbank , the usual procedure for responding to a review would be to comment here, then transition the ticket to "Review Complete" when you're satisfied (either when the code is in all fixed, or when your comments were trivial enough that you don't feel you need to see it again after it's fixed). I'll let you do that here.
Hide
John Swinbank added a comment - - edited

I agree with Jim that these commits should be squashed before merging.

What should the failure mode be if testDM384.fits already exists? Will catalog.writeFits() clobber it, or will the test fail? If the former, is that desired behaviour?

If the test fails for another reason, do you want to clean up testDM384.fits or leave it lying around for forensics?

I'm not sure if this is within the scope of this review, but: structurally, this looks more like three tests than one to me. That's ugly, and there's a lot of repeated code. You could consider restructuring things to avoid the repetition and make the cleanup automatic. Something like:

 class TestDM384(unittest.TestCase):  def setUp(self):  self.filename = "testDM384.fits"  self.schema = lsst.afw.table.Schema()  self.schema.setVersion(5)  self.schema.addField("f1", doc="f1a", type="I")  self.schema.addField("f2", doc="f2a", type="Flag")  self.schema.addField("f3", doc="f3a", type="ArrayF", size=4)    def tearDown(self):  os.unlink(self.filename)    def _run_test(self, catalog):  self.assertEqual(catalog.getTable().getVersion(), 5)  catalog.writeFits(self.filename)  # now read the table just written to disk, and see if it reads back correctly  catalog = catalog.readFits(self.filename)  metadata = catalog.getTable().getMetadata()  self.assertEqual(catalog.schema.getVersion(), 5)  self.assertFalse(metadata == None)  self.assertFalse(metadata.exists("AFW_TABLE_VERSION"))    def test_BaseCatalog(self):  self._run_test(BaseCatalog(self.schema))    def test_SimpleCatalog(self):  self._run_test(SimpleCatalog(self.schema))    def test_SourceCatalog(self):  self._run_test(SourceCatalog(self.schema))

(I've not actually tested the above, so it's probably riddled with typos etc, and I'm not sure if there's a substantive difference between lsst.afw.table.SimpleTable.makeMinimalSchema and lsst.afw.table.Schema, but you get the gist.)

This goes significantly beyond the immediate scope of this issue, though, so I don't think it has to be done before this is merged. (Indeed, I'm not even sure if I'm allowed to request it here, or if I should open a new issue...)

Show
Hide
Jim Bosch added a comment -

I think it's normally best to put requests for large changes that are beyond the scope of the original issue on a new issue (small change requests are fine). And it's also allowed for reviewees to take what they feel is a too-large change request and make a new issue instead of addressing it immediately. I'll leave it to Perry to decide whether to do your suggested cleanup here, or push it to a new issue, as I think it falls somewhere in the middle.

And since Perry might not know the answer off the top of his head, I can confirm that writeFits will clobber, and I do think that's the desired behavior. I personally like leaving the files around for forensics after a test failure, but I'm not certain that opinion is unanimous.

Show
Jim Bosch added a comment - I think it's normally best to put requests for large changes that are beyond the scope of the original issue on a new issue (small change requests are fine). And it's also allowed for reviewees to take what they feel is a too-large change request and make a new issue instead of addressing it immediately. I'll leave it to Perry to decide whether to do your suggested cleanup here, or push it to a new issue, as I think it falls somewhere in the middle. And since Perry might not know the answer off the top of his head, I can confirm that writeFits will clobber, and I do think that's the desired behavior. I personally like leaving the files around for forensics after a test failure, but I'm not certain that opinion is unanimous.
Hide
Perry Gee added a comment -

I queried Robin on whether finally statements should be included in tests which create files, and her response is that leaving the test files around on failure is desirable.

This isn't my test, and the only thing I did when I read it was to look for name with test.fits and remove them. However, I agree that using the same filename three times is a bad idea, even though it is actually OK to destroy each file once the test has passed. But the lack of unique names is confusing. So I will fix that, but not restructure the code.

If this is OK with you, please mark Review Complete so that it will come back to me.

Show
Perry Gee added a comment - I queried Robin on whether finally statements should be included in tests which create files, and her response is that leaving the test files around on failure is desirable. This isn't my test, and the only thing I did when I read it was to look for name with test.fits and remove them. However, I agree that using the same filename three times is a bad idea, even though it is actually OK to destroy each file once the test has passed. But the lack of unique names is confusing. So I will fix that, but not restructure the code. If this is OK with you, please mark Review Complete so that it will come back to me.
Hide
John Swinbank added a comment -

Ok; agreed that further restructuring is outside the narrow scope of this issue.

Show
John Swinbank added a comment - Ok; agreed that further restructuring is outside the narrow scope of this issue.

## People

• Assignee:
Perry Gee
Reporter:
Robyn Allsman [X] (Inactive)
Reviewers:
John Swinbank
Watchers:
Jim Bosch, John Swinbank, Perry Gee, Robert Lupton, Robyn Allsman [X] (Inactive)


text:
# On complements and substitutes with a CES function

Define the CES function $$q : \mathbb R_+^n \to [0,1]$$ by \begin{align} q(x) = \left[\frac{1}{n}\sum_{j=1}^n{x_j^\frac{\sigma-1}{\sigma}}\right]^\frac{\sigma}{\sigma-1} \end{align} where $$x \in \mathbb R_+^n$$ denote differentiated inputs, $$\sigma \in \mathbb R_{++} \setminus \{1\}$$ the constant elasticty of substitution among inputs and $$q(x)$$ a homogeneous output. Let $$t \in \mathbb R_{++}^n$$ denote the input prices. The input demand function solves \begin{align} x_i(t) &= \arg\max_{x_i}\{q(x)(1-q(x)) - t \cdot x\}\\ & = \frac{1}{2t_i^\sigma q(t^{-\sigma})}\left(1-\frac{n}{q(t^{-\sigma})^\frac{1}{\sigma}}\right) \end{align} where $$q(t^{-\sigma}) = q(t_1^{-\sigma},\ldots,t_n^{-\sigma})$$ is given by \begin{align} q(t^{-\sigma}) = \left[\frac{1}{n}\sum_{j=1}^n{(t_j^{-\sigma})^\frac{\sigma-1}{\sigma}}\right]^\frac{\sigma}{\sigma-1} = \left[\frac{1}{n}\sum_{j=1}^n{t_j^{1-\sigma}}\right]^\frac{\sigma}{\sigma-1} \tag{1} \end{align} The cross price derivative reads \begin{align} \frac{\partial x_i(t)}{\partial t_j} = \frac{1}{2t_i^\sigma}\left(-q(t^{-\sigma})^{-2}\frac{\partial q(t^{-\sigma})}{\partial t_j}+n\left(\frac{1}{\sigma}+1\right)q(t^{-\sigma})^{-\frac{1}{\sigma}-2}\frac{\partial q(t^{-\sigma})}{\partial t_j}\right) \tag{2} \end{align} where the partial derivative of $$(1)$$ is given by \begin{align} \frac{\partial q(t^{-\sigma})}{\partial t_j} = \frac{\sigma}{\sigma-1}\left[\frac{1}{n}\sum_{j=1}^n{t_j^{1-\sigma}}\right]^{\frac{\sigma}{\sigma-1}-1}\frac{1-\sigma}{n}t_j^{-\sigma} = -\frac{\sigma}{n}q(t^{-\sigma})^\frac{1}{\sigma}t_j^{-\sigma} \end{align} such that $$(2)$$ becomes \begin{align} \frac{\partial x_i(t)}{\partial t_j} = \frac{1}{2t_i^\sigma t_j^\sigma q(t^{-\sigma})^2}\left(\frac{\sigma}{n}q(t^{-\sigma})^\frac{1}{\sigma} - 1 -\sigma\right). \end{align}

In my application it turns out that the goods are complements for $$\sigma < 1$$, independent for $$\sigma \to 1$$ and substitutes for $$\sigma > 1$$. I cannot, however, verify this via the cross price derivative. I thus want to show \begin{align} \frac{\partial x_i(t)}{\partial t_j} \begin{cases} <0\quad \text{for }\sigma < 1\\ =0\quad \text{for }\sigma \to 1\\ >0\quad \text{for }\sigma > 1 \end{cases} \end{align} Does anyone has an idea how to approach the problem?

• Maybe I'm missing something super basic, but where is the demand coming from? $q(t)$ defines the production function, I believe, so it is weird for me that a parameter of the production function determines the cross-price elasticity. We would expect elasticities to be determined by demand parameters instead. Taking your demand as given, I agree with the derivation. The other thing I'm thinking is whether you know anything about the size of $q(t)$ in equilibrium? – Regio May 8 at 19:41
• If $x = (x_1,\ldots,x_n)$ are inputs and $q(x) = \left[\frac{1}{n}\sum_{i}x_i^\frac{\sigma-1}{\sigma}\right]^\frac{\sigma}{\sigma-1}$ is output, then $(x_1(t),\ldots,x_n(t)) = \arg\max_{x}\{q(x)(1-q(x)) - t \cdot x\}$, where $t$ are input prices. – clueless May 8 at 20:11
• So you do have extra assumptions that were not in the original problem. Would you mind stating it in its complete form for future reference? For example, I see that you are assuming that the demand is given by $p(x)=1-q(x)$. Therefore, the optimal quantity is bounded between 0 and 1: $q(x)\in(0,1)$. This observation is sufficient to sign the term in parenthesis: $\left(\frac{\sigma}{n}q(t)^{\frac1{\sigma}}-(1+\sigma)\right)$. – Regio May 8 at 21:23
• Okay, now the notation between the comments and the question is messed up. I edited the question to further clarify the issue. – clueless May 8 at 22:53
• Thanks for the update, now I see the complication. I think that the conditions on the cross-price elasticity assume that the solution is interior, which puts restrictions on the input prices. My guess is that when $\sigma<1$, then $q(t^{-\sigma})<1$ in order to have an interior solution, and thus you get the condition. I would also use the fact that an interior solution requires $q(x)\in(0,1)$ – Regio May 8 at 23:53