text:
Einstein Group

1. Jun 29, 2007

Klaus_Hoffmann

if we consider the Group structure of $$[ \pi _{ij} , g_{ab}]= \delta _{ia,jb}$$

of the Einstein equation for the momenta and metric, could we obtain its Casimir Operator, conserved quantities and so on?

2. Jun 30, 2007

shoehorn

It may be a misunderstanding on my part, by the expression you've given above makes no sense. Care to give us some context?

3. Jul 3, 2007

Klaus_Hoffmann

Yes of course , if you have the Einstein Lagrangian $$\sqrt{-g}R$$

then the Einstein Group (as my definition) would be the group that leaves the Lagrangian invariant so if you change the metric in the from $$Fg_{ab} \rightarrow h_{ab}$$ where h and g are the transformed metric under the group G so the Lagrangian remains the same but a surface term, so using NOether's theorem the infinitesimal generators of the Group will be the (physical) conserved quantities.

4. Jul 3, 2007

olgranpappy

I shoehorn may be refering to the $$\left[\;\;,\;\;\right]$$ symbol. What do you mean by that?

5. Jul 3, 2007

pervect

Staff Emeritus
The [ , ] symbol is most likely a commutator (see for instance Wald, GR, pg 18). Given two smooth vector fields v and w, a commutator defines a new vector field:

[v,w](f) = v(w(f)) - w(v(f))

Of course in this case v and w are rank 2 tensor fields, not vector fields. I believe it's sensible to talk about the commutator of a rank 2 tensor field, but I'd have to look up the details.

I would furthermore assume that the $\pi$ are cannonical momenta in the Hamiltonian formulation of GR.

Unfortunately I don't know the answer to the original poster's questions offhand - I was hoping that someone else would tackle it.

6. Jul 3, 2007

shoehorn

I'm mystified. The OP seems to be defining an algebra using a three-momentum ($\pi^{ij}$) and a four-metric ($g_{ab}$). This is obviously fruitless since, without further restrictive qualification, such an algebra can't even be defined.

What's even more confusing is that he's mixing in the Einstein-Hilbert Lagrangian with manifestly three-dimensional quantities such as the three-momentum.

7. Jul 3, 2007

pervect

Staff Emeritus

Maybe he meant the metric induced on 3-d space, but I usually see that written as $\Sigma_{ij}$.

8. Jul 3, 2007

shoehorn

Care to give me a link to where the three-metric is denoted by a capital sigma? In the literate it is almost always either g or lower case gamma. Regardless, even if he was talking about the three-metric, his expression still doesn't make any sense since any conceivable algebra would have to respect the symmetry of the three-metric and its momentum. If you look at the expression the OP gave, the rhs isn't symmetric in (i,j) or (a,b).

What's more, he should have some form of distribution on the rhs also.

9. Jul 3, 2007

pervect

Staff Emeritus
I thought Wald did, but I see now that I was confused, $\Sigma_t$ is a spacelike slice at time t, not a metric.

<snip some silly stuff I wrote earlier>

So I have to agree it's not really clear what the original question is about, but it seems to me that we can be polite about asking the OP what he had in mind.

BTW, I'm not really confident that [] represents commutators, maybe they're Poisson brackets.

Last edited: Jul 4, 2007
10. Jul 4, 2007

masudr

Surely

$$\pi_{ab} = \frac{\partial \mathcal{L}}{\partial g_{ab}}$$

which is not three-momenta, but instead the canonical momenta, given that $g_{ab}$ is the field variable.

11. Jul 4, 2007

shoehorn

When I say "three-momenta" I'm taking it as given that I'm referring to "field momentum canonically conjugate to the three-metric on a spatial slice".

12. Jul 4, 2007

masudr

Ah, my mistake. My ignorance has been publically displayed.

13. Jul 4, 2007

shoehorn

Let me clarify it even further for you. When I say "three-momentum" I use it in exactly the same sense that almost every paper I've ever seen on canonical general relativity uses.

Also, your definition of the canonical momentum

$$\pi_{ab}= \frac{\partial\mathcal{L}}{\partial g_{ab}}$$

is incorrect for several reasons.

14. Jul 4, 2007

Klaus_Hoffmann

in GR or its quantum version physicist asume that metric can be written by means of a foliation.

$$g_{ab}=dt^{2}+g_{ij}dx^{i}dx^{j}$$ hence i and j runs only over space variables x,y,z

15. Jul 4, 2007

pervect

Staff Emeritus
I've seen $$\frac{\pi^{ij}}{16 \pi} = \pi_{\mathrm{true}}^{ij} = \frac{\delta L}{\delta g_{ij}}$$

for instance, MTW pg 521

so you're very close, but apparently you won't be getting any cigar from shoehorn :-). This assumes $g_{ij}$ is a three metric, in the sense that's already been discussed. The difference betweeen $\partial$ and $\delta$ is the difference between the partial derivative of a function and a functional derivative (the action is a functional, i.e. it's a map from a function to a scalar).

I hope this is both more helpful than shoehorn's terse reply and also close to being correct (the textbook quote is definitely quoted correctly) unfortunately I don't really work much with the ADM formalism of which this is a part.

If you have Goldstein, Classical Mechanics, you might also look at the section on pg 420 about the symmetry groups of mechanical systems - rereading this makes it seem pretty likely to me that the [ ] are indeed Poisson brackets, though I can't quite justify the specific relation in the original question in my mind.

Last edited: Jul 4, 2007
16. Jul 4, 2007

shoehorn

Please don't take my abrupt comments as being rude; I certainly don't intend to be so and if I've come across that way, my apologies.

You claim that MTW say that the momentum is defined by:

$$\pi^{ij} = \frac{\delta L}{\delta g_{ij}}$$

You're correct when you claim that MTW say this is how the momentum is defined. However, the important point is that MTW are wrong! This is not as heretical as it may sound. Consider, for example, an ordinary classical system with generalised coordinates $q^i[/tex], generalised velocities [itex]\dot{q}^i$, and a Lagrangian $L$. In this trivial case we don't define the momentum conjugate to $q^i$ as

$$\pi_i = \frac{\partial L}{\partial q^i}$$

This is the analogue of what you've written for the momentum in general relativity. The correct way to define the momentum is of course

$$\pi_i = \frac{\partial L}{\partial\dot{q}^i}$$

This is a trivial observation. The correct way to define the three-momentum in general relativity is then

$$\pi^{ij} = \frac{\delta \mathcal{L}}{\delta\dot{g}_{ij}}$$

where the Lagrangian density (and note that the correct thing to use is the Lagrangian density, not the Lagrangian itself due to the possible presence of surface terms) is understood to have been expressed in terms of the first and second fundamental forms of a hypersurface in the spacetime.

If you work through the calculations you'll find that my correct way of defining the three-momentum gives

$$\pi^{ij} = \sqrt{g}(g^{ij}K - K^{ij})$$

On the other hand, if you use MTW's incorrect definition, you'll get something a whole lot more complicated (you'll get the euler-lagrange equations actually, as you could have noticed had you thought a little bit about the equation in MTW before transcribing it).

Last edited: Jul 4, 2007
17. Jul 4, 2007

masudr

General cigar shortage, it appears (:

18. Jul 4, 2007

pervect

Staff Emeritus
LOL, yep, but educational.


text:
# Polygon-Circle Collision Algorithm not working

EDIT: Updated code and video

I've been working on one of the last pieces of my collision detection system for my game, a polygon-circle collision method. I'm almost there with it, but there's a few minor issues that seem to pop up with it. I'll explain the few things I'm seeing, but it's probably easier just to watch the short video I have below:

https://1drv.ms/v/s!AjUDP95TjAMqje8AVA0LpPfeszVYoA

There are the three things I'm seeing:

• Little bit of bumpiness when going down a slope vs up (I'm guessing I just need to smooth out the movement adjustment a little bit
• When going around certain corners, the adjustment distance gets computed incorrectly, which results in either:
• A small bit of excess distance
• A large amount of excess distance

Below are the major components of my code, happy to update the post and add any other relevant code chunks that made be needed. Any assistance with this would be appreciated. Thanks!

Physics World Update Method:

IEnumerable<PhysicsFixtureBase> results = this.physicsTree.Query(fixture);
foreach (PhysicsFixtureBase otherFixture in results)
{
if (fixture.Body != otherFixture.Body && fixture.Intersects(otherFixture, out adjustment))
{
this.OnContact(fixture, otherFixture);
body.SetVelocity(Vector3.Zero);
}
}

Main Intersection Method:

public static bool Intersects(PhysicsCircleFixture circle, PhysicsPolygonFixture otherPolygon, out Vector3 adjustment)
{
bool result = PhysicsCollisionHandler.Intersects(otherPolygon, circle, out adjustment);
return result;
}

public static bool Intersects(PhysicsPolygonFixture polygon, PhysicsCircleFixture otherCircle, out Vector3 adjustment)
{

Vector2 circleCenter = otherCircle.GetPosition2D();

Vector2 closestPoint = Vector2.Zero;
float closestDistance = float.MaxValue;

foreach (Vector2 point in polygon.Points)
{
float distance = circleCenter.Distance(point);
if (distance < closestDistance)
{
closestDistance = distance;
closestPoint = point;
}
}

Vector2 previousPoint = polygon.Points[polygon.Points.Count - 1];
foreach (Vector2 currentPoint in polygon.Points)
{
Vector2 edge = currentPoint - previousPoint;
float interp = edge.DotProduct(circleCenter - previousPoint) / edge.DotProduct(edge);
if (0.0f < interp && interp < 1.0f)
{
Vector2 point = previousPoint + edge * interp;
float distance = circleCenter.Distance(point);

if (distance < closestDistance)
{
closestDistance = distance;
closestPoint = point;
}
}
previousPoint = currentPoint;
}

{
float penetrationDistance = circleRadius - closestDistance;
Vector2 normalizedVector = (closestPoint - circleCenter) / closestDistance;
}

}

Helper Code:

public static Vector2 Normal(this Vector2 vector) { return new Vector2(-vector.Y, vector.X); }

public class Range
{
public float Min { get; set; }

public float Max { get; set; }

public Range(float min, float max)
{
this.Min = min;
this.Max = max;
}

public float Length() { return this.Max - this.Min; }

public Range Intersects(Range other)
{
Range longestDistance = new Range(Math.Min(this.Min, other.Min), Math.Max(this.Max, other.Max));
if (longestDistance.Length() < (this.Length() + other.Length()))
{
return new Range(Math.Max(this.Min, other.Min), Math.Min(this.Max, other.Max));
}
return null;
}
}

public Range PhysicsPolygonFixture.ProjectOnAxis(Vector2 axis)
{
Range range = new Range(float.MaxValue, float.MinValue);
foreach (Vector2 point in this.Points)
{
float projection = point.DotProduct(axis);
if (projection < range.Min)
{
range.Min = projection;
}
if (projection > range.Max)
{
range.Max = projection;
}
}
return range;
}

public Range PhysicsCircleFixture.ProjectOnAxis(Vector2 axis)
{
float circleCenterProjection = this.GetPosition2D().DotProduct(axis);
}

The code that checks for edge collisions is definitely causing the problems you're seeing. Since it's also a little more complex than necessary, I think the right solution is to rewrite it completely.

Remove the entire foreach (Vector2 edge in polygon.Edges) loop, and add the following code above the line if (closestDistance < circleRadius):

Vector2 pointPrev = polygon.Points[polygon.Points.Length - 1];
foreach (Vector2 pointCur in polygon.Points)
{
Vector2 edge = pointCur - pointPrev;

float interp = edge.DotProduct(circleCenter - pointPrev) / edge.DotProduct(edge);

if (interp > 0.0f && interp < 1.0f)
{
Vector2 point = pointPrev + edge * interp;
float distance = circleCenter.Distance(point);

if (distance < closestDistance)
{
closestDistance = distance;
closestPoint = point;
}
}

pointPrev = pointCur;
}

Note 1

I tried to use your function and type names. The only thing I didn't have a reference for was whether polygon.Points is an array or a list.

Note 2

The only tricky bit there is the calculation of interp; it combines two calculations into one to avoid a square root. It normalizes the edge vector and also divides the projection of the circle's center onto the edge by the length of the edge vector.

• Thanks for the feedback. I put in your changes and gave it a run, but there not seems to be the opposite effect of the previous code. Instead of the corners leaving gaps between the two objects, the corners now end up going into the object and causing a slingshot back and forth effect. I've edited the original post with the updated code and included a new video of the effects: 1drv.ms/v/s!AjUDP95TjAMqje8AVA0LpPfeszVYoA I'll continue looking into it, but my guess is the new logic is saying that the edges are closer than the points someone, to a certain extent. – SaviorXTanren May 9 '17 at 4:21
• I think I see the problem. In your new code, try negating adjustment. Right now, it points from the circle toward the collision point, and that seems backwards to me. – Victor T. May 9 '17 at 13:59
• I tried that, but that actually makes it get even worse. The circle ends up sling-shot effect through the entire triangle like a weird black hole. I definitely think the effects I'm seeing have something to do specifically with the point collision chunk of code; either in determining which point is the closest (unlikely) or in the adjustment chunk of code (more likely). – SaviorXTanren May 10 '17 at 16:23
• I did some testing around in the code when the circle hits one of the corners and here's what I do know: 1) The correct closest point is selected. 2) One of the edges is NOT selected as the closest point. 3) Every time the collision detection is determined with the point, an adjustment is made. 4) My guess is that every time the collision happens with a point, the first adjustment ends up pushing it into the triangle, which makes the second collision push it out of the triangle, thus giving the ping-pong effect. I'll keep digging into the adjustment logic for points. – SaviorXTanren May 10 '17 at 16:23
• I figured it out! Had absolutely nothing to do with the code above. I have some QuadTree code I'm using to reduce physics calculations. My QuadTree Query code to find objects that are nearby it was failing when it came to the edges of the shape. That's why there was the ping-pong effect (It wouldn't find it for a few frames, then find it and shoot it back). Thanks for all your help with the other logic though! – SaviorXTanren May 11 '17 at 0:44

format: plain


text:
+0

# help plz matrices/vectors

0
126
3
+29

Find the matrix $$\mathbf{A}$$ such that $$\mathbf{A} \mathbf{w} = \begin{pmatrix} 4 \\ 7 \\ -1 \end{pmatrix} \times \mathbf{w}$$ for all vectors $$\mathbf{w}.$$

Jun 22, 2020

#1
0

The matrix A is

$$\begin{pmatrix} 4 & 7 & -1 \\ 7 & -1 & 4 \\ -1 & 4 & 7 \end{pmatrix}$$

Jun 22, 2020
#2
+31296
+1

How are we to interpret

as a cross-product, as element by element multiplication or what?

Jun 22, 2020
#3
+29
0

Crossproduct. Im sorry that i didn't specify

SomeNewUser276  Jun 24, 2020


text:
# Positive Rational Numbers under Addition form Ordered Semigroup/Proof 1

## Theorem

Let $\Q_{\ge 0}$ denote the set of positive rational numbers.

$\struct {\Q_{\ge 0}, +, \le}$

forms an ordered semigroup.

## Proof

It is necessary to ascertain that $\struct {\Q_{\ge 0}, +, \le}$ fulfils the ordered semigroup axioms:

An ordered semigroup is an algebraic system $\struct {S, \circ, \preceq}$ which satisfies the following properties:

 $(\text {OS} 0)$ $:$ Closure $\ds \forall a, b \in S:$ $\ds a \circ b \in S$ $(\text {OS} 1)$ $:$ Associativity $\ds \forall a, b, c \in S:$ $\ds a \circ \paren {b \circ c} = \paren {a \circ b} \circ c$ $(\text {OS} 2)$ $:$ Compatibility of $\preceq$ with $\circ$ $\ds \forall a, b, c \in S:$ $\ds a \preceq b \implies \paren {a \circ c} \preceq \paren {b \circ c}$ where $\preceq$ is an ordering $\ds a \preceq b \implies \paren {c \circ a} \preceq \paren {c \circ b}$

From Rational Numbers form Ordered Field, $\struct {\Q, +, \times, \le}$ is an ordered field.

Hence $\struct {\Q, +, \le}$ is an ordered group, and so an ordered semigroup.

From Positive Rational Numbers are Closed under Addition we have that $\text {OS} 0$ holds.

From Restriction of Associative Operation is Associative we have that $\text {OS} 1$ holds.

From Restriction of Ordering is Ordering we have that $\text {OS} 2$ holds.

The result follows.

$\blacksquare$


text:
## How to plot the result of Grad function?

When I calculate the gradient of a two dimension function like $$r=\frac{1}{\sqrt{x^2+y^2}}$$ with the syntax of

h[x_,y_]:=Grad[1/r,{x,y}]

and when I checked the result with

h[x,y][[1]] h[x,y][[2]]

I got a right result of $$-\frac{x}{(\sqrt{x^2+y^2})^{-3/2}}$$ and $$-\frac{y}{(\sqrt{x^2+y^2})^{-3/2}}$$, respectively.

However, when I tried to plot the function with syntax of

VectorPlot[{h[x,y][[1]],h[x,y][[2]]},{x,0.1,0.3},{y,-0.3,0.3}]

I found the value in y direction is 0, and I also confirmed with

Plot3D[h[x,y][[1]],{x,-0.3,0.3},{y,-0.3,0.3}] Plot3D[h[x,y][[2]],{x,-0.3,0.3},{y,-0.3,0.3}]

and the results are that the first one has a proper plot while the second one shows the function value is 0.

Would anyone give me some clue that how this happened? Thank you and best regards!

## Is this a Lost Mine of Phandelver Plot Hole?

I’m DM’ing for the first time with a group playing for the first time (Table of Noob’s :p). In the 1st chapter of Lost Mine of Phandelver, the characters come across dead horses, are attacked by goblins, and discover a path into the woods. The campaign book says they “can easily steer the wagon away from the road and tie off the oxen while the group pursues the goblins“. This, to me, implied that the wagon couldn’t go down the path.

Fast forward a bit, at the end of the path is a cavern/goblin hideout, PC’s enter, kill goblins and bugbear leader (Klarg), yada yada yada. In Klarg’s lair, there are a bunch of supply crates, and the description says “the captured stores are bulky, and the characters will need a wagon to transport them“. They have a wagon, but apparently no way to get it to the cave.

The trail is 5 miles long, so carrying the crates back to the wagon is out. My solution was to retroactively say that when they entered the clearing where the cave is, they could see another, wider path leaving the clearing that has clearly been used for moving vehicles/supplies. This was met with dissent, as it was deemed “railroading” the story and not letting them discover a way themselves. So finally, 3 questions off this:

1. Is this actually a plot hole, or have I missed something?

2. Is the discovery/creation of the 2nd path both an appropriate solution, and one that a DM should make?

1. What other alternatives could there be for this situation?

I greatly appreciate any insight/help with this…

## How do I plan sessions that are still fun even if they don’t move the plot forward?

I’m fairly new to DMing, but I really enjoy it. My campaign is still pretty early in, and plot is moving forward pretty well; last session actually revealed a huge chuck of the relevant current events. Last session was also a nightmare; the entire party suddenly became hectic and chaotic (borderline murder-goblins). Next session is going to be pretty quiet in comparison; not really any new information, or any new goals (yet), and really, their characters are probably in trouble for causing several messes in town.

I’m not sure how to rectify this. How can I keep the players entertained while they’re not going anywhere or doing anything that progresses the plot? How do I make sure they’re having fun while the plot is at a standstill?

## how can I plot two variables (inside a definite integral) against each other

I want to plot x against y in this relation:

## How to super impose a curve onto a 2-D contour plot

I have created a smooth color gradient 2-D contour plot with existing compiled data. I have an x-axis, y-axis, and z-data contour plotted as a colormap. I have a single value of z-data that I want to plot as a curve onto the colormap.

x = 0.05:0.05:1; y = 0.0:0.05:1; [X, Y] = meshgrid(x, y); Z = [data] contourf(X, Y, Z); pcolor(X, Y, Z); shading interp title() xlabel() ylabel() colorbar

## How to plot 3d surface graph for a tuple inside a list in Python?

I’ve data set as shown below. I need to have a surface plot with x, y and z values (j needs to be ignored). Each tuple inside the data list must represent a point in the surface plot.

For example, when plotting python must take (-1.0, -5.0, 0.0, 128.05219942419836) value and plot it and then go to the next tuple and so on. I get a graph with my attempt but it seems to be incorrect.

Could someone help me to find out the error?

import matplotlib.pyplot as plt import numpy as np   data_list = [(-1.0, -5.0, 0.0, 128.05219942419836), (-1.0, 5.0, -5.0, 1050.0514787687544), (-1.0, 5.0, 0.0, 787.8822046898542), (-1.0, 5.0, 5.0, 35.6         0, 22.371836318366924), (-6.0, -10.0, 5.0, 4.702288827001351), (4.0, -5.0, 0.0, 216.35187799230525), (4.0, 5.0, 0.0, 1970.733458386331)]  #My attempt #zipping data j, x, y, z = zip(*data_list)  z = tuple(map(float, z))    dim_of_z = np.shape(z)  X, Y = np.meshgrid(x, y) Z = np.reshape(z,(1,(dim_of_z[0])))   fig = plt.figure() ax = fig.add_subplot(111, projection='3d')  ax.plot_surface(X, Y, Z, rstride=1, cstride=1, linewidth=0.1)           plt.show()

#https://stackoverflow.com/questions/21161884/plotting-a-3d-surface-from-a-list-of-tuples-in-matplotlib

## R plot text: How to add regular text prefix to polynomial rendered in exponent form (not ^)

I’m trying to add this text to a plot: “Model: y = 1 + 2x – 3x^2 + 4x^3” where actual exponents are rendered as such (no ^ chars). (See screenshot)

Below is repro code. The first text() call works fine (no prepended regular text), but the second does not (with prepended text). (Execute soTest() to repro.)

Any suggestions? I guess I don’t know which R keywords to search for to find a solution. Any help would be appreciated! (Please pardon the camel-casing, I’m writing a slide deck for an audience with at least a few non-R coders.)

evalPoly = function( x, coeff ) {     if ( length( coeff ) < 1 ) return( c(0) )        termSum <- 0     for ( i in 1:length(coeff) ) {         termSum <- termSum + coeff[i] * x^(i-1)     }     return( termSum ) }  soTest <- function() {     coeff <- c( 1, 2, -3, 4 )     x <- 1:8     y <- evalPoly( x, coeff )     plot( x, y )     text( 2, 1600, parse( text="1+2*x-3*x^2+4*x^3" ), adj=0 )     text( 2, 1400, parse( text="Model:  y = 1+2*x-3*x^2+4*x^3" ), adj=0 ) }

## Parameterization of boundary curve in 3D Plot

I am considering a function of the form:

u0 = p[1](Q1[1] – K1)/(p[1] – K1 + Sqrt[(K1)^2 – m1^2](1 – 2*alpha));

with p[1],Q1[1], and m1 being constant (set p[1] = 1, Q1[1] = 1/2, m1 = 0.1). Therefore, i am considering u0 as a function of K1 and alpha. Due to physical restrictions, i want my u0 to be between the values 4/9 and 0.48, while K1 might be between 0.1 and 1/2 and alpha between 1/2 and 1. One can easily check that the domain for K1 and alpha are too large in order to guarantee that u0 lies between 4/9 and 0.48 by checking the equation above. Hence, i need to restrict alpha or K10 such that u0 always lies in my desired domain. A plot might be somewhat revealing:

Plot3D[u0Max3*0.48, {K1, 0.1, 1/2}, {alpha, 1/2, 1}, PlotRange -> {4/9, 0.48}];

Ultimately, i aim for integrating this volume with numerical procedures like NIntegrate or Vegas, but for this i need to state the domain of the variables. So i am looking for a way to get a functional dependence between alpha and K1 such that i can integrate this and obtain the correct volume.

## Custom plot markers in DistributionChart

I would like to use the ChartElementFunction option of DistributionChart to plot data with a custom style that includes custom plot markers, such as open circles. I am struggling with the scaling of the markers, though.

If I use Points as plot markers, everything is fine:

data = Table[RandomReal[i + {1, 3}, 10], {i, 5}];  cef1[{{xmin_, xmax_}, {ymin_,ymax_}}, data_, metadata_]:=     {Black, PointSize[Large], Point[{RandomReal[{xmin, xmax}], #}]& /@ data};  DistributionChart[data, ChartElementFunction -> cef1]

If I use Circles, they are affected by the aspect ratio of the plot and shown as ellipses:

cef2[{{xmin_, xmax_}, {ymin_, ymax_}}, data_, metadata_] :=      {Black, Circle[{RandomReal[{xmin, xmax}], #}, 0.05] /@ data};  DistributionChart[data, ChartElementFunction -> cef2]

Is there a way to get the scaling right, for example make the markers behave like PlotMarkers in ListPlot?

## How to scatter plot from matrix with many y-axes values for each x-axes value?

Consider matrix

A = {{0, 2.54343, 3.566, 4.2323, 2.3434}, {0.1, 6.432, 4.6465, 5.656,  1.34},  {0.2, 0.3423, 1.6342, 3.323, 2.04}};

X-axes values are 0, 0.1, 0.2.

Their are 4 y-axes values for each x-axes data point

How to plot this?

Naive use of

ListPlot[A]

fails.


text:
+0

+4
953
2
+395

Altitudes AP and BQ of an acute triangle ABC intersect at point H. If HP=5 while HQ=2, then calculate (BP)(PC)-(AQ)(QC).

- Daisy

Aug 9, 2018
edited by dierdurst  Aug 22, 2018

#1
+994
+5

This similarity relationship is derived from the fact that each triangle has one right angle and acute angle in common:

$$\because \angle BQC= \angle BPH= \angle HQA = \angle CPA\\ \because \angle QBC = \angle QBC\ \&\ \angle PAC = \angle PAC \ \& \ \angle BHP=\angle AHQ$$

$$\therefore \triangle BQC\sim \triangle BPH\sim \triangle HQA\sim \triangle CPA$$

From the similarity of corresponding triangles:

$$\frac{HP}{BP}=\frac{HQ}{QA}=\frac{PC}{AP}=\frac{QC}{BQ}$$ results in:  $$BP\cdot PC-AQ\cdot QC =HP\cdot AP-HQ\cdot BQ\\ =HP(HP+HA)-HQ(HQ+HB)=HP^2-HQ^2=\boxed{21}.$$

Aug 9, 2018
#2
+395
+5

Thank you very much, this solution is very clear!

- Daisy

dierdurst  Aug 9, 2018
edited by dierdurst  Aug 22, 2018


text:
### Perl advocacy, CGI/ModPerl vs ASP/JSP

by rinceWind (Monsignor)
 on Jun 17, 2002 at 13:04 UTC Need Help??

I was recently having to defend Perl in a bar discussion with some techie friends. I was hearing everything from "the syntax is horrible - all those %@$~/" to "Perl is slow and clunky for doing web stuff, look at CGI". Most of the arguments I was using can be found here with a search. Some of my responses were admittedly vague - "Don't worry, that will be fixed in Perl 6". I was wondering whether anybody has put together a list of Perl advocacy arguments, either on Perlmonks or elsewhere. If this is missing, maybe this thread could form the basis. I did find this node, but it is a year old, and probably out of date. Also, the discussion homed in on websites. I was having to explain how ModPerl is streets ahead of the competition in terms of performance, and does not need rocket scientists to program it (just careful programmers who are prepared to follow rules). I also contend that CGI is perfectly adequate for single user development (i.e. unit test), and IMO is superior to ASP and JSP as its very clear what is happening server side. However, the technologies are not interchangeable. The discussion moved to security and Perl was in the firing line. I was pleased to be able to give an update on Matt's Scripts and NMS. I also started to explain about taint mode checking, but was faced with guys insisting that no special mode is needed if you program in Java as everything is secure anyway... At this point, I realised that my seeds were falling on parched earth, and I managed to shift discussion away from technical subjects. I could have done with a few Perl Mongers or Monks backing me up, then I would probably have continued the discussion. Still, I'm looking for advocacy arguments for Perl, and for CGI and ModPerl versus the rest. Replies are listed 'Best First'. Re: Perl advocacy, CGI/ModPerl vs ASP/JSP by demerphq (Chancellor) on Jun 17, 2002 at 13:26 UTC no special mode is needed if you program in Java as everything is secure anyway... From the security books ive been reading this is a totally crap argument. Java's security model was tacked on after much of the Java development had been completed (and has been changed several times). There have been a number of instances of Java being compromised because programmers blindly relied on the security model to protect them. Perls security model is simple and designed to prevent this type of false security. Distrust everything. Always be aware of potential holes. And since Java has no taint'ing mechanism it is thus more susecptable to programmer oversight. Which as we all know happens a lot. "the syntax is horrible - all those %@$~/"

Those sigils are intended very specifically to seperate things that are different. Damian Conway co-write a paper on how languages that avoid such differentiation have higher error rates and are less suitable for teaching.

And frankly I hate the try/catchiness of java. :-)

Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.

Re: Perl advocacy, CGI/ModPerl vs ASP/JSP
by Matts (Deacon) on Jun 17, 2002 at 14:47 UTC
1. The sigils are ugly in my opinion (arguments that they help you figure out the type of a variable fall down with references and slices). So I'd avoid arguing against that one if I were you.
2. Perl has warts. The whole $self as first argument thing is one, but there are many others. 3. But, despite the warts, Perl has CPAN. I'm afraid CPAN kills arguments about other languages stone dead. I've tried really hard to move to other languages (C, Java, Ruby) because I don't like Perl's warts, but none of those languages have the simple elegance of CPAN. 4. Speed issues tend to evaporate when put under real tests. Slashdot gets a lot of hits and runs perl. Other sites get a lot of hits and run JSP, others ASP. In the end it all comes down to good design and network architectures. 5. Did I mention perl has CPAN? 6. Java is fundamentally not immune to security problems. That's the most naive thing I've ever heard a developer say. What about cross site scripting bugs? What about SQL injection bugs? No matter what language you're programming in, when you're working on the web you always *always* check your user input. Perl's taint mode makes it hard to avoid doing that, but it still doesn't alleviate security issues. That's probably not exactly everything you wanted to hear. It's not so much an advocacy argument - the best thing about Perl is CPAN (and sometimes the worst thing about Perl is CPAN, but that's a whole other node). Update: wedman reminded me of perldoc. That's such an awesome tool I can't rave enough. Show me another language that has as good and as easy to find docs as perl when you're working on the command line. • Slashdot gets a lot of hits and runs perl. <...> In the end it all comes down to good design and network architectures. • Doesn't Slashdot have a big fat load balancing system in place? The speed issue was dealt with by throwing more hardware at the problem. So, like you said, it comes down to design and achitecture. I suppose somebody could code a website using Q-BASIC on several heavy duty machines behind a load balancing system, but that's probably not good design. To me, I find Perl very fast and easy to develop with. Not only is CPAN sweet, but PerlDoc rocks as well. I use references constantly when I code, and PerlDoc is always there when I need a hint. They describe the machines that power the site here. I wouldn't call 10 Intel boxes a big fat system. They probably cost less than one Sun box. Slashdot actually used to be fast, and back then it ran out of Malda's appartment. (I have a userid in the 2000's). It requires a big fat pipe because it uses it. It requires load balancing because it gets enough traffic to need a big fat pipe. Sigils are *not* ugly! They are useful to show the type of values. Your contention that they "fall down with references" is mildly 'true', but not for the most part. Even if its a reference to a hash, you still know its one value, a scalar value, thus fufilling the point of the sigil. And more over, if you see "%$foo" then you know $foo is hash reference. And you can easily determine what type it is, merely by using the 'ref' function. I love sigils, they also help to make the code visually distinctive, you can always tell what is a variable and what is a keyword, and allowing interpolation is just a ++ I'm afraid I can't agree. There are just so many cases where the sigils aren't enough to disambiguate clearly in people's brains. And references are the main cause of this. But also look at slices. Here's a hash slice: @foo{ qw(a b c) } = qw(x y z); [download] Now what does the @ have to do with the variable? The correct answer is absolutely nothing. The sigils in perl are used to denote the type of the operation, NOT the type of the variable. Because the slice above operates on a list it uses the @ to denote a list. But damn, is it ever confusing. To take it further, you say ref($var) is enough, but how do you do that while coding? You can't - you can only run ref() at runtime. So sigils aren't serving their purpose there. Also now let's suppose ref($var) returns nothing, so what does$var->(); do? It possibly executes a function! But ref() told you nothing, and the $told you nothing. (yes, I'm aware strict will catch that, but what if the purpose is to run a function? Then you have to have strict refs off for that section of code). Now take it a step further. What about$var->{entry}. Most people these days are doing OO (aren't they?) so what does the $tell us this time? Nothing, because the type of$var->{entry} is totally and utterly opaque to the naked eye.

Extreme example time. How do you do a hash slice of a hashref belonging to an object implemented as a blessed hashref? (did you parse that? It's hard to read, but it's even harder to figure out without severe experimentation how to do it). The solution is the totally inelegant:

@{$var->{entry}}{qw(a b c)} = qw(x y z); [download] So now what part of the above defines the fact that it's a hashref? The answer is the openning curly bracket just before the first qw. Nope, sigils were pretty useless once again. OK, rant over. Sigils really aren't all they're worked up to be. They have a purpose, which was fine for perl 4, but I think when perl 5 came along it all but made them useless. Re: Perl advocacy, CGI/ModPerl vs ASP/JSP by simon.proctor (Vicar) on Jun 17, 2002 at 20:45 UTC When I first read this I was going to reply with my comments on all the technologies (as I have to use them at work) and then, hopefully, give some good reasons for using Perl. Or at least help win some (but not all, lets be honest) arguments. However, lets face it, no-one ever got sacked recommending Java. Its in the press, big named companies are pushing it etc etc. Faced with this push from the press and the academic community no IT director is going to face his peers without being anywhere near buzzword compliant. Lets face it, its very rare for those who make strategy to actually understand what they are advocating. So when they turn to their subordinates for advice, very few will make a reasoned argument for the right technology or even evaluate it in a language agnostic fashion because they don't want to get caught making the wrong choice. I was recently in a meeting with the senior technology services people to find out about their technology strategy. And guess what? As soon as they found out I was a Perl guy they tried to spend most of the meeting pulling it down (till I put my foot down). The basis for this? Well someone installed a Mats Script formmail on the main webserver that is used by most of the revenue generating sites (over £25M) and wonders why they get hacked all the time. I didn't know whether to laugh or cry. Of course servlets are fast, you've embedded the run time into a server environment, loaded the app and stuck it in memory and started a new thread for each new hit. Sound like mod_perl? Of course JSPs make the designers life easy. But they just do not compare to the Template Toolkit. In fact the only thing that I have seen that comes close is Velocity from the Apache project. But if you also consider that a JSP page gets converted to a servlet by the container before running and you tend to wonder how much of a bolt on it really is. Frankly, ASP and JSP just don't cut it IMHO. My reasons for ASP are numerous (and I do have to use it :/). Most of which are here: 143745. Don't get me even started on IIS recycle, white pages and how, allegedly, Microsoft have mucked up IIS 5 and left their community in the rain (so to speak). Of course, we mustn't forget Python (no really). Servlet technology lacks the rapid prototyping that a scripting language allows. I've spent 3 weeks developing a prototype that would hav taken days in Perl. However, I've managed to speed this up using Jython in a servlet environment. So how flawed is that? Running one language inside another just to get the speed of development you need? And of course this raises the issue of speed. Most people who read that CGI is slow have only ever seen that in a magazine and gone with the author. Yes of course CGI is slow but its not the same environment as a servlet so doesn't compare. But if you consider that most sites never have the number of hits required to show and truly marked difference. Because if you were building a massive site with thousands of hits - you wouldn't use CGI or ASP. It would be mod_perl or a servlet system, a cluster of servers and lots of tiers, replication etc. Most sites run badly because of poor system design and then a magic consultant comes along and says - Java is the key. So of course, no-one ever got sacked recommending Java. Because I truly feel there is 'fast' and there is 'fast enough'. Does the trade off of a few percentage points of speed pay against the fact that it took less than half the time to develop? That you didn't have to spend cash on invitations to tender, specialist hardware, training etc. The money you've saved could buy you a better network, pipe and more 'puters. Simon PS: sorry I went on a bit but I wanted to get some of this off my chest. Servlet technology lacks the rapid prototyping that a scripting language allows. I've spent 3 weeks developing a prototype that would have taken days in Perl. This may be true for you, but what about a company where everyone knows servlets inside out, but barely anyone has written any Perl? When making these decisions one should keep in mind the skills of their employees. Of course, in many situations it's worth it to train employees, if the language/product/whatever can get your job done sufficiently easier. The money you've saved could buy you a better network, pipe and more 'puters. Excellent point. Developer time is almost always far more expensive than hardware and bandwith costs. It's a pretty safe bet to try and minimize the former with a small investment in the latter. Actually the point about CGI's being slow is a dumb one too. I can get about 80 requests/second on a small C CGI. And I can get about 90-100 requests/second on the same server from a mod_perl Apache::Registry script doing pretty much the same thing. CGI has a reputation for being slow mostly because of the Perl startup time, because perl became synonymous with CGI. Er, what exactly is that supposed to prove? That mod-perl is faster then C? I would hope so. We all know that non-mod-perl perl (wee, dept redundancy dept calling) is slow, this is an accepted fact. The point is that no one uses it for anything speed critical. They use fast things! Update: er, forgot a word... I don't know if anyone ever got sacked for recommending Java, but I did interview with a shop (who shall remain nameless) at one point that was generating an image-based search engine. They seemed to have a highly competent technical team. After they had done a bunch of prototyping in Perl, they decided that they had to do the real thing in Java. After a coule of months, they discovered that development time was significantly slower (and couldn't keep up with their changing business demands) and the execution time of the Java code was unacceptable relative to Perl. They immediately switched back to Perl and discovered that, although the business folks had lost a bit of buzzword-compliance, Perl had been by far the most practical choice from the get-go. Go figure. Re: Perl advocacy, CGI/ModPerl vs ASP/JSP by perrin (Chancellor) on Jun 17, 2002 at 14:56 UTC Thanks for the props, cjf. The thing about Java being inherently secure is indeed absurd. Most web app security bugs are things like people being able to change the prices of items they buy on commerce sites or hijack other people's sessions and steal their personal data. Java can't prevent you from making these kinds of mistakes. Perl tries harder than Java by offering a taint mode, but you can still shoot yourself in the foot. In addition to the fact that mod_perl is at least as fast as Java servlets, ask them to name some big sites that run on Java. Then point out some big sites that run a lot of perl: Yahoo, Amazon, Ticket Master/CitySearch. I don't see anything in the top 10 that runs a significant part of their site on Java. You could also quote some stats to them from my article about using mod_perl at eToys. Re: Perl advocacy, CGI/ModPerl vs ASP/JSP by cjf (Parson) on Jun 17, 2002 at 13:46 UTC Perl is slow and clunky for doing web stuff Yell mod_perl at them really loudly (update: apparently you did, but yell it louder, and throw in some benchmarks :). That should end that discussion. Also read perrin's excellent reply to a similar thread at Re: CGI (Perl) vs JSP. Re: Perl advocacy, CGI/ModPerl vs ASP/JSP by Aristotle (Chancellor) on Jun 18, 2002 at 05:26 UTC ### Sigils They may look like line noise to the uninitiated, but I dearly miss them when I'm not working in Perl. They offer anchor points to my eyes - I can see where there's a variable and where there ain't with just a casual glance over the code. Together with Java's tendency to use reallyLongMashedTogetherIdentifiersWithNoVisualSpacing and the fact that as a strongly typed language, it needs a lot of paperwork to get the simplest tasks done, it takes me many times longer to figure out the shortest bits of Java, compared to Perl where a short eye-over will often suffice to tell me what's going on. Even more important, in Perl, when an eye-over doesn't suffice, I know just by that fact that I'm looking at a tricky little ditty. ### CGI = clunky You can write CGI scripts in Java too. Guess how clunky that is. *grin* They're not realizing that mod_cgi != perl. ### Taint Well, I needn't reinstate the previous points. If you don't check your input data for single quotes, Java's security model won't prevent you from feeding user-supplied SQL into your database. Java is "secure" because it the VM mistrusts the code. Perl is secure (if the programmer took the proper care) because the script mistrusts its input. There's a fundamental difference in the way of thinking here. The former mainly fixes symptoms and makes me as the programmer feel handcuffed. The latter lets me hang myself with the long leash I have if I'm careless, but constantly reminds me to be cautious and responsible. ____________ Makeshifts last the longest. Re: Perl advocacy, CGI/ModPerl vs ASP/JSP by domm (Chaplain) on Jun 18, 2002 at 09:39 UTC Those two documents from the hopefully-soon-to-be-released new mod_perl website contain a lot of arguments why mod_perl rocks. -- #!/usr/bin/perl for(ref bless[],just'another'perl'hacker){s-:+-$"-g&&print$_.$/}
[download]
(wil) Re: Perl advocacy, CGI/ModPerl vs ASP/JSP
by wil (Priest) on Jun 18, 2002 at 11:00 UTC
I think a big problem at the moment is that hosting providers will not load mod_perl on shared hosting plans. I've often heard the argument from ISPs saying that any process can grow uncontrollably and take all a server's memory and/or CPU resources, which could theoretically mean one user could destabilize the machine for hundreds of users quite easily.

However, mod_perl 2 is supposed to do something about this. I think this is a very important step. If mod_perl 2 can find it's way onto most major shared hosting providers, then we'll see it's usage increase and, hopefully, we'll see more and more people using mod_perl instead of the traditional Perl/CGI route which will put Perl back on the speed map again in terms of web programming.

- wil
I think a big problem at the moment is that hosting providers will not load mod_perl on shared hosting plans.

This is true, but just try to find an ISP that will run Java/JSP on a shared server or on any managed environment. Most of the time (as with mod_perl) you will be completely responsible for everything except the cables being plugged in. The truth is, that JSP/J2EE is still not very mature and the ISPs are rightly careful about supporting something that hasn't really proven to be all that stable.

OTOH, if you make a system in Perl/CGI and you take some care of your coding practices, you can start your site on a shared server and move on to a dedicated machine and mod_perl when the need arises (and in my expirience, it mostly doesn't).

As for one user taking out the whole system, those providers are right: any process can grow uncontrollably and take all a server's memory. This includes a CGI program if it's determined (or stupid) enough. It's just easier in mod_perl. :-)

--
Joost       downtime n. The period during which a system
is error-free and immune from user input.
[download]
Hosting is still an issue since it requires mod_perl to run properly, but I've found Apache::ASP to be awesome after having used CGI, ColdFusion, and servlets/JSP. I say just colocate a server and use what's best for you if you can't find a host with the right stuff. The big advantage that most people aren't mentioning much is speed of *development*! You can always throw more hardware at it if you find execution speed to really be an issue (I never have...mod_perl is plenty zippy for me). Hardware is cheap; programming effort is not. I am a Sun Certified Java programmer, but I can do the same things I can do in Java in Perl with probably 1/3 of the code. I've reached the point where the only reason I care about Java is for my resume. Perl is the language for getting things done!
Re: Perl advocacy, CGI/ModPerl vs ASP/JSP
by ignatz (Vicar) on Jun 18, 2002 at 10:56 UTC
The big thing that is missing with Perl is kickbacks. Perl needs some perky young sales reps that can take corporate bigwigs out to lunch and dazzle them with powerpoint presentations and Pacoware version 6.0 Now with scrubbing SOAP bubbles cloth briefcases and in the case of Fortune 500 accounts games of golf where big envelopes full of \$ can be discretely passed. Where did companies get the idea that throwing millions at technology while treating their programmers like surfs is going to achieve anything of value?
()-()
\"/

`
Re: Perl advocacy? Why have a dog and bark yourself?
by frankus (Priest) on Jun 20, 2002 at 08:26 UTC
I find advocacy discussions are moot.
Rarely do participants enter with an open mind.
Best to smile politely, let the people air their opinions.
Perl wins, as good things do, in use: not in debates or classrooms.
It's pragmatic and don't forget that.

--

Brother Frankus.

¤

Create A New User
Node Status?
node history
Node Type: perlmeditation [id://175067]
Approved by rob_au
Front-paged by cjf
help
Chatterbox?
 [choroba]: needed everywhere, available rarely [LanX]: Question: starting a script from an icon in Windows, but after C-c the window closes ... what I want is to restart in the cmd.exe. Recommendations? [Corion]: LanX: What do you mean by "restart in the cmd.exe" ? [Corion]: Do you want to launch a script and keep the command prompt/console window open? [Corion]: Do you want to wait for a key press before closing the window? [LanX]: I want the command line in the history [tye]: -Mouse [Corion]: Option a) would mean launching cmd.exe /k c:\path\to\ batchfile- launching-perl- script.cmd. Option b) would be to add pause as the last line of said batch file.

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2017-03-27 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should Pluto Get Its Planethood Back?

Results (320 votes). Check out past polls.


text:
This is the online version of The Hacker Ways.
Get your copy: epub, mobi and PDF, DRM-free.

§7 — Making the computer work for you

In the previous chapter we saw how to interact with Python. In this chapter we want to start using it to do interesting stuff, but before we'll spend some time improving our work environment.

First we'll introduce screen, a wonderful piece of software that will allow you to do many things at once within the terminal, without losing track of any; get used to screen, and you won't be able to be without it.

Once we understand screen we'll learn how to install Python packages.

By the end of the chapter you will know how to use screen to work in parallel workspaces within the terminal. You will have also learned how to find and install Python packages, and you'll know a bit more about system administration. You will have a rather nice Python environment set up, and we'll use it to take a mathematical detour that will give you a feeling of the many cool things you can do easily with Python once you know your way around. You may, of course, skip the last part if you don't care about math: read the first parts, were we talk about screen and Python packages, and move on.

The case for improving your work environment

It is good that you experiment with your work environment, and figure out how to tailor it to your needs. And not only for the obvious fact that you might spend many hours a day in front of your computer, and you'd rather be comfortable. The best work happens when the computer does not interfere between you and your task. The interface to the computer should be as transparent to your thought processes as possible, the interaction effortless and automatic. Only then your attention will be focused, and your work your best1.

It might be that one of the reasons that makes the UNIX work environment so compelling is that it lends itself so well to tuning and automating, leaving plenty of room for you to find your perfect setup. Most things can be done with keyboard shortcuts that can be learned until they become almost autonomous. When in Emacs, my fingers reach out for C-x C-s every now and then without me being fully aware of it; movement between applications happens with Command-TAB; the mouse is hardly every touched.

Because I think (and this is a strongly felt guess, but a guess nevertheless) that reaching for the mouse, and aiming at a place to click, imposes a much higher cognitive load on your brain than just letting your fingers press a fully automated chord in the keyboard. And I'd much rather have my brain working out the problem at hand than thinking about what it's doing with the mouse.

Running things in parallel with screen

When you have been working at the terminal for a while there may be quite a bit of information in it. Its value is usually in the short term —whatever you want to store for the future you'll stash away in a file and save it— but it is important anyway. It is your command line history, environment variables you might have declared, a Python session in which you have defined a couple of helper functions, and have stored some values in variables that you are using to perform repetitive computations.

The time will come in which your work-flow will make you close valuable sessions. For example, you are working with the Python interpreter when you realize that you need to install a new package, and while you are at it you need to check if a library is installed. You'd rather not interrupt the interpreter, and you'd rather not leave your package installation to check the library out.

There's a simple solution: start a new terminal or, if in OS-X, open another window with Command-n (or another tab with Command-t). But it quickly becomes cumbersome, you end up with lots of terminal windows in your screen, and it's not the best way. The best solution is to have multiple workspaces within your terminal, which is what screen does for you. And it is the best because it works, it is based on easy-to-automate keyboard commands, you find it everywhere, and it affords you some measure of permanence between sessions.

Starting screen

Enter

clear

in your terminal to clean up. We'll be showing how screen works with a little experiment, and keeping things tidy will help. We are just about to start creating parallel workspaces and moving among them, and it might get confusing. So we are going to leave tracks, writing something recognizable; type something like this:

echo "This is the starting bash"

And now prepare to run screen. This is what you should see just before you press enter, after typing screen:

Once you press enter you will see a page-long description (check it out, you might see an invitation to send pizza to the authors). Pressing space or enter will clear this page and start screen proper. You should see a new, clean shell. Let's leave a track,

echo "This is the first screen"

Your terminal should now look more or less like this:

Creating a new screen workspace

Type C-a c, and you'll find your terminal looking like a new shell again. The screen man page calls it a window, but I'll use workspace because it does not look like a window at all. Leave a track for later,

And, just for fun, build another one, C-a c again, and echo to know where you are:

Moving between screen workspaces

If you type C-a p you will go back to the previous workspace. Try it out, and your terminal should be back at

With C-a n you will go forward to the next workspace. Experiment circling between workspaces back and forth, making sure you recognize them.

Leaving screen

When you are done with screen, or when you want to do something else with your terminal, type C-a d. This will detach your screen, and it will leave you at your initial bash,

where you can work as usual. Now what's really nice is that, if you want to go back to your screen workspaces, you just run screen again, this time with the -r switch for reattach,

screen -r

and you'll be back, moving with C-a n and C-a p among workspaces that remember your previous work and the state your programs were in, as if you had never left.

Actually closing screen

When you are done with it, you close screen by leaving all the shells it is running. You close a shell by typing C-d (remember that C-d means end of file, and is also how you leave the Python interpreter). When you have closed all the shells within screen it will not have further reason to stay alive, and it will exit.

Pre-packaged screen

Like most UNIX programs, screen is easily configurable with a text file. Its configuration file, ~/.screenrc, allows you to pre-load several workspaces. And, while you are at it, you can also give them names, and make them start in different directories. This is how my .screenrc looks like,

startup_message off
defutf8 on
nonblock on

# hardstatusline
hardstatus on
hardstatus lastline
hardstatus string '%{= b}%-Lw%{= g}%50> %n%f %t%{= b}%+w%<'

# Startup settings
screen -t home 0
chdir /Users/juanre/hp
screen -t hp 1
chdir /Users/juanre/prj
screen -t prj 2

# Fix screen overwriting
altscreen on

So when I start screen I have three workspaces, labeled home, hp and prj, and a nice text at the bottom of the terminal showing me where I am:

A remote server running screen

In a remote server screen becomes much more than a convenience. A remote server is, for example, the computer hosting your web pages. We'll talk about how to connect to another computer in a later chapter.

When you are working in a remote server it feels just like when you are working at the terminal in your computer, but slower. The main difference is that the computer who's answering your commands is your server, not yours.

The first thing you do after login in your server, before starting to work, is to run screen. This allows you to keep several tracks in parallel, creating workspaces as you need them. But then you have to disconnect from the server, and you don't want to stop what you are doing, because maybe one of the workspaces contains a long running program that has not finished, and in another you are editing a file.

So you just detach from your screen, C-a d, and exit the server. The next time you log in you'll reattach with screen -r, and it will be as if nothing had happened. You'll be back to your long running program, maybe finished by now, and to the file you are editing, and to whatever workspaces you left when you disconnected.

You can try something similar now: just exit your screen-running terminal. Open a terminal again, then do screen -r. If all has gone well you should be looking at the workspace where you were before you closed the terminal.

Python packages

Another way in which you improve your work environment is by adding functionality to it. Python gives you an easy way to do it.

Say you are a programmer. You've been working on a cool problem, you've come up with a piece of software to solve it, and you decide to give it to the community.

You want to make it available to other programmers, who may want to contribute to your code. Luckily, you have been using git to keep track of your versions (more on git on a coming chapter), so you decide to store your software as a repository in Github. Once your software is there it is easy for other programmers to get copies, make improvements, and share them with you.

The chances are not low that there will be other programmers around who want to help, or who can take advantage of your software to help them solve other problems: there were 3.5 million users on Github on April 2013, and on December 2013 Github was hosting 10 million repositories.

You also want to make your software available to users, so you package it up in a way that makes it is easy for other people to install. In this section we'll be talking about these packages, and how to install them.

The Python package index

Say your hypothetical piece of software is a Python package. If you want to make it as easy as possible for your users to find it you'll go and register it at the Python Package Index, PyPI for short2. Once your package is listed there your users will be able to find it and install it using a program called pip.

Installing Python packages with pip

Installing pip

It might be that your system already has pip installed. Remember which? Try it out:

which pip

If pip is installed which will tell you where it is. If it is not installed which will stay quiet.

Most likely pip will not be installed, so you'll need to install it. The installation procedure is a rather unusual one: you need to download the installer,

wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py

and then run it with Python,

sudo python get-pip.py

Administrative privileges with sudo

Note that we are not running Python as we usually do: there is a sudo before the call to python. It is required because the installation procedure will need to write in locations of your computer that are protected.

On your day-to-day interaction with the computer you are a normal user: you can modify and delete files in your home directory (either /Users/your-login-name/ if you are in a Mac, or /home/your-login-name/ if you are in Linux), which is plenty enough for normal work and it does not put the integrity of the computer at risk.

But software is usually installed in places of the computer where all users will be able to run it, like /usr/local/bin/, and is usually protected so that normal users cannot remove it.

If you want to install something you will need to temporarily acquire the power to do so: you will need administrative privileges. This is what a sudo before a command does. It will ask for your password, and if you enter it correctly it will grant administrative privileges to the command that you are running. It will work if you are on the sudoers group; if you are not, you will be informed, and you will have to find somebody with administrative rights to your computer to do the installation for you.

To recap, when you do this:

sudo python get-pip.py

you'll be asked for your password and, if you enter it correctly, you'll be giving administrative rights to python get-pip.py. If the person who wrote get-pip.py wanted to wipe out your computer, he could. If somebody intercepts it when you download it, on its way from the Github server where it resides to your computer, she could make it do anything she wanted. Which is kind of scary.

But you'll be all-right. There are many people making sure that get-pip.py does what it's supposed to do; and the address you'll be downloading get-pip.py from begins with https, which means that it will travel encrypted.

Python offers a mechanism that helps you avoid installing things in your machine for everybody. It is called virtualenv, and it makes a local installation of everything Python wherever you want. It is very convenient when you are developing Python packages, but unless you don't have administrative rights to your computer you don't need to worry about it now.

Checking the pip installation

Make sure that you've installed pip, and it's available:

which pip

/usr/local/bin/pip

You should now be ready to run it, if the shell is able to find it. If it doesn't —if which does not return a proper location— it might be because you didn't follow my suggestion to add /usr/local/bin to the PATH environment variable, in which case you should do it now,

export PATH=/usr/local/bin:\$PATH

Improve your Python environment with IPython

IPython is a great addition to your Python toolset. We are going to install and use it for the Python shell it provides, much nicer than the standard python you've been interacting with so far. But IPython does many more things: you might want to spend some time exploring it.

Command line completion

Command line completion is a big deal. It is much easier and quicker to interact with a program that's helping you write —as bash and Emacs do. Let's install IPython, and then we'll take a closer look at completion.

Installing IPython is easy, thanks to pip. But it turns out that it has a dependency —a package it depends on— that you may need to install first: Readline, which "defines a number of functions to facilitate completion and reading/writing of history files from the Python interpreter". It should be straight-forward to install:

sudo pip install readline

sudo pip install ipython

If everything went well you should have now a working IPython installation. Try it out typing

ipython

This should open the ipython shell.

Testing command line completion

Import math,

import math

Then type

math.

and a TAB. IPython will show you all the possible command completions, which are all the functions and variables available in the math module,

math.acos       math.degrees    math.fsum       math.pi
math.acosh      math.e          math.gamma      math.pow
math.asinh      math.erfc       math.isinf      math.sin
math.atan       math.exp        math.isnan      math.sinh
math.atan2      math.expm1      math.ldexp      math.sqrt
math.atanh      math.fabs       math.lgamma     math.tan
math.ceil       math.factorial  math.log        math.tanh
math.copysign   math.floor      math.log10      math.trunc
math.cos        math.fmod       math.log1p
math.cosh       math.frexp      math.modf

This is an extremely convenient thing to have. If you want a quick glance of a module you just import it, then use command line completion to see its contents.

Keep typing: a f, and TAB again:

math.f

math.fabs       math.floor      math.frexp
math.factorial  math.fmod       math.fsum

You see where this is going. If you now type ac, then TAB, it will finish the command for you:

math.factorial

When you are in the terminal, interacting with the shell, you ask for help with man. When in Emacs you do M-x describe-function. When you are interacting with Python you ask for help with the function help,

help(math.cos)

help(math.cos)
Help on built-in function cos in module math:

cos(...)
cos(x)

Return the cosine of x (measured in radians).

When you are in IPython asking for help is even simpler: you only need to do

?math.cos

Playing with Python and math

In the previous chapter we asked the computer to manipulate numbers. It is reasonably easy to convince Python to do simple operations, such as the ones we did, or even combinations of them, such as the average of a list of numbers.

It is a bit more difficult —but very rewarding— to convince your computer to do symbolic math for you. By symbolic we mean that we expect symbols to be manipulated, symbols like the $x$ in the following equation

$x^5 + 3x^4 - 11x^3 - 27x^2 + 10x + 24 = 0.$

How about a way to write a program that would perform algebraic manipulations in symbols such as the above, and maybe find the exact values of $x$ for which the equation is true? It is actually quite straight forward if you have the right package installed.

With pip we can search for an algebra package,

pip search algebra

sympy                     - Computer algebra system (CAS) in
Python
VectorDict                - dict with recursive operations
(algebraic, set, logicial)
Assimulo                  - A package for solving ordinary
differential equations and
differential algebraic equations.
features                  - Feature set algebra for linguistics
qmath                     - qmath provides a class for deal with
quaternion algebra and 3D rotations.
Root evaluations and Moebius
transformations are implemented.
scikits.odes              - A python module for ordinary
differential equation anddifferential
algebraic equation solvers
colorname                 - colorname tries to assign a name to a
color, using predefined color
definitions and linear algebra.
Ceygen                    - Cython helper for linear algebra with
typed memoryviews built atop the Eigen
C++ library
relalg                    - Relational algebra for python
...

The first one is sympy, an awesome package for symbolic mathematics. Let's install it:

sudo pip install sympy

And you are ready to start playing.

Solve equations and plot graphs

Open ipython. First we need the functionality that sympy available. Remember that in order to make the functionality in a package available to the current session we need to import it,

import sympy as sp

but here we are playing a trick. We'll be using sympy later on, and we don't want to use the full name every time we call one of its functions. By adding the as sp to the import we define sp as a synonym, so we can type sp wherever sympy was called for.

Once sympy is loaded we define x as a variable,

x = sp.var('x')

After this we can use x in equations. We may, for example, want to solve the previous one. We start by storing it into a variable p, for polynomial,

p = x**5 + 3*x**4 - 11*x**3 - 27*x**2 + 10*x + 24

where x**5 means $x^5$.

Now we can evaluate the polynomial at any value of x simply by running its subs function (for substitute),

p.subs(x, 10)

116424

Note that you can explore it further simply by typing p., then tab: IPython will show you all the possible completions, which include subs and all the other functions defined in p.

Can we solve the equation? Sure,

sp.solve(p, x)

[-4, -2, -1, 1, 3]

Now you may ask, how come I came up with such a nice polynomial as an example, one that has neat roots? I cheated, of course. I defined it as

p = (x+4) * (x+2) * (x+1) * (x-1) * (x-3)

which was easy to see when it would be zero, and then asked sympy to expand it for me,

sp.expand(p)

x**5 + 3*x**4 - 11*x**3 - 27*x**2 + 10*x + 24

I didn't even have to write it up in LaTeX for nice formatting, sympy did that for me as well:

sp.latex(sp.expand(p))

x^{5} + 3 x^{4} - 11 x^{3} - 27 x^{2} + 10 x + 24

Can we plot it? We can, with sp.plot. We need to give it the coordinate with which we want to plot, x, and its range:

sp.plot(p, (x, -4.5, 3.5))

Some familiarity with Python and sympy can do a lot for your appreciation of mathematics, and your ability to explore them.

Footnotes:

1

Only then can you hope to enter what top athletes and many computer programmers call the flow, a state of mind in which you let your mind focus by itself, and in which you can spend many joyful hours feeling as if your work just happens.

2

There are 39361 packages available at PyPI as of 2014-01-14.

This is the online version of The Hacker Ways.
Get your copy: epub, mobi and PDF, DRM-free.


text:
# Optimality of the Width-$w$ Non-adjacent Form: General Characterisation and the Case of Imaginary Quadratic Bases

@article{Heuberger2011OptimalityOT,
title={Optimality of the Width-\$w\$ Non-adjacent Form: General Characterisation and the Case of Imaginary Quadratic Bases},
author={Clemens Heuberger and Daniel Krenn},
journal={arXiv: Number Theory},
year={2011}
}
• Published 5 October 2011
• Mathematics
• arXiv: Number Theory
Efficient scalar multiplication in Abelian groups (which is an important operation in public key cryptography) can be performed using digital expansions. Apart from rational integer bases (double-and-add algorithm), imaginary quadratic integer bases are of interest for elliptic curve cryptography, because the Frobenius endomorphism fulfils a quadratic equation. One strategy for improving the efficiency is to increase the digit set (at the prize of additional precomputations). A common choice is…
12 Citations

## Figures from this paper

### Non-minimality of the width-w non-adjacent form in conjunction with trace one 휏-adic digit expansions and Koblitz curves in characteristic two

• Mathematics
Math. Comput.
• 2018
This article deals with redundant digit expansions with an imaginary quadratic algebraic integer with trace $\pm 1$ as base and a minimal norm representatives digit set. For $w\geq 2$ it is shown

### Existence and optimality of w-non-adjacent forms with an algebraic integer base

• Mathematics
• 2012
We consider digit expansions in lattices with endomorphisms acting as base. We focus on the w-non-adjacent form (w-NAF), where each block of w consecutive digits contains at most one non-zero digit.

### Multi-Base Representations of Integers: Asymptotic Enumeration and Central Limit Theorems

• Mathematics, Computer Science
• 2015

### Arithmetic of Supersingular Koblitz Curves in Characteristic Three

• Mathematics, Computer Science
IACR Cryptol. ePrint Arch.
• 2010
Digital expansions of scalars for supersingular Koblitz curves in characteristic three are considered, allowing for a very simple and efficient precomputation strategy, whereby the rotational symmetry of the digit set is also used to reduce the memory requirements.

### New Minimal Weight Representations for Left-to-Right Window Methods

• Computer Science, Mathematics
CT-RSA
• 2005
This work introduces a new family of radix 2 representations which use the same digits as the w-NAF but have the advantage that they result in a window method which uses less memory.

In the seminal papers [6, 7], Koblitz curves were proposed for cryptographic use. For fast operations on these curves, these papers also initiated a study of the radix-τ expansion of integers in the

### Efficient Arithmetic on Koblitz Curves

• J. Solinas
• Computer Science, Mathematics
Des. Codes Cryptogr.
• 2000
An improved version of theoblitz algorithm, which runs 50 times faster than any previous version, is given, based on a new kind of representation of an integer, analogous to certain kinds of binary expansions.

### Analysis of Alternative Digit Sets for Nonadjacent Representations

• Mathematics
• 2006
Abstract.It is known that every positive integer n can be represented as a finite sum of the form ∑iai2i, where ai ∈ {0, 1,−1} and no two consecutive ai’s are non-zero (“nonadjacent form”, NAF).


text:
# Right Module Does Not Necessarily Induce Left Module over Ring

## Theorem

Let $\struct {R, +_R, \times_R}$ be a ring.

Let $\struct{G, +_G, \circ}$ be a right module over $\struct {R, +_R, \times_R}$.

Let $\circ' : R \times G \to G$ be the binary operation defined by:

$\forall \lambda \in R: \forall x \in G: \lambda \circ' x = x \circ \lambda$

Then $\struct{G, +_G, \circ'}$ is not necessarily a left module over $\struct {R, +_R, \times_R}$

## Proof

Let $\struct {S, +, \times}$ be a ring with unity

Let $\struct {\map {\mathcal M_S} 2, +, \times}$ denote the ring of square matrices of order $2$ over $S$.

From Ring of Square Matrices over Ring is Ring, $\struct {\map {\mathcal M_S} 2, +, \times}$ is a ring.

Let $G = \set {\begin{bmatrix} x & y \\ 0 & 0 \end{bmatrix} : x, y \in S }$

### Lemma

$G$ is a right ideal of $\struct {\map {\mathcal M_S} 2, +, \times}$.

$\Box$

From Right Ideal is Right Module over Ring, $\struct {G, +, \times}$ is a right module over $\struct {\map {\mathcal M_S} 2, +, \times}$.

Let $R = \map {\mathcal M_S} 2$.

Let $\mathbf A = \begin{bmatrix} 1 & 1 \\ 0 & 0 \end{bmatrix}, \mathbf B = \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix}, \mathbf C = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}$

Then:

 $\displaystyle \mathbf A \times \paren {\mathbf B \times \mathbf C}$ $=$ $\displaystyle \begin{bmatrix} 1 & 1 \\ 0 & 0 \end{bmatrix} \times \paren {\begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix} \times \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} }$ $\displaystyle$ $=$ $\displaystyle \begin{bmatrix} 1 & 1 \\ 0 & 0 \end{bmatrix} \times \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}$ $\displaystyle$ $=$ $\displaystyle \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}$

And:

 $\displaystyle \mathbf A \times \paren {\mathbf C \times \mathbf B}$ $=$ $\displaystyle \begin{bmatrix} 1 & 1 \\ 0 & 0 \end{bmatrix} \times \paren {\begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} \times \begin{bmatrix} 1 & 0 \\ 0 & 0 \end{bmatrix} }$ $\displaystyle$ $=$ $\displaystyle \begin{bmatrix} 1 & 1 \\ 0 & 0 \end{bmatrix} \times \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix}$ $\displaystyle$ $=$ $\displaystyle \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix}$

Hence for $\mathbf A, \mathbf B \in R, \mathbf C \in G$:

$\mathbf A \times \paren{\mathbf B \times \mathbf C} \neq \mathbf A \times \paren {\mathbf C \times \mathbf B}$

Let $\circ : G \times R \to R$ be the binary operation defined by:

$\forall \mathbf \Lambda \in R: \forall \mathbf X \in G: \mathbf \Lambda \circ \mathbf X = \mathbf X \times \mathbf \Lambda$

From Right Module induces Left Module over same Ring iff Actions are Commutative, $\struct {G, +, \circ}$ is not a left module over $\struct {R, +, \times}$

$\blacksquare$


text:
# How can I model a density function of a compressible fluid?

• B

## Main Question or Discussion Point

I have a cylinder of some dimensions. I have a compressible liquid inside. Assuming a constant temperature, no atmosphere, no convection currents within, because it is in a cylinder, there will be no variations in density horizontally (the fluid will have time to settle). Now because there is gravity, the liquid will be pulled down and because the volume of water on top increases as depth increases, the fluid will be more dense at the bottom than at the top. So I pick for example two densities: 0.5 and 1 with 0.5 at the very top of the cylinder and 1 at the very base of it. Something as follows:

https://ibb.co/DCWmTZH < Sloppy Diagram of what I mean

So my question is how can I model this? How can I get some kind of density function out of this? Please go easy on me, I don't really do physics, this is for a Mathematics investigation. Thank you in advance for help, I'm kinda desperate at this point :P.

#### Attachments

• 64.7 KB Views: 151
Last edited by a moderator:

Related Classical Physics News on Phys.org
BvU
Homework Helper
2019 Award

Perhaps you can find some inspiration in the derivation of the barometric formula ?

Chestermiller
Mentor
For a liquid, the density can be approximated by $$\rho=\rho_0[1+\beta (P-P_0)]$$where ##\rho_0## is the liquid density at pressure ##P_0##, P is the local pressure in the liquid, and ##\beta## is the bulk compressibility of the liquid.

The liquid in the cylinder is under hydrostatic conditions, so the pressure is related to elevation z above the bottom of the cylinder by $$\frac{dP}{dz}=-\rho g$$If we combine these two equations, we obtain: $$\frac{dP}{dz}=-\rho_0 g[1+\beta (P-P_0)]$$If we solve this equation for the pressure P as a function of the elevation z, we obtain:
$$P=P_Be^{-\rho_{0} g \beta z}+\left[P_0-\frac{1}{\beta}\right](1-e^{-\rho_{0} g \beta z})$$
where ##P_B## is the pressure at the base of the cylinder z = 0.

Once the pressure at the base is specified, we can determine the pressure at any elevation in the cylinder. We can also integrate this equation over the height of the cylinder to get the average pressure, and also the average liquid density.


text:
# Math Help - Contradiction proof

2. ok, e n is odd and $n^3$ is even. By def of odd and even, there
$\exists \: m \in \mathbb{Z}$ such that $n = 2m + 1$ similarly, $\exists \: k \in \mathbb{Z}$ such that $n^3 = 2k$ so $(2m+1)^3 = 2k$ if you remember what division meant, if a divides b then there exists an integer g such that b = ag. since k is an integer, this means 2 divides (2m+1)^3 which means 2 divides (2m+1) which is a contradiction.


text:
Q&A

Low loss impedance matching without a transformer

+2
−0

I have a signal at 10 MHz produced from a 50 Ω source. How can I match that to a 300 Ω load with low losses without using an RF transformer (space constraints)? Are there any circuits and formulas that can help me achieve this?

Why should this post be closed?

+2
−0

Theory

Input Impedance: -

$$Z_{IN} = j\omega L + \dfrac{\dfrac{R_L}{j\omega C}}{R_L + \dfrac{1}{j\omega C}} = j\omega L +\dfrac{R_L}{1 + j\omega R_L C} = \dfrac{j\omega L - \omega^2 R_L LC + R_L}{1 + j\omega R_L C}$$

Multiply numerator and denominator by the denominator's complex conjugate to get: -

$$Z_{IN} = \dfrac{(j\omega L - \omega^2 R_L LC + R_L)(1 - j\omega R_L C)}{1 + \omega^2 R_L^2 C^2}$$

$$Z_{IN} = \dfrac{j\omega L -\omega^2 R_L LC + R_L + \omega^2 R_L LC +j\omega^3 R_L^2 LC^2 - j\omega R_L^2 C}{1 + \omega^2 R_L^2 C^2}$$

$$\boxed{Z_{IN} = \dfrac{j\omega L + R_L + j\omega^3 R_L^2 LC^2 - j\omega R_L^2 C}{1 + \omega^2 R_L^2 C^2}}$$

To find $\color{red}{\boxed{\omega}}$ that produces a real impedance, equate the numerator's imaginary terms to zero: -

$$\omega L + \omega^3 R_L^2 LC^2 - \omega R_L^2 C = 0$$

$$\color{red}{\boxed{\omega = \sqrt{\dfrac{R_L^2 C - L}{R_L^2 LC^2}} = \sqrt{\dfrac{1}{LC} - \dfrac{1}{R_L^2 C^2}}}}$$

$\color{red}{\boxed{\omega}}$ is the operating frequency of the impedance transformer. We use this relationship below: -

With imaginary terms at zero, $Z_{IN}\rightarrow R_{IN}$ hence: -

$$\boxed{R_{IN} = \dfrac{\cancel{j\omega L} + R_L + \cancel{j\omega^3 R_L^2 LC^2} - \cancel{j\omega R_L^2 C}}{1 + \omega^2 R_L^2 C^2}} = \dfrac{R_L}{1 + \omega^2 R_L^2 C^2}$$

If we substitute the formula for $\color{red}{\boxed{\omega}}$ in the above equation, we can drill down to this: -

$$\boxed{R_{IN} = \dfrac{L}{R_L C}} \text{ and therefore } \boxed{L = R_{IN} R_L C}$$

We can now substitute for L in the $\color{red}{\boxed{\omega}}$ equation hence: -

$$\color{red}{\omega = \sqrt{\dfrac{1}{LC} - \dfrac{1}{R_L^2 C^2}}}\color{black}{ \Longrightarrow \dfrac{1}{C}\sqrt{\dfrac{1}{R_{IN} R_L} - \dfrac{1}{R_L^2}} = \dfrac{1}{R_L C}\sqrt{\dfrac{R_L}{R_{IN}}-1}}$$

We can now solve for C: -

$$\boxed{ C = \dfrac{1}{\omega R_L}\sqrt{\dfrac{R_L}{R_{IN}}-1} }$$

So, if the frequency is 10 MHz, C = 118.62 pF

Given C, we can calculate L = 1.779 μH

Low-pass simulation

Circuit

Results

Conclusion

What the results tell us at 10 MHz is this: -

• The voltage amplification to the load from the source is 1.761 dB
• A 50 Ω to 50 Ω interface will naturally attenuate by 6 dB hence, the result is good
• The phase angle of current into L1 is leading the applied voltage by a fraction of 1 degree (0.0147°) i.e. the circuit input impedance can be regarded as resistive
• The input impedance magnitude is 50.003 Ω i.e. as desired
• The usable bandwidth (± 10°) is about 2 MHz producing a 63 Ω to 46 Ω impedance magnitude change across the bandwidth

High-pass impedance transformation

The alternative to the above circuit is to swap L and C like this: -

Without going through the math again we get: -

$$\boxed{R_{IN} = \dfrac{L}{R_L C}} \text{ and therefore } \boxed{L = R_{IN} R_L C}\text{ (as previously) but,}$$

$$\boxed{ C = \dfrac{1}{\omega R_{IN}}\sqrt{\dfrac{1}{\dfrac{R_L}{R_{IN}}-1}} }$$

So, if the frequency is 10 MHz, C = 142.35 pF

Given C, we can calculate L = 2.135 μH and we see this AC response: -

High-pass simulation

Circuit

Results

Conclusion

• The voltage amplification is 1.761 dB (as per low-pass version)
• The phase angle of current into L1 is leading the applied voltage by a fraction of 1 degree (0.000493°) i.e. the circuit input impedance can be regarded as resistive
• The input impedance magnitude is 49.995 Ω i.e. as desired

Why choose one over the other?

Both circuits work just fine for resistive loads but, if the load is partially reactive (as is often the case), the load can be broken into its parallel equivalent circuit. Then, you choose the top circuit for a load that has parallel capacitance and, you choose the lower circuit for a load that has parallel inductance. Then make the appropriate numerical adjustments to C (low-pass) or L (high-pass).

+0
−0

As an alternative to doing the math, as detailed in Andy's answer, you can use a graphical aid called a Smith chart:

These were used routinely before computers to match transmitters to antennas. The math behind them is what Andy described. See the Wikipedia page for details, which is where the image above was copied from.

@Olin your image is not showing. I am going to add more sections to this answer so it might be that your answer "what Andy described" might not hit the mark in terms of the fullness of what I hope to complete! Andy aka 18 days ago

@Andy: Strange. I see it in my browser. I'm using Edge on Win 10, and also just tested it with IE on Win 10. Both showed the image correctly. What browser and OS are you using? Olin Lathrop 18 days ago

@Olin I'm using google chrome and I still can't see it - bug alert!!! Andy aka 18 days ago

And I can't see it Firefox on Android manassehkatz 18 days ago

@Andy: See the main meta question https://meta.codidact.com/questions/276272 and let them know which images you see. Olin Lathrop 18 days ago

This site is part of the Codidact network. We have other sites too — take a look!

Want to advertise this site? Use our templates!

Chat


text:
# MOSFET: How can I find conduction parameter and transconductance based on graphs?

So I have my graphs (below) with various MOSFET characteristics. I don't know device dimensions or geometry, therefore I can't solve for the 2 directly with an equation. Otherwise I would just do that.

That being said, any ideas on how to solve for transconductance and the conduction parameter based on my graphs?

Conduction parameter:

Transconductance at the area shown above is approximately (9-7)volts/4 mA = ~500. At lower gate voltages, transconductance is more because the change in $$\I_D\$$ is less.


text:
Procedural Modeling

Prerequisites:

The following is a list of all prerequisites in order to make the most out of the following tutorial.

In this tutorial, I am going to teach you the basics of low level procedural modeling and we are going to apply using Animation Nodes.

We can divide procedural modeling into two categories:

1. Low Level: We create objects from scratch by generating vertices locations and the connections between them, this process require some creativity, fun and is the one we will be looking at in this tutorial.
2. High Level: We start by simple objects like geometrical primitives and arrange them in such a way to create more advanced and complicated shapes, this process is fairly simple and usually used when it come to procedural modeling.

Of course there is modeling using math either by defined parametric equations or through implicitly defined equations. But we won’t look at any of them now, however I may explain some of the concepts in a later tutorial.

This topic is hard to explain because it need a good mathematical imagination which most people don’t have, so please excuse me if I haven’t explained it clear enough. I really encourage you to debug every node and every step to better understand it.

First Polygon

You probably know that any object is composed multiple elements including:

• Vertices: They are represented by 3D vectors that define their location.
• Edges : They are represented by a list of 2 integers where the first integer is the index of the first vertex and the second is the index of the second vertex.
• Polygons: They are represented by a list of integers where each integer define the index of one of the vertices that compose the polygon.

Animation Nodes gives us couple of nodes which we can use to create an object:

You can check the documentation for each of them if you don’t know what they do , but they are pretty much self explanatory.

Vertices

Here I create 2 vectors which are $0.2$ units apart, then I use them to create an object. In that case, they represent 2 vertices that are $0.2$ units apart.

An Edge

Here I add edges information and connect the 2 vertices. There is a single edge index that contain $(0,1)$ which are the indices of the only available vertices.

A Polygon

Here I removed the edge and added a polygon info. I basically told it to connect the vertices with indices $(0,1,2)$ which are the indices of the only available vertices. Minimum number of vertices to create a polygon is 3 (A triangle) but there really isn’t a maximum amount.

Order of indices matters of course, even if it was just a triangle.

Here I revered the list resulting in inverting the normal (Because cross product it used to compute normals).

Generate A Line

Lets suppose that we have 2 points and we want to generate a line with a specific number of vertices between them, should I add every point manually? No ! We use a loop.

Algorithm

The algorithm is pretty simple, Having the two input points $A$ and $B$, I can compute a vector $\vec{AB}$ by subtracting $B$ from $A$, lets call it $\vec{D}$, we like to compute vectors instead of using discrete points because they are easier to deal with. See first and second figures:

Then I am going to multiply that vector by some scalar so that its tip is at the second vertex in the line, such scalar is basically the reciprocal of the number of points between the 2 points plus one, so we multiple $\vec{D}$ by $\frac{1}{n+1}$ where $n$ is the number of points between the starting and ending point, lets call it $\vec{D_n}$, we shall see why I did that in a moment. See orange vector in the third figure.

Ok, so how do I compute the points locations using what we just computed? Well, it is very simple, we are going to use such an equation:

Where $t$ is an integer that runs between 0 and $n+1$ where $n$ is the number of points between the starting point and ending point. Lets try this equation.

At $t=0$ we get:

Which is our starting point, At $t=1$ we get:

Which is the second point as we saw before, At $t=2$ we get:

Which is the third point, and so on till $t=n+1$ which is the point $B$:

Ok, now we have our vertices locations, we should now connect them using edge indices, which is pretty easy to do.

If $n$ is equal to four, means we have 4 vertices between the starting and ending point, then their indices exist in $[0,n+1]$ because we are counting both the starting and ending point:

So how do we get edge indices, we can use this simple equation:

where $i$ ranges between $0$ and $n$. Using the above equation we get:

Which if we compared to the image above, it is exactly what we want.

Implementation

I added 2 empties and got their location to use as my starting and ending point then I input them to a group that does some stuff and return me the vector list and edge indices, then it combine those data into a mesh data block then it output it to an object. Lets look at the gears behind this group.

In this group, I compute $\vec{D}$ and $\vec{D_n}$ using the equations we define above, I then input them to a magical loop that return me the vertices locations and edge indices. Notice that the number of iterations is $n+2$ because I am including the starting and ending point. Now lets look at the magical loop.

This is the loop that compute the vertices location and the edges incides. It basically applied the equation we saw before:

Where $t$ is the index in this case. It also used the equation of the edge indices:

Where $i$ is the index, but we encounter a problem here, $i$ is suppose to range between $0$ and $n$ while our index range between $0$ and $n+1$ and we can’t really change that domain. So what I did was add a condition for the Edge Indices output, I told it to return the output if and only if $i+1$ isn’t equal to the number of iterations which is equal to $n$, so I am basically telling it not to include the last indices which it was suppose to compute. If you can’t understand how loops work, go back to my tutorial on loops.

And here is the outcome of our work:

Generate A Grid

I basically want to generate a grid if I know its width and its height, by width and height I just mean the number of vertices in both x and y direction.

Algorithm

First, I want to compute the location of the vertices, putting in mind that we want a function that takes an integer (Index of the vertex) and return a vector (Its location). There is a very simple way to do this, lets look at this equation:

Where $i$ is the index of the vertex which ranges between $0$ and $(W \cdot H)-1$ where $W$ and $H$ are the width and height of the grid.

To make a grid that is $W \times H$ , the number of points we will need is … $W \cdot H$ so this is our number of iterations, but indices starts from zero so thats why $i$ ranges between zero and $(W \cdot H)-1$. Lets try some values of $i$ assuming that the width is $5$.

At $i = 0$, we get:

At $i = 1$, we get:

At $i = 2$, we get:

If we keep inputing values that is between $0$ and $4$ we just get $x=i$ and $y=0$ because if you think about it, the remainder of $i/5$ is just the pattern $[0,1,2,3,4,01,2,3,4,0,1,2,3,4, … ]$ while the floor division is the integer without its fraction, but since we divided $i$ by $5$ then all the values between $0$ and $4$ will just be zero and the floor division produce the pattern $[0,0,0,0,0,1,1,1,1,1,2,2,2,2,2, … ]$. Look at this illustration to understand it better:

You may have noticed by now that the height does not contribute to this equation, well, no, the height contributed very early when we used it to compute the number of points, If you think about it, the above gif could have continues increasing the height of the grid forever, but I limited it to a specific number of vertices and thats what height do, except it will continue the row it started since it is an integer.

Ok we computed the vertices locations, How do we compute their polygon indices? lets look at their indices first:

We want the polygons to be clean quads so we have to sample 4 points for each polygon. An example would be the indices $(0,1,6,5)$ or $(1,2,7,6)$, you probably know the pattern by now, we can describe it as follow:

Where $i$ is the index of the vertex and $w$ is the width. Go ahead and try this equation, compare it with the results we got above and with the drawing above.

If you did try it, you would have noticed that some points just fail when we try to compute their indices, and you probably noticed that those points are at the right edge like $(4,9,14,19,24)$ or at the top edge like $(20,21,22,23,24)$ So we just have to make sure not to include those points in our indices output.

We computed both the the locations and indices, lets move to implementation.

Implementation

Added a group with width and height, inside the group I subtracted 1 from both and handed them to a magical loop then multiplied them and used it as the magical loop iterations. You will see why I needed this subtraction now. Lets look at the loop:

It just apply the equations we described above, the modulo and floor division to get the location and the edge indices by basic arithmetics. The only extra thing here is the condition, I basically told the loop not to output the indices if and only if the x location was not equal to the width minus 1 AND the y location was not equal to the height minus 1. And that is it, we have our grid!

Lets look at the results:

So far we have been setting the z location to zero, but we can just put any value we want. I can for instance control it by a 2D distance function:

Challenge!

Can you create the above example using what we learned so far?

Or I could use a F2-F1 Voronoi diagram to compute the z location:

I will make a full tutorial about voronoi diagrams in the future and I will teach you how to make custom 2D,3D and 4D diagrams from scratch. But for now, you can just use blender’s limited mathutils noise function:

import mathutils
mathutils.noise.noise(Vector,Index)
# Where Vector is your vector and Index is just an integer
# that ranges between 0 and 8 which define the noise type.

I was planning to give you tens of examples but the post became too full just after 2 examples, So I will have to split this tutorial into multiple parts, So stay tuned for the next part !

Yash

What is position of the interpolation in challange.

A possible solution to the challenge is to compute the distance between each point and the point $(0.5, 0.5, 0)$ then evaluate the interpolation at the output distance using the Evaluate Interpolation Node and use the output as the z location.


text:
# Surface Area of a Cone 60 yards by 88 yards Calculator

Enter the value of base radius(r)

Enter the Value of height(h)

The surface area of a cone is equal to the area of the base plus the area of the cone. If the cone Radius 60 yards by height 88 yards is 31370.1478276 yards2.

Surface Area of a Cone 60 yd by 88 yd in other units

Value unit
28.6848632 km2
17.8239919 mi2
28684.8631736 m2
94110.4434828 ft2
1129325.3217936 in2
31370.1478276 yd2
2868486.3173557 cm2
28684863.1735574 mm2

## Surface Area of a Cone 60 yards by 88 yards

Steps:

Given that Base radius(r) = 60 yd and height(h) = 88 yd

Surface Area of a Cone = $(π⋅(Radius))$⋅($(Radius)$ + $\sqrt{(Radius)^2+(Height)^2}$)

Substitute the values of the radius r = 60 yd and height h = 88 yd into the formula. Pi (π) is approximately equal to 3.14 .

$(π⋅(60))$⋅ $(60$ + $\sqrt{(60)^2 + (88)^2})$

Move 60 to the left of π.

$(60π)$⋅$(60$ + $\sqrt{(60)^2 + (88)^2}$

Simplify each term

Raise 60 yd to the power of 2 and 88 to the power of 2

$(60π)$⋅$(60$ + $\sqrt{(3600.0) + (7744.0)}$ yd

Add 3600.0 yd and 7744.0 yd

$(60π)$ yd⋅$(60$ + $\sqrt{(11344.0)}$ yd

Multipy 60π yd and 60 yd

3600.0π yd + (60π . $\sqrt11344.0$)yd

Put the value of $\sqrt11344.0$ = 106.5082156 in formula

3600.0π yd + (60π . 106.5082156) yd

Mulitply the 60π and 106.5082156

3600.0π yd + (6390.4929387π)

Add 3600.0π yd and 6390.4929387π yd

The result can be shown in multiple forms

Exact Form

Area = 9990.4929387π yd

∴ Surface Area of Cone 60 yd by 88 yd is 9990.4929387π yd2

Decimal Form

31370.1478276 yd2

∴ Surface Area of Cylinder 60 yd by 88 yd is 31370.1478276 yd2

### Surface Area & Volume of a Cone Calculations

Here are examples of Surface Area of a Cone calculations.

Here are examples of Volume of a Cone calculations.