text:
# Does multiverse theory obviate the need for fine tuning?

I recently read the book by Max Tegmark, The mathematical Universe, where he expounds upon the multiverse and how if ANYTHING can happen, will happen, because of all the ways things can be arranged.

I came away confused because he also talked about fine tuning of the universe.

But if one believes in the multiverse, then there shouldn't be a need for fine tuning because if some thing can happen, it will. Meaning, there's a universe where the the orbit of the electron is X, and then there's a universe the orbit is X.1, and X.2, etc etc etc...

So eventually there will be a universe where the constants are set to what they are in ours, because if anything can happen, it will.

I am not a physicist, obviously, or scientist. Only a curious mind in need of clarification.

• multiverse theory or an infinite number of universes does not imply that anything that can happen will happen. similar to the statement I have an infinite set of integers does not imply that this set contains even numbers Feb 17 at 21:03
• Hi and welcome to physics SE! Could you please clarify what you mean by fine tuning and why it would be needed without a multiverse? Thanks! Feb 17 at 21:05
• "The" multiverse does not refer to one specific idea. In fact, Tegmark describes four distinct "levels" of multiverses, so you may want to clarify which conception of a multiverse you're talking about. Feb 17 at 21:31

• String theory has a vast number of possible solutions (more technical term is "vacua") - as many as $$10^{500}$$. For comparison the number of atoms in the observable universe is of the order $$10^{80}$$.
• It seems possible that all of these vacua correspond to their own universe. All the universes have their own laws of physics at low energies (at high energies they are all governed by string theory). Together, all these $$10^{500}$$ universes are called the "multiverse".
In other words, some (and only some) of the $$10^{500}$$ universes are going to have laws of physics conducive for life, and we are necessarily going to live in one of them. We then observe that the laws of physics are conducive for life, i.e. we observe fine tuning. So yes, the multiverse sort of obviates the need for fine tuning.


text:
# System of 2 equations in 4 unknowns

I have this system of 2 equations in 4 unknowns: $$\begin{cases} \displaystyle y_1=\pi_1 \frac{1}{1+e^{\alpha_1}}+\pi_2 \frac{1}{1+e^{\alpha_2}}+\pi_3 \frac{1}{1+e^{\alpha_3}}+\pi_4 \frac{1}{1+e^{\alpha_4}}\\ \displaystyle y_2=\pi_1 \frac{e^{\alpha_1}}{1+e^{\alpha_1}}+\pi_2 \frac{e^{\alpha_2}}{1+e^{\alpha_2}}+\pi_3 \frac{e^{\alpha_3}}{1+e^{\alpha_3}}+\pi_4 \frac{e^{\alpha_4}}{1+e^{\alpha_4}}\\ \end{cases}$$ The unknowns are $\alpha_1,\alpha_2,\alpha_3,\alpha_4$; all other terms are known.

I have never taken any course on solving systems of equations and my questions are very basics (apologies in advance): what can I say about the number of solutions? Are there infinite solutions and why? Is there any way to pin down a unique solution?

• Add the two equations to get $y_1+y_2=\pi_1+\pi_2+\pi_3+\pi_4$. If that is false, then the system has no solution. If that is true, then one of the equations are redundant, which means you only need to solve one of the equations. Sep 8 '16 at 14:37
• Thank you very much. It is true. Does it mean that I have 1 equation in 4 unknowns? Is there any way to pin down $\alpha_1,\alpha_2,\alpha_3,\alpha_4$? Or, at least, can I say that there are infinite solutions?
– TEX
Sep 8 '16 at 14:43
• No you cannot. With four unknowns there must be infinite solutions. However if these unknowns are restricted, then things might be different. Sep 9 '16 at 1:41

Adding together the two equations and collecting terms gives $$y_1+y_2=\sum_{i=1}^4\frac{\pi_i}{1+e^{\alpha_i}}(1+e^{\alpha_i})=\sum_{i=1}^4{\pi_i}.$$

format: plain


text:
# Why is the softmax used to represent a probability distribution?

In the machine learning literature, to represent a probability distribution, the softmax function is often used. Is there a reason for this? Why isn't another function used?

From an optimization perspective it has some nice properties in terms of differentiability. For a lot of machine learning problems it's a good fit for 1-of-N classification.

From a deep learning perspective: One could also argue that in theory, using a deep network with a softmax classifier on top can represent any N-class probability function over the feature space as MLPs have the Universal Approximation property.

• So the main reason for popularity of Softmax is it's nice differentiation properties which are helpful in Gradient Based learning setting. That's it, right? Jan 6, 2016 at 18:42
• Yeap, in my opinion anyway. Softmax is a simple with nice derivatives and is attractive for gradient based learning. Agree with everything you said. Jan 6, 2016 at 18:46
• You can think softmax as probability mass/density function of the function you are going to optimize. In my opinion, softmax is just a convenience way to model a probability mass/density function. Dec 22, 2018 at 21:55

Softmax is also a generalization of the logistic sigmoid function and therefore it carries the properties of the sigmoid such as ease of differentiation and being in the range 0-1. The output of a logistic sigmoid function is also between 0 and 1 and therefore naturally a suitable choice for representing probability. Its derivative is also exoressed in terms of its own output. However, if your function has a vector output you need to use the Softmax function to get the probability distribution over the output vector. There are some other advantages of using Softmax which Indie AI has mentioned, although it does not necessarily has anything to do with the Universal Approximation theory since Softmax is not a function only used for Neural Networks.

References

See section 4.2 of Bishop's Pattern Recognition and Machine Learning on probabilistic generative models. He shows on page 197 that in the two-class case, given classes $$\mathcal{C}_1, \mathcal{C}_2$$, that $$p(\mathcal{C}_1 \mid \mathbf{x})$$, the posterior for class $$\mathcal{C}_1$$ (i.e. conditional on input example $$\mathbf{x} \in \mathbb{R}^d$$), is such that (by Bayes' rule)

$$p(\mathcal{C}_1 \mid \mathbf{x}) = \frac{p(\mathbf{x} \mid \mathcal{C}_1)p(\mathcal{C}_1)}{p(\mathbf{x} \mid \mathcal{C}_1)p(\mathcal{C}_1) + p(\mathbf{x} \mid \mathcal{C}_2)p(\mathcal{C}_2)} = \frac{1}{1 + e^{-a(\mathbf{x})}} = \sigma \circ a(\mathbf{x})$$

Here $$\sigma : \mathbb{R} \rightarrow (0, 1)$$ is the sigmoid function and $$a : \mathbb{R}^d \rightarrow \mathbb{R}$$ is such that

$$a(\mathbf{x}) \triangleq \log\frac{p(\mathbf{x} \mid\mathcal{C}_1)p(\mathcal{C}_1)}{p(\mathbf{x} \mid \mathcal{C}_2)p(\mathcal{C}_2)} = \log\frac{p(\mathcal{C_1}, \mathbf{x})}{p(\mathcal{C}_2, \mathbf{x})}$$

In the multiclass case, i.e. with classes $$\mathcal{C}_1, \ldots \mathcal{C}_K$$, we naturally have for $$k \in \{1, \ldots K\}$$,

$$p(\mathcal{C}_k \mid \mathbf{x}) = \frac{p(\mathbf{x} \mid \mathcal{C}_k)p(\mathcal{C}_k)}{\sum_{j = 1}^Kp(\mathbf{x} \mid \mathcal{C}_k)p(\mathcal{C}_j)} = \frac{e^{a_k(\mathbf{x})}}{\sum_{j = 1}^Ke^{a_j(\mathbf{x})}}$$

Here for $$k \in \{1, \ldots K\}$$, $$a_k : \mathbb{R}^d \rightarrow \mathbb{R}$$ is such that

$$a_k(\mathbf{x}) \triangleq \log\left(p(\mathbf{x} \mid \mathcal{C}_k)p(\mathcal{C}_k)\right) = \log p(\mathcal{C}_k, \mathbf{x})$$

The $$a, a_k$$ functions can be given parametric forms--for example, in multiclass logistic regression, $$a_k(\mathbf{x}) \triangleq \mathbf{w}_k^\top\mathbf{x} + b_k$$ for $$\mathbf{w}_k \in \mathbb{R}^d, b_k \in \mathbb{R}$$. In fact, page 203 states that for class conditional distributions, i.e. $$X \mid \mathcal{C}_k$$, that are members of the exponential family of distributions, the $$a_k$$ functions are affine functions of $$\mathbf{x}$$. An example is linear discriminant analysis, which assumes Gaussian class-conditional distributions with a shared covariance matrix, as equation (4.68) on page 199 shows that the $$a_k$$ function is affine.

The softmax function itself, probabilistic interpretations aside, is a smooth, differentiable approximation to the max function, which of course the other answers have mentioned is helpful when using gradient-based methods to minimize an objective function. For example, the binary (multiclass) logistic regression objective is convex and differentiable, with the differentiability partly because of its inclusion of the sigmoid (softmax) function.

The softmax function has a number of desirable properties for optimisation and other mathematical methods dealing with probability vectors. Its most important property is that it gives a mapping that allows you to represent any probability vector as a point in unconstrained Euclidean space, but it does this in a way that has some nice smoothness properties and other properties that are useful in various types of problems.

Given any scale parameter $$\lambda>0$$ the probability vector $$\mathbf{p} = (p_0,p_1,...,p_n)$$ can be mapped to or from a point $$\boldsymbol{\eta} \in \mathbb{R}^n$$ using the softmax function and inverse-softmax function:

\begin{align} \text{soft}(\boldsymbol{\eta}) &= \Bigg( \frac{1}{1 + \sum_{i=1}^n \exp(\lambda \eta_i)}, \frac{\exp(\lambda \eta_1)}{1 + \sum_{i=1}^n \exp(\lambda \eta_i)}, ..., \frac{\exp(\lambda \eta_n)}{1 + \sum_{i=1}^n \exp(\lambda \eta_i)} \Bigg), \\[12pt] \text{invsoft}(\mathbf{p}) &= \Bigg( \frac{\log(p_1) - \log(p_0)}{\lambda}, ..., \frac{\log(p_n) - \log(p_0)}{\lambda} \Bigg). \\[12pt] \end{align}

This mapping is sufficient for all probability vectors with non-zero elements, which also gets you arbitrarily close to any probability vector with one or more zero elements. The mapping has several useful properties:

• The domain of the softmax function is unconstrained Euclidean space, which makes it useful in optimisation problems that have a probability vector as an input. Specifically, if you have an objective function $$H$$ that maps an input probability vector to a real number, you can form the function composition $$G = H \circ s : \mathbb{R}^n \rightarrow \mathbb{R}$$ to convert the problem to an unconstrained optimisation.

• The softmax function is an analytic function (i.e., it is infinitely differentiable and has a convergent Taylor series) which means it is nice and smooth and can be represented closely by a polynomial in a neighbourhood of any point.

• The first two derivatives of the softmax function and inverse-softmax function have simple forms and can be computed explicitly. This is also useful for optimisation problems and other mathematical problems involving probability vectors.

Of course, it is possible to form other mappings from unconstrained Euclidean space to the space of probability vectors, and other forms might also be similarly useful for some purposes. The softmax function is a form that has simple derivatives and so it is useful in a range of optimisation problems and other mathematical methods involving probability vectors.


text:
Share

# F(X) = | Sin 4x+3 | on R - Mathematics

#### Question

f(x) = | sin 4x+3 | on R ?

#### Solution

Given: f(x) = $\left| \sin 4x + 3 \right|$

We know that −1 $\leq$ sin 4x $\leq$1.

⇒ 2 $\leq$ sin 4x + 3 $\leq$4

⇒ 2 $\leq$ $\left| \sin 4x + 3 \right|$ $\leq$ 4
⇒ 2 $\leq$ f(x) $\leq$ 4

Hence, the maximum and minimum values of f are 4 and 2, respectively.

Is there an error in this question or solution?


text:
#### 11th Standard Physics Kinematics English Medium Free Online Test One Mark Questions with Answer Key 2020 - 2021

11th Standard

Reg.No. :
•
•
•
•
•
•

Physics

Time : 00:20:00 Hrs
Total Marks : 20

20 x 1 = 20
1. Identify the unit vector in the following

(a)

$\hat { i } +\hat { j }$

(b)

$\frac { \hat { i } }{ \sqrt { 2 } }$

(c)

$\hat { k } -\frac { \hat { j } }{ \sqrt { 2 } }$

(d)

$\frac { \hat { i } +\hat { j } }{ \sqrt { 2 } }$

2. If the velocity is $\overrightarrow { v } =2\hat { i } +{ t }^{ 2 }\hat { j } -9\overrightarrow { k }$ then the magnitude of acceleration at t=0.5 s is

(a)

1 ms-2

(b)

2 ms-2

(c)

zero

(d)

-1 ms-2

3. A ball is projected vertically upwards with a velocity v. It comes back to ground in time t. Which v-t graph shows the motion correctly?

(a)

(b)

(c)

(d)

4. A ball is dropped from some height towards the ground. Which one of the following represents the correct motion of the ball?

(a)

(b)

(c)

(d)

5. Two objects are projected at angles 30° and 60° respectively with respect to the horizontal direction. The range of two objects are denoted as R30° and R60° Choose the correct relation from the following.

(a)

R30° =R6

(b)

R30° =4R6

(c)

R30° =$\frac{R_{60°}}{2}$

(d)

R30° =2R6

6. The angle between A i +j and B = i - j is

(a)

45°

(b)

90°

(c)

-45°

(d)

180°

7. Consider the quantities pressure, power, energy, impulse, charge. Out of these, the only vector quantity is

(a)

pressure

(b)

power

(c)

impulse

(d)

charge

8. Distance is a scalar quantity and ______________ is a vector.

(a)

Speed

(b)

Length

(c)

Time

(d)

Displacement

9. Choose the motion in two dimension from the following.

(a)

Motion of a train along a straight railway track

(b)

An object falling freely under gravity close to the Earth.

(c)

A particle moving along a curved path in a plane.

(d)

Flying ofa kite on a windy day.

10. The displacement of particle is given by X = a$\frac{a_1t}{2}-\frac{2_2t^2}{3}$ What is its acceleration?

(a)

$\frac{2a_2}{3}$

(b)

$-\frac{2a_2}{3}$

(c)

a2

(d)

zero

11. A man should hold his umbrella with vertical, when rain falls vertically with velocity $\vec { { V }_{ R } }$ and man walks horizontally with velocity $\vec{{V}_{M}}$ is:

(a)

$tan^{-1}(\frac{\vec{V}_{M}}{\vec{V}_{R}})$

(b)

$tan^{-1}(\frac{\vec{V}_{R}}{\vec{V}_{M}})$

(c)

tan-1(VR)

(d)

tan-1(VM)

12. The maximum range of a gun of horizontal terrain is 16 km. If g = 10 ms2, then muzzle velocity of a shell must be:

(a)

160 ms-1

(b)

200 $\sqrt{2}$ ms-1

(c)

400 ms-1

(d)

800 ms-1

13. The path of the projectile, projected horizontally is:

(a)

hyperbola

(b)

parabola

(c)

straight line

(d)

circle

14. A person performing a somersault is an example of__________motion.

(a)

circular

(b)

vibratory

(c)

linear

(d)

rotational

15. Resultant of the 2 vector is maximum when angle between them is:

(a)

90°

(b)

180°

(c)

(d)

270°

16. The dot product of two vectors is:

(a)

commutative

(b)

associative

(c)

unit-commutative

(d)

none of the three

17. If for two vectors $\bar A,\bar B$ $\bar A\times\bar B=0$ then the vectors are:

(a)

perpendicular to each other

(b)

parallel to each other

(c)

act at an angle 60°

(d)

act at an angle 30°

18. Two vectors $\bar A$ and $\bar B$ are such that $\bar A \times\bar B=\bar C$ and A = B = C then angle between  $\bar A$ and $\bar B$ is:

(a)

120°

(b)

90°

(c)

60°

(d)

30°

19. The expression for time of flight of a projectile is tf = :

(a)

$\frac{\sin\theta}{g}$

(b)

$\frac{u\sin\theta}{g}$

(c)

$\frac{u\sin\theta}{2g}$

(d)

$\frac{2u\sin\theta}{2g}$

20. During a projectile motion if the maximum height equals the horizontal range, then the angle of projection with the horizontal is:

(a)

tan-1(1)

(b)

tan-1(2)

(c)

tan-1(3)

(d)

tan-1(4)


text:
+0

# An inequality problem

+1
146
2

Find the set of all z such that neither 2+z nor 2-z is in the interval (-1,1]. Express your answer as an interval or as a union of intervals.

Jul 21, 2019

#1
+8733
+2

Find the set of all z such that neither 2+z nor 2-z is in the interval (-1,1]. Express your answer as an interval or as a union of intervals.

z \in \{z|\  (-1) < z < 1 \}

!

LaTeX does not work.

Jul 21, 2019
edited by asinus  Jul 21, 2019
edited by asinus  Jul 21, 2019
edited by asinus  Jul 21, 2019
edited by asinus  Jul 21, 2019
#2
+8733
+2

$$z \in \{z|\ (-1) < z < 1 \}$$

!

Jul 21, 2019
edited by asinus  Jul 21, 2019


text:
# atari 800xl

I finally got around to working on the atari 800xl that I mentioned back in October.

This machine has been a nightmare.

To start, it would power up to a slightly reddish black screen. I couldn’t find any good info online about this particular ailment, so I decided to just start swapping chips between the atari 800xl and the 600xl that I have.

I’m not sure if the 600xl is in working order. I don’t have anything with an RF input that I can test the 600xl with, but luckily all of the chips in the 600xl were socketed. Unfortunately, that was not the case with the 800xl.

I swapped the few chips that were socketed, like the ANTIC, GTIA, Sally, and Pokey, but no luck.

At this point, I figured that the ram was a likely problem, so I desoldered all of the ram and installed sockets and new ram chips.

This board had a weird extra resistor bodged in for each ram chip. You can see the broken trace on the bottom of the board in the image below followed by the resistor on the top of the board.

I left it as is when I installed the sockets, but later on, I bridged the resistor with a jumper wire.

New ram didn’t fix it, so I desoldered all of the rest of the chips on the board and installed sockets. I then swapped each chip individually and tested.

At some point during the testing, I went from a black screen to a screen with stripes, and full white screen, and variations between.

The screen changed every few times that I powered it up, but there were no other signs of life.

I had no real way of testing the chips in either machine, but I was going under the assumption that some combination between the two machines should work, but it seemed that everything that I tried left me with the same result.

I was running out of ideas, so I just started replacing other active components like the transistors, common logic chips, etc. I touched up all of the suspicious looking solder joints, and tested continuity on all of the buses.

Still nothing.

At some point, I started thinking that there may be an issue with the rom chips. I pulled each one from both machines and dumped the roms and bingo. The basic roms looked okay, but both OS roms seemed to be bad.

Or did they…

I guess an easy way to check is to just replace it with a known working rom, but I didn’t have a pin compatible rom chip. I did have an AT28C256 that was close.

Atari Stock OS Rom

AT28C256

I wrote an OS rom binary to the AT28C256 and I bent pins 1 and 27 up 90 degrees. I bridged pin 27 and 28 together to keep WE high and I soldered a jumper wire from pin 1 (A14) and connected it to the socket’s pin 27.

I installed my makeshift rom and powered up.

Voila! It worked!

At this point, I was tired of this machine, so I quickly re-assembled it for a final test.

Still good. It still has a few sticky keys on the keyboard and could use some new capacitors, but for now, I’m going to put this one aside and work on some of my other recent aquisitions.


text:
# Exam P Practice Problem 64 – Median Claim Size

Problem 64-A

The following is the density function of the claim size $X$ of an insurance policy from a block of property and casualty insurance policies:

$\displaystyle f(x)=\frac{1}{2} \biggl( 0.4 \ e^{-0.4 x} \biggr) + \frac{1}{2} \biggl( 0.2 \ e^{-0.2 x} \biggr) \ \ \ \ \ \ \ 0

Calculate the median claim size $X$.

$\displaystyle (A) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0.618$

$\displaystyle (B) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 1.739$

$\displaystyle (C) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2.406$

$\displaystyle (D) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2.599$

$\displaystyle (E) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 3.533$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

Problem 64-B

The following is the density function of the claim size $X$ of an insurance policy from a block of auto insurance policies:

$\displaystyle f(x)=\frac{3}{4} \biggl( \frac{1}{8} \ x \biggr) + \frac{1}{4} \biggl( \frac{1}{64} \ x^3 \biggr) \ \ \ \ \ \ \ 0

Calculate the median claim size $X$.

$\displaystyle (A) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2.2216$

$\displaystyle (B) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2.4972$

$\displaystyle (C) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2.8653$

$\displaystyle (D) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2.9622$

$\displaystyle (E) \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2.9975$

______________________________________________________________________

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

$\text{ }$

______________________________________________________________________

$\copyright \ 2013$


text:
Search Result

Search Conditions

Years
All Years
for journal 'PTP'
author 'K.* Kasahara' : 4
total : 4

Search Results : 4 articles were found.

1. Progress of Theoretical Physics Vol. 39 No. 6 (1968) pp. 1487-1500 :
New Method of High Energy Jet Shower Analysis
Shun-ichi Hasegawa, Katsuaki Kasahara and Tōru Shibata
2. Progress of Theoretical Physics Vol. 55 No. 6 (1976) pp. 1896-1911 : (5)
Can We Understand High Energy Cosmic-Ray Spectra on the Basis of the Scaling Hypothesis?
Katsuaki Kasahara and Yoshiyuki Takahashi
3. Progress of Theoretical Physics Vol. 79 No. 2 (1988) pp. 416-428 : (3)
Energy Spectrum of Ultra High Energy $\gamma$-Rays from Supernova
Yoshiyuki Yamada, Takashi Nakamura, Katsuaki Kasahara and Humitaka Sato
4. Progress of Theoretical Physics Vol. 81 No. 1 (1989) pp. 93-103 : (3)
X-Ray and $\gamma$-Rays from a Non-Spherical Patchy Supernova Ejecta
Yoshiyuki Yamada, Katsuaki Kasahara and Takashi Nakamura


text:
# Regression problem with “error in variables”

Suppose that there is a deterministic relation $$y_t=ax_t$$ where $$x_t,y_t$$ are real sequences or real functions and $$a$$ a constant. But only $$X_t=x_t+e_t$$ and $$Y_t+u_t$$ can be observed, with $$e_t, u_t$$ being zero mean i.i.d. random variables.

How can I estimate the parameter $$a$$ using $$X_t$$ and $$Y_t$$?

I looks simple, but when setting a linear regression model: $$Y_t=\beta X_t+v_t$$ the error is given by $$v_t=y_t-\beta x_t+u_t-\beta e_t$$. It doesn't look good for a least squares problem and may cause inconsistency. What is the simplest approach to obtain reasonable estimates for $$a$$?

• Why is $e_t$ divided by $a$? You already have to estimate the variance $e_t$, so including the additional constant $a$ overspecifies it. Am I misunderstanding? – Ryan Volpi Jul 4 '20 at 17:02
• You are right. It is not needed and simplifies the problem. – Celine Harumi Jul 4 '20 at 17:06


text:
Hackerrank - String Construction Solution

# Hackerrank - String Construction Solution

Amanda has a string of lowercase letters that she wants to copy to a new string. She can perform the following operations with the given costs. She can perform them any number of times to construct a new string :

• Append a character to the end of string  at a cost of  dollar.
• Choose any substring of  and append it to the end of  at no charge.

Given  strings , find and print the minimum cost of copying each  to  on a new line.

For example, given a string , it can be copied for  dollars. Start by copying ,  and  individually at a cost of  dollar per character. String  at this time. Copy  to the end of  at no cost to complete the copy.

Function Description

Complete the stringConstruction function in the editor below. It should return the minimum cost of copying a string.

stringConstruction has the following parameter(s):

• s: a string

Input Format

The first line contains a single integer , the number of strings.
Each of the next  lines contains a single string, .

Constraints

• for  of the maximum score.

Output Format

For each string  print the minimum cost of constructing a new string  on a new line.

Sample Input

2
abcd
abab

Sample Output

4
2

Explanation

1. Append character '' to  at a cost of  dollar, .
2. Append character '' to  at a cost of  dollar, .
3. Append character '' to  at a cost of  dollar, .
4. Append character '' to  at a cost of  dollar, .

Because the total cost of all operations is  dollars, we print  on a new line.

1. Append character '' to  at a cost of  dollar, .
2. Append character '' to  at a cost of  dollar, .
3. Append substring  to  at no cost, .

Because the total cost of all operations is  dollars, we print  on a new line.

Note

A substring of a string  is another string  that occurs "in"  (Wikipedia). For example, the substrings of the string "" are "", "" ,"", "", "", and "".

### Solution in Python

def stringConstruction(s):
return len(set(s))

for _ in range(int(input())):
print(stringConstruction(input()))


text:
# General theory of divergent, highly oscillatory integrals

I'm interested in evaluation of integrals of the form $$\int e^{i S(x)}O(x) dx,$$ where $S(x)$ is a polynomial of degree higher than one and $O(x)$ is a polynomial or more generally, polynomialy bounded smooth function ($|O(x)|<C (1+x^2)^N$). The conventional way to provisionally define the value of such integral is to replace it by an expression of the form $$\int e^{i S(x)}O(x) \chi(\epsilon x) dx,$$ where $\chi$ is some smooth function such that $\chi(0)=1$, $\chi(x) \to 0$ as $x \to \infty$ sufficiently rapidly for the integral to converge and look at the limit $\epsilon \to 0$. This can be seen to work and give finite results in special cases which are computationally tractable. I want to know if some general results are known concerning the following questions: 1. Is the limit $\epsilon \to 0$ guaranteed to exist, 2. Is it independent of $\chi$, 3. Can a theory analogous to that of distributions be developed (I'd like to think of $e^{iS(x)}$ as sort of a distribution, but note that my $O(x)$ is much more general than test functions in Schwartz space).


text:
Ideal Diode

Ideal diode

 Description The Ideal Diode component models a diode with an on-state resistance of ${R}_{\mathrm{on}}$ and an off-state conductance of ${G}_{\mathrm{off}}$. An optional thermal port is enabled when the Use Heat Port is true.
 Equations $i={i}_{p}=-{i}_{n}$ $v={v}_{p}-{v}_{n}$ $\left\{\begin{array}{cc}i=v{G}_{\mathrm{off}}& v<{V}_{\mathrm{knee}}\\ v=i{R}_{\mathrm{on}}\phantom{\rule[-0.0ex]{0.5ex}{0.0ex}}& \mathrm{otherwise}\end{array}$ $\mathrm{LossPower}=vi$

Variables

 Name Units Description Modelica ID $v$ $V$ Voltage drop between the two pins v ${v}_{x}$ $V$ Voltage at pin $x$, $x\in \left\{n,p\right\}$ x.v $i$ $A$ Current flowing from pin p to pin n i ${i}_{x}$ $A$ Current into pin $x$, $x\in \left\{n,p\right\}$ x.i $\mathrm{LossPower}$ $W$ Loss power leaving component via HeatPort LossPower ${T}_{\mathrm{heatPort}}$ $K$ Temperature of HeatPort T_heatPort $\mathrm{off}$ Switching state off

Connections

 Name Description Modelica ID $p$ Positive pin p $n$ Negative pin n $\mathrm{Heat Port}$ heatPort

Parameters

 Name Default Units Description Modelica ID ${R}_{\mathrm{on}}$ $1·{10}^{-5}$ $\mathrm{\Omega }$ On-state resistance Ron ${G}_{\mathrm{off}}$ $1·{10}^{-5}$ $S$ Off-state conductance Goff ${V}_{\mathrm{knee}}$ $0$ $V$ Forward threshold voltage Vknee Use Heat Port $\mathrm{false}$ True (checked) means heat port is enabled useHeatPort $T$ $293.15$ $K$ Fixed device temperature if Use Heat Port is false T

 Modelica Standard Library The component described in this topic is from the Modelica Standard Library. To view the original documentation, which includes author and copyright information, click here.


text:
4 edited body

Can't we base-change $f : X \to Y$ with $Z$ and obtain: $g : f^{-1}(Z) \to Z$? This also is a universal homeomorphism by construction, right? So now we have a universal homeomorphism to a regular scheme, but a regular scheme is weakly normal, see A. Andreotti and E. Bombieri, Sugli omeomorfismi delle varietà algebriche''.

Therefore $g$ is an isomorphism at least as long as $f^{-1}(Z)$ is reduced and the map $g$ is birational.

EDIT: My argument that $f^{-1}(Z)$ was reduced was junk. I shouldn't have tried to do math while on the run. But as long as $f^{-1}(Z)$ is reduced and $g$ is birationalreduced, then I think things are ok.

3 added 52 characters in body

Can't we base-change $f : X \to Y$ with $Z$ and obtain: $g : f^{-1}(Z) \to Z$? This also is a universal homeomorphism by construction, right? So now we have a universal homeomorphism to a regular scheme, but a regular scheme is weakly normal, see A. Andreotti and E. Bombieri, Sugli omeomorfismi delle varietà algebriche''.

Therefore $g$ is an isomorphism at least as long as $f^{-1}(Z)$ is reduced and the map $g$ is birational.

EDIT: My argument that $f^{-1}(Z)$ was reduced was junk. I shouldn't have tried to do math while on the run. But as long as $f^{-1}(Z)$ is and $g$ is birational reduced, then I think things are ok.

2 deleted 83 characters in body

Can't we base-change $f : X \to Y$ with $Z$ and obtain: $g : f^{-1}(Z) \to Z$? This also is a universal homeomorphism by construction, right? So now we have a universal homeomorphism to a regular scheme, but a regular scheme is weakly normal, see A. Andreotti and E. Bombieri, Sugli omeomorfismi delle varietà algebriche''.

Therefore $g$ is an isomorphism at least as long as $f^{-1}(Z)$ is reduced. But

EDIT: My argument that $f^{-1}(Z)$ has to be reduced, because if it isn't was reduced this would imply inseparability of $f$ at some (possibly generic) point of $Z$, which contradicts the universal homeomorphism of $f$.was junk. I shouldn't have tried to do math while on the runfor a couple hours. But as long as $f^{-1}(Z)$ is reduced, but did then I misunderstand the question?think things are ok.

Post Undeleted by Karl Schwede
Post Deleted by Karl Schwede
1


text:
# channelflow.org

### Site Tools

docs:math:newton_krylov_hookstep

# The Newton-Kyrylov-hookstep algorithm

The following is a detailed guide to Divakar Viswanath's Newton-Krylov-hookstep solution algorithm for equilibria, traveling waves, and periodic orbits of the Navier-Stokes equations. See Viswanath, “Recurrent motions within plane Couette turbulence”, J. Fluid Mech. 580 (2007), http://arxiv.org/abs/physics/0604062 for a higher-level description.

In this exposition, f stands for the finite-time map of the Navier-Stokes equations, not the residual being minimized (as it does in Dennis & Schnabel and Trefethen's discussions of constrained minimization and Krylov methods. Also, I use t and dt for the orbit period and its Newton-step increment, although in my code these variables are named T and dT, and dt stand for the integration time step.

## Problem definition

Let

We seek solutions of the equation

t can be a fixed or a free variable, as can σ. For plane Couette the possible continuously varying variables in σ are a_x,a_z in the phase shifts x → x + a_x L_x and z → z + a_z L_z.

## Discretization

Let x be the vector of unknown real numbers being sought. For concreteness in this exposition I will assume that we're looking for a relative periodic orbit, so that the period t of the orbit and the phase shifts a_x and a_z are unknowns. Then x = (u, σ, t), where by u I really mean the finite set of real-valued variables that parameterize the discrete representation of the velocity field (e.g. the real and imaginary parts of the spectral coefficients). To be perfectly pedantic (and because it will come in handy later), let there be M independent real numbers {u_m} in the discrete representation of u, and let P represent the map between continuous fields u and the discrete representation {u_m}.

Then x = (u, σ, t) is an M+3 dimensional vector

and the discrete equation to be solved is

This is M equations in M+3 unknowns. The indeterminacy follows from the equivariance of the f and G under time and spatial phase shifts. We will get three more equations by constraining the Newton step to be orthogonal to time and space shifts.

## The Newton algorithm

The Newton algorithm for solving G(x) = 0 is as follows. Let x* = (u*,σ*,t*) be the solution, i.e. G(x*) = G(u*,σ*, t*) = 0. Suppose we start with an initial guess x near x*. Let

In these equations the N subscript signifies the Newton step. Then

Drop higher order terms and solve the Newton equation

Because DG is a M x (M+3) matrix, we have to supplement this system with three constraint equations to have a unique solution dx_N.

( , ) here signifies an inner product, so these are orthogonality constraints preventing the Newton step from going in the directions of the time, x, and z equivariance. That forms an (M+3) x (M+3) dimensional system

## Krylov subspace solution of the Newton equation

Since since M is very large, we will use the iterative GMRES Krylov-subspace algorithm to find an approximate solution dx_N to the (M+3)x(M+3) system A dx_N = b. GMRES requires multiple evaluations of the product A dx for test values of dx. A dx is an M+3 dimensional vector whose first M entries can be approximated with finite differencing and time integration:

The last three entries of A dx are simple evaluations of the inner products (du, du/dt), (du, du/dx), and (du, du/dz). For details of the GMRES algorithm, see Trefethen and Bau.

That gives us the Newton step dx_N. However if we are too far from the solution x*, the linearization inherent in the Newton algorithm will not be accurate. At this point we switch from the pure Newton algorithm to a constrained minimization algorithm called the “hookstep”, specially adapted to work with GMRES.

## The hookstep algorithm

The classic hookstep algorithm is this: If the Newton step dx_N does not decrease the residual || G(x+dx_N) || sufficiently, we obtain a smaller step dx_H by minimizing || A dx_H - b ||^2 subject to ||dx_H||^2 ⇐ \delta^2, rather using the Newton step, which solves A dx = b.

In the current case A is very high-dimensional, so we further constrain the hookstep dx_H to lie within the Krylov subspace obtained from the solution of the Newton step equations. I.e. we minimize the norm of the projection of A dx_H - b onto the Krylov subspace. The nth GMRES iterate gives matrices Q_n, Q_{n-1}, and H_n such that

where Q_n is M x n, Q_{n-1} is M x (n+1), and H_n is (n+1) x n. The projection of A dx - b onto the (n+1)th Krylov subspace is Q_{n-1}^T (A dx - b). Confine the dx_H to nth Krylov subspace by letting dx_H = Q_n s where s = {s_n} is a n-dimensional vector to be determined by constrained optimization. Namely, we minimize

subject to ||dx_H||^2 = || s ||^2 ≤ δ^2. Note that the quantity in the norm on the right-hand side of (10) is only n-dimensional, and n is small (order 10 or 100) compared to M (10^5 or 10^6).

The constrained minimization problem simplifies if we decompose H_n with SVD: H_n = U D V^T. Then the RHS of the previous equation becomes

where \hat{s} = V^T s and \hat{b} = U^T Q_{n-1}^T b. Now we need to minimize || D \hat{s} - \hat{b} ||^2 subject to ||\hat{s}||^2 ≤ δ^2

## Solving for the Krylov-hookstep

From Divakar Viswanath, personal communication: Since D is diagonal D_{i,i} = d_i, the constrained minimization problem can be solved easily with Lagrange multipliers. The solution is

(no Einstein summation) for the μ such that ||\hat{s}||^2 = δ^2. This value of μ can be found with a 1d Newton search for the zero of

A straight Newton search a la μ → μ - Φ(μ)/Φ'(μ) is suboptimal since Φ'(μ) → 0 as μ → ∞ with Φ''(μ) > 0 everywhere, so we use a slightly modified update rule for the Newton search over μ. Please refer to Dennis and Schnabel regarding that. Then, given the solution \hat{s}(μ), we compute the hookstep solution s from

## Determining the trust-region radius δ

How do we know a good value for δ? Essentially, by comparing the reduction in residual obtained by actually taking the hookstep dx_H to the reduction predicted by the linearized model G(x+dx_H) = G(x) + DG(x) dx_H. If the reduction is accurate but small, we increase δ by small steps until the reduction is marginally accurate but larger. If the reduction is poor we reduce δ.

(Note: the trust-region optimization is actually performed in terms of the squared residual, so the comments in the code refer to a quadratic rather than linear model of the residual.)

The heuristics associated with adjusting the trust region are fairly complex. Dennis and Schnabel has a decent description, but it took quite a bit of effort to translate that description into an algorithm. Rather than attempt to translate the algorithm back into prose, I recommend you read Dennis and Schnabel and then refer to the code and comments. This portion of findorbit.cpp is very liberally commented.