text:
# Evaluating a “binomial-like” sum

I suspect there is a way to do the following sum by hand, but I'm having some trouble: $$\sum_{x=0}^{n} x^{2} {n \choose x} p^{x}(1-p)^{n-x}$$

There are a couple questions like this, but for general $x^{k}$, I wanted to know for k = 2.

-
$=E(X^2)=(E(X))^2+\sigma^2_X=(np)^2+np(1-p)$ for $X\sim B(n,p)$. For general $k$, you could probably use $k$th derivative of moment generating function for a binomial. – A.S. Mar 19 at 18:22
@A.S. ya this is how i ended up doing it when i answered orginially – yoshi Mar 19 at 19:05
I'm assuming $k$ and $n$ are the same thing? And $x$ does not generally represent an integer variable, but that's more of a convention. – Teepeemm Mar 20 at 0:21

\begin{align*} \sum_kk^2\binom{n}kp^k(1-p)^{n-k}&=n\sum_kk\binom{n-1}{k-1}p^k(1-p)^{n-k}\\ &=n\sum_k(k+1)\binom{n-1}kp^{k+1}(1-p)^{n-k-1}\\ &=n\sum_kk\binom{n-1}kp^{k+1}(1-p)^{n-k-1}+n\sum_k\binom{n-1}kp^{k+1}(1-p)^{n-k-1}\\ &=n(n-1)\sum_k\binom{n-2}{k-1}p^{k+1}(1-p)^{n-k-1}+np\sum_k\binom{n-1}kp^k(1-p)^{(n-1)-k}\\ &=n(n-1)\sum_k\binom{n-2}kp^{k+2}(1-p)^{n-2-k}+np\\ &=n(n-1)p^2+np\\ \end{align*}

-
is the second line just a re-indexing? – yoshi Mar 19 at 19:00
@yoshi: Yes, and so is the first part of the fifth line. – Brian M. Scott Mar 19 at 19:01
is there anyway to see that would work? i got to the first equality when I did this myself. – yoshi Mar 19 at 19:04
@yoshi: I wasn’t positive when I started, but experience suggested that it could probably be pushed through with a bit of work. After that I just kind of followed my nose. – Brian M. Scott Mar 19 at 19:06

Take $q$ to be a constant in the following, and use the identity $$\sum_{x=0}^n \left(n\atop x\right)p^x q ^{n - x} = (p +q )^n.$$ Apply the operator $D = p \,{d\over dp}$ to both sides $k$ times (twice, here), and then set $q = 1-p$, and you'll get the same answer (for $k=2$) as is on this page... i.e., $p^2n (n-1) +pn = (pn)^2 + np(1-p).$

-
Solid approach. Tantamount to "Feynman's Trick" and the way forward I would have presented. Well done! +1 - Mark – Dr. MV Mar 19 at 18:47
o man, this is good, thanks! – yoshi Mar 19 at 19:00

format: plain


text:
# 3.8: Implicit Differentiation

Learning Objectives

• Find the derivative of a complicated function by using implicit differentiation.
• Use implicit differentiation to determine the equation of a tangent line.

We have already studied how to find equations of tangent lines to functions and the rate of change of a function at a specific point. In all these cases we had the explicit equation for the function and differentiated these functions explicitly. Suppose instead that we want to determine the equation of a tangent line to an arbitrary curve or the rate of change of an arbitrary curve at a point. In this section, we solve these problems by finding the derivatives of functions that define $$y$$ implicitly in terms of $$x$$.

## Implicit Differentiation

In most discussions of math, if the dependent variable $$y$$ is a function of the independent variable $$x$$, we express y in terms of $$x$$. If this is the case, we say that $$y$$ is an explicit function of $$x$$. For example, when we write the equation $$y=x^2+1$$, we are defining y explicitly in terms of $$x$$. On the other hand, if the relationship between the function $$y$$ and the variable $$x$$ is expressed by an equation where $$y$$ is not expressed entirely in terms of $$x$$, we say that the equation defines $$y$$ implicitly in terms of $$x$$. For example, the equation $$y−x^2=1$$ defines the function $$y=x^2+1$$ implicitly.

Implicit differentiation allows us to find slopes of tangents to curves that are clearly not functions (they fail the vertical line test). We are using the idea that portions of $$y$$ are functions that satisfy the given equation, but that y is not actually a function of $$x$$.

In general, an equation defines a function implicitly if the function satisfies that equation. An equation may define many different functions implicitly. For example, the functions

$y=\sqrt{25−x^2}\nonumber$

and

$y=\begin{cases}\sqrt{25−x^2}, & \text{if }−25≤x<0\\ −\sqrt{25−x^2}, & \text{if }0≤x≤25\end{cases}\nonumber$

which are illustrated in Figure $$\PageIndex{1}$$, are just three of the many functions defined implicitly by the equation $$x^2+y^2=25$$.

If we want to find the slope of the line tangent to the graph of $$x^2+y^2=25$$ at the point $$(3,4)$$, we could evaluate the derivative of the function $$y=−\sqrt{25−x^2}$$ at $$x=3$$. On the other hand, if we want the slope of the tangent line at the point $$(3,−4)$$, we could use the derivative of $$y=−\sqrt{25−x^2}$$. However, it is not always easy to solve for a function defined implicitly by an equation. Fortunately, the technique of implicit differentiation allows us to find the derivative of an implicitly defined function without ever solving for the function explicitly. The process of finding $$\dfrac{dy}{dx}$$ using implicit differentiation is described in the following problem-solving strategy.

Problem-Solving Strategy: Implicit Differentiation

To perform implicit differentiation on an equation that defines a function $$y$$ implicitly in terms of a variable $$x$$, use the following steps:

1. Take the derivative of both sides of the equation. Keep in mind that $$y$$ is a function of $$x$$. Consequently, whereas $\dfrac{d}{dx}(\sin x)=\cos x\nonumber$ and $\dfrac{d}{dx}(\sin y)=\cos y\cdot\dfrac{dy}{dx}\nonumber$ because we must use the chain rule to differentiate $$\sin y$$ with respect to $$x$$.
2. Rewrite the equation so that all terms containing $$dy/dx$$ are on the left and all terms that do not contain $$dy/dx$$ are on the right.
3. Factor out $$dy/dx$$ on the left.
4. Solve for $$dy/dx$$ by dividing both sides of the equation by an appropriate algebraic expression.

Example $$\PageIndex{1}$$: Using Implicit Differentiation

Assuming that $$y$$ is defined implicitly by the equation $$x^2+y^2=25$$, find $$\dfrac{dy}{dx}$$.

Solution

Follow the steps in the problem-solving strategy.

 $$\dfrac{d}{dx}(x^2+y^2)=\dfrac{d}{dx}(25)$$ Step 1. Differentiate both sides of the equation. $$\dfrac{d}{dx}(x^2)+\dfrac{d}{dx}(y^2)=0$$ Step 1.1. Use the sum rule on the left.On the right $$\dfrac{d}{dx}(25)=0$$. $$2x+2y\dfrac{dy}{dx}=0$$ Step 1.2. Take the derivatives, so $$\dfrac{d}{dx}(x^2)=2x$$ and $$\dfrac{d}{dx}(y^2)=2y\dfrac{dy}{dx}$$. $$2y\dfrac{dy}{dx}=−2x$$ Step 2. Keep the terms with $$\dfrac{dy}{dx}$$ on the left.Move the remaining terms to the right. $$\dfrac{dy}{dx}=−\dfrac{x}{y}$$ Step 4. Divide both sides of the equation by $$2y$$.(Step 3 does not apply in this case.)

Analysis

Note that the resulting expression for $$\dfrac{dy}{dx}$$ is in terms of both the independent variable $$x$$ and the dependent variable $$y$$. Although in some cases it may be possible to express $$\dfrac{dy}{dx}$$ in terms of $$x$$ only, it is generally not possible to do so.

Example $$\PageIndex{2}$$: Using Implicit Differentiation and the Product Rule

Assuming that $$y$$ is defined implicitly by the equation $$x^3\sin y+y=4x+3$$, find $$\dfrac{dy}{dx}$$.

Solution

 $$\dfrac{d}{dx}(x^3\sin y+y)=\dfrac{d}{dx}(4x+3)$$ Step 1: Differentiate both sides of the equation. $$\dfrac{d}{dx}(x^3\sin y)+\dfrac{d}{dx}(y)=4$$ Step 1.1: Apply the sum rule on the left.On the right, $$\dfrac{d}{dx}(4x+3)=4$$. $$(\dfrac{d}{dx}(x^3)⋅\sin y+\dfrac{d}{dx}(\sin y)⋅x^3)+\dfrac{dy}{dx}=4$$ Step 1.2: Use the product rule to find $$\dfrac{d}{dx}(x^3\sin y)$$.Observe that $$\dfrac{d}{dx}(y)=\dfrac{dy}{dx}$$. $$3x^2\sin y+(\cos y\dfrac{dy}{dx})⋅x^3+\dfrac{dy}{dx}=4$$ Step 1.3: We know $$\dfrac{d}{dx}(x^3)=3x^2$$.Use the chain rule to obtain $$\dfrac{d}{dx}(\sin y)=\cos y\dfrac{dy}{dx}$$. $$x^3\cos y\dfrac{dy}{dx}+\dfrac{dy}{dx}=4−3x^2\sin y$$ Step 2: Keep all terms containing $$\dfrac{dy}{dx}$$ on the left. Move all other terms to the right. $$\dfrac{dy}{dx}(x^3\cos y+1)=4−3x^2\sin y$$ Step 3: Factor out $$\dfrac{dy}{dx}$$ on the left. $$\dfrac{dy}{dx}=\dfrac{4−3x^2\sin y}{x^3\cos y+1}$$ Step 4: Solve for $$\dfrac{dy}{dx}$$ by dividing both sides of the equation by $$x^3\cos y+1$$.

Example $$\PageIndex{3}$$: Using Implicit Differentiation to Find a Second Derivative

Find $$\dfrac{d^2y}{dx^2}$$ if $$x^2+y^2=25$$.

Solution

In Example $$\PageIndex{1}$$, we showed that $$\dfrac{dy}{dx}=−\dfrac{x}{y}$$. We can take the derivative of both sides of this equation to find $$\dfrac{d^2y}{dx^2}$$.

\begin{align*} \dfrac{d^2y}{dx^2}&=\dfrac{d}{dy}\left(−\dfrac{x}{y}\right) & & \text{Differentiate both sides of }\dfrac{dy}{dx}=−\dfrac{x}{y}.\4pt] &=−\dfrac{\left(1⋅y−x\dfrac{dy}{dx}\right)}{y^2} & & \text{Use the quotient rule to find }\dfrac{d}{dy}\left(−\dfrac{x}{y}\right).\\[4pt] &=\dfrac{−y+x\dfrac{dy}{dx}}{y^2} & & \text{Simplify.}\\[4pt] &=\dfrac{−y+x\left(−\dfrac{x}{y}\right)}{y^2} & & \text{Substitute }\dfrac{dy}{dx}=−\dfrac{x}{y}.\\[4pt] &=\dfrac{−y^2−x^2}{y^3} & & \text{Simplify.} \end{align*} At this point we have found an expression for $$\dfrac{d^2y}{dx^2}$$. If we choose, we can simplify the expression further by recalling that $$x^2+y^2=25$$ and making this substitution in the numerator to obtain $$\dfrac{d^2y}{dx^2}=−\dfrac{25}{y^3}$$. Exercise $$\PageIndex{1}$$ Find $$\dfrac{dy}{dx}$$ for $$y$$ defined implicitly by the equation $$4x^5+\tan y=y^2+5x$$. Hint Follow the problem solving strategy, remembering to apply the chain rule to differentiate $$\tan y$$ and $$y^2$$. Answer \[\dfrac{dy}{dx}=\dfrac{5−20x^4}{\sec^2y−2y}

## Finding Tangent Lines Implicitly

Now that we have seen the technique of implicit differentiation, we can apply it to the problem of finding equations of tangent lines to curves described by equations.

Example $$\PageIndex{4}$$: Finding a Tangent Line to a Circle

Find the equation of the line tangent to the curve $$x^2+y^2=25$$ at the point $$(3,−4)$$.

Solution

Although we could find this equation without using implicit differentiation, using that method makes it much easier. In Example $$\PageIndex{1}$$, we found $$\dfrac{dy}{dx}=−\dfrac{x}{y}$$.

The slope of the tangent line is found by substituting $$(3,−4)$$ into this expression. Consequently, the slope of the tangent line is $$\dfrac{dy}{dx}\Big|_{(3,−4)}=−\dfrac{3}{−4}=\dfrac{3}{4}$$.

Using the point $$(3,−4)$$ and the slope $$\dfrac{3}{4}$$ in the point-slope equation of the line, we obtain the equation $$y=\dfrac{3}{4}x−\dfrac{25}{4}$$ (Figure).

Example $$\PageIndex{5}$$: Finding the Equation of the Tangent Line to a Curve

Find the equation of the line tangent to the graph of $$y^3+x^3−3xy=0$$ at the point $$\left(\frac{3}{2},\frac{3}{2}\right)$$ (Figure). This curve is known as the folium (or leaf) of Descartes.

Solution

Begin by finding $$\dfrac{dy}{dx}$$.

$$\dfrac{d}{dx}(y^3+x^3−3xy)=\dfrac{d}{dx}(0)$$

$$3y^2\dfrac{dy}{dx}+3x^2−(3y+\dfrac{dy}{dx}3x)=0$$

$$\dfrac{dy}{dx}=\dfrac{3y−3x^2}{3y^2−3x}$$.

Next, substitute $$\left(\frac{3}{2},\frac{3}{2}\right)$$ into $$\dfrac{dy}{dx}=\dfrac{3y−3x^2}{3y^2−3x}$$ to find the slope of the tangent line:

$$\dfrac{dy}{dx}\Bigg|_{\left(\frac{3}{2},\frac{3}{2}\right)}=−1$$.

Finally, substitute into the point-slope equation of the line to obtain

$$y=−x+3$$.

Example $$\PageIndex{6}$$: Applying Implicit Differentiation

In a simple video game, a rocket travels in an elliptical orbit whose path is described by the equation $$4x^2+25y^2=100$$. The rocket can fire missiles along lines tangent to its path. The object of the game is to destroy an incoming asteroid traveling along the positive $$x$$-axis toward $$(0,0)$$. If the rocket fires a missile when it is located at $$\left(3,\frac{8}{3}\right)$$, where will it intersect the $$x$$-axis?

Solution

To solve this problem, we must determine where the line tangent to the graph of

$$4x^2+25y^2=100$$ at $$\left(3,\frac{8}{3}\right)$$ intersects the $$x$$-axis. Begin by finding $$\dfrac{dy}{dx}$$ implicitly.

Differentiating, we have

$$8x+50y\dfrac{dy}{dx}=0.$$

Solving for $$\dfrac{dy}{dx}$$,

we have

$$\dfrac{dy}{dx}=−\dfrac{4x}{25y}$$.

The slope of the tangent line is $$\dfrac{dy}{dx}\Bigg|_{\left(3,\frac{8}{3}\right)}=−\dfrac{9}{50}$$. The equation of the tangent line is $$y=−\dfrac{9}{50}x+\dfrac{183}{200}$$. To determine where the line intersects the $$x$$-axis, solve $$0=−\dfrac{9}{50}x+\dfrac{183}{200}$$. The solution is $$x=\dfrac{6}{13}$$. The missile intersects the $$x$$-axis at the point $$\left(\frac{61}{3},0\right)$$.

Exercise $$\PageIndex{2}$$

Find the equation of the line tangent to the hyperbola $$x^2−y^2=16$$ at the point $$(5,3)$$.

Hint

$$\dfrac{dy}{dx}=\dfrac{x}{y}$$

$$y=\dfrac{5}{3}x−\dfrac{16}{3}$$

## Key Concepts

• We use implicit differentiation to find derivatives of implicitly defined functions (functions defined by equations).
• By using implicit differentiation, we can find the equation of a tangent line to the graph of a curve.

## Glossary

implicit differentiation
is a technique for computing $$\dfrac{dy}{dx}$$ for a function defined by an equation, accomplished by differentiating both sides of the equation (remembering to treat the variable $$y$$ as a function) and solving for $$\dfrac{dy}{dx}$$


text:
# Must all AI states be able to react to any event?

FSMs implemented with the State design pattern are a common way to design AI agents. I am familiar with the State design pattern and know how to implement it.

How is this used in games to design AI agents?

Consider a simplified class Monster, representing an AI agent:

class Monster {
State state;
// other fields omitted

public void update(){ // called every game-loop cycle
state.execute(this);
}

public void setState(State state){
this.state = state;
}

// irrelevant stuff omitted
}

There are several State subclasses implementing execute() differently. So far, classic State pattern.

AI agents are subject to environmental effects and other objects communicating with them. For example, an AI agent might tell another AI agent to attack (i.e. agent.attack()). Or a fireball might tell an AI agent to fall down. This means that the agent must have methods such as attack() and fallDown(), or commonly some message receiving mechanism to understand such messages.

1. With an FSM, the current State of the agent should be the one taking care of such method calls - i.e. the agent delegates to the current state upon every event. Is this correct?

2. If correct, how is this done? Are all states obligated by their superclass to implement methods such as attack(), fallDown() etc., so the agent can always delegate to them on almost every event? Or is it done in some other way?

I would probably try and keep everything that changes the agent's attributes with the agent (decreaseHealth) and split the involved behaviour into several FSMs (animation, combat, etc).

IE: the agent has a method getHit that is somehow called when the agent gets hit (by the physics system, other agents, fireballs, etc).

Other FSMs can register to be informed when getHit is called. For example the combat system, which would then change state: if the agent has a shield or protection spell, reduce it's value and change to 'defensive' state, if not call decreaseHealth directly on the agent and go to 'suppressed' state.

Other FSMs would register to be informed when decreaseHealth is called: The sound-system would change from 'talking' to 'screaming' state, the animation-system would change from 'play running animation' to 'play falling down animation' state, etc.

I think this situation would benefit from a Hierarchical State Machine which is the type I use in my games to solve this problem.

A hierarchical state machine (HSM) is a state machine where states are grouped together and have parent states. Therefore grouped states can all react to events collectively to produce behavior that is general for a specific set of states. For example I'm currently working on a generic ground based movement script for my game, the 'Legs' component supplies the states:

• grounded
• standing
• walking
• running
• airborne
• jumping
• falling

etc...

You can see that some states are substates of others, in this way if the actor entity receives an event such as 'jump' and it is in the ground state (which is to say that it is in any of the states: standing, walking or running) it will transition to the jumping state. A similar event could occur for something only applicable to the airborne state.


text:
1. ## Delta-Epsilon Proof

This was a problem from my calculus final a year ago that I've wanted to see for a while:

Use the delta-epsilon definition of a limit to prove that the limit as x approaches 0 of f(x) = sin(x)/(x^2 +1) is 0.

I tried using the squeeze theorem in an effort to bound sin(x), because I really don't know how to deal with sin(x) in a delta epsilon proof. This problem has just been on my mind for a while. Thanks for the help!

2. Originally Posted by amee
This was a problem from my calculus final a year ago that I've wanted to see for a while:

Use the delta-epsilon definition of a limit to prove that the limit as x approaches 0 of f(x) = sin(x)/(x^2 +1) is 0.

I tried using the squeeze theorem in an effort to bound sin(x), because I really don't know how to deal with sin(x) in a delta epsilon proof. This problem has just been on my mind for a while. Thanks for the help!
For all $x \in \mathbb{R}$ and $x\ne 0$: $|\sin(x)|< |x|$

CB

3. Can you show me how to do this proof? CB, what you wrote is true, but I'm not familiar with delta-epsilon proofs to know how to incorporate it into the rest of the proof.

4. You want d such that |x- 0| < d then |f(x) - 0 | < e

|f(x) - 0 | = | sin(x)/(x^2+1)| < |sin(x)|

take d = arcsin(e)

then if |x| < arcsin(e) then |sin(x)| < |sin(arcsin(e)| = e

5. Originally Posted by Calculus26
You want d such that |x- 0| < d then |f(x) - 0 | < e

|f(x) - 0 | = | sin(x)/(x^2+1)| < |sin(x)|

take d = arcsin(e)

then if |x| < arcsin(e) then |sin(x)| < |sin(arcsin(e)| = e
But since $|\, \sin (x) \,| < |\, x \,|\; \text{for}\; |\, x \, | > 0$ then you can chose $\delta = \varepsilon$ .


text:
# How do you solve the inequality x^2+2x>=24?

May 9, 2017

By trial and error. Your answer is with the exception of -6<x<4, all x values provide solution.

#### Explanation:

x must be a real number and let me try +3 provide the solution. There are two numbers provide the solution (one is positive and the other one is negative):

${3}^{2} + 2 \cdot 3 = 15$ therefore it does not provide solution.

Now let me try +4

${4}^{2} + 2 \cdot 4 = 24$ Yes. This is one answer. Therefore x must be greater than or equal to +4.

On the negative side, let me try -3 first:

${\left(- 3\right)}^{2} - 2 \cdot 3 = 2$ does not satisfy the requested condition.

Try -4 now:

${\left(- 4\right)}^{2} - 2 \cdot 4 = 8$ does not satisfy the requested condition.

Try -5 now:

${\left(- 5\right)}^{2} - 2 \cdot 5 = 15$ does not satisfy the requested condition.

Try -6 now:

${\left(- 6\right)}^{2} - 2 \cdot 6 = 24$ Yes it satisfies.

Any number less than -6 (including -6) will satisfy the given.

For instance (-8):

${\left(- 8\right)}^{2} - 2 \cdot 8 = 48$ which is greater than 24.

Now your solution is x must be greater than or equal to 4 or x must be less than or equal to -6.

May 9, 2017

The solution is $x \in \left(- \infty , - 6\right] \cup \left[4 , + \infty\right)$

#### Explanation:

We solve this equation with a sign chart

Let's rearrange and factorise the inequality

${x}^{2} + 2 x \ge 24$

${x}^{2} + 2 x - 24 \ge 0$

$\left(x + 6\right) \left(x - 4\right) \ge 0$

Let $f \left(x\right) = \left(x + 6\right) \left(x - 4\right)$

Now, we construct the sign chart

$\textcolor{w h i t e}{a a a a}$$x$$\textcolor{w h i t e}{a a a a}$$- \infty$$\textcolor{w h i t e}{a a a a}$$- 6$$\textcolor{w h i t e}{a a a a}$$4$$\textcolor{w h i t e}{a a a a}$$+ \infty$

$\textcolor{w h i t e}{a a a a}$$x + 6$$\textcolor{w h i t e}{a a a a a}$$-$$\textcolor{w h i t e}{a a a a}$$+$$\textcolor{w h i t e}{a a a a}$$+$

$\textcolor{w h i t e}{a a a a}$$x - 4$$\textcolor{w h i t e}{a a a a a}$$-$$\textcolor{w h i t e}{a a a a}$$-$$\textcolor{w h i t e}{a a a a}$$+$

$\textcolor{w h i t e}{a a a a}$$f \left(x\right)$$\textcolor{w h i t e}{a a a a a a}$$+$$\textcolor{w h i t e}{a a a a}$$-$$\textcolor{w h i t e}{a a a a}$$+$

Therefore,

$f \left(x\right) \ge 0$, when $x \in \left(- \infty , - 6\right] \cup \left[4 , + \infty\right)$


text:
# Bibliotek

Musik » The Smiths »

## Please, Please, Please, Let Me Get What I Want

215 spelade låtar | Gå till låtsida

Låtar (215)
Låt Album Längd Datum
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 16:26
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:33
Please, Please, Please, Let Me Get What I Want 1:53 15 jul 2013, 15:31
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 1 jul 2013, 21:21
Please, Please, Please, Let Me Get What I Want 1:53 28 maj 2013, 01:34
Please, Please, Please, Let Me Get What I Want 1:53 13 maj 2013, 10:05
Please, Please, Please, Let Me Get What I Want 1:53 28 apr 2013, 16:31
Please, Please, Please, Let Me Get What I Want 1:53 22 apr 2013, 09:28
Please, Please, Please, Let Me Get What I Want 1:53 26 mar 2013, 21:09
Please, Please, Please, Let Me Get What I Want 1:53 19 mar 2013, 22:55
Please, Please, Please, Let Me Get What I Want 1:53 8 jan 2013, 22:14
Please, Please, Please, Let Me Get What I Want 1:53 6 jul 2012, 22:57
Please, Please, Please, Let Me Get What I Want 1:53 6 jul 2012, 13:49
Please, Please, Please, Let Me Get What I Want 1:53 6 jul 2012, 13:12
Please, Please, Please, Let Me Get What I Want 1:53 6 jul 2012, 12:09
Please, Please, Please, Let Me Get What I Want 1:53 6 jul 2012, 08:49
Please, Please, Please, Let Me Get What I Want 1:53 6 jul 2012, 08:14
Please, Please, Please, Let Me Get What I Want 1:53 6 jul 2012, 01:40
Please, Please, Please, Let Me Get What I Want 1:53 27 jun 2012, 17:32
Please, Please, Please, Let Me Get What I Want 1:53 12 jun 2012, 10:19
Please, Please, Please, Let Me Get What I Want 1:53 12 jun 2012, 10:00
Please, Please, Please, Let Me Get What I Want 1:53 30 maj 2012, 13:17
Please, Please, Please, Let Me Get What I Want 1:53 28 maj 2012, 21:30
Please, Please, Please, Let Me Get What I Want 1:53 28 maj 2012, 20:29
Please, Please, Please, Let Me Get What I Want 1:53 23 maj 2012, 02:32
Please, Please, Please, Let Me Get What I Want 1:53 23 maj 2012, 02:31
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 23:20
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 23:09
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 19:29
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 19:07
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 18:49
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 12:15
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 11:31
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 10:52
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 08:09
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 07:46
Please, Please, Please, Let Me Get What I Want 1:53 22 maj 2012, 02:05
Please, Please, Please, Let Me Get What I Want 1:53 2 maj 2012, 20:58
Please, Please, Please, Let Me Get What I Want 1:53 26 apr 2012, 22:35
Please, Please, Please, Let Me Get What I Want 1:53 20 apr 2012, 08:24
Please, Please, Please, Let Me Get What I Want 1:53 20 apr 2012, 06:17
Please, Please, Please, Let Me Get What I Want 1:53 20 apr 2012, 03:27
Please, Please, Please, Let Me Get What I Want 1:53 19 apr 2012, 13:59
Please, Please, Please, Let Me Get What I Want 1:53 19 apr 2012, 11:55
Please, Please, Please, Let Me Get What I Want 1:53 19 apr 2012, 10:56
Please, Please, Please, Let Me Get What I Want 1:53 19 apr 2012, 05:12
Please, Please, Please, Let Me Get What I Want 1:53 19 apr 2012, 04:19
Please, Please, Please, Let Me Get What I Want 1:53 19 apr 2012, 03:52
Please, Please, Please, Let Me Get What I Want 1:53 19 apr 2012, 02:10
Please, Please, Please, Let Me Get What I Want 1:53 18 apr 2012, 23:04
Please, Please, Please, Let Me Get What I Want 1:53 25 mar 2012, 21:59
Please, Please, Please, Let Me Get What I Want 1:53 25 mar 2012, 20:02
Please, Please, Please, Let Me Get What I Want 1:53 25 mar 2012, 17:41
Please, Please, Please, Let Me Get What I Want 1:53 22 mar 2012, 20:44
Please, Please, Please, Let Me Get What I Want 1:53 14 mar 2012, 00:28
Please, Please, Please, Let Me Get What I Want 1:53 13 mar 2012, 08:46
Please, Please, Please, Let Me Get What I Want 1:53 1 mar 2012, 09:28
Please, Please, Please, Let Me Get What I Want 1:53 1 mar 2012, 09:28
Please, Please, Please, Let Me Get What I Want 1:53 29 feb 2012, 19:34
Please, Please, Please, Let Me Get What I Want 1:53 29 feb 2012, 02:51
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 18:32
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 18:32
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 18:32
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 18:32
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 18:32
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 18:30
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 17:31
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 17:31
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 17:31
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 17:31
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 17:29
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 13:30
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 12:29
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 08:29
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 05:35
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 02:02
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 01:03
Please, Please, Please, Let Me Get What I Want 1:53 20 feb 2012, 01:01
Please, Please, Please, Let Me Get What I Want 1:53 19 feb 2012, 02:44
Please, Please, Please, Let Me Get What I Want 1:53 18 feb 2012, 18:48
Please, Please, Please, Let Me Get What I Want 1:53 18 feb 2012, 16:49
Please, Please, Please, Let Me Get What I Want 1:53 17 feb 2012, 07:40
Please, Please, Please, Let Me Get What I Want 1:53 17 feb 2012, 05:46
Please, Please, Please, Let Me Get What I Want 1:53 2 feb 2012, 04:39
Please, Please, Please, Let Me Get What I Want 1:53 2 feb 2012, 03:38
Please, Please, Please, Let Me Get What I Want 1:53 1 feb 2012, 19:45
Please, Please, Please, Let Me Get What I Want 1:53 1 feb 2012, 18:43
Please, Please, Please, Let Me Get What I Want 1:53 1 feb 2012, 14:52
Please, Please, Please, Let Me Get What I Want 1:53 20 jan 2012, 20:10
Please, Please, Please, Let Me Get What I Want 1:53 20 jan 2012, 19:09
Please, Please, Please, Let Me Get What I Want 1:53 19 jan 2012, 18:06
Please, Please, Please, Let Me Get What I Want 1:53 19 jan 2012, 17:04
Please, Please, Please, Let Me Get What I Want 1:53 17 jan 2012, 14:43
Please, Please, Please, Let Me Get What I Want 1:53 17 jan 2012, 13:42
Please, Please, Please, Let Me Get What I Want 1:53 17 jan 2012, 09:51
Please, Please, Please, Let Me Get What I Want 1:53 17 jan 2012, 08:50
Please, Please, Please, Let Me Get What I Want 1:53 17 jan 2012, 00:45
Please, Please, Please, Let Me Get What I Want 1:53 16 jan 2012, 23:44
Please, Please, Please, Let Me Get What I Want 1:53 13 jan 2012, 08:20
Please, Please, Please, Let Me Get What I Want 1:53 9 jan 2012, 07:24
Please, Please, Please, Let Me Get What I Want 1:53 9 jan 2012, 04:40
Please, Please, Please, Let Me Get What I Want 1:53 9 jan 2012, 00:34
Please, Please, Please, Let Me Get What I Want 1:53 8 jan 2012, 23:33
Please, Please, Please, Let Me Get What I Want 1:53 4 jan 2012, 21:31
Please, Please, Please, Let Me Get What I Want 1:53 4 jan 2012, 21:15
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 23 dec 2011, 10:16
Please, Please, Please, Let Me Get What I Want 1:53 22 dec 2011, 23:56
Please, Please, Please, Let Me Get What I Want 1:53 20 dec 2011, 06:40
Please, Please, Please, Let Me Get What I Want 1:53 20 dec 2011, 06:08
Please, Please, Please, Let Me Get What I Want 1:53 19 dec 2011, 18:31
Please, Please, Please, Let Me Get What I Want 1:53 19 dec 2011, 01:16
Please, Please, Please, Let Me Get What I Want 1:53 30 nov 2011, 18:37
Please, Please, Please, Let Me Get What I Want 1:53 30 nov 2011, 17:36
Please, Please, Please, Let Me Get What I Want 1:53 30 nov 2011, 13:45
Please, Please, Please, Let Me Get What I Want 1:53 30 nov 2011, 12:44
Please, Please, Please, Let Me Get What I Want 1:53 30 nov 2011, 08:53
Please, Please, Please, Let Me Get What I Want 1:53 30 nov 2011, 07:52
Please, Please, Please, Let Me Get What I Want 1:53 30 nov 2011, 04:01
Please, Please, Please, Let Me Get What I Want 1:53 30 nov 2011, 03:00
Please, Please, Please, Let Me Get What I Want 1:53 19 nov 2011, 16:01
Please, Please, Please, Let Me Get What I Want 1:53 19 nov 2011, 14:26
Please, Please, Please, Let Me Get What I Want 1:53 19 nov 2011, 10:08
Please, Please, Please, Let Me Get What I Want 1:53 19 nov 2011, 09:51
Please, Please, Please, Let Me Get What I Want 1:53 19 nov 2011, 05:05
Please, Please, Please, Let Me Get What I Want 1:53 19 nov 2011, 04:56
Please, Please, Please, Let Me Get What I Want 1:53 16 nov 2011, 15:24
Please, Please, Please, Let Me Get What I Want 1:53 16 nov 2011, 15:22
Please, Please, Please, Let Me Get What I Want 1:53 16 nov 2011, 14:23
Please, Please, Please, Let Me Get What I Want 1:53 16 nov 2011, 14:21
Please, Please, Please, Let Me Get What I Want 1:53 16 nov 2011, 10:30
Please, Please, Please, Let Me Get What I Want 1:53 16 nov 2011, 09:29
Please, Please, Please, Let Me Get What I Want 1:53 16 nov 2011, 05:37
Please, Please, Please, Let Me Get What I Want 1:53 16 nov 2011, 04:37
Please, Please, Please, Let Me Get What I Want 1:53 16 nov 2011, 00:20
Please, Please, Please, Let Me Get What I Want 1:53 15 nov 2011, 23:48
Please, Please, Please, Let Me Get What I Want 1:53 4 nov 2011, 19:55
Please, Please, Please, Let Me Get What I Want 1:53 4 nov 2011, 18:54
Please, Please, Please, Let Me Get What I Want 1:53 3 nov 2011, 01:52
Please, Please, Please, Let Me Get What I Want 1:53 3 nov 2011, 00:52
Please, Please, Please, Let Me Get What I Want 1:53 31 okt 2011, 07:45
Please, Please, Please, Let Me Get What I Want 1:53 31 okt 2011, 07:06
Please, Please, Please, Let Me Get What I Want 1:53 20 okt 2011, 23:02
Please, Please, Please, Let Me Get What I Want 1:53 20 okt 2011, 22:01
Please, Please, Please, Let Me Get What I Want 1:53 16 okt 2011, 23:10
Please, Please, Please, Let Me Get What I Want 1:53 16 okt 2011, 22:41
Please, Please, Please, Let Me Get What I Want 1:53 16 okt 2011, 21:40
Please, Please, Please, Let Me Get What I Want 1:53 16 okt 2011, 09:18
Please, Please, Please, Let Me Get What I Want 1:53 16 okt 2011, 08:18
Please, Please, Please, Let Me Get What I Want 1:53 13 okt 2011, 18:14
Please, Please, Please, Let Me Get What I Want 1:53 11 okt 2011, 00:42
Please, Please, Please, Let Me Get What I Want 1:53 10 okt 2011, 23:41
Please, Please, Please, Let Me Get What I Want 1:53 9 okt 2011, 08:00
Please, Please, Please, Let Me Get What I Want 1:53 9 okt 2011, 04:39
Please, Please, Please, Let Me Get What I Want 1:53 8 okt 2011, 23:59
Please, Please, Please, Let Me Get What I Want 1:53 8 okt 2011, 22:58
Please, Please, Please, Let Me Get What I Want 1:53 6 okt 2011, 07:14
Please, Please, Please, Let Me Get What I Want 1:53 6 okt 2011, 05:30
Please, Please, Please, Let Me Get What I Want 1:53 4 okt 2011, 23:26
Please, Please, Please, Let Me Get What I Want 1:53 4 okt 2011, 08:17
Please, Please, Please, Let Me Get What I Want 1:53 4 okt 2011, 08:15
Please, Please, Please, Let Me Get What I Want 1:53 24 sep 2011, 23:01
Please, Please, Please, Let Me Get What I Want 1:53 13 sep 2011, 01:55
Please, Please, Please, Let Me Get What I Want 1:53 9 sep 2011, 16:47
Please, Please, Please, Let Me Get What I Want 1:53 9 sep 2011, 02:03
Please, Please, Please, Let Me Get What I Want 1:53 28 aug 2011, 05:20
Please, Please, Please, Let Me Get What I Want 1:53 28 aug 2011, 05:18
Please, Please, Please, Let Me Get What I Want 1:53 27 aug 2011, 05:37


text:
# Taking the integral of a strange function.

This is my second question on the exchange. I've been wrestling with this particular problem for several weeks now, ever since I discovered a certain function, which I call the 'grum' function. I don't know if it's ever been discovered before. I'm just doing street math, pretty much.

In any case, the grum function gives the answer to the following question:

Given any right triangle, and any line segment connecting:

• The vertice of the angle opposite the hypotenuse, and:
• Any point p resting on the hypotenuse, where the distance between the point p and the adjacent vertices of the triangle is given as the following ratio:
• $d_{1} = \frac{r}{n}$
• $d_{2} = r - \frac{r}{n}$

The distance of said line segment can be found via the following function:

$$grum_{n}(\theta) \equiv n^{-1}\sqrt{(n-1)^{2}\cos^{2}(\theta) + sin^{2}(\theta)}$$

pronounced "grum with index 'n' and evaluated at 'theta'". The proof is fairly simple, and involves a geometric argument involving right triangles inscribed within right triangles, but that's not relevant to the question at the moment. Although, if you guys do want the proof, then I'll provide it.

In any case, however, my problem revolves around taking the indefinite integral of this function. I can take the derivative of grum with respect to theta like so:

$$\frac{d}{d\theta} n^{-1}\sqrt{(n-1)^{2}\cos^{2}(\theta) + \sin^{2}(\theta)}$$ $$\frac{-2(n-1)^{2}\cos(\theta)\sin(\theta) + 2\sin(\theta)\cos(\theta)}{2n\sqrt{(n-1)^{2}\cos^{2}(\theta) + \sin^{2}(\theta)}}$$

Which, if we multiply the denominator by 'n' and then simplify the expression, we get the nifty equation of:

$$\frac{d}{d\theta} grum_{n}(\theta) \equiv \frac{\sin(2\theta)(1 - (n-1)^{2})}{2n^{2}grum_{n}(\theta)}$$

So far, so good! However, I got stuck when I tried to take the indefinite integral of this function. I really want to learn not just what the indefinite integral is, but how to get it, and why it works. In any case, here's what I've gotten so far.

First, I draw out the constant in front of the radical, and rewrite the exponents.

$$n^{-1}\lmoustache ((n-1)^{2}\cos^{2}(\theta) + \sin^{2}(\theta))^{\frac{1}{2}}d\theta$$

Next, I rewrite $\sin^{2}(\theta)$ in the form of $1 - \cos^{2}$ and simplify the expression, which yields:

$$n^{-1}\lmoustache((n-1)^{2}\cos^{2}(\theta) - \cos^{2}(\theta) + 1)^{\frac{1}{2}}d\theta$$ $$n^{-1}\lmoustache(\cos^{2}(\theta)((n-1)^{2} - 1)) + 1)^{\frac{1}{2}}d\theta$$

Then I use the trig substitution identity $\sqrt{a^{2} + b^{2}x^{2}} = \frac{a}{b}\tan(x)$ to get the following form:

$$\frac{1}{n\sqrt{((n-1)^{2}-1) + 1)}}\lmoustache\tan(cos^{2}(\theta))d\theta$$

And... here's where I get stuck. How in hell does one calculate the indefinite integral of $\tan(cos^{2}(\theta))$? Am I even doing this the right way? In using the trigonometric substitution, I simply inserted $\cos^{2}(\theta)$ where x would have gone, but there's no guarantee that that's a valid operation.

If I could get some guidance, or even just a push in the right direction, I would be grateful. In the meantime, I'll keep working on it, and let you guys know if I make any progress on it.

Sorry for the long question, haha. I hope it was at least interesting in some small way, and I thank you very much for your time.

Thank you very much,

sincerely,

Druid.

• You can directly integrate your function in Wolfram Alpha. Unfortunately, the integral is elliptic, so it looks like there's no closed form for your integral: wolframalpha.com/input/?i=Integrate%5BSqrt%5B%28n-1%29%5E2*Sin%5Bx%5D%5E2%2BCos%5Bx%5D%5E2%5D%2Cx%5D – Alex R. Feb 10 '15 at 0:12
• I see. I don't know what an elliptic integral is, but that definitely gives me a path to follow. Let me look into it. Thank you very much, Alex! – Druid Feb 10 '15 at 0:18
• Woah. This is some deep stuff(although stuff might not be the word I'd use, haha). I'm going to mark the question as solved, as I have a feeling it's not a simple answer. I'm going to need to do some serious research on it. Thanks, Alex. – Druid Feb 10 '15 at 0:33
• Oops. Forgot to mark it as solved. – Druid Feb 10 '15 at 2:15
• Oh, wait. You weren't supplying an answer, but just giving a comment? In that case... never mind! haha. my bad. – Druid Feb 10 '15 at 2:16

$$\int \sqrt{(n-1)^{2}\cos^{2}(\theta) + \sin^{2}(\theta)} \space d\theta$$ is a known integral called "elliptic integral of the second kind" : http://mathworld.wolfram.com/EllipticIntegraloftheSecondKind.html

It cannot be expressed with a finite number of elementary functions. It can be expressed on the form of infinite series, or on a closed form referenced as a "special function".

The special functions are functions especially defined to deal with such cases. A paper for general public : https://fr.scribd.com/doc/14623310/Safari-on-the-country-of-the-Special-Functions-Safari-au-pays-des-fonctions-speciales

In the present case, the symbol used for the convenient special function is E$(x,k)$ or alternatively E$(x | m)$ with $m=k^2$ (which is a bit confusing). $$\int \sqrt{(n-1)^{2}\cos^{2}(\theta) + \sin^{2}(\theta)} \space d\theta=(n-1)\text{E}(\theta | m)+constant$$ $$m=\frac{n(n-2)}{(n-1)^2}$$

• Fascinating stuff! Thank you very much for your help, JJacquelin. I am very grateful. :D – Druid Feb 10 '15 at 22:25


text:
# Homework Help: Skydiver differential equation

1. May 24, 2010

### darryw

1. The problem statement, all variables and given/known data
the velocity of a skydiver falling to the ground is governed by:
m dv/dt = mg - kv^2

solve for v(t) with initial conditions v(0) = 0

i rearranged equation into standard form:

v' + (k/m)v^2 = g

so i got an integrating factor, mu(x) = e^integ(k/m), but does the fact that the v is squared prohibit me from using an integrating factor?

thanks
2. Relevant equations

3. The attempt at a solution
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

2. May 24, 2010

### Cyosis

Strictly a non linear differential equation doesn't prohibit you from using an integrating factor. It does however prohibit you from using the integrating factor in the way you did. You used a 'formula' for an integrating factor which was derived for linear ODEs, which does not apply in this case.

Hint: Note that the equation is separable.

3. May 24, 2010

### jackmell

No, you can't do that. Need y'+ay=b(x) for that. Surely you can take the expression:

$a\frac{dv}{dt}=G(v)$

and separate variables to get $a\frac{dv}{G(v)}=dt$.

Try that.

4. May 24, 2010

### darryw

how do you know just from looking at an equation if it is separable or not? What do you look for specifically? What is a giveaway that tells you that, nope this equation cant be separable also.
thanks

5. May 24, 2010

### Cyosis

You look whether or not you can put all v-s on one side of the equation and all t-s on the other side.

And yes this equation is separable.

6. May 24, 2010

### darryw

m dv/dt = mg - kv^2

dv/dt + kv^2 / m = g

dv + v^2 = mg/k dt

its separated but it looks sort of weird to me??
also, can u please clarify this: that k,g and m are all constants, right? thanks

7. May 24, 2010

### darryw

but if this is correct i will proceed, thank u.

8. May 24, 2010

### Cyosis

No that is not correct. Compare your equation to the one in post #3.

9. May 24, 2010

### darryw

i glossed over post 3 because i wasnt sure where the a comes from, and why the caps G.
Is the a acceleration?
thanks

10. May 24, 2010

### Cyosis

'a' is just a constant and with G(v) he means a function that depends on v. He might as well have called it f(v) or g(v) etc.

11. May 24, 2010

### jackmell

Sorry you're having problems with my notation. You have got to review Separation of Variables today in some elementary DE text book. Tons in the library. You need to get the DE in the form $A(x)dx+B(y)dy=0$ to separate the variables. You have:

$mdv=(mg-kv^2)dt$

now I bet you can put that into the form $A(v)dv=B(t)dt$ and thus separated. Wouldn't that just be $\frac{m}{mg-kv^2}dv=dt$

12. May 24, 2010

### darryw

actually i do understand what you are doing, but i think all the constants are confusing me.

so, just to clarify: m, g and k are all constants right?

Also I was trying to get all the constants to go with "dt", but am i right in saying that it doesnt matter what side of the equation i put the constants?

(i was trying to get it so that equations was v^2 dv = "something" dt and it was really difficult.

So i now have:

m/mg-kv^2 dv = (1)dt

integrate both sides...

so, because m,g and k are all constants i can take them out of the integral right?

m/(mg-k) integ 1/(v^2) = (1)dt

m/(mg-k) * -(1/v) = t+c

m/(mg-k)v = t+c

v = (t/m) (mg-k) + (c/m) (mg-k)

is this correct so far? thanks

13. May 25, 2010

### Cyosis

You really need to brush up on basic algebraic manipulations.

What you're claiming here is that $mg-kv^2=(mg-k)v^2$. I suggest you work out the brackets so you can see it's wrong.

14. May 26, 2010

### darryw

i have the following equality, that i need to now integrate (correctly)

integ: m/(mg-kv^2) dv = integ :(1)dt

heres how i integrated LHS...

u = mg-kv^2
du = -2kv

dv = m
v = v

integ: m/(mg-kv^2) dv = mg-kv^2(v) - integ (v)(-2kv)

................................= mg-kv^2(v) - (-2)((1/3)(v^3)

simplify..

................................ = mgv-kv^3 +(2v^3/3)

then add the RHS integration

mgv-kv^3 +(2v^3/3) = t + c

is this correct so far?

15. May 26, 2010

### Cyosis

Wrong if $u=mg-kv^2$ then $du=-2kvdv$

What are you doing here?

It seems that you have tried to do something like partial integration. Notice how $mg-v^2$ is in the denominator on the left side and suddenly in the numerator on the right side.. I have no idea how you managed to do that, but I can tell you it is wrong.

As a result all other steps are wrong as well.

This is the only correct part of your post.

I suggest you use $1-v^2=(1-v)(1+v)$ in combination with partial fractions.

Last edited: May 26, 2010
16. May 26, 2010

### jackmell

May I offer a modern approach which I believe may help Darry but is controversial. I do realize I'm new here and don't wish to cause trouble. Let me know.

You have:

$\frac{dv}{mg-kv^2}=dt$

and you know the right side is just t+c and you want to integrate the left side. Here comes the controversial part:

First enter the equation in Wolfram Alpha:

Wolfram Alpha: Integrate[m/(m g-k v^2),v]

Now that gives you an answer in terms of Arctanh. So immediately, you go to your Calculus text and find "Integrals yielding Inverse Hyperbolic Functions" and I find the one that says:

$\int \frac{du}{a^2-u^2}=\begin{cases} 1/a \tanh^{-1} u/a+c &|u|<a \\ 1/a \coth^{-1} u/a+c & |u|>a \end{cases}$

Now, it's not difficult to put your integral into that a^2-u^2 form which you can then integrate using the formula above. Try this approach in general when you have integration problems but always try to do it yourself first and not come to rely on a CAS to do your work for you.

Last edited: May 26, 2010
17. May 26, 2010

### sebb1e

Last edited by a moderator: Apr 25, 2017


text:
# American Institute of Mathematical Sciences

1999, 5: 35-39.

## The special Schubert calculus is real

Citation: Frank Sottile. The special Schubert calculus is real. Electronic Research Announcements, 1999, 5: 35-39.
 [1] Penka Georgieva, Aleksey Zinger. Real orientations, real Gromov-Witten theory, and real enumerative geometry. Electronic Research Announcements, 2017, 24: 87-99. doi: 10.3934/era.2017.24.010 [2] Rafał Kamocki, Marek Majewski. On the continuous dependence of solutions to a fractional Dirichlet problem. The case of saddle points. Discrete and Continuous Dynamical Systems - B, 2014, 19 (8) : 2557-2568. doi: 10.3934/dcdsb.2014.19.2557 [3] Gabriella Pinzari. Global Kolmogorov tori in the planetary $\boldsymbol N$-body problem. Announcement of result. Electronic Research Announcements, 2015, 22: 55-75. doi: 10.3934/era.2015.22.55 [4] Hayato Ushijima-Mwesigwa, MD Zadid Khan, Mashrur A. Chowdhury, Ilya Safro. Optimal Placement of wireless charging lanes in road networks. Journal of Industrial and Management Optimization, 2021, 17 (3) : 1315-1341. doi: 10.3934/jimo.2020023 [5] Annalisa Iuorio, Christian Kuehn, Peter Szmolyan. Geometry and numerical continuation of multiscale orbits in a nonconvex variational problem. Discrete and Continuous Dynamical Systems - S, 2020, 13 (4) : 1269-1290. doi: 10.3934/dcdss.2020073 [6] Ioan Bucataru, Matias F. Dahl. Semi-basic 1-forms and Helmholtz conditions for the inverse problem of the calculus of variations. Journal of Geometric Mechanics, 2009, 1 (2) : 159-180. doi: 10.3934/jgm.2009.1.159 [7] Gisella Croce, Nikos Katzourakis, Giovanni Pisante. $\mathcal{D}$-solutions to the system of vectorial Calculus of Variations in $L^∞$ via the singular value problem. Discrete and Continuous Dynamical Systems, 2017, 37 (12) : 6165-6181. doi: 10.3934/dcds.2017266 [8] Ivar Ekeland. From Frank Ramsey to René Thom: A classical problem in the calculus of variations leading to an implicit differential equation. Discrete and Continuous Dynamical Systems, 2010, 28 (3) : 1101-1119. doi: 10.3934/dcds.2010.28.1101 [9] Hema K. Achanta, Soura Dasgupta, Raghuraman Mudumbai, Weiyu Xu, Zhi Ding. Optimum sensor placement for localization of a hazardous source under log normal shadowing. Numerical Algebra, Control and Optimization, 2019, 9 (3) : 361-382. doi: 10.3934/naco.2019024 [10] B. Cantó, C. Coll, A. Herrero, E. Sánchez, N. Thome. Pole-assignment of discrete time-delay systems with symmetries. Discrete and Continuous Dynamical Systems - B, 2006, 6 (3) : 641-649. doi: 10.3934/dcdsb.2006.6.641 [11] Daniel Lear, David N. Reynolds, Roman Shvydkoy. Grassmannian reduction of cucker-smale systems and dynamical opinion games. Discrete and Continuous Dynamical Systems, 2021, 41 (12) : 5765-5787. doi: 10.3934/dcds.2021095 [12] Vaibhav Mehandiratta, Mani Mehra, Günter Leugering. Existence results and stability analysis for a nonlinear fractional boundary value problem on a circular ring with an attached edge : A study of fractional calculus on metric graph. Networks and Heterogeneous Media, 2021, 16 (2) : 155-185. doi: 10.3934/nhm.2021003 [13] Fabrizio Colombo, Graziano Gentili, Irene Sabadini and Daniele C. Struppa. A functional calculus in a noncommutative setting. Electronic Research Announcements, 2007, 14: 60-68. doi: 10.3934/era.2007.14.60 [14] Sriram Nagaraj. Optimization and learning with nonlocal calculus. Foundations of Data Science, 2022, 4 (3) : 323-353. doi: 10.3934/fods.2022009 [15] Lixuan Zhang, Xuefei Yang. On pole assignment of high-order discrete-time linear systems with multiple state and input delays. Discrete and Continuous Dynamical Systems - S, 2022, 15 (11) : 3351-3368. doi: 10.3934/dcdss.2022022 [16] Gokhan Yener, Ibrahim Emiroglu. A q-analogue of the multiplicative calculus: Q-multiplicative calculus. Discrete and Continuous Dynamical Systems - S, 2015, 8 (6) : 1435-1450. doi: 10.3934/dcdss.2015.8.1435 [17] Bernard Dacorogna, Giovanni Pisante, Ana Margarida Ribeiro. On non quasiconvex problems of the calculus of variations. Discrete and Continuous Dynamical Systems, 2005, 13 (4) : 961-983. doi: 10.3934/dcds.2005.13.961 [18] Elisa Gorla, Maike Massierer. Index calculus in the trace zero variety. Advances in Mathematics of Communications, 2015, 9 (4) : 515-539. doi: 10.3934/amc.2015.9.515 [19] Daniel Faraco, Jan Kristensen. Compactness versus regularity in the calculus of variations. Discrete and Continuous Dynamical Systems - B, 2012, 17 (2) : 473-485. doi: 10.3934/dcdsb.2012.17.473 [20] Vladimir V. Kisil. Mobius transformations and monogenic functional calculus. Electronic Research Announcements, 1996, 2: 26-33.

2020 Impact Factor: 0.929


text:
# How can I delete a file marked as backup item?

I'm trying to delete a file, but I get a message from Trash saying:
"The operation can’t be completed because backup items can’t be modified."

What does that mean and how can I delete it?

-

According to this thread at Apple, this is a bug. This means it will hopefully be fixed in a coming update to OS X.

In the meantime, you have to relaunch the Finder, which you can do either through force quit (⎇⌘⎋, or through the  menu), or by less violent means by quitting it normally, which you must first activate through the following command issued in the Terminal:

defaults write com.apple.Finder QuitMenuItem 1

-
Thanks, as suggested in the thread rebooting worked. –  Louis Nov 20 '11 at 17:03
You could always do killall Finder in the Terminal –  segiddins Apr 3 '13 at 2:42
Option-click on the Finder's Dock icon and choose Relaunch Finder. –  Kirk McElhearn Apr 3 '13 at 7:20

## The root of the cause

Time Machine backups are protected at kernel level -- on a verbose boot it's possible to spot in the first screenful of text a TMSafetyNet.kext extension being loaded.

This ensures the integrity of your backups. Access control provisions are applied via a kernel extension located at /System/Library/Extensions/TMSafetyNet.kext

## Deleting in Time Machine

The officially sanctioned method for deleting items from a specific backup or all of them is to locate the item in the "in space" Time Machine view and selecting the appropriate delete option from the contextual menu or the Action button in the toolbar.

The ability to move backups to the Trash added in Lion is not only comparatively more buggy, but designed to operate on entire snapshots, i.e. the folders named with the time the backup was created which in turn contain a directory for each included volume.

## Deleting from commandline (more flexible, more control)

There exists a a helper program (commandline binary) at...

/System/Library/Extensions/TMSafetyNet.kext/Contents/MacOS/bypass

...which allows you to supply a command and argument to completely bypass the access restrictions.

In Lion you run:

sudo /System/Library/Extensions/TMSafetyNet.kext/Contents/MacOS/bypass rm -rfv /Volumes/[disk]/Backups.backupdb/[path]

In Mountain Lion bypass moved to the Helpers directory:

sudo /System/Library/Extensions/TMSafetyNet.kext/Helpers/bypass rm -rfv /Volumes/[disk]/Backups.backupdb/[path]

Credits:

[1] - Michael Rushanan on TMSafetyNet bypass
[2] - A brief explanation of the Time Machine Safety Net by Joel Cowgill
[3] - Similar question on SuperUser

-
Yay, this worked indeed! Entering Time Machine and deleting the file from there was not an option since this backup is linked to another user. However, after deleting the *.exe files using your solution, the Finder would still show them as present. I had to kill the Finder process for the displayed content to refresh. –  gentmatt Apr 1 '13 at 19:35
This is now moved to: "/System/Library/Extensions/TMSafetyNet.kext/Helpers/bypass", and otherwise works as advertised. –  David Pisoni Jul 22 '14 at 5:28


text:
# Why is market equilibrium pareto efficient?

Let us assume that the current price $$P$$ is lower than the 'equilibrium price' $$P^\star$$ so that $$Q$$ is lower than $$Q^\star$$. If we move from this combination towards the equilibrium one, it may be the case that the producer surplus decreases. I understand that the total surplus (consumers+producers) increases, but it is not clear to me why producers should be willing to reduce their surplus. So it looks like to me that there is not pareto improvement in moving from $$(P,Q)$$ to ($$P^\star$$,$$Q^\star$$), in that consumers are better off but producers may be worse off. What is wrong with my reasoning? Could you help me with this, please?

• As pointed out in Kenny LJ's answer, you are using the wrong definition of Pareto efficiency (which requires there to be no universal improvment over $(P^*,Q^*)$, not that there is no other such $(P,Q)$. But, putting that aside, your example also isn't very well thought-through. Indeed, it is perfectly possible for there the be a Pareto improvement in moving from $(P,Q)$ to $(P^*,Q^*)$. For example, if $P=0$ and $Q=0$ then both producer surplus and consumer surplus are zero and almost anything would be a Pareto improvement! – Ubiquitous Sep 26 '19 at 13:02
• That is why I wrote: 'it MAY be the case' – Alchemy Sep 26 '19 at 13:40
• According to the definition you gave it may be the case that $(P,Q)$ is still Pareto efficient – Alchemy Sep 26 '19 at 13:43


text:
×

# Minimum Value

I recently solved a trigonometric question which asked for the minimum value of the $$(\sin\theta + \csc\theta)^{2}+(\cos\theta +\sec\theta)^{2}$$.I found there ar two answers, which one of them is correct?

A)8 B)9

Note by Puneet Pinku
11 months, 1 week ago

Sort by:

Hint: Expand and simplify the expression by using $$\sin^2 A + \cos^2 A = 1$$. Then apply double angle formula $$\sin(2A) = 2\sin A \cos A$$.

- 11 months, 1 week ago

I believe that you didn't check the conditions under which we could apply arithmetic mean - geometric mean.

Staff - 11 months, 1 week ago


text:
# Interpretting LASSO variable trace plots

I am new to the glmnet package, and I am still unsure of how to interpret the results. Could anyone please help me read the following trace plot?

The graph was obtaining by running the following:

library(glmnet)
return <- matrix(ret.ff.zoo[which(index(ret.ff.zoo)==beta.df$date[2]), ]) data <- matrix(unlist(beta.df[which(beta.df$date==beta.df$date[2]), ][ ,-1]), ncol=num.factors) model <- cv.glmnet(data, return, standardize=TRUE) op <- par(mfrow=c(1, 2)) plot(model$glmnet.fit, "norm",   label=TRUE)
plot(model\$glmnet.fit, "lambda", label=TRUE)
par(op)


text:
Tag Info

Hot answers tagged modeling

7

To recover the Black-Scholes pricing equation, you should first express the standard normal cdf in terms of its characteristic function analogous to the Heston solution: $$N(x) = \frac{1}{2} - \frac{1}{\pi} \int_0^{\infty} Re [\frac{e^{-i\phi x} f(\phi)}{i\phi}] d\phi$$ where $f(\phi)$ is the characteristic function of the standard normal distribution: $$... 5 If at first you don't have a model at all, then geometric Brownian motion is not bad. As others before me said: log-returns are normally distributed in this model. This is debatable and there are times and markets where this is not true. There is more than enough research about this. But why is a model based on Brownian motion not that bad? The reason is ... 4 You can use \sin or \cos to model seasonality. If all you have is a calculator it might be the most practical way. 4 One can use the Karhunen–Loève expansion to approximate a trajectory of a Wiener Process, which can be used to model the evolvement of returns in time. (http://en.wikipedia.org/wiki/Karhunen%E2%80%93Lo%C3%A8ve_theorem#The_Wiener_process) Though the Karhunen–Loève expansion has theoretical advantages to other variants to generate a trajectory of a Wiener ... 4 Brownian motion - because it is simple, and results in intuitive closed form solutions, and it's not a terrible description of asset prices, especially when employed in high-frequency event time. Geometric - because the returns compound, and equities cannot go below zero due to the fact that they are limited liability corporations There are many, many ... 3 To provide a straight forward answer: It is not a good model. It never was, it never will be. Until we all do not come up with a better model that provides better modeling accuracy while it is equally intuitive and makes similarly simplifying assumptions the BS model with its geometric brownian motion component is here to stay. It actually does not matter ... 3 To solve the expectation directly, you need to remember that a density function is not the same as the probability of the event. We have, \frac{S_1}{S_0} \sim \ln \mathcal{N} \left(-\frac{\sigma^2}{2},\sigma\right), therefore, \begin{eqnarray} \mathbb{E}\left(\frac{S_1}{S_0}\right) &=& \int_{-\infty}^\infty x\, f_{\frac{S_1}{S_0}}(x)dx\\ ... 3 Fourier methods use sine and cosine functions, and are used in calculating option prices, VaR, time series analysis etc. It is an alternative process for doing many things in finance. Some links Fourier Methods in trading on StackExchange and Wiki 3 I have asked myself the very same question when I first read the book. As far as I can tell, the "scalability" condition is only imposed for technical reasons. It simplifies the subsequent proof of the Fundemental Theorem of Asset Pricing in constrained markets. There are several papers that have shown that the theorem is valid for conic constraints. ... 2 Trigonometric functions show up in econometric models for business cycles. For example: the average length of a cycle of an AR(2) process is  k = \frac{2 \pi}{\cos^{-1}( \phi_1/ (2 \sqrt{-\phi_2}))} For an AR(2) model given by  r_t = \phi_0 + \phi_1 r_{t-1} + \phi_2 r_{t-2} + a_t with complex roots, \phi_1^2 + 4\phi_2 <0  2 When you do Monte Carlo simulation and would like to draw sample from the normal distribution \mathcal{N}(\mu,\sigma^2), you may use Box-Muller transform and come up with formulas using \sin and \cos. 2 First of all, GNP and GDP are economic time series and they are not economic model. Secondly, you can also get these time series with different frequency, as quarterly data, avalaible on OECD website. In the case you need for lower frequency data you can get it by interpolation (as, for instance, the cubic spline interpolation); This is the Matlab tutorial ... 2 These games are usually won by luck. If there is no fee for buying stocks I'd diversify, i.e. buy many different stocks, to get stable returns. After some weeks you'll see which profit you'll need to beat. Depending on the rules if options are allowed you could invest in highly leveraged derivatives and hope you win. As there is no point not to try to win I ... 2 In Andersen & Piterbarg's book, LGM is referred to as "The Hagan and Woodward Parameterization" and treated separately in 11.3.2.6. The fact that this practice-oriented book devotes a couple of pages would imply LGM is of practical use in the real market. I know two large software providers adopt LGM. 2 Basically, Black-Scholes is an "industry standard" formula. It is widely used by practitioners and usually augmented with extra specifications or intuition. It has a closed form solution, which is rare in option pricing models. It is also relative to simple to understand. Otherwise, you usually need to rely on Monte Carlo simulation or some other way. And ... 2 I am also not aware of any papers in this area. But having developed many such models, I can list the important steps: Decide on the target variable: usual choices are historical default data, agency ratings and expert rankings Create a sample containing the possible predictors Reduce the list with the help of some expert, e.g. exclude all the predictors ... 2 Most of the papers concern CDS spreads which you will need to convert to a PD. Paper using country specific fundamentals: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2517018 This paper uses leverage: http://papers.ssrn.com/sol3/papers.cfm?abstract_id=2361872 Another one that decomposes them against peer groups: ... 2 This is what Moody's does to calculate default probabilities, but I don't believe they give a whole lot of detail on their exact methodology because they sell their models as software. I quickly found this which gives a brief overview: http://www.moodysanalytics.com/~/media/Brochures/Enterprise-Risk-Solutions/RiskCalc/RiskCalcPlus-Fact-Sheet.ashx Edit- ... 1 Bloomberg has a Default Risk model, which is similar to what you are querying. You can see a screenshot in this PDF. There you can also see the kind of variables they use. You can access it by typing DRSK at the CDS screen is Bloomberg. (If the screenshot in the PDF is not clear enough, let me know and I can post one with better resolution from Bbg) This ... 1 Did you try rmgarch package of R ? http://cran.r-project.org/web/packages/rmgarch/index.html http://unstarched.net/r-examples/rmgarch/mgarch-comparison-using-the-hong-li-misspecification-test/ 1 Given that other corporate events are reasonably modelled through regression models (compare The Detection of Earnings Manipulation I would try for using an regression approach. I believe a more recent and related paper has been published but I don't seem to find it at this time. Edit: and now I did - Earnings Manipulation and Expected Returns That said, ... 1 I agree with the previous statement that this is more stats related than anything else (it's not quant finance). But it's still a great question! This sounds awfully similar to linear regression testing with multiple predictor variables; you're basically doing it in a "monte carlo" fashion :) Depending on how your data is formatted, you could enter it into ... 1 Choose the most robust (or insensitive) strategy. You are right that the best strategy might be overfit. So look at your parameter space and focus on the area where profitability, for example, changes least when you change the parameter value. Here is a 1D example: The most profitable strategy is that single point that unfortunately leaves no room for ... 1 Number one, the central limit theorem means a lot of things that may not be normal end up looking normal when lots of little 'experiments' or impacts are added up. Number 2, when dealing with finance you need a model that seems plausible. An arithmetic Brownian motion could go negative, but stock prices can't. On the other hand, it seems quite plausible ... 1 The normal distribution is very powerful distribution: By the central limit theorem, the mean of any large sample always converges to the normal distribution Considering the most simplistic Binomial Tree model, where price goes only up or down each period, it can be shown that the distribution of returns of this tree converges to Normal for infinetesimal ... 1 In terms of end-user applications, all trading desks and middle office places I know, use either their own proprietary or expensive third party sources. On the other hand there exists a c++ library called QuantLib that is well known among real world practitioners, probably because it contains several routines that are well tested and robust. Often pieces of ... 1 If S_t = S_0 e^{(\mu-\sigma^2/2)t + \sigma W_t}, we can compute$$\mathbb{E}^Q\left[S_T\middle\vert \mathcal{F}_0\right] = S_0 e^{r T} = \text{forward price of } S_T \text { at time } 0.  To show the details, \$\mathbb{E}^Q\left[S_T\middle\vert \mathcal{F}_0\right] = S_0 e^{(r-\sigma^2/2) T} \mathbb{E}^Q\left[e^{\sigma W_T} \middle\vert ...

1

If you mean by fat tails just fatter tails than the gaussian distribtuion, i.e. a distribution with finite variance, for instance the Student's t-distribution has fatter tails than the normal distribution. If you mean distributions with infinite variance, you have to have a look at Lévy distribution. In a first attempt you could just substitute the standard ...

1

Trigonometric functions are WAVE phenomena. As such, they are best used to model so-called periodic functions, that is, functions with cycles of a fixed period in length. That's why they are good for modelling, seasonal, annual, "blue moon" (once every two and half years), or other functions with set "periods."

1

Solving some heat/diffusion equations under certain conditions needs trigonometric functions. Black-Scholes reduces to a heat/diffusion equation by a change of variables.

Only top voted, non community-wiki answers of a minimum length are eligible


text:
Read Graphviz file .dot in R
0
0
Entering edit mode
@pleaseteachmehowtodoit-10908
Last seen 6.3 years ago

I am trying to read this GraphViz file .dot in R and obtain a matrix with relevant information. After reading the file I will work on the matrix to obtain the output in specific format (I've worked a bit with matrices in R before and that is work I want and have to do). Instead of trying to parse and analyze the file from scratch, I'm trying to use an R package to speed it up.

The file was originally a .glm file GridLab-D converted through a ruby script to DOT file by Michael A. Cohen as he expains here. I am interested in obtaining parameters, especially "pos" for every element.

The code I've tried is:

    library(Rgraphviz)
g<-agread("R3-12.47-2.dot")
b<-str(g)

c<-lapply(g@AgNode, function(i) i@center)

From this output I can't obtain the information from the "pos" field.

I'm willing to learn, read, look and work a new solution, hopefully with some of your expertise it will be faster.

I'm open to other packages too if you think that it could be a better solution for this particular case.

Thanks in advance.

Note: RStudio version 0.99.902

r rstudio rgraphviz graphviz .dot • 1.5k views
ADD COMMENT

Login before adding your answer.

Traffic: 524 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6


text:
related.tex 23 KB
 Kim Nguyễn committed Jul 09, 2019 1 2 3 4 \kim{ I don't really know about these:\\ Occurrence typing is for variables in TypeScript, also paths in Flow. STRESS THE USE OF INTERSECTIONS AND UNIONS. ACTUALLY SPEAK OF UNION AND NEGATION (UNION FOR ALTERNATIVES, NEGATION FOR TYPING THE ELSE BRANCH AND THEREFORE WE GET INTERSECTION FOR FREE) extend to selectors, logical connectives, paths, and user  Giuseppe Castagna committed Jul 03, 2019 5 6 7 8 9 10 defined predicates. [IMPORTANT: check the differences with what we do here] State what we capture already, for instance lists since we have product and recursive types.  Kim Nguyễn committed Jul 09, 2019 11 }  Kim Nguyễn committed Feb 26, 2020 12 13 14 \kim{Need to clean-up and insert at the right place. }  Giuseppe Castagna committed Jul 09, 2019 15   Giuseppe Castagna committed Jul 10, 2019 16   Kim Nguyễn committed Jul 09, 2019 17 18 19 Occurrence typing was introduced by \citet{THF08} and further advanced in \cite{THF10} in the context of the Typed Racket language. This latter work in particular is close to ours, with some key differences.  Giuseppe Castagna committed Jul 10, 2019 20 \citet{THF10} define $\lambda_{\textit{TR}}$, a core calculus for  Giuseppe Castagna committed Sep 20, 2021 21 Typed Racket. In this language types are annotated by two logical  Giuseppe Castagna committed Jul 10, 2019 22 propositions that record the type of the input depending on the  Kim Nguyễn committed Jul 09, 2019 23 24 (Boolean) value of the output. For instance, the type of the {\tt number?} function states that when the output is {\tt true}, then  Giuseppe Castagna committed Sep 20, 2021 25 the argument has type {\tt Number}, and when the output is {\tt false}, the  Kim Nguyễn committed Jul 09, 2019 26 argument does not. Such information is used selectively  Giuseppe Castagna committed Jul 10, 2019 27 in the then'' and else'' branches of a test. One area where their  Giuseppe Castagna committed Jul 10, 2019 28 work goes further than ours is that the type information also flows  Kim Nguyễn committed Jul 09, 2019 29 outside of the tests to the surrounding context. In contrast, our type  Giuseppe Castagna committed Jul 10, 2019 30 system only refines the type of variables strictly in the branches of a  Giuseppe Castagna committed Sep 20, 2021 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 test. \rev{This is particularly beneficial when typing functions since the logical propositions of Tobin-Hochstadt and Felleisen can record dependencies on expressions other than the input of a function. Consider for instance the following example (due to~\cite{kent19phd}) in JavaScript \code{function is-y-a-number(x) \{ return(typeof(y)\,===\,"number") \}} which defines a functions that disregards its argument and returns whether the variable \code{y} is an integer or not.\footnote{Although such a function may appear nonsensical, Kent~\cite{kent19phd} argues that it corresponds a programming patter that may occurr in Typed Racked due to the the expansion of some sophisticated macro definitions.} While our approach cannot deduce for this function but the type $\Any\to\Bool$, the logical approach of Tobin-Hochstadt and Felleisen can record in the type of \code{is-y-a-number} that fact when the function returns \texttt{true} then \code{y} is a number, and the opposite when it returns \texttt{false}. In our approach, the only possibility to track such a dependency is that the variable \code{y} is the parameter of an outer function to which our analysis could give an overloaded type by splitting the type \texttt{Any} of \texttt{y} into \texttt{Number} and \texttt{$\neg$Number}. Under the hypothesis of \texttt{y} being of type \texttt{Number} the type inferred for \code{is-y-a-number} will then be $\Any\to\True$, and $\Any\to\False$ otherwise, thus capturing the wanted dependency. % Although the approach of using logical proposition has the undeniable advantage over ours of providing more a flow sensitive analysis, we believe that using semantic subtyping as a foundation as we do has also several merits over the logical proposition approach. }%%%rev First, in our case, type  Kim Nguyễn committed Jul 09, 2019 62 63 predicates are not built-in. A user may define any type predicate she wishes by using an overloaded function, as we have shown in  Giuseppe Castagna committed Sep 20, 2021 64 65 66 Section~\ref{sec:practical}. Second, in our setting, {\em types\/} play the role of formulæ. Using set-theoretic types, we can express the complex types of variables without resorting to a meta-logic. This  Kim Nguyễn committed Jul 10, 2019 67 allows us to type all but two of their key examples (the notable  Giuseppe Castagna committed Sep 20, 2021 68 69 70 71 72 73 74 exceptions being Example~9 and 14 in their paper, which use the propagation of type information outside of the branches of a test). While Typed Racket supports structured data types such as pairs and records only unions of such types can be expressed at the level of types, and even for those, subtyping is handled axiomatically. For instance, for pairs, the subtyping rule presented in \cite{THF10} is unable to deduce that  Kim Nguyễn committed Feb 26, 2020 75 $(\texttt{number}\times(\texttt{number}\cup\texttt{bool}))\cup  Giuseppe Castagna committed Sep 20, 2021 76 77 78 79 80 (\texttt{bool}\times (\texttt{number}\cup\texttt{bool}))$ is a subtype of (and actually equal to) $((\texttt{number}\cup\texttt{bool})\times\texttt{number})\cup ((\texttt{number}\cup\texttt{bool})\times\texttt{bool})$ (and likewise for other type constructors combined with union types). For record  Kim Nguyễn committed Feb 26, 2020 81 types, we also type precisely the deletion of labels, which, as far as  Giuseppe Castagna committed Feb 26, 2020 82 83 we know no other system can do. On the other hand, the propagation of logical properties defined in \cite{THF10} is a powerful tool, that  Kim Nguyễn committed Feb 26, 2020 84 85 86 87 88 can be extended to cope with sophisticated language features such as the multi-method dispatch of the Closure language \cite{Bonn16}. \kim{Remove or merge : Also, while they  Kim Nguyễn committed Jul 09, 2019 89 90 91 extend their core calculus with pairs, they only provide a simple {\tt cons?} predicate that allows them to test whether some value is a pair. It is therefore unclear whether their systems allows one to  Giuseppe Castagna committed Jul 10, 2019 92 write predicates over list types (e.g., test whether the input  Kim Nguyễn committed Jul 09, 2019 93 is a list of integers), which we can easily do thanks to our support  Kim Nguyễn committed Feb 26, 2020 94 for recursive types.}  Giuseppe Castagna committed Jul 11, 2019 95 96 97 %Further, as far as we know, a code analysis such as the %one performed by Code 8 for extensible records is not handled by the %current typing systems.  Kim Nguyễn committed Jul 10, 2019 98   Giuseppe Castagna committed Sep 15, 2021 99 100 101  \rev{%%% For what concerns the first work by~\citet{THF08} it is interesting to  Giuseppe Castagna committed Sep 15, 2021 102 compare it with our work because the comparison shows two rather  Giuseppe Castagna committed Sep 15, 2021 103 different approaches to deal with the property of type  Giuseppe Castagna committed Sep 15, 2021 104 preservation. \citet{THF08} define a first type system that does not  Giuseppe Castagna committed Sep 15, 2021 105 106 satisfy type-preservation. The reason for that is that this first type system checks all the branches of a type-case expression,  Giuseppe Castagna committed Sep 15, 2021 107 108 109 110 111 112 113 114 115 116 117 independently from whether they are selectable or not; this may result in a well-typed expression to reduce to an expression that is not well-typed because it contains a type-case expression with a branch that, due to the reduction, became both non-selectable and ill-typed (see \cite[Section 3.3]{THF08}). To obviate this problem they introduce a \emph{second} type system that extends the previous one with some auxiliary typing rules that type type-case expressions by skipping the typing of non-selectable branches. They use this second type system only to prove type preservation and obtain, thus, the soundness of their type system. In our work, instead, we prefer to start directly with a system that satisfies type preservation. Our  Giuseppe Castagna committed Sep 15, 2021 118 system does not have the problem of the first system of~\cite{THF08}  Giuseppe Castagna committed Sep 15, 2021 119 thanks to the  Giuseppe Castagna committed Sep 15, 2021 120 presence of the \Rule{Efq} rule, that we included for that very purpose,  Giuseppe Castagna committed Sep 15, 2021 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 that is, to skip non-selectable branches during typing. The choice of one or the other approach is mostly a matter of taste and, in this specific case, boils down to deciding whether some typing problems must be signaled at compile time by an error or a warning. The approach of~\citet{THF08} ensures that every subexpression of a program is well-typed and, if not, it generates a type-error. Our approach allows some subexpressions of a program to be ill-typed, but only if they occur in dead branches of type-cases: in that case any reasonable implementation would flag a warning to signal the presence of the dead branches. The very same reasons that explain the presence in our system of \Rule{Eqf}, explain why from the beginning we included in our system the typing rule \Rule{Abs-} that deduces negated arrow types: we wanted a system that satisfied type preservation (albeit, for a parallel reduction: cf: \Appendix\ref{app:parallel}). We then defined an algorithmic system that is not \emph{complete} with respect to the type-system but from which it inherits its soundness. Of course, we could have proceeded as~\citet{THF08} did: start directly with a type-system corresponding to the algorithm (i.e., omit the rule \Rule{Abs-}) and later extend this system with the rule to infer negated arrows, the only purpose of this extension being to prove type preservation. We preferred not to, not only because we favor type preserving systems, but also because in this way we were able to characterize different subsystems that are complete with respect to the algorithmic system, thus exploring  Giuseppe Castagna committed Sep 15, 2021 144 different language designs and arguing about their usefulness.  Giuseppe Castagna committed Sep 15, 2021 145 146 }%%%rev  Giuseppe Castagna committed Sep 20, 2021 147 148 149 150  \rev{%%%  Giuseppe Castagna committed Sep 21, 2021 151 152 153 Highly related to our work is Andrew M.\ Kent's PhD.\ dissertation~\cite{kent19phd}, in particular its Chapter 5 whose title is A set-theoretic foundation for occurrence typing'' where he endows the logical techniques of~\cite{THF10} with the set-theoretic types of semantic  Giuseppe Castagna committed Sep 21, 2021 154 subtyping~\cite{Frisch2008}. Kent's work builds on the approach  Giuseppe Castagna committed Sep 21, 2021 155 156 developed for Typed Racket that, as recalled above, consists in enriching the types of the expressions with information to track under which hypotheses an expression  Giuseppe Castagna committed Sep 21, 2021 157 158 159 160 161 162 163 164 165 166 167 168 169 170 returns false or not (it considers every non false value to be truthy''). This tracking is performed by recording in the type of the expression two logical propositions that hold when the expression evaluates to false or not, respectively. The work in~\citet[Chapter 5]{kent19phd} uses set-theoretic types to express type predicates (a predicate that holds only for a type $t$ has type $p:(t\to\texttt{True})\land(\neg t\to\texttt{False})$) as well as to express in a more compact (and, sometimes, more precise) way the types of several built-in Typed Racket functions. It also uses the properties of set-theoretic types to deduce the logical types (i.e., the propositions that hold when an expressions produces \texttt{false} or not) of arguments of function applications. To do that it defines a type operator called \emph{function application inversion}, that determines the largest subset of the domain of a function for which an  Giuseppe Castagna committed Sep 21, 2021 171 172 application yields a result of a given type $t$, and then uses it for the special cases when the type $t$ is either \texttt{False} or \texttt{$\lnot$False} so  Giuseppe Castagna committed Sep 21, 2021 173 174 as to determine the logical type of the argument. For instance, this operator can be used to deduce that if the application \texttt{boolean?\,x}  Giuseppe Castagna committed Sep 21, 2021 175 yields false, then the logical proposition \texttt{x${\in}\neg$Bool} holds true. The definition  Giuseppe Castagna committed Sep 21, 2021 176 of our \emph{worra} operator that we gave in equation~\eqref{worra} is, in  Giuseppe Castagna committed Sep 21, 2021 177 178 its spirit, the same as Kent's \emph{function application inversion} operator (more precisely, the same as the operator \textsf{pred} Kent defines in Figure  Giuseppe Castagna committed Sep 21, 2021 179 180 181 182 183 5.7 of his dissertation), even though the two operators were defined independently from each other. The exact definitions however are slightly different, since the algorithm given in~\citet[Figure 5.2]{kent19phd} for \emph{function application inversion} works only for functions whose type is an intersection of arrows, whereas our definition  Giuseppe Castagna committed Sep 21, 2021 184 of worra, given in~\eqref{worralgo}, works for any function, in  Giuseppe Castagna committed Sep 21, 2021 185 186 187 188 189 190 particular, for functions that have a union type, too. The main difference of Kent's approach with respect to ours is that, since it builds on the logical propositions approach, then it focus the use of set-theoretic types and of the worra (or application inversion) operator to determine when an expression yields a result of type \texttt{False} or \texttt{$\lnot$False}. We have instead a more  Giuseppe Castagna committed Sep 21, 2021 191 holistic approach since, not only our analysis strives to infer type  Giuseppe Castagna committed Sep 21, 2021 192 193 194 information by analyzing all types of results (and not just \texttt{False} or \texttt{$\lnot$False}), but also it tries to perform this analysis for all possible expressions (and not just for a  Giuseppe Castagna committed Sep 22, 2021 195 196 restricted set of expressions). For instance, we use the operator worra also to refine the type of the function in an application (see  Giuseppe Castagna committed Sep 23, 2021 197 discussion in Section~\ref{sec:ideas}) while in Kent's approach  Giuseppe Castagna committed Sep 21, 2021 198 199 200 the analysis of an application \texttt{f\,x} refines the properties of the argument \texttt{x} but not of the function \texttt{f} (as our approach does); and when such an application is the argument of a type  Giuseppe Castagna committed Sep 22, 2021 201 test, such as in \texttt{number?\,(f\,x)}, then in Kent's approach it is no longer possible  Giuseppe Castagna committed Sep 21, 2021 202 to refine the information on the argument \texttt{x}. The latter is  Giuseppe Castagna committed Sep 22, 2021 203 204 not is a flaw of the approach but a design choice: as we explain at the end of this section, the approach of Type Racket non only focus on the inference of two logical  Giuseppe Castagna committed Sep 21, 2021 205 206 207 208 propositions according to the truthy or false value of an expression, but it does it only for a selected set of \emph{pure} expressions of the language, to cope with the possible presence of side effects (and applications do not belong to this set since they can be be impure).  Giuseppe Castagna committed Sep 23, 2021 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 That said the very fact of focusing on truthy vs.\ false results may make Kent's analysis fail even for pure Boolean tests where it would be expected to work---e.g., if a result must be true rather than just truthy. For example, consider the polymophic function that when applied to two integers returns whether they have the same parity and false otherwise: \code{have\_same\_parity:$(\Int\To\Int\To\Bool)\land(\neg\Int\To\ANY\To\False)\land(\ANY\To\neg\Int\To\False)$}. We can imagine to use this function to implicitly test whether two arguments are both integers, as in the body of the following function: }%%%rev \begin{alltt}\color{darkblue} let f = fun (x : Any) -> fun (y : Any) -> if have\_same\_parity x y is True then add x y else 0 \end{alltt} \rev{%%% While our approach can correctly deduce for this function the type $\ANY\To\ANY\To\Int$, Kent's approach fails to type check it since to type the then'' branch requires to deduce that the application \code{have\_same\_parity\,x} returns the constant function \code{true} only if \code{x} is an integer.  Giuseppe Castagna committed Sep 21, 2021 228 229 230 231 232 Finally, Kent's approach inherits all the advantages and disadvantages that the logical propositions approach has with respect to ours (e.g., flow sensitive analysis vs.\ user defined type predicates) that we already discussed at the beginning of this section.  Giuseppe Castagna committed Sep 20, 2021 233 234 235 }%%%rev  Kim Nguyễn committed Feb 28, 2020 236 237 238 239 240 Another direction of research related to ours is the one of semantic types. In particular, several attempts have been made recently to map types to first order formul\ae. In that setting, subtyping between types translates to logical implication between formul\ae. \citet{Bierman10} introduce Dminor, a data-oriented  Giuseppe Castagna committed Feb 26, 2020 241 language featuring a {\tt SELECT}-like construct over  Kim Nguyễn committed Feb 28, 2020 242 243 collections. Types are mapped to first order formulæ and an SMT-solver is then used to (try to) prove their satisfiability. The refinement  Kim Nguyễn committed Feb 26, 2020 244 245 types they present go well beyond what can be expressed with the set-theoretic types we use (as they allow almost any pure expression to occur in  Giuseppe Castagna committed Mar 03, 2020 246 types). However, the system forgoes any notion (or just characterization) of completeness  Kim Nguyễn committed Feb 28, 2020 247 and the  Giuseppe Castagna committed Jul 08, 2020 248 subtyping algorithm is largely dependent on the subtle behavior of  Giuseppe Castagna committed Feb 26, 2020 249 the SMT solver (which may timeout or give an incorrect model that  Kim Nguyễn committed Feb 26, 2020 250 251 252 253 cannot be used as a counter-example to explain the type-error). As with our work, the typing rule for the {\tt if~$e$ then $e_1$ else $e_2$} construct of Dminor refines the type of each branch by remembering that $e$  Giuseppe Castagna committed Mar 03, 2020 254 (resp. $\lnot e$) is true in $e_1$ (resp. $e_2$) and this information  Kim Nguyễn committed Feb 26, 2020 255 is not propagated to the outer context.  Giuseppe Castagna committed Feb 26, 2020 256 A similar approach is taken in \cite{Chugh12}, and extended to so-called nested refinement types. In these types, an arrow type may  Kim Nguyễn committed Feb 26, 2020 257 appear in a logical formula (where previous work only allowed formulae  Giuseppe Castagna committed Feb 26, 2020 258 on base types''). This is done in the context of a dynamic  Kim Nguyễn committed Feb 26, 2020 259 language and their approach is extended with polymorphism, dynamic  Kim Nguyễn committed Feb 28, 2020 260 dispatch and record types.  Kim Nguyễn committed Sep 22, 2021 261 262 263 264 265 266 267 268 269 270 \rev{A problem that is faced by refinement type systems is the one of propagating in the branches of a test the information learned on a \emph{sub-expression} of a tested expression. A solution e.g. choosen by \cite{OTMW04} and \cite{KF09} is to devise a meta-function that recursively explores both a type and an expression and propagates the type information on the sub-expressions. This process (called \emph{selfification} in the cited works) roughly corresponds to our $\constrf$ function (see Section~\ref{sec:typenv}). Another approach is the one followed by \cite{RKJ08} is based purely on a program transformation, namely putting the the term  Kim Nguyễn committed Sep 22, 2021 271 in \emph{administrative normal form} (\cite{F92}). Using a program  Kim Nguyễn committed Sep 22, 2021 272 273 274 275 276 277 278 279 280 281 282 283 transformation, every destructor application (function application, projection, \ldots) is given a name through a let-binding. The problem of tracking precise type information for every sub-expression is therefore reduced to the one of keeping precise typing information for a variable. While this solution seems appealing, it is not as straightforward in our case. Indeed, to retain the same degree of precision, we would need to identify alpha equivalent sub-expressions and share the same binding, something that a plain A-normalisation does not provide. } \rev{TODO Intersection + refinement} \rev{TODO refinement + gradual ?}  Kim Nguyễn committed Feb 26, 2020 284   Giuseppe Castagna committed Jul 08, 2020 285 \citet{Kent16} bridge the gap between prior work on occurrence typing  Kim Nguyễn committed Feb 28, 2020 286 287 288 289 290 291 292 293 and SMT based (sub) typing. It introduces the $\lambda_{RTR}$ core calculus, an extension of $\lambda_{TR}$ where the logical formulæ embedded in types are not limited to built-in type predicates, but accept predicates of arbitrary theories. This allows them to provide some form of dependent typing (and in particular they provide an implementation supporting bitvector and linear arithmetic theories). The cost of this expressive power in types is however paid by the programmer, who has to write logical  Giuseppe Castagna committed Mar 02, 2020 294 295 296 annotations (to help the external provers). Here, types and formul{\ae} remain segregated. Subtyping of structural'' types is checked by syntactic rules (as in \cite{THF10}) while logical formul{\ae} present  Kim Nguyễn committed Feb 28, 2020 297 in type predicates are verified by the SMT solver.  Giuseppe Castagna committed Jul 11, 2019 298 299 300  \citet{Cha2017} present the design and implementation of Flow by formalizing a relevant fragment of the language. Since they target an industrial-grade  Giuseppe Castagna committed Jul 11, 2019 301 implementation, they must account for aspects that we could afford to  Giuseppe Castagna committed Jul 11, 2019 302 303 304 305 306 307 308 postpone to future work, notably side effects and responsiveness of the type checker on very large code base. The degree of precision of their analysis is really impressive and they achieve most of what we did here and, since they perform flow analysis and use an effect system (to track mutable variables), even more. However, this results in a specific and very complex system. Their formalization includes only union types (though, Flow accepts also intersection types as  Giuseppe Castagna committed Mar 03, 2020 309 we showed in \eqref{foo2}) which are used in \emph{ad hoc} manner by the type  Giuseppe Castagna committed Jul 11, 2019 310 311 312 313 314 system, for instance to type record types. This allows Flow to perform an analysis similar to the one we did for Code 8 in Table~\ref{tab:implem}, but also has as a consequence that in some cases unions do not behave as expected. In contrast, our approach is more classic and foundational: we really define a type system, typing  Giuseppe Castagna committed Mar 03, 2020 315 rules look like classic ones and are easy to understand, unions are  Giuseppe Castagna committed Jul 11, 2019 316 317 318 unions of values (and so are intersections and negations), and the algorithmic part is---excepted for fix points---relatively simple (algorithmically Flow relies on constraint generation and  Giuseppe Castagna committed Mar 02, 2020 319 solving). This is the reason why our system seems more adapted to study  Giuseppe Castagna committed Jul 11, 2019 320 321 322 323 and understand occurrence typing and to extend it with additional features (e.g., gradual typing and polymorphism) and we are eager to test how much of their analysis we can capture and enhance by formalizing it in our system.  Giuseppe Castagna committed Jul 11, 2019 324 325 \nocite{typescript,flow}  Giuseppe Castagna committed Sep 21, 2021 326 327 \rev{%%% We end this presentation of related work with a discussion on side  Giuseppe Castagna committed Sep 22, 2021 328 effects. Although in our system we did not take into account  Giuseppe Castagna committed Sep 22, 2021 329 330 side-effects---and actually our system works because all the expressions of our language are pure---it is interesting to see how the different  Giuseppe Castagna committed Sep 22, 2021 331 332 333 approaches of occurrence typing position themselves with respect to the problem of handling side effects, since this helps to better place our work in the taxonomy of the current literature. As Sam Tobin-Hochstadt insightfully  Giuseppe Castagna committed Sep 22, 2021 334 noticed, one can distinguish the approaches that use types to reason about  Giuseppe Castagna committed Sep 22, 2021 335 the dynamic behavior of programs according to the set of expressions  Giuseppe Castagna committed Sep 22, 2021 336 337 338 339 340 341 342 343 344 345 346 that are taken into account by the analysis. In the case of occurrence typing, this set is often determined by the way impure expressions are taken into account. On one end of the spectrum lies our approach: our analysis takes into account \emph{all} expressions but, in its current formulation, it works only for pure languages. On the other end of the spectrum we find the approach of Typed Racket whose analysis reasons about a limited and predetermined set of \emph{pure} operations (all data structure accessors). Somewhere in-between lies the approach of the Flow language which, as hinted above, implements a complex effect systems to determine pure expressions. While the system presented here does not work for impure languages, we argue that its foundational nature predisposes it  Giuseppe Castagna committed Sep 22, 2021 347 348 to be adapted to handle impure expressions as well, by adopting existing solutions or proposing new ones. For instance, it is not hard to  Giuseppe Castagna committed Sep 22, 2021 349 350 351 352 353 354 modify our system so that it takes into account only a set of predetermined pure expressions, as done by Typed Racket: it suffices to modify the definition of $\Gamma \evdash e {(\neg)t} \Gamma'$ (cf.\ Section~\ref{sec:static}) so that $\Gamma'$ extends $\Gamma$ with type hypotheses for all expressions occurring in $e$ that are also in the set of predetermined pure expressions  Giuseppe Castagna committed Sep 22, 2021 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 (instead of extending it for all subexpressions of $e$, \emph{tout court}). However, such a solution would be marginally interesting since by excluding from the analysis all applications we would lose most of the advantages of our approach with respect to the one with logical propositions. Thus a more interesting solution would be to use some external static analysis tools---e.g., to graft the effect system of~\citet{Cha2017} on ours---to detect impure expressions. The idea would be to mark different occurrences of a same impure expression using different marks. These marks would essentially be used to verify the presence of type hypotheses for a given expression in a type environment $\Gamma$; the idea being that expressions with different marks are to be considered as different expressions and, therefore, would not share the same type hypothesis. For instance, consider the test $\ifty{f\,x}\Int{\,...\,}{\,...}$: if $f x$ were flagged as impure then the occurrence of $f x$ in the then'' branch would not be supposed to be of type $\Int$ since it would be typed in an environment $\Gamma$ containing a binding for an $f\,x$ expression having a mark different from the one in the then'' branch: the regular typing rules would apply for $f\, x$ in that case. This would certainly improve our analysis, but we believe that ultimately our system should not resort to external static analysis tools to detect impure expressions but, rather, it should integrate this analysis with the typing one, so as to mark \emph{only} those impure expression whose side-effects may affect the semantics of some type-cases. For instance, consider a JavaScript object \code{obj} that we modify as follows \code{obj["key"] = 3}. If the field \code{"key"} is already present in \code{obj} with type \Int{} and we do not test it more than about this type, then it is not necessary to mark different occurrences of \code{obj} with different marks, since the result of the type-case would not be changed by the assignment; the same holds true if the field is absent but type-cases do not discriminate on its presence. Otherwise, some occurrences of \code{obj} must use different marks: the analysis will determine which ones. We leave this study for future work.  Giuseppe Castagna committed Sep 21, 2021 390 }%%%rev