text:
# Group Members

TU/e Number Name E-mail
0833049 Sam Roovers s dot roovers at student dot tue dot nl
0886654 Siebrand Keja s dot c dot keja at student dot tue dot nl
1022624 Milan Haverlag m dot a dot haverlag at student dot tue dot nl
1279637 Piyush George Alexander p dot g dot alexander at student dot tue dot nl

## Initial Design

The Initial Design document can be found here : File:Emc-designrequirements.pdf

## Escape room competition

To escape the room, PICO will first scan its surroundings. By the use of a corner detection program the exit is determined from two laser sets (from the front and back). PICO aligns with the angle at which the exit is detected and will drive forward. A potential field must make sure that PICO does not hit any walls.

Simulation for the Escape room challenge is shown below.

Figure 1 Animation of the Escape room challenge

### Exit detection

For detecting the exit, the range from the laser data was considered. PICO does a 360 degree scan and detects an exit point based on distance criteria, i.e. if the distance between consecutive sections is within the exit door tolerance ( 0.5-1 m). After detecting the two points, it searches for the point right in the middle of the detected points, which would be a waypoint for PICO to drive to, followed by which it would drive till the exit is reached.

Figure 2 Exit detection

### Potential field method

In order to prevent PICO from crashing into the walls, obstacle avoidance is needed. For this it is chosen to implement potential field method. The potential field method works by combining a attractive force towards a desired set-point with repulsive forces generated from obstacles.

The Attractive force is calculated from the distance between the robot and the set-point. $r_{att} = \sqrt{(x_{set}-x_{PICO})^2+(y_{set}-y_{PICO})^2}$ and the angle: $\alpha_{att} = tan(\frac{x_{set}-x_{PICO}}{y_{set}-y_{PICO}})$

The attractive force is calculated using a proportional controller:

Fatt = ratt * Katt

The repulsive forces are calculated by taking the inverse of the distance to the wall measured with the laser range finder with the following formula: $r_{rep}(i) = \sqrt{(x_{wall}(i)-x_{PICO})^2+(y_{wall}(i)-y_{PICO})^2}$ $F_{rep}(i) = \frac{K_{rep}}{r_{rep}(i)^3}$

The attractive and repulsive forces are then split in their x and y parts. Their respective x an y parts are then added together:

$F_{tot}(x) = F_{att}(x) + \sum{F_{rep}(i)(x)}$ $F_{tot}(y) = F_{att}(y) + \sum{F_{rep}(i)(y)}$

These Forces are then used to determine where PICO should drive to.

#### Problems with the potential field.

During testing the potential field proved unreliable. When close to a wall, Pico could get in a deadlock or start behaving erraticaly. If a way-point was set inaccurately, The potential field would cause PICO to get stuck next to a wall. It was decided to not implement the potential field on the hospital challenge but instead focus on gaining more accurate way-points. with properly set way-points coupled with a localization algoritmh, Pico would stay away from walls by itself and a potential field wasn't neccesary anymore.

### Shortcommings

Due to time constraints the following features are not implemented which would have made the escape room routine a lot better.

• the positioning of a waypoint in front of the exit with enough clearing from the walls to drive to.
• alignment with the corridor after the waypoint has been reached.

### At the Escape Room Competition

At the Escape room competition we face a segmentation fault, which was mainly due to reading the laser data seperately in different functions into arrays. Now only one copy of the laser data is maintained in the world model for the final architecture. This is being read by the other functions and updated.

### Major take-aways

The scan made by PICO for 360 degrees in the Escape room during the test session was identified and later used as a reference for the hospital challenge. The data points in the real world were used as a reference in order to filter the laser data.

From the scanned data we decided to take one data point for every degree and maintain scan only upto 180 degrees.

The major problem that was resolved was multiple reading of laser and odometry data. This was only done once, and later updated and only a single copy was maintained in the World model for all the functions in the program to use.

## Hospital challenge

### Final Software Architecture

Interface
The figure below shows the data flow of our code. The core of the code is the world model. Information processed is stored here, and action taken are based on information of the world model. The world model is depicted by the green box in the centre. To the right the states inside the code can be observed. Each state uses data from the world to make decisions about the next action to take. Those actions are defined as functions, and those can be seen on the left. These functions are called in several states inside the taks manager code. The arrows connecting the several blocks indicate the data flow, receiving and sending. The data exchanged indicated above the arrows.

#### Scanning and map

The first part of the challenge consists of mapping the hospital. The program to do this consists of the following steps. The steps are schematically shown in the figure above. The several steps in the progress being made as states in the code. At each state functions AND/OR operations are performed on the data. See the legend for the symbol declaration. While executing this part of the code, the Mapping and finding so-called markers, from the world model are constantly updated. Therefore there are no connectors drawn between the states and the world model block. The waypoints are only updated when the particular function waypointfinder is called.

Step 1 (States 1, 2 and 3):
Pico rotates 360 degrees at its starting position to start creating a map of the hallway. The program calculates the end of the hallway using the furthest set of corners that it can find (state 1). A way-point is placed half a meter from the end and Pico drives to that way-point (state 2). When Pico has arrived at the way-point, it starts rotating 360 degrees again completing the map of the hallway (state 3).

Step 2 (State 3):
The program tries to find the doors by looking at corner points found while scanning the hallway. Way-points are then placed in front and behind the center point of the found exits. The way-points that are placed behind the exit are each given a new room number. The created way-points are considered connected with each other, meaning that the robot can use them to drive to another room.

Step 3:
The program checks which way-point is closest. If no way-point can be found that has not already been used, Pico will check which room it is in at that moment. If Pico is in the hallway, Pico will go back to its initial location and go to the parking program. If Pico is not in the hallway, it will check from which way-point it entered the room and go back through that way-point. If an unused way-point is found Pico drives towards that way-point. When Pico arrives at the closest way-point, it then drives to the way-point that is connected to it. The program starts rotating 360 degrees again, adding the room to the exiting map of the hallway.

Step: 4
The program again tries to find the doors by looking at corner points found while scanning the new room. Way-points are then placed in front of and behind the center point of the found exits. The way-points that are placed behind the exits are each given a new room number. Steps 2-4 are repeated until no more unused way-points are found in any of the rooms.

#### Waypoints

In the task.cpp file a function waypointf, standing for waypoint finder, is defined, which returns a waypoint data type struct. As input argument, two exit corner markers are needed. From the coordinates of these exit corners, the waypoint coordinates are defined. The waypoint lies exactly between the two corners, with an offset perpendicular to the direction of the line connected between the two exit corners. This offset was taken into account to prevent Pico driving into a wall.

#### Parking Pico

After Pico has scanned all the unused waypoints, Pico returns to its initial location, where a waypoint was set. This is done as follows. After scanning all the unused waypoints, a function is called to determine the order of waypoints which needs to be followed to reach the initial position. Unfortunately, this function was not completely finished. The idea was that a vector would contain the waypoints, and this vector would be filled by this function. Subsequently, the function navigation in task.cpp is called, which uses this vector as an input argument. The navigation function drives pico in the direction of the first waypoint in the vector. When Pico is close enough to a waypoint, this waypoint is removed from the vector and Pico navigates to the next waypoint. This process continues untill Pico reaches the last waypoint, then the navigation function returns a true boolean, and the state driving back to the initial position is finished, within the function park_Pico, of task.cpp . In the next state the function park is called, which drives Pico with a speed of 0.2, in the x direction untill the control effort is larger than 330. From testing it appeared that the control effort would increase to >300, when Pico bumps into a wall at this speed, therefore this limit was chosen.

#### Using the Hint

After Parking, Pico has to start searching the object. The following hint is given on the location of the object, The object is located in the room that's connected with the hallway through the highest number of doors. A program has been written that determines the room that's furthest away from the hallway. The function find_longest_path, starts by looking at the first way-point in the hallway and finds its connected way-point. the program then looks at which room the connected way-point is located and looks if there any other way-points if there are other way-points then for each of those way-points, the function finds the connected way-points and again looks for other way-points. This is repeated until no more unused way-points can be found. The program then saves the longest path it could find. The function then repeats this for all way-points in the hallway. When all way-points in the hallway are used, the program saves the longest path and the room number that the path leads to. This path consists of an array of consecutive way-points that lead to the room. This information is then fed to the function drive_to_room. A flow diagram of the function is shown below.

In the image below, a visual representation of the function is given for the hospital challenge map.

In the provided map, 3 paths can be found from the hallway. The first path (blue) connects 4 way-points and crosses 2 doors. The second path (red) connects 2 way-points and crosses 1 door. The last path (green) connects 2 way-points and crosses 1 door. The program then returns the path with the most door crossings. In this case this is the blue path.

In the snippets section at the end of this document, the written code for the functions find_path and find_longest_path can be found.

#### Driving to a room

When Pico has determined where the object is expected to be using the given hint, the function drive_to_room is given the path derived by the find_longest_path function and starts driving to the first way-point in the input array. When Pico has reached the point, it starts driving the second way-point. this is repeated until the last way-point in the array. when the last way-point is reached, the object detection function is called.

### Find the object

The last part of the assignment consists of finding the newly placed object. Although the functionality was not implemented yet, as was done for mapping the hospital, we already thought of a possible implementation of the functions, as can be seen in the figure above.

Step 1 (State 1):
In the first state the find_longest_path function is called, which determine the most likely rooms the object to be in.

Step 2 (State 2):
After the room order is determined, Pico starts driving to the rooms where the object is most likely in.

Step 3 (State 3):
When arrived in the room, Pico start scanning the room and compares the laser data found with the original mapping. When too much deviations are found beyond the wall, the object is found and the next state is reached. If nothing is found, Pico returns to the previous state and drives to next most likely room for the object to be in.

## Modified Split and Merge Algorithm

For the detecting the features first it is essential to find out the number of sections in the surrounding. A section comprises a continuous set of data points. A section ends when the distance between consecutive data points exceeds a threshold value. In this case, it is 0.5. In the function that is made, the section details are verified by returning the indexes of the beginning and end section details into separate vectors. The index details are further used to determine the number of sections. The beginning and end details of each section is used in the split and merge algorithm to find the corners and ultimately return a 2 dimensional vector in which each row corresponds to each section and each column has elements which are of a structure type that has the x and y coordinate details, whether itś an intermediate point/ corner and if itś an exit corner or not.

In order to generate the Map, it is essential to detect the features. This is attained using a split and merge algorithm. The basic idea of the split and merge algorithm is as follows if the endpoint and the starting point of the section are known, it fits a line between these two points and evaluates the distance of each point from this line. The point that is at a maximum distance from this line, greater than the threshold set for it being part of a wall, would be marked as corner point1, and a boolean would mark it as false for a corner point( true for intermediate point). If not, it would be identified as a wall. Now the program searches for any more corners between the starting point and the corner point1 and in between the corner point 1 and the exit point. If it finds more corner points it returns the details of these corner points and repeats until only wall segments are identified. For a section, the function ultimately returns the initial point, corner1, corner2 ... corner#n, the endpoint of the section as each row.

### Algorithm

The Modified split and merge algorithm works in the following sequence:

• The starting node = Section beginning point, ending node is the section ending point.
• Line is fitted between these points and distance to each point in between is found.
• distance of each point inbetween from the fitted line is determined with the equation given below.
dist = abs( a*x+ b*y + c )/ sqrt( a²+ b² )

a = (yi - ye)/(xi - xe)

b = -1

c= (xi*ye - xe*yi)/(xi - xe)
• Check is all distances are within the threshhold.( here threshhold was tuned to 0.1 considering the fact that the wall thickness is 20 cm.
 if (distance < threshold )

Return the initial and end point with flag as true indicating that itś a wall.

else fit lines line between the initial point - cornerpoint found and the exit - corner point and search for more corners.

If all wall segments are identified with no more corners, return for the current section, the initial point, corner 1, corner 2 ... etc end point in sequence.

goto the next section, follow the same steps until the last section.

For illustration of the modified split and merge algorithm refer the sequence generated below. The threshold length mentioned here is the length for the point separated from the wall to be categorized as not a wall.

Figure 2.1 Animation of Modified split and merge

The feature depends on laser data as input, the data on reading the CSV file showed several data points as Nan( not a number). These are eliminated from the section by filtering the laser data.

• Separate structure to characterize the points(Marker Allocation)

Figure 3 Identifying the points

Every point that has been detected is a structure of the following form.

• x coordinate
• y coordinate
• bool, true if it's an intermediate point, false if a corner
• bool, true if it's an exit corner

### Characterizing the corners found

Figure 4 : Characterising Corners
• Distinguishing between exterior corners and interior corners.

In order to distinguish between interior corner points and exterior points the following characterisation is made using the MARKERALLOCATION function. A tuning parameter(INDEX) is considered and datapoints with indices before and after the detected corner point are taken and the average of both the indices are considered. If the length of this point to PICO is more than that of the length of the corner point till PICO then itś an exterior corner point, else its an interior corner point.

• Identifying the exit points

The main criteria that was considered for an exit point to be a door is to identify that the distance between the exit point and the next immediate point in the laser range to be within the range of 0.5-1m, except for the last point in the section. If the criteria is satisfied, then the flag for the point is returned with an index of true. This can also be seen in the debugger that has been attached alongside. Only one for the points is identified with an exit corner index.The next immediate point which is at the shortest distance is found.

Figure 5: Exit detection

### Test results

The simulation was performed on the PICO simulator by changing the threshold values do that all the features of the map are identified correctly. The results are depicted below.

From the simulation test results for split and merge algorithm it was possible to adequately determine the corners, however, in real world testing certain features at distances where the density for laser data points are less was missing. This was rectified by adjusting the threshold so that even less dense points are connected together as sections.

## Debugging interface

Figure 6 debugging interface

The above interface was used to debug the modified split and merge algorithm. It gives real time values that are detected as corner/ intermediate points and on whether they are exit or not( from the bool flag). As PICO moves through the map it dynamically gives out the point which can be verified from the map used for in the PICO simulator.

The interface gives real time details of each section under CORNER MATRIX DETAILS. The details are mentioned for each section identified in the anti-clockwise direction with respect to PICO. A span angle of 180 degree is considered for each scan. Note that all end points of a section are identified as intermediate points.

### Limitations and solutions

• Missing corners case .

As shown in the above figure, for a general split and merge algorithm if the index of the first corner that is detected is after another corner point, it would update the initial point to the corner found and miss it. Also, to resolve this it would be required to run the algorithm with the endpoint to the initial point to identify the missed corners. Followed by which a separate function would have been needed in order to arrange them in sequence. These requirements are implicitly carried out in the modified split and merge algorithm.

• Fitted line being a parallel case

Another major drawback faced was if the line fitted between the starting and end node of a section is searching for a corner point in a line thatś formed by two corner points which is parallel to the initial fitted line.

In this case, the corner is identified as a point on the line to which the fitted line is parallel. In this case, for the new algorithm, it checks for more corners between the corner initially found and the start point and as well as between the corner point and the endpoint. Two other corners are found on fitting. On connecting these corners the first corner would lie on a line connecting the two corners found. Hence the first corner would lie on a line.

## Mapping the world

Figure 7 : Linking of markers

With the data from the feature detection the program can determine what the world around PICO looks like. This data can is used to create a map of the world. The feature detection returns the begin and end points of all walls, including the corners it detects between the begin and end points. The feature detection always returns these values in sequence, so it is known that the first returned point is connected to the second point and the second point in the section is connected to the third point in the section, this is illustrated in figure 7

This knowledge is saved in the world model. All these marker points are referenced against the already saved markers and saved if not saved previously. The knowledge of which markers are connected is also saved. Because the markers in a section will always be put out in the same order it can be deduced which corner markers are connected to each other. Intermediate points are not saved if they are not connected to a corner marker.

### Generating the map

The map is made by drawing lines between saved corner markers and its connected markers. This map is saved with the help of opencv in a structure of 3000 by 3000 points. Walls are drawn as black lines. Markers also shown in the map with color coded points for debug purposes. Markers are only saved if they are corner markers or connected to a corner marker. So if a section consists of two intermediate points they will not be saved into the world model. The information which these markers represent is however still very valuable for localization, because it indicates there is a wall between those two points. This is why when a section of two intermediate points is detected, a line will be immediately be drawn in the map, making sure that the localization can use this information without saving the markers themselves.

A doorway between rooms is simply put an open space between walls. The end of those walls are indicated with exit markers. However, the exit markers need to be linked together to represent a doorway. To link those exit corners, first the connected markers are checked. The exit marker should be connected to one regular corner marker and either another exit marker or intermediate marker. By determining the direction from corner marker to exit marker, the approximate angle can be determined where the accompanying exit marker is located on the map. A closest point to the exit marker is searched for within a cone. The approximated direction determined from the corner marker and exit marker is used as the center of the cone. Between the distance of 0.5 meter and 1.5 meter the algorithm searches for the closest point, as this is the minimal and maximal specified width of a doorway. If a closest point is found it will be referenced with all saved markers. If the difference in position between the found point and marker are small enough, approximately 0.1 meter, they will be linked. The correct functioning of this program is verified by drawing these cones and drawing blue lines between the linked exit markers. The result can be seen in figure 8. When these exit markers are linked they can be used to create way points to navigate the world.

Figure 8 : a mapped hospital

## Localization

Figure 9 : graphical representation of the localization algorithm

To localize PICO in the world the current laser data is referenced against the known world, the map. To help localize PICO the change in odometry is used. This gives an indication of where PICO will be. It is however not feasible to do localization purely on odometry due to the fact that wheels can slip, making it unreliable data over long periods of time. The laser data is converted from polar coordinates to cartesian and fitted on the map with varying hypothetical positions on the map, visualized in figure 9. These hypothetical positions are slight variations in angle, x and y on top of the change in odometry.

The quality of the fit is expressed with a number, the higher the number, the better the fit. This number is calculated by the number of points in the map, and their proximity, to a laser data point. The closer the point of the map to the laser point, the more points are added to the quality of the fit. Only a fraction of the laser data points are used for the localization because it is accurate enough and comparing more data would require more processing power, by which the program would slow down. In the end, the hypothetical position of PICO with the best fit will be stored as PICO's current position. To test the proper working of this algorithm the best laser fits are drawn alongside the map. Additionally, all the current calculated positions of PICO are drawn on the map, showing the path it has driven. This is shown in figure 10. The figure shows the simultaneous mapping and localization after implementation.

Figure 10 : fitted laser data on the map together with the driven path

### Simulation in hospital Map

Figure 11.1 : Simulation on the Hospital Map given

### Map generated at the Hospital Challenge

During the challenge PICO did not manage to map the complete hospital. A problem occurred whereby the feature detection did not assign exit markers the correct value, which made it impossible to link exit markers and create waypoints. This is why PICO did a scan only from two points on the map. The map itself looks like we expect it to. The distance criteria not being met in real time due to excessive noise is the speculated reason. by adjusting the threshold properly this problem could be corrected.

Figure 11.2 : Actual Map generated at Hospital competition

## Recomendations

• The function used for the feature detection could be made more robust to ensure it will work properly all the time, for now there are some quick fixes present.
• Due to time constraints there were deviations from the planned interface, for a more compartmentalized working this could be improved upon.
• The high level functions were not working properly, these should be finished and tested for the a program that can complete the hospital competition.
• It could be implemented that the program automatically sets the size of the laser array it should use, now it is hardcoded and may lead to segmentation errors if not handled properly.
• The occurrence of diagonal walls when mapping on the real robot should be investigated, this does not seem to happen in the simulation. It can be that the source of the problem lays with the feature detection.


text:
# NDepend

Improve your .NET code quality with NDepend

## You Have No Excuse for Dead Code

In darker times, software management would measure productivity as a function of lines of code.  More code means more done, right?  Facepalm.  When I work with IT management in my capacity as a consultant, I encourage them to view code differently.  I encourage them to view code as a liability, like inventory.  And when useful code is a liability, think of what a boat anchor dead code is.

I once wrote a fun post about the fate of dead code in your codebase.  And while I enjoyed writing that, it had a serious underlying message.  Dead code costs you time, money, and maintenance headaches.  And it has absolutely no upside.

### A Working Definition for Dead Code

Okay. If I’m going to make a blog post out of disparaging dead code, I should probably offer a definition.  Let’s do that here.

Some people will draw a distinction between code that can’t be executed (unreachable) and executed code whose effects don’t matter (dead).  I acknowledge this definition but won’t use it here.  For the sake of simplicity and clarity of message, let’s create a single category of dead code: any code in your codebase that has no bearing on your application’s behavior is, for our purposes here, dead.

### The Problems with Dead Code

Having defined it, what’s the problem?  If it has no bearing on your application’s behavior, what’s the harm?  How does it cost time and money, as I claimed a moment ago?

Well, simply put, your code does not live in a shrink-wrapped vacuum.  As your application evolves, developers have to change the code.  When you have only code that matters in your codebase, they can do this with the most efficiency.  If, on the other hand, you have thousands of lines of useless code, these developers will spend hundreds of hours maintaining that useless code.

Think of having dead code as being reminiscent of running your heat in the winter while keeping all of your windows open.  It’s self-defeating and wasteful.

But even worse, it’s a totally solvable problem.  Let’s take a look at different types of dead code that you encounter and what you can do about it.

## Static analysis of .NET Core 2.0 applications

NDepend v2017.3 has just been released with major improvements. One of the most requested features, now available, is the support for analyzing .NET Core 2.0 and .NET Standard 2.0 projects. .NET Core and its main flavor, ASP.NET Core, represents a major evolution for the .NET platform. Let’s have a look at how NDepend is analyzing .NET Core code.

## Resolving .NET Core third party assemblies

In this post I’ll analyze the OSS application ASP.NET Core / EntityFramework MusicStore hosted on github. From the Visual Studio solution file, NDepend is resolving the application assembly MusicStore.dll and also two test assemblies that we won’t analyze here. In the screenshot below, we can see that:

• NDepend recognizes the .NET profile, .NET Core 2.0, for this application.
• It resolves several folders on the machine that are related to .NET Core, especially NuGet package folders.
• It resolves all 77 third-party assemblies referenced by MusicStore.dll. This is important since many code rules and other NDepend features take into account what the application code is using.

It is worth noticing that the .NET Core platform assemblies have high granularity. A simple website like MusicStore references no fewer than 77 assemblies. This is because the .NET Core framework is implemented through a few NuGet packages that each contain many assemblies. The idea is to release the application only with needed assemblies, in order to reduce the memory footprint.

NDepend v2017.3 has a new heuristic to resolve .NET Core assemblies. This heuristic is based on .deps.json files that contain the names of the NuGet packages referenced. Here we can see that 3 NuGet packages are referenced by MusicStore. From these package names, the heuristic will resolve third-party assemblies (in the NuGet store) referenced by the application assemblies (MusicStore.dll in our case).

## Analyzing .NET Standard assemblies

Let’s be clear that NDepend v2017.3 can also analyze .NET Standard assemblies. Interestingly enough, since .NET Standard 2.0, .NET Standard assemblies reference a unique assembly named netstandard.dll and found in C:\Users\[user]\.nuget\packages\NETStandard.Library\2.0.0\build\netstandard2.0\ref\netstandard.dll.

By decompiling this assembly, we can see that it doesn’t contain any implementation, but it does contain all types that are part of .NET Standard 2.0. This makes sense if we remember that .NET Standard is not an implementation, but is a set of APIs implemented by various .NET profiles, including .NET Core 2.0, the .NET Framework v4.6.1, Mono 5.4 and more.

## Browsing how the application is using .NET Core

Let’s come back to the MusicStore application that references 77 assemblies. This assembly granularity makes it impractical to browse dependencies with the dependency graph, since this generates dozens of items. We can see that NDepend suggests viewing this graph as a dependency matrix instead.

The NDepend dependency matrix can scale seamlessly on a large number of items. The numbers in the cells also provide a good hint about the represented coupling. For example, here we can see that  22 members of the assembly Microsoft.EntityFrameworkCore.dll are used by 32 methods of the assembly MusicStore.dll, and a menu lets us dig into this coupling.

Clicking the menu item Open this dependency shows a new dependency matrix where only members involved are kept (the 32 elements in column are using the 22 elements in rows). This way you can easily dig into which part of the application is using what.

## All NDepend features now work when analyzing .NET Core

We saw how to browse the structure of a .NET Core application, but let’s underline that all NDepend features now work when analyzing .NET Core applications. On the Dashboard we can see code quality metrics related to Quality Gates, Code Rules, Issues and Technical Debt.

Also, most of the default code rules have been improved to avoid reporting false positives on .NET Core projects.

We hope you’ll enjoy using all your favorite NDepend features on your .NET Core projects!

## How to Use NDepend’s Trend Charts

Imagine a scene for a moment.  A year earlier, a corporate VP spun up a major software project for his organization.  He brought a slew of his organization’s software developers into the project.  But he also needed to add more staff in the form of contractors.

This strained the budget, so he cut a few corners in terms of team member experience.  The VP reasoned that he could make up for this with strategic use of experienced architects up front.  Those architects would prototype good patterns and make it so the less seasoned contractors could just kind of paint by numbers.  The architects spent a few months doing just that and handed the work off to the contractors.

Fast forward to the present.  Now a consultant sits in a nice office, explaining to a beleaguered VP how they got so far behind schedule.  I can picture this scene quite easily because organizations hire me to be this consultant.  I live this scene over and over again.
Continue reading How to Use NDepend’s Trend Charts

## Computing Technical Debt with NDepend

For years, I have struggled to articulate technical debt to non-technical stakeholders.  This struggle says something, given that technical debt makes an excellent metaphor in and of itself.

The concept explains that you incur a price for taking quality shortcuts in the code to get done quickly.  But you don’t just pay for those shortcuts with more work later — you accrue interest.Save yourself an hour today with some copy pasta, and you’ll eventually pay for that decisions with many hours down the road.

So I say to interested, non-technical parties, “think of these shortcuts today as decisions upon which you pay interest down the line.”  They typically squint at me a little and say, “yeah, I get it.”  But I generally don’t think they get it.  At least, not fully.

### Lack of Concreteness

I think the reason for this tends to come from a lack of actual units.  As a counterexample, think of explaining an auto loan to someone.  “I’m going to loan you $30,000 to buy a car. With sales tax and interest factored in, you’ll pay me back over a 5 year period, and you’ll pay me about$36,000 in total.”  Explained this way to a consumer, they get it.  “Oh, I see.  It’ll cost me about \$6,000 if I want you to come up with that much cash on my behalf.”  They can make an informed value decision.

But that falls flat for a project manager in a codebase.  “Oh man, you don’t want us to squeeze this in by Friday.  We’ll have to do terrible, unspeakable things in the code!  We’ll create so much tech debt.”

“Uh, okay.  That sounds ominous.  What’s the cost?”

“What do you mean?  There’s tech debt!  It’ll be worse later when we fix it than if we do it correctly the first time.”

“Right, but how much worse?  How much more time?”

“Well, you can’t exactly put a number to it, but much worse!”

And so and and so forth.  I imagine that anyone reading can recall similar conversations from one end or the other (or maybe even both).  Technical debt provides a phenomenal metaphor in the abstract.  But when it comes to specifics, it tends to fizzle a bit.

format: plain


text:
## Missouri Journal of Mathematical Sciences

### Induced Fibrations on Spaces of Fiber Transferring Maps: The $C^r$ Case

Manolis Magiropoulos

#### Abstract

For $C^r$ differentiable manifolds $E$ and $B$ of the same dimension, and $\pi \colon E \to B$ a local $C^r$ diffeomorphism and onto, we examine, as with the topological case, the extent to which some basic properties of $\pi$ are inherited by the induced map $p$ on spaces of fiber transferring maps with respect to $\pi$.

#### Article information

Source
Missouri J. Math. Sci., Volume 13, Issue 1 (2001), 24-28.

Dates
First available in Project Euclid: 5 October 2019

https://projecteuclid.org/euclid.mjms/1570240920

Digital Object Identifier
doi:10.35834/2001/1301024

Mathematical Reviews number (MathSciNet)
MR1816336

Zentralblatt MATH identifier
1034.57025

#### Citation

Magiropoulos, Manolis. Induced Fibrations on Spaces of Fiber Transferring Maps: The $C^r$ Case. Missouri J. Math. Sci. 13 (2001), no. 1, 24--28. doi:10.35834/2001/1301024. https://projecteuclid.org/euclid.mjms/1570240920


text:
Hi, does anybody of you know of the Wheat chessboard legend? \ If not, it goes something like this:

Shihram, ruler of India, was quite a abusive ruler. To show him the wrongness of his ways without risking his own live, Sissa developed a game in which the king was the most important figure, but was not able to do anything without his pawns. You may have already guessed that, but this game was chess. Playing chess with Sissa, Shihram became a more calm ruler. To reward Sissa for this, Shihram granted him a wish. And Sissa wished to have wheat grains put onto a chessboard, one grain on the first field, two on the second, four on the third and so on. Shihram started laughing and granted his wish, still being annoyed because he thought Sissa was wishing for so little. Two days later, he asked his underlings if Sissa had gotten his reward, but was told that his underlings were still calculating. Two more days later, he was told that the reward was not yet calculated, but already much more then all wheat in his whole kingdom.

So how much was it exactly?

A chessboard has 64 fields so we would have:

$$w = \sum_{i=0}^{63} 2^i$$

We notice if we wrote this in binary, this would be:

$$w = 0111111111111111111111111111111111111111111111111111111111111111$$

which we also can write as:

$$w = 1000000000000000000000000000000000000000000000000000000000000000 - 1$$

or again in decimal:

$$w = 2^{64} - 1$$

so how do we calculate this without a calculator?

Lets assume we know: $1024 = 2^{10}$ so we get $w = 2^4 \cdot 1024^6$.

Now the question is, how much is $1024^6$?

Spliting it into $(1000 + 24)^6$ and using Pascal's triangle

$$\begin{array}{c|ccccccccccccc} 0& & & & & & & 1 & & & & & & \\ 1& & & & & & 1 & & 1 & & & & & \\ 2& & & & & 1 & & 2 & & 1 & & & & \\ 3& & & & 1 & & 3 & & 3 & & 1 & & & \\ 4& & & 1 & & 4 & & 6 & & 4 & & 1 & & \\ 5& & 1 & & 5 & & 10& &10 & & 5 & & 1 & \\ 6& 1 & & 6 & &15 & &20 & &15 & & 6 & & 1 \end{array}$$

\begin{align*} (1000 + 24)^6 &= 1 &\cdot 24^0 &\cdot 1000^6 \\ &+ 6 &\cdot 24^1 &\cdot 1000^5 \\ &+ 15 &\cdot 24^2 &\cdot 1000^4\\ &+ 20 &\cdot 24^3 &\cdot 1000^3\\ &+ 15 &\cdot 24^4 &\cdot 1000^2\\ &+ 6 &\cdot 24^5 &\cdot 1000^1\\ &+ 1 &\cdot 24^6 &\cdot 1000^0 \end{align*}
Actually calculating them will give us $\approx 18.447 \cdot 10^{18}$ wheat grains. No wonder they could not find enough of it ^^


text:
# Problem #884

 884 Charlyn walks completely around the boundary of a square whose sides are each $5$ km long. From any point on her path she can see exactly $1$ km horizontally in all directions. What is the area of the region consisting of all points Charlyn can see during her walk, expressed in square kilometers and rounded to the nearest whole number? $\mathrm{(A)} 24 \qquad\mathrm{(B)}\ 27 \qquad\mathrm{(C)}\ 39 \qquad\mathrm{(D)}\ 40 \qquad\mathrm{(E)}\ 42$ This problem is copyrighted by the American Mathematics Competitions.
Note: you aren't logged in. If you log in, we'll keep a record of which problems you've solved.


text:
# How to Do Percentage Calculations? (+FREE Worksheet!)

Want to find a percent of a number? You can calculate percentages in a few simple and easy steps.

## Step by step guide to solving percentage problems

• Percent is a ratio of a number and $$100$$. It always has the same denominator, $$100$$. The percent symbol is $$\%$$.
• Percent is another way to write decimals or fractions. For example:
$$40\%=0.40=\frac{40}{100}=\frac{2}{5}$$
• Use the following formula to find part, whole, or percent:
$$\color{blue}{part =\frac{percent}{100} \ × \ whole }$$

### Percentage Calculations – Example 1:

What is $$15\%$$ of $$50$$?

Solution:

Use the this formula: $$\color{ blue }{part =\frac{percent}{100} \ × \ whole }$$.
$$part$$ $$=\frac{15}{100} \ × \ 50 →$$ $$part$$ $$=\frac{15 \ × \ 50}{100}→$$ $$part$$ $$=\frac{75}{10}→$$ $$part$$ $$=7.5$$

### Percentage Calculations – Example 2:

What is $$30\%$$ of $$35$$?

Solution:

Use the this formula: $$\color{ blue }{part =\frac{percent}{100} \ × \ whole }$$.
$$part$$ $$=\frac{30}{100} \ × \ 35 →$$ $$part$$ $$=\frac{30 \ × \ 35}{100}→$$ $$part$$ $$=\frac{105}{10}→$$ $$part$$ $$=10.5$$

### Percentage Calculations – Example 3:

What is $$10\%$$ of $$45$$?

Solution:

Use the this formula: $$\color{ blue }{part =\frac{percent}{100} \ × \ whole }$$.
$$part$$ $$=\frac{10}{100}×45 →part$$$$=\frac{1}{10}×45$$→$$part$$ $$=\frac{45}{10}→$$ $$part$$ $$=4.5$$

### Percentage Calculations – Example 4:

What is $$15\%$$ of $$24$$?

Solution:

Use the percent formula: $$\color{ blue }{part =\frac{percent}{100} \ × \ whole }$$.
$$part$$ $$=\frac{15}{100}×24 →$$ $$part$$ $$=\frac{15 \ × \ 24}{100}$$→ $$part$$ $$=\frac{360}{100} →$$ $$part$$ $$=3.6$$

## Exercises for Doing Percentage Calculations

### Calculate the percentages.

1. $$\color{blue}{50\% \ of \ 25}$$
2. $$\color{blue}{ 80\% \ of \ 15 }$$
3. $$\color{blue}{ 30\% \ of \ 34 }$$
4. $$\color{blue}{ 70\% \ of \ 45 }$$
5. $$\color{blue}{ 10\% \ of \ 0 }$$
6. $$\color{blue}{ 80\% \ of \ 22 }$$

1. $$\color{blue}{12.5}$$
2. $$\color{blue}{12}$$
3. $$\color{blue}{10.2}$$
4. $$\color{blue}{31.5}$$
5. $$\color{blue}{0}$$
6. $$\color{blue}{17.6}$$

### What people say about "How to Do Percentage Calculations? (+FREE Worksheet!)"?

No one replied yet.

X
30% OFF

Limited time only!

Save Over 30%

SAVE $5 It was$16.99 now it is \$11.99


text:
You are currently browsing the category archive for the ‘911’ category.

I wish to pen down (key in?) a singular event I happened to experience, something that I wouldn’t forget soon. This blog post I hope will serve to me as a refresher down the memory lane, years later.

On Alex’s advice, I decided to run hills. (In his words, “You’ll hate yourself running uphill but I know no other method to improve your running speed and stamina.”)  I biked to the top of “Mt. Salisbury” and after running it up and down, was on my way back home. On the bridge on Lindberg Rd, I saw a girl drooping, leaning across the bridge. I gave her a second glance and biked ahead wondering if it she was running and the sun dehydrated her. But who runs in their sandals? I turned back and rode toward her.

“Are you alright? Do you want some water?”

She started sobbing. (Uh oh!) She drank some water and hugged me. My turn to freak out, because it wasn’t a brisk hug but a painfully long one.

“Whatever it is, it’ll be alright.” (I offered my two pennies of  solace).

“Would you help me commit suicide? I want to jump over.”

“This won’t help, it’s too shallow” (Who commits suicide jumping in a bog? She wouldn’t even have fractured herself! But I agree, this isn’t the best reply you can give to a girl contemplating death. In my defence, I handled it good enough, overall.)

She fell on the trail and I sat next to her, wondering what action to take. I asked her which direction her home was and that we should walk that direction. She told she was drunk, a fact I deduced during the aforementioned hug. I compelled her to keep walking to her home and get some rest. On the way, we embarked on a (trivial) discussion about the existence of god and the goodness in people. She told me how other people on the trail ignored her and walked past. She was a Purdue undergrad; her life was in shambles and she had no one. (I believe the last part is false; for you need some parent / guardian who’ll fund your undergrad, especially in this country. I didn’t challenge her.)

She also mentioned she had been contemplating suicide for years and that I should help her. (Now I am of the opinion that if a person truly wants to die in spite of being counseled, the government should give them the opportunity. In India and Indiana, it’s a felony. Nonsense; but I’ll save this discussion for another day.)

Now this girl jumps over the railing and stands on the road, waiting to be hit by a car. The speed limit for that road is 30 mph, so again an ineffective way to kill oneself. Again I sprung into action and made her jump to the other side. At this time, she collapsed in the grass. I felt it the perfect moment to call 911. She rose up and tried to snatch my cellphone but I overpowered her. Sensing trouble, she ran away in the direction of her home. I gave her description to the authorities and no sooner than I traveled some 100m than I saw a Sheriff car (without sirens, interestingly!) turn towards the apartment complex. They caught her as soon as she was about to enter the house and interrogated her. My role ended with me narrating the cops this incident and giving my identity.

———————————————————————————————————————-

Tailpiece: Do you think we have free will? Was it my own free will that made me turn around and help (?) the girl out? Or was I programmed? My life would have been a bit different had I chosen to ignore and bike past her.

Assume for the moment that we do have free will. Was I right in doing what I did? For all I know, this suicide attempt stays on her “file” possibly throughout her life. Perhaps she was suffering with a terminal disease and death was her best option. Even then, I think I acted wisely. I think I can justify my actions. What do you say?

(You might have read about my running the first $\pi$ miles. This is a rather different experience).

(Edit: 6 July, ’12 — If you have fractured a jaw and are looking for a liquid diet, see this post I wrote recently).

Today evening I completed running $\pi$ miles on the Wabash river trail. I have done it more than a hundred times in the last few months. But today was special. Completing the track was a liberating moment. For one, I completed it with less-than-usual oxygen; I breathed only through my nose and not once through the mouth.

As I write this, I feel the steel wires and rubber-bands in my mouth. My teeth are fixed, the jaws are immovable and there are six stitches on the chin. I can feel one molar chipped off and one week after the accident, I feel pain in my wrist.

It was on the evening of 26th May that the four of us set out for biking. We were around 10 miles from Purdue where I had this accident. It was a reckless daredevilry, something that I am not proud of & something I wouldn’t like to recollect¹. After the accident, we called a friend and also 911 (the latter came before) and I was taken to the Emergency room of the hospital². I had the X-ray and CT-scan done but already knew my jaw was fractured. The doctor stitched the chin-injury and discharged me with the desperately-needed painkillers. Three days later, I had a surgery with an oral surgeon who (after knocking me unconscious) implanted steel braces and rubber-bands in my mouth thus completely immobilizing any jaw movement. For six weeks, I shall not be able to open my mouth. No coughing or yawning please! And only liquid diet.

#### Tailpiece:

I realize that the pain-killers have subdued any painful sensation in my jaws. Most of me is perfectly fine, most importantly my brain. And I am doing Mathematics with acetaminophen. Just like Erdös!³ Hope I am able to come up with some theorem in these six weeks!

##### ³ If you are unaware, the legendary mathematician Paul Erdös took amphetamines and said the drug helped him do mathematics. Read his biography here.

Abhishek Parab

I? An Indian. A mathematics student. A former engineer. A rubik's cube addict. A nature photographer. A Pink Floyd fan. An ardent lover of Chess & Counter-Strike.

View my complete profile

### Quotable Quotes

ABHISHEK PARAB
“Do not think; let the equation think for you”

PAUL HALMOS
”You cannot be perfect, but if you won’t try, you won’t be good enough”

ALBERT EINSTEIN
“Don’t worry about your maths problems; I assure you, mine are greater”

THE BEST MATH JOKE
"A comathematician is a device for turning cotheorems into ffee"

More quotes


text:
# Math Help - graph of equation over given interval

1. ## graph of equation over given interval

Identify the graph of the equation over the given interval.

y=3sin (2x-pi/2)

x is greater than or equal to -pi/4 and x is less than or equal to 3pi/2.

I think I found the period to be: pi
the amplitude is 3.
the phase shift is pi as well?

I'm unsure as to what to do after this though.

My choices are these, but I don't know how to determine which is correct. I'm not just looking for an easy answer, I really want to try to understand this. Thanks so much guys.

2. Actually, phase shift is $\frac{\pi}{4}$ since: $y = 3\sin \left(2x - \frac{\pi}{2}\right) = y = 3\sin \left[ 2\left(x - {\color{red}\frac{\pi}{4}}\right)\right]$

Now from your typical $y = \sin x$ graph, make the changes accordingly. Change its amplitude to 3. Shift it to the right $\frac{\pi}{4}$ units. Adjust the period.
____________________________

Alternatively ...

To make things easier, note that: $\sin \left(\theta - \frac{\pi}{2}\right) = -\cos \theta$

So we have: $y = 3\sin \left(2x - \frac{\pi}{2}\right) \ \Leftrightarrow \ y = 3 (-cos 2x) = -3 \cos (2x)$

Much easier to graph


text:
# 241 [-/2.27 Points] 1 sum DETAILSUse the [0/2.27 5 Tormula Points] "} 5 DETAILS 1 series PREVIOUS ANSWERS find

###### Question:

241 [-/2.27 Points] 1 sum DETAILS Use the [0/2.27 5 Tormula Points] "} 5 DETAILS 1 series PREVIOUS ANSWERS find ROGACALCET} L;2.026. Use the fumula [-1227 Pointa] 46)" the sum DETNLS 1 ROGACALCET? find the 10.2.025. stat Uat tha Jieluory ROGACALCET3 10.2.029, 1 (If the 1 1 1 " 1 6 0

#### Similar Solved Questions

##### Write a program C++ about Copmputer struct Redo lab 3 and change the Computer class to...
write a program C++ about Copmputer struct Redo lab 3 and change the Computer class to a struct. 1. Keep the default and non-default constructors 2. Your struct does not need the accessors and mutators since all variables are public by default. 3. Write a main(): - Create an instance of type Compute...
##### Find and identify all the equilibrium points and plot the phase portrait ofthe system31 - r2 Sry ~V+ry +y?Show your work and essential details. If you use maple, You should send your maple code to me by email: To finish the analysis, you may need the following Theorem: Theorem (Chengzhi Li; 1982): Consider~Y + azr2 +ary + Q02y? r + b2oz? + bry + bozy?_DefineWi W2 W3Aa _ BB, [B(5A - 8) + a(B a)ly; (AB + Ba)y6,whereA = 620 + Q02. B = bzo + bo2. a = C11 2boz. 8 = b1 + 2020; b20.43 (a20 b1)APB + (bo
Find and identify all the equilibrium points and plot the phase portrait ofthe system 31 - r2 Sry ~V+ry +y? Show your work and essential details. If you use maple, You should send your maple code to me by email: To finish the analysis, you may need the following Theorem: Theorem (Chengzhi Li; 1982):...
##### 2 A periodic signal is given by z(t) = 3cos(t) + cos (5t2sin (8t + & (a) Sketch both amplitude and phase spectra for the Fourier series of ~(t); If r(t) is nOw to be sampled, what is the least sampling frequency Wsmin in order to avoid any distortion? (c) Determine the DTFT of this sampled signal > (t); (d) Suppose r (t) is ready to be truncated for DFT, find the minimum number of sampling points No to resolve every component if the sampling frequency Ws = 20 rad:/sec.
2 A periodic signal is given by z(t) = 3cos(t) + cos (5t 2sin (8t + & (a) Sketch both amplitude and phase spectra for the Fourier series of ~(t); If r(t) is nOw to be sampled, what is the least sampling frequency Wsmin in order to avoid any distortion? (c) Determine the DTFT of this sampled sign...
##### Find the moment generating function of the following exponential distribution and hence find its varianceAe-Ax x >0 f(x; A) = 10 otherwise
Find the moment generating function of the following exponential distribution and hence find its variance Ae-Ax x >0 f(x; A) = 10 otherwise...
##### Linearity is an extremely useful property of equations in physics. If an equation is linear, it...
Linearity is an extremely useful property of equations in physics. If an equation is linear, it allows you to easily add together simple contributions from individual elements to get a solution for a more complex situation. One example of a simple linear equation in classical mechanics is F ma. If y...
##### [-{2 Points]DETAILSMY NOTESDetermine whether the set, together with the indicated operations vecto space If it not; then identify one The set f all quadratic functions wnose araphs pass through the pbint 1) with the standard operationsthe vector space axioms that fails.The setvector spaceThe setvector space becauseosed under additionThe setvector space because the commutative propentyadditionnot satisfied_The setvector space because the assoclative propertyaddition not satisfled,The set not . ve
[-{2 Points] DETAILS MY NOTES Determine whether the set, together with the indicated operations vecto space If it not; then identify one The set f all quadratic functions wnose araphs pass through the pbint 1) with the standard operations the vector space axioms that fails. The set vector space The ...
##### This is very important and very useful formula One use is to relate the polar coordinate and cartesian coordinate formulas for the complex number: If can be represented by both coordinates x + iy and by polar coordinates r, 0 thenreie rcos(e) + ir sin(0) =x +iy =2A. Find and () (use an angle betweenand x) such that the red point Z1reiosqrt37Find and 0 (use an angle between ~T and m) such that the blue point Zz reiesqrt10Using the law of exponents it is really easy to multiply complex numbers rep
This is very important and very useful formula One use is to relate the polar coordinate and cartesian coordinate formulas for the complex number: If can be represented by both coordinates x + iy and by polar coordinates r, 0 then reie rcos(e) + ir sin(0) =x +iy =2 A. Find and () (use an angle betwe...
##### Ihausidot ol tha heghbs = ainlallaadant obarud 0041 apunmoni conducied 0 Dass tequatsy dateon Io tnrito cons NUCA [email protected] coreuledtom dalnbiot rnedc Maly WeeerteTegis? Spvalcaly co tha r0ijts nppcar to bubhuHHW reported &' measufed? Twdula Anntnt fuperleo Curlun nta Hupronattonal nunu dpnam TEnni UEL rouahttha MeautG Nealane Certut htee taa Jprpertoni dliennnnm nunbur &l Untel muufed hahts OTUI mlh mudy Iha Ha ejutngnln
Ihausidot ol tha heghbs = ainlallaadant obarud 0041 apunmoni conducied 0 Dass tequatsy dateon Io tnrito cons NUCA hiteorn_ @jilFrequengy Mie coreuledtom dalnbiot rnedc Maly WeeerteT egis? Spvalcaly co tha r0ijts nppcar to bu bhu HHW reported &' measufed? Twdula Anntnt fuperleo Curlun nta H...
##### Use Excel (or another plotting program) to plot the 2s and 2p radial distribution functions By differentiation, determine the most probable radii that a 2s and 2p electrons. Why are these values different than that calculated in 92
Use Excel (or another plotting program) to plot the 2s and 2p radial distribution functions By differentiation, determine the most probable radii that a 2s and 2p electrons. Why are these values different than that calculated in 92...
##### Q) What is the force F on the 2.9 nC charge in the middle of (Figure...
Q) What is the force F on the 2.9 nC charge in the middle of (Figure 1 below) due to the four other charges? Give your answer in component form. 一2.0 nC 2.0 nC 1.0 cm :1.0cm 一2.0 nC 2.0 nC...
##### What is the p-value when we test H0 : µ = 10 versus Ha: µ < 10 and have a calculated test statistic Z = -2.41 (ó is known)
What is the p-value when we test H0 : µ = 10 versus Ha: µ < 10 and have a calculated test statistic Z = -2.41 (ó is known) .008 -.008 .016 .4920 -.4920...
##### A monatomic ideal gas expands slowly to twice its original volume, doing $450 \mathrm{~J}$ of work in the process. Find the heat added to the gas and the change in internal energy of the gas if the process is (a) isothermal; (b) adiabatic; (c) isobaric.
A monatomic ideal gas expands slowly to twice its original volume, doing $450 \mathrm{~J}$ of work in the process. Find the heat added to the gas and the change in internal energy of the gas if the process is (a) isothermal; (b) adiabatic; (c) isobaric....
##### A) Explain Democratic leadership style b) How is Democratic leadership style works and is used? C)...
a) Explain Democratic leadership style b) How is Democratic leadership style works and is used? C) How effective is the Democratic leadership style? d) Examples of the Democratic leadership style?...
##### ~5 [Ot?Fiudl litn Sn" sin n (ii) Find M[3][9] (iii) By uxing pproprinte test_ dleterwine whcther thcne crics COnverge or diverge.()[4]() 2[4](iv) Find the rualius of COuVergenee of thee power sricsnI"
~5 [Ot? Fiudl litn Sn" sin n (ii) Find M [3] [9] (iii) By uxing pproprinte test_ dleterwine whcther thcne crics COnverge or diverge. () [4] () 2 [4] (iv) Find the rualius of COuVergenee of thee power srics nI"...
##### Mollie had a 16 -ounce cappuccino at her neighborhood coffee shop. The cappuccino had 110calories. If Mollie walks for one hour, she burns 246 calories. For how many minutes must Mollie walk toburn off the calories in the cappuccino? Explain your reasoning.
Mollie had a 16 -ounce cappuccino at her neighborhood coffee shop. The cappuccino had 110 calories. If Mollie walks for one hour, she burns 246 calories. For how many minutes must Mollie walk to burn off the calories in the cappuccino? Explain your reasoning....
##### Does accreditation impact quality? Are there less errors in hospitals that are accredited? What is the...
Does accreditation impact quality? Are there less errors in hospitals that are accredited? What is the value of accreditation? Do quality concerns initiate changes in staff behavior? Should accreditation be based on results?...
##### . If minor losses are neglected, determine the flow rate in each pipe ( is out...
. If minor losses are neglected, determine the flow rate in each pipe ( is out and - is into the reservoir) Elevation= 50 m Elevation 20m Elevation 10 m D=0.10 m に150m f 0.015 D = 0.08 m = 150m f 0.020 D 0.08 m 300m f 0.020...
##### 3. Assume this circuit contains an ideal battery and that enough time passes that the capacitors...
3. Assume this circuit contains an ideal battery and that enough time passes that the capacitors in this circuit reach their maximum charge. a) What is the equivalent capacitance? b) What is the charge on the 12.0 pF capacitor? c) If each capacitor was originally air filled and now has a polysterene...
##### Circle the molecule that gave rise t0 the spectrum shown below. The exact values on the x axis are not available: (2 points)100-
Circle the molecule that gave rise t0 the spectrum shown below. The exact values on the x axis are not available: (2 points) 100-...
##### Name 1. This problem is designed to test your skill in using the Tables in the...
Name 1. This problem is designed to test your skill in using the Tables in the Appendix to find probabilities and cutoffs. (Drawing a picture is highly recommended.) (a) Suppose that the random variable B follows a Binomial distribution with no 9 and p = .70, find P(B = 6). (b) Suppose that the rand...
##### Evaluate J Js F SP using the divergence theorem:
Evaluate J Js F SP using the divergence theorem:...
##### It is NOT answer C Price Index Value in June 2018 Value in June 2019 Inflation...
It is NOT answer C Price Index Value in June 2018 Value in June 2019 Inflation rate Consumer Price Index for All Urban Consumers: All Items 251.13 255.31 1.66 % Personal Consumption Expenditures (Chain-type Price Index) 108.18 109.65 1.36 % Personal consumption expenditures excluding food and energy...
##### What is defined as "the purposeful and systematic process to problem solving?
What is defined as "the purposeful and systematic process to problem solving?...


text:
# Partitions of Primes

Problem 461 from Parabola (Volume 16, Issue 2, p.32) asked: Partition the set $P_n=\{2,3,5,\dots,p_n\}$ of the first $n$ primes into two nonempty disjoint parts $A,B$ and let $a, b$  be their respective products. Is $|a-b|$ always a prime or 1? If not, find the smallest $n$ for which it isn't. The answer (given in Parabola 1981, volume 17, issue 1, p.~31--32) is  no, and the smallest $n$ is 5. Taking $A=\{2,5,7,11\}$ and $B=\{3\}$, one has $a=770, b=3$ and $a-b=767=13\cdot59$. To see this, the key observation is that the numbers $a,b$ share no common factors. It follows that the  prime factors of $a-b$  can't divide either $a$ or $b$. So the smallest possible prime factor of  $a-b$ is $p_{n+1}$. Armed with this information, it doesn't take long to find the required answer. And this is all done easily by hand; after all, the problem was posed in 1980. We propose a modern variation of this problem.


text:
# Challenge

Write a program that takes an array of 4 integers (which represents a sequence of numbers generated by a certain algorithm) and returns the next integer that would follow.

We will only be using simple addition, subtraction, multiplication and division algorithms with a constant (i.e non-variable) variation.

For division we will use the floor integer values: 133/4 = 33 and 33/4 = 8

You can assume that there will always be one single valid return value

# Test cases

[14,24,34,44] should return 54 (addition Algorithm)

[105,45,-15,-75] should return -135 (subtraction algorithm)

[5,25,125,625] should return 3125 (multiplicative algorithm)

[256,64,16,4] should return 1 (division algorithm)

# General rules

• This is a simplified version of What comes next? and borderline duplicate. – Peter Taylor Aug 30 '16 at 14:15
• In the future, I recommend you to post in Sandbox before going live so that you can receive other people's comments beforehand. – Leaky Nun Aug 30 '16 at 14:52
• You should really add some tests cases for integer division. Almost all replies fail to give correct result for [261,65,16,4], [4,2,1,0], or [2,1,0,0] – Damien Aug 30 '16 at 16:40
• I disagree with the duplicate vote(s). Finding the algorithm is simpler in the sense that there's only one operation to consider, but at the same time, it's harder because integer division has to be accounted for. I don't think there's porting an answer from the other challenge would be substantially easier than writing one from scratch. – Dennis Aug 30 '16 at 16:57
• You should probably specify non-negative integers, as when a division series is negative there are two interpretations. For example -81/4 is either 21 r 3 or -20 r -1. – Jonathan Allan Aug 30 '16 at 18:42

# 05AB1E, 1816 18 bytes

D¥¬QPi+s-ër/s\*î

Explanation

D                   # duplicate
¥                  # delta's
¬Q                # compare first delta to the other deltas
P               # product (1 if all deltas are equal, otherwise 0)
i              # if 1 (we're dealing with addition or subtraction)
+s-          # add the difference between the elements to the last element
ë         # else (we're dealing with multiplication or division)
r/      # divide the 2nd element by the 1st
s\*   # multiply with the 4th element
î  # round up

Try it online!

• The output is wrong with [4,2,1,0] ... – Damien Aug 30 '16 at 16:30
• @Damien: Thanks for letting me know. I fixed it and it even saved me a couple of bytes :) – Emigna Aug 30 '16 at 16:44
• Great. Now it validates all my test cases. – Damien Aug 30 '16 at 16:47
• Try edge case for divide by four: [-325, -82, -21, -6] – Jonathan Allan Aug 30 '16 at 18:32
• ...actually I guess the question should either be just for non-negative integers or should specify which convention is to be used. – Jonathan Allan Aug 30 '16 at 18:40

## Javascript (ES6),  44  42  44 bytes (fixed)

(a,b,c,d)=>a-b+d-c?d/(a<b?a/b:a/b|0)|0:d+c-b

Saved 2 bytes, following IsmaelMiguel's advice.
Fixed version for [2,1,0,0] and [1,0,0,0] as suggested by edc65

### 30 bytes version

For the record, my first attempt was 32 30 bytes but was lacking floor() support for the division. It also fails for special cases such as [2,1,0,0] and [1,0,0,0].

(a,b,c,d)=>c-2*b+a?d*c/b:d+c-b

### Demo

var f =
(a,b,c,d)=>a-b+d-c?d/(a<b?a/b:a/b|0)|0:d+c-b

var test = [
[ 14, 24, 34, 44 ],     // should return 54 (addition Algorithm)
[ 105, 45, -15, -75 ],  // should return -135 (subtraction algorithm)
[ 5, 25, 125, 625 ],    // should return 3125 (multiplicative algorithm)
[ 256, 64, 16, 4 ],     // should return 1 (division algorithm)
[ 260, 65, 16, 4 ],     // should return 1 (division algorithm with floor())
[ 2, 1, 0, 0 ],         // should return 0 (special case of division algorithm)
[ 1, 0, 0, 0 ]          // should return 0 (special case of division algorithm)
];

test.forEach(l => console.log('[' + l.join, + '] => ' + f(...l)));

• Wow, I didn't know that js has pattern matching. – Leaky Nun Aug 30 '16 at 14:13
• @LeakyNun - Destructuring assignment was indeed introduced in ES6. Note that you can't do [a,b]=> for function parameters. The parentheses are required. – Arnauld Aug 30 '16 at 14:22
• Nice, but you should handle integer division: [260, 65, 16, 4] => 0.9846153846153847. It should give 1 – Damien Aug 30 '16 at 14:30
• @Damien - Ah well... I knew someone would notice. ;-) That's fixed. – Arnauld Aug 30 '16 at 14:57
• What about [2,1,0,0] ? Should give 0. I think it's the only counter example for b*2==c+a <=> addition/substraction algorithm – Damien Aug 30 '16 at 16:26

# Brachylog, 3733 27 bytes

b:[E]cL,?:Iz{:+a|:*a|:/a}Lt

Saved 10 bytes thanks to @LeakyNun.

### Explanation

Input = [A:B:C:D]

b:[E]cL,     L = [B:C:D:E]
?:Iz         Create the list [[B:I]:[C:I]:[D:I]:[E:I]]
{            Either…
:+a          Sum all couples of that list
|            or…
:*a          Multiply all couples of that list
|            or…
:/a          Integer divide all couples of that list
}L          The result is L
t           Output is the last element of L

As LeakyNun pointed out, we don't need the subtraction case because I can be any integer.

• wow, brachylog(& prolog) are awesome – Maltysen Aug 30 '16 at 14:19
• Addition and subtraction is the same – Leaky Nun Aug 30 '16 at 14:22
• @LeakyNun Correct, thanks! – Fatalize Aug 30 '16 at 14:25
• 29 bytes – Leaky Nun Aug 30 '16 at 14:31
• 27 bytes – Leaky Nun Aug 30 '16 at 14:31

f l@[a,b,c,d]|[a,b..d]==l=d+b-a|z<-b+0^b=div(d*b)$a-mod(max b a)z  # Python 2, 40 bytes lambda(a,b,c,d):[d+c-b,d*c/b][c-2*b+a>0]  It's literally the JS answer ported into Python (thanks @LeakyNun!). My previous approach was ridiculously long, but here it is: ## Python 2, 169 166 bytes The second and third levels are a raw tab and a raw tab plus a space, respectively, which plays really badly with Markdown, so the tabs have been replaced by 2 spaces. x=input() q='%d%s%d' for i in range(max(x)): for o in'+-*/': a=1 for e,n in zip(x,x[1:]): try:1/(eval(q%(e,o,i))==n) except:a=0 if a:print eval(q%(x[-1],o,i))  Pretty simple; tries every constant and operator it thinks could be the constant, then if the constant/operator combination works for every element in the list (using a try/except pair to avoid ZeroDivisionErrors), it prints the result for the last element in the list. I'm sure there's a better method here, this is the naive method. • You'd better just port the js answer into Python – Leaky Nun Aug 30 '16 at 14:24 • Breaks for [1,0,0,0] which should output 0 – Jonathan Allan Aug 30 '16 at 18:35 # TSQL, 55 bytes This script is trying adding and subtraction in the same check, then it tries to multiply, if that fails, it must be division. DECLARE @1 INT=6561, @2 INT=729, @3 INT=81, @ INT=9 PRINT IIF(@2-@1=@-@3,@*2-@3,IIF(@1*@2=@3,@*@1,sqrt(@)))  Fiddle # C#, 63 bytes int f(int[]x)=>2*x[1]-x[0]==x[2]?x[3]+x[1]-x[0]:x[3]*x[1]/x[0];  Checks whether the difference between the first and second element is the same as the difference between the second and third element. If so, it does addition/subtraction, otherwise it does multiplication/division. # JavaScript, 73 bytes (a,b,c,d)=>(x=b-a,c-b==x&&d-c==x)?d+x:(x=b/a,b*x|0==c&&c*x|0==d)?d*x|0:-1  Tests: console.log(s.apply(null,[14,24,34,44]), 54); console.log(s.apply(null,[105,45,-15,-75]), -135); console.log(s.apply(null,[5,25,125,625]), 3125); console.log(s.apply(null,[256,64,16,4]), 1); console.log(s.apply(null,[2,1,0,0]),0); console.log(s.apply(null,[1,0,0,0]),0); console.log(s.apply(null,[-325,-82,-21,-6]),-1); console.log(s.apply(null,[-1,-1,-1,-1]),-1); console.log(s.apply(null,[0,0,0,0]),0);  Works for them all. • Wasn't sure about the etiquette here. I know there's already another JS answer, but it doesn't address the edge cases. Mine is longer, but handles all those. Let me know if I didn't do this right. – Whothehellisthat Aug 31 '16 at 14:13 • There's nothing wrong with posting an answer in the same language as another answer, especially if your answer is correct and the other one is not. I don't know if you have enough rep to do so, but you might also want to comment on that answer to let them know which edge cases they are missing. – DJMcMayhem Aug 31 '16 at 14:29 • I actually took the edge cases from that other post, but they haven't solved the issue. ;P – Whothehellisthat Aug 31 '16 at 14:30 # GameMaker Language, 70 bytes a=argument0;If a[3]+a[1]=a[2]*2return a[4]*2-a[3]return a[4]*a[4]/a[3]  ## R, 68 74 Array: 68 bytes function(x)if(x[2]-x[1]==x[3]-x[2])x[4]+x[2]-x[1]else x[4]%/%(x[1]%/%x[2]) > (function(x)if(x[2]-x[1]==x[3]-x[2])x[4]+x[2]-x[1]else x[4]*x[2]/x[1])(c(14,24,34,44)) [1] 54  4 inputs: 45 bytes function(a,b,c,d)if(b-a==c-b)d+b-a else d*b/a  Bonus solution with log, exp, var, 71 bytes if(var(v<-diff(x<-scan(,1)))==0)x[4]+v[1]else x[4]*exp(diff(log(x)))[1]  update: integer division • Isn't this taking four variables rather than an array? If not you can get rid of the parentheses around b-a to save a byte though (and I note that your example calls are adding spaces back in). – Jonathan Allan Aug 30 '16 at 20:32 • @JonathanAllan You are right. It does not take an array. The byte count has been updated. The parenthesis are needed due to else, but we can save a byte by adding a space instead. The calls don't need the additional spaces. – Vlo Aug 30 '16 at 21:16 • Yep, that's why I said you could save 1 byte rather than 2 – Jonathan Allan Aug 30 '16 at 21:34 • Note, it does not currently handle the integer division requirement fully, e.g. 261,65,16,4 returns 0.9961686 rather than 1 (of course there should be a test case for this in the question). – Jonathan Allan Sep 1 '16 at 11:09 • @JonathanAllan function(x)if(x[2]-x[1]==x[3]-x[2])x[4]+x[2]-x[1]else x[4]%/%(x[1]%/%x[2]) – Vlo Sep 1 '16 at 14:09 # Java, 125 123 bytes Golfed: int m(int[]a){int r=(a[1]>a[0])?a[1]/a[0]:a[0]/a[1];return(a[0]-a[1]==a[1]-a[2])?a[3]-a[0]+a[1]:(a[0]<a[1])?a[3]*r:a[3]/r;}  Ungolfed: int m(int[] a) { int r = (a[1] > a[0]) ? a[1] / a[0] : a[0] / a[1]; return (a[0] - a[1] == a[1] - a[2]) ? a[3] - a[0] + a[1] : (a[0] < a[1]) ? a[3] * r : a[3] / r; }  This code surely has some issues since it doesn't handle division by zero and such things. It also won't work of course if there are more (or less) than 4 integers in the input array a. Which makes it beyond stupid, but I had fun :) Try it out: https://ideone.com/nELH5I # TI-Basic, 37 bytes Works on any TI-83/84 calculator Input L1 gets input into an array L1(4)²/L1(3 calculate the fifth number in a geometric series If not(sum(ΔList(ΔList(L1 if ΔList(ΔList(L1)) yields an array of all zeroes L1(4)2-L1(3 calculate the fifth number in an arithmetic series Ans is implicitly returned  # Python 2, 75 66 65 61 bytes lambda(a,b,c,d):d*2-c if d-c==b-a else d*b/a or b and d/(a/b)  Much longer than my previous 38 byte entry which did not cater for the division series correctly (just as most others didn't). Test cases and more edge cases are on ideone Note: integer division for a negative here is defined as having a remainder with the same sign as the divisor, so -81/4 would be -21 with a remainder of 3 and -81/-4 would be 20 with a remainder of -1. • negative number divided by negative number is positive... -81/-4 != -21 – Destructible Lemon Aug 31 '16 at 23:15 • @DestructibleWatermelon Indeed it is. I have edited that and added the test case [325,-82,20,-5]. – Jonathan Allan Sep 1 '16 at 10:20 # Jelly, 14 bytes ṪḤ_ṪµṪ²:ṪµIE$?

Try it online!

ṪḤ_ṪµṪ²:ṪµIE$? Main Link = ? If IE$   [condition]
I     The differences between consecutive elements
E    Is equal
ṪḤ_Ṫ            [then]
Ṫ               The last element
Ḥ              Doubled
_             Minus
Ṫ            The last element (second-last of original list)
µṪ²:Ṫµ      [else]
Ṫ          The last element
²         Squared
:        Divided by
Ṫ       The last element (second-last of original list)

# Pyth, 18 Bytes

?-+vzJEyQ/^E2J-yEJ

Accepts input as a newline-separated list of values.

Try it online!

Explanation:

?                         If
-                          the following are not equal:
+vzJE                      the sum of first and third values (and call the third value J)
yQ                    and the second value * 2;
(i.e. if it is not an additive or subtractive formula)
^E2             Then: square the fourth value
/   J              and divide by the third
?                         Else:
yE           double the fourth value
-  J          and subtract the third


text:
## Google code jam 2008 QR - Train Timetable

Problem

A train line has two stations on it, A and B. Trains can take trips from A to B or from B to A multiple times during a day. When a train arrives at B from A (or arrives at A from B), it needs a certain amount of time before it is ready to take the return journey - this is the turnaround time. For example, if a train arrives at 12:00 and the turnaround time is 0 minutes, it can leave immediately, at 12:00.

A train timetable specifies departure and arrival time of all trips between A and B. The train company needs to know how many trains have to start the day at A and B in order to make the timetable work: whenever a train is supposed to leave A or B, there must actually be one there ready to go. There are passing sections on the track, so trains don't necessarily arrive in the same order that they leave. Trains may not travel on trips that do not appear on the schedule.

Input

The first line of input gives the number of cases, N. N test cases follow.

Each case contains a number of lines. The first line is the turnaround time, T, in minutes. The next line has two numbers on it, NA and NB. NA is the number of trips from A to B, and NB is the number of trips from B to A. Then there are NA lines giving the details of the trips from A to B.

Each line contains two fields, giving the HH:MM departure and arrival time for that trip. The departure time for each trip will be earlier than the arrival time. All arrivals and departures occur on the same day. The trips may appear in any order - they are not necessarily sorted by time. The hour and minute values are both two digits, zero-padded, and are on a 24-hour clock (00:00 through 23:59).

After these NA lines, there are NB lines giving the departure and arrival times for the trips from B to A.

Output

For each test case, output one line containing "Case #x: " followed by the number of trains that must start at A and the number of trains that must start at B.

Limits

1 ≤ N ≤ 100

Small dataset

0 ≤ NA, NB ≤ 20

0 ≤ T ≤ 5

Large dataset

0 ≤ NA, NB ≤ 100

0 ≤ T ≤ 60

Sample

 Input Output 253 209:00 12:0010:00 13:0011:00 12:3012:02 15:0009:00 10:3022 009:00 09:0112:00 12:02 Case #1: 2 2Case #2: 2 0

Analysis

This problem can be solved with a greedy strategy. The simplest way to do this is by scanning through a list of all the trips, sorted by departure time, and keeping track of the set of trains that will be available at each station, and when they will be ready to take a trip.

When we examine a trip, we see if there will be a train ready at the departure station by the departure time. If there is, then we remove that train from the list of available trains. If there is not, then our solution will need one new train added for the departure station. Then we compute when the train taking this trip will be ready at the other station for another trip, and add this train to the set of available trains at the other station. If a train leaves station A at 12:00 and arrives at station B at 13:00, with a 5-minute turnaround time, it will be available for a return journey from B to A at 13:05.

We need to be able to efficiently identify the earliest a train can leave from a station; and update this set of available trains by adding new trains or removing the earliest train. This can be done using a heap data structure for each station.

Sample Python code provided below that solves a test case for this problem:

def SolveCase(case_index, case):
T, (tripsa, tripsb) = case
trips = []
for trip in tripsa:
trips.append([trip[0], trip[1], 0])
for trip in tripsb:
trips.append([trip[0], trip[1], 1])

trips.sort()

start = [0, 0]
trains = [[], []]

for trip in trips:
d = trip[2]
if trains[d] and trains[d][0] <= trip[0]:
# We're using the earliest train available, and
# we have to delete it from this station's trains.
heappop(trains[d])
else:
# No train was available for the current trip,
start[d] += 1
# We add an available train in the arriving station at the
# time of arrival plus the turnaround time.
heappush(trains[1 - d], trip[1] + T)

print "Case #%d: %d %d" % (case_index, start[0], start[1])

Luckily Python has methods that implement the heap data structure operations. This solution takes O(n log n) time, where n is the total number of trips, because at each trip we do at most one insert or one delete operation from the heaps, and heap operations take O(log n) time.

Source Code in C++
1#include <hash_set>
2#include <iostream>
3
4using namespace std;
5
6#define Rep(i,n) for (int i(0),_n(n); i<_n; ++i)
7
8struct Time
9{
10    int HH;
11    int MM;
12    void Add(int deltaMM, int deltaHH=0)
13    {
14        MM += deltaMM;
15        if(MM>=60{
16            MM%=60;
17            deltaHH++;
18        }

19        HH += deltaHH;
20        if(HH>=24{
21            HH%=24;
22        }

23    }

24    bool operator< (const Time& B) const
25    {
26        if(HH<B.HH)
27            return true;
28        else if(HH==B.HH) {
29            if(MM<B.MM)
30                return true;
31            else
32                return false;
33        }
else
34            return false;
35    }

36    bool operator> (const Time& B) const
37    {
38        if(HH>B.HH)
39            return true;
40        else if(HH==B.HH) {
41            if(MM>B.MM)
42                return true;
43            else
44                return false;
45        }
else
46            return false;
47    }

48    bool operator<= (const Time& B) const
49    {
50        return !(*this>B);
51    }

52}
;
53
54struct Trip
55{
56    Time departure;
57    Time arrive;
58    char station; //0:A;1:B
59    Trip()
60    {
61    }

62    Trip(char pos)
63    {
64        station = pos;
65    }

66    bool operator< (const Trip& B) const
67    {
68        if(arrive<B.arrive)
69            return true;
70        else
71            return false;
72    }

73}
;
74
75int main()
76{
77    int T;
78    freopen("..\\s.in","r",stdin);
79    freopen("..\\s.out","w",stdout);
80    scanf("%d"&T);
81    Rep(t, T) {
82        int turnTime;
83        scanf("%d"&turnTime);
84        int NA, NB;
85        scanf("%d%d"&NA, &NB);
86        vector<Trip> trips;
87        vector<Time> trains[2];
88        trips.reserve(NA+NB);
89        Rep(i, NA) {
90            Trip trip(0);
91            scanf("%d:%d %d:%d"&trip.departure.HH, &trip.departure.MM, &trip.arrive.HH, &trip.arrive.MM);
92            trips.push_back(trip);
93        }

94        Rep(i, NB) {
95            Trip trip(1);
96            scanf("%d:%d %d:%d"&trip.departure.HH, &trip.departure.MM, &trip.arrive.HH, &trip.arrive.MM);
97            trips.push_back(trip);
98        }

99        sort(trips.begin(), trips.end());
100
101        int start[2= {0};
102        Rep(i, NA+NB) {
103            int d = trips[i].station;
104            if(!trains[d].empty() && trains[d][0<= trips[i].departure) {
105                pop_heap(trains[d].begin(),trains[d].end(),greater<Time>());
106                trains[d].pop_back();
107            }
else {
108                start[d]++;
109            }

110            Time train(trips[i].arrive);
112            trains[1-d].push_back(train);
113            push_heap(trains[1-d].begin(),trains[1-d].end(),greater<Time>());
114        }

115
116        printf("Case #%d: %d %d\n", t+1, start[0], start[1]);
117    }

118    return 0;
119}

120

posted on 2009-08-13 14:09  CLive Studio  阅读(...)  评论(...编辑  收藏

• 随笔 - 23
• 文章 - 0
• 评论 - 33
• 引用 - 0


text:
# No space before first section in framed box

I am looking for the correct way to lay out content in a framed box. In my opinion the space before the first section in a box looks odd in comparison to the same content at the start of a page. How can I remove the horizontal space before the first section in a framed box? In particular I am looking for a compositional solution, that is, I would like to use the same latex code no matter whether it is placed within a box or not.

\documentclass{article}

\setlength{\parindent}{0pt}

\setlength{\fboxrule}{2pt}

\usepackage{showframe}
\usepackage{blindtext}

\begin{document}

\section{Title}
\blindtext

\section{Title}
\blindtext

\fbox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{%
\section{Title}
\blindtext

\section{Title}
\blindtext}}

\end{document}

-

Consider the following, where a minipage is used rather than a parbox in the third instance:

\documentclass{article}

\setlength{\parindent}{0pt}

\setlength{\fboxrule}{2pt}

\usepackage{showframe}
\usepackage{blindtext}

\begin{document}

\section{Title}
\blindtext

\section{Title}
\blindtext

\fbox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{%
\section{Title}
\blindtext

\section{Title}
\blindtext}}

\fbox{%
\begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule}
\section{Title}
\blindtext

\section{Title}
\blindtext
\end{minipage}%
}
\end{document}

and which gives an output on the third page like:

-
oh and do note the % both in \fbox{% and at the end of the minipage where it necessary to type \end{minipage}% (or in fact \end{minipage}} if you prefer having the closing brace on the same line). –  greyshade Aug 11 '14 at 7:46
and I hope you are aware that neither with a parbox nor with a minipage this will behave nicely at a page break.. –  greyshade Aug 11 '14 at 7:51
Ah, I see, so I was actually looking for a minipage rather than a parbox, thanks. I am aware that the box is not broken. –  Jan Christiansen Aug 11 '14 at 9:39

The usage of package tcolorbox provides, correctly setup, very tight boxes around the text and other nice features

Since two sections are involved, the box should be breakable.

The options left,top,right,bottom and boxsep control the spacing between the box frame and the box content.

\documentclass{article}

\usepackage{tcolorbox}
\tcbuselibrary{breakable}%

\usepackage{showframe}
\usepackage{blindtext}

\begin{document}

\section{Title}
\blindtext

\section{Title}
\blindtext

\begin{tcolorbox}[breakable,arc=0pt,auto outer arc,left=0pt,right=0pt,bottom=0pt,boxsep=0pt,top=0pt,width=\textwidth]%
\section{Title}
\blindtext

\section{Title}
\blindtext
\end{tcolorbox}%

\begin{tcolorbox}[breakable,arc=0pt,outer arc=0pt,left=0pt,right=0pt,bottom=0pt,boxsep=0pt,top=0pt,width=\textwidth,colback={yellow},boxrule=4pt]%
\section{Title}
\blindtext

\section{Title}
\blindtext
\end{tcolorbox}%

\end{document}

-
you forgot the breakable option in the specification of the tcolorbox - without it your solution has no advantage over the others. –  greyshade Aug 11 '14 at 7:56
@greyshade: Yes, I noticed, that I have forgotten it, but it is not your job to edit my answers. While you were editing my answer, I was just adding it ;-) –  Christian Hupfer Aug 11 '14 at 7:58
couldn't have known there was a bigger edit coming ;-) (and in the case of including \tcbuselibrary{breakable}, but then not using breakable I felt the author's intend was clear enough that an edit was warranted). –  greyshade Aug 11 '14 at 8:03
@greyshade: A comment is often sufficient. And I personally refrain from editing other users' answers, except in the First Post queue, for formatting issues. –  Christian Hupfer Aug 11 '14 at 8:06
Thanks for the solution, I was looking for a solution without using tcolorbox, I should probably have mentioned that. –  Jan Christiansen Aug 11 '14 at 9:40

A solution with the framed package. To illustrate what can be done with it, I define a frshaded and a frshaded* environments, for which you can choose the colour of the frame and of the background. The difference is that the former environment has frame width equal to \linewidth, while the latter has frame built around a text of width \linewidth.

I adjusted the vertical spacing above first framed section with a \vspace*{-\baselineskip}, compensated by \vspace{\baselineskip} before the frame. That can easily be incorporated in a framedsections environment.

Here is the code:

    \documentclass{article}

\setlength{\parindent}{0pt}
\usepackage{etoolbox}
\usepackage[x11names]{xcolor}
\usepackage{showframe, framed}
\usepackage{blindtext}

\setlength\FrameRule{0.8pt}
\setlength\FrameSep{3pt}

\colorlet{framecolor}{Red1}

\MakeFramed {\FrameRestore}}%
{\endMakeFramed}

{\endMakeFramed}

\begin{document}

\section{Title}
\blindtext

\section{Title}
\blindtext
\vspace*{\baselineskip}
\section{Title}
\blindtext

\blindtext
\section{Title}
\blindtext

\vspace*{\baselineskip}

Thanks very much for the example. I do not know whether the content in the box actually starts with a section or not. Therefore, I would like to avoid the use of an explicit vspace with a negative amount. Can I avoid this approach without using a minipage? –  Jan Christiansen Aug 18 '14 at 14:56


text:
# Bicategories with base change

Published:

Abstract: The notion of double category was first introduced and studied by Ehresmann in [1]&[2]. The structure of a weak double category includes a bicategory of horizontal morphisms and a category of vertical morphisms. So, one can view double categories as a generalization of bicategories in which there are two types of morphisms: vertical morphisms that may be taken to compose strictly among themselves and horizontal morphisms that behave like bimodules. Double categories are also useful for making sense of certain constructions such as calculus of mates, spans, and Parametrized Spectra in homotopy theory.

In this notes I will review fibrant double categories (aka framed bicategories introduced in [3]) in which one has a structure of a bicategory and the base change along vertical morphisms. I will give important example of fibrant double category of bimodules of algebras in which base change corresponds to extension, restriction , and coextension of bi-modules along algebra maps. The idea of a bicategory with base change was first (to my knowledge) formalized in Dominic Veritys PhD thesis [4]. There he uses concept of 2-categories with proarrow equipment which turns out to be equivalent to framed bicategories.

[1] Ehresmann, A. & Ehresmann, C. (1978), ‘Multiple functors. ii. the monoidal closed category of multiple categories’, Cahiers Topologie Geom. Differentielle Vol.19, 295333.

[2] Ehresmann, C. (1963), ‘Categories et structures’, Ann. Sci. Ecole Norm. Sup. Vol.19, 349– 426.

[3] Shulman, M. (2009), ‘Framed bicategories and monoidal fibrations’. URL: arXiv:0706.1286

[4] Verity, D. (1992), ‘Enriched categories, internal categories and change of base (phd thesis)


text:
# Relating velocities of different bodies using classical mechanics [closed]

In the given question, I'm required to figure out the velocity of block $C$, given that both blocks $A$ and $B$ move towards left with velocities $1$ $m/s$ each.

Its easy to figure out that in horizontal direction, as block $C$ is in contact with block $B$, it would move with $1$ $m/s$.

Doubt: How can I possibly find the velocity of block $C$ in the vertical direction. I know I have to relate the motion of blocks with the pulleys, but how can I possibly do this? Also, if I'm assuming the tension as $T$ in the longest string, what would the tensions in the other smaller strings? How can these tensions be related to one another?

I've literally tried to answer this question for 2 weeks but I'm failing time and again. Please let me know the general approach to solve problems of similar type, also if you happen to solve it just by simple observation , please let me know the logic . This really matters to me. Thanks for giving this your precious time

EDIT :Can I use the method in the answer in this post to solve this problem ? If yes , then how and if no then why not ? I tried but I couldn't solve it by this . Finding the acceleration of Block attached using tricky string setup

• Is the bottom left pulley moving relative to block B? Is the bottom left pulley moving relative to the bottom right pulley? Is the length of string between the block B and the bottom right pulley changing? – Farcher Oct 29 '17 at 14:44
• Well , nothing of that sort is specified in the question , though like other questions , it can be assumed that all velocities are in the frame of reference of earth(ground).So , the length of the bottom string should not change . – Tanuj Oct 29 '17 at 14:47
• Put another way., if you are sitting on block B do you see block A moving? – Farcher Oct 29 '17 at 14:54
• No , I don't think so , No. – Tanuj Oct 29 '17 at 14:56
• So you have answered the question as sitting on block B you see nothing moving. – Farcher Oct 29 '17 at 15:02

Given that all three blocks $A, B, C$ are moving left with the same velocity, and that the string attached to $C$ is fixed at the other end to $B$, and that all of the pulleys are fixed to blocks $A$ and $B$, the only way block $C$ could have a vertical velocity would be if blocks $A$ and $B$ had differing velocities (changing separation).

We know that $A$ and $B$ are moving with the same velocity, which means that the string cannot love around any of the pulleys. Therefore, $C$ has no vertical component of its velocity.

Elaboration

In the general case, the only way such a block can move in a pulley system like this is if the string moves around the pulley. If the string is fixed at one end, and given that the string cannot be stretched, the only way it can move around the pulleys is if the pulleys themselves move.

Since the blocks are moving with the same velocity, we can consider them at rest relative to one another. Given that the pulleys are fixed to the blocks, they can also be considered at rest relative to one another. By definition, because they are at rest, they are not moving, and thus, the string is not moving over them.

In The Case of Differing Velocities

This problem is made simpler by the fact that all of the pulleys cause the string to turn at right angles.

In the case of, for example, block $B$ moving left at $4\text{ms}^{-1}$, the velocity of the leftmost pulley relative to the two rightmost pulleys is $3\text{ms}^{-1}$ to the left. The means that the length that the string has to travel to pass through the pulley system is decreasing by $6\text{ms}^{-1}$.

Since the string remains the same length, but the path through which it must travel does not, this allows block $C$ to have a vertical component of its velocity of $6\text{ms}^{-1}$ downwards.

• This is the correct answer dude ! Congrats. Can you possibly put a more elaborate and clearer explanation to it ? I'm a beginner and would really appreciate all of your help ! Thanks man ! :) – Tanuj Oct 29 '17 at 14:53
• Here I would like to ask why the following method cannot be used to solve the following problem ? (Method in the answer )physics.stackexchange.com/questions/43875/… – Tanuj Oct 29 '17 at 14:57
• This explains it pretty clear , but in the similar problem , if block A has a velocity 1 m/s and block B has a velocity 4 m/s , then how would you figure out the velocity of block C in this case ? – Tanuj Oct 29 '17 at 15:06
• Just one word , WOW ! Hey is there anyway I can "ping" you for help with my future physics doubts here ? – Tanuj Oct 29 '17 at 15:28
• What did you mean by this - "This problem is made simpler by the fact that all of the pulleys cause the string to turn at right angles." ? – Tanuj Oct 29 '17 at 15:29


text:
# Amazing math typesetting with MathJax

By accident, I stumbled on something interesting. You are probably aware that I write my books and most of the class handouts with LaTeX. Equations are particularly convenient, because LaTeX typesets equations just… right. Something that I can’t do in, say, html. It would appear, though, that others already solved this problem: A script that lets you remotely render a LaTeX equation — MathJax.

This means, you type in your html code (or post) something like

F(s) = \int_0^\infty f(t) e^{-st} dt

and what you get is:

$F(s) = \int_0^\infty f(t) e^{-st} dt$