text:
### Home > A2C > Chapter 10 > Lesson 10.1.1 > Problem10-19

10-19.

One way to win in a game with two dice is to roll a sum of six before getting a sum of seven. (Anything else that happens ” sums of $2, 3, 4, 5, 8, 9, 10, 11, \text{ or } 12$- are ignored.)

1. How many ways are there to get a sum of six?

$5$

2. How many ways are there to get seven?

$6$

3. How many possible outcomes are important in this problem?

Do the other sums have any effect on the probability of winning the game?

4. What is the probability of getting a six before a seven?

What fraction of the important outcomes are sums of six?


text:
# Documentation

Lean.Elab.PreDefinition.WF.Rel

def Lean.Elab.WF.getNumCandidateArgs (fixedPrefixSize : Nat) (preDefs : ) :
Equations

Given a predefinition with value fun (x_₁ ... xₙ) (y_₁ : α₁)... (yₘ : αₘ) => ..., where n = fixedPrefixSize, return an array A s.t. i ∈ A∈ A iff sizeOf yᵢ reduces to a literal. This is the case for types such as Prop, Type u, etc. This arguments should not be considered when guessing a well-founded relation. See generateCombinations?

Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.WF.generateCombinations? (forbiddenArgs : ) (numArgs : ) (threshold : ) :
Equations
def Lean.Elab.WF.generateCombinations?.isForbidden (forbiddenArgs : ) (fidx : Nat) (argIdx : Nat) :
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.WF.generateCombinations?.go (forbiddenArgs : ) (numArgs : ) (threshold : ) (fidx : Nat) :
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.WF.elabWFRel {α : Type} (preDefs : ) (unaryPreDefName : Lean.Name) (fixedPrefixSize : Nat) (argType : Lean.Expr) (wf? : ) (k : ) :
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.WF.elabWFRel.go {α : Type} (preDefs : ) (unaryPreDefName : Lean.Name) (fixedPrefixSize : Nat) (k : ) (expectedType : Lean.Expr) (elements : ) :
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.WF.elabWFRel.generateElements (preDefs : ) (numArgs : ) (argCombination : ) :
Equations
• One or more equations did not get rendered due to their size.
def Lean.Elab.WF.elabWFRel.guess {α : Type} (preDefs : ) (unaryPreDefName : Lean.Name) (fixedPrefixSize : Nat) (k : ) (expectedType : Lean.Expr) :
Equations
• One or more equations did not get rendered due to their size.

format: plain


text:
# The acute angle formed by intersecting lines is equal to the acute angle formed by their normals

Whilst reading my geometry notes I came across the statement given without proof:

The acute angle formed by intersecting lines is equal to the acute angle formed by their respective normals

I decided to attempt to prove this statement in $\Bbb R^2$ and got stuck. Suppose line $L_1$ is given by the direction vector $(1, m_1)$, and line $L_2$ by $(1,m_2)$, then comparing the two formulas for $\theta$, the angle between the two lines is:

$cos (\theta) = \frac {1 + m_1m_2} {\sqrt {1+ m_1^2} \sqrt{1+m_2^2} }$

Then this should be equal to $\frac {1 + \frac {1}{m_1m_2}} {\sqrt {1+ \frac {1} {m_1^2}} \sqrt{1+\frac {1} {m_2^2}} }$ by taking the normal vectors to have negative reciprocal of the respective direction vectors in $L_1,L_2$, but I am not sure how to sure these are equal, or if I have made a mistake.

Furthermore how can I generalize this to $\Bbb R^n$?

## 2 Answers

The two formulae ARE equal - multiply the "normal" one by $1 = \frac{m_1 m_2}{m_1 m_2}$. You get

$$\frac {1 + \frac {1}{m_1m_2}} {\sqrt {1+ \frac {1} {m_1^2}} \sqrt{1+\frac {1} {m_2^2}} } \frac{m_1 m_2}{m_1 m_2} = \frac {{m_1m_2} +1} {m_1 \sqrt {1+ \frac {1} {m_1^2}} m_2\sqrt{1+\frac {1} {m_2^2}} } = \frac {{m_1m_2} +1} {\sqrt {{m_1^2} +1} \sqrt{{m_2^2} +1} }$$

In $n$ dimensions, by orthonormal transformation you can always choose a coordinate system such that the direction vector is $(1, m_1, 0 , \cdots , 0)$ and likewise for the other vectors. Then, the same formulae hold that you already have.

• Can you elaborate on that simplication with $\frac {m_1m_2} {m_1m_2}$ – IntegrateThis Mar 19 '17 at 18:43
• I put it in the main text. – Andreas Mar 19 '17 at 18:47

There is no need for lengthy formulas. Just remember the meaning of "normal." The normal to a line is perpendicular to it. So if one line is at an angle $\theta_1$ from the $x$-axis, and the other line is at an angle $\theta_2$ from the $x$-axis, their normals are at angles $\theta_1 + \frac\pi2$ and $\theta_2 + \frac\pi2$ from the $x$-axis. The angle between those normals is the difference of those two angles, $$\left(\theta_1 + \frac\pi2\right) - \left(\theta_2 + \frac\pi2\right) = \theta_1 - \theta_2,$$ which is the same as the angle between the two lines.

• Ok great I should have thought of that. – IntegrateThis Mar 19 '17 at 19:00


text:
# Imposing pressure variation instead of Dirichlet boundary conditions on Finite Element Method

I always see Finite Element codes solving PDE with Dirichlet or Neumann boundary conditions. But, I have a problem now consisting of a straight cylinder with a circular base (a simple 3D tube), with inflow and outflow given by a pressure variation (for example, $$p_\textrm{inflow}=20$$ at the left circular "cap" and $$p_\textrm{outflow}=0$$ at the right circular "cap", and velocity equal to zero in the boundary that is not inflow nor outflow (so, the flow go in through the inflow circular side and go out through the outflow circular side because of a pressure variation).

I'm solving Navier--Stokes equations for the fluid (I think it is not an important data):

$$u_t-\nu\Delta u+(\nabla u)u+\nabla p=f$$ in a boundary domain $$\Omega$$

$$\nabla\cdot u=0$$ in $$\Omega$$

so my unknowns are the velocity $$u$$ and the pressure $$p$$. The effects of gravity are neglected. For simplicity, we may consider the stationary equation only.

How I must modify the code in order to work with that pressure difference data? My code (and numerical analysis) only accepts Dirichlet and Neumann boundary conditions.

• The equation is important information, that determines what type of boundary conditions you have Sep 16 '20 at 16:15
• Thanks @nicoguaro, I added explicitly the Navier--Stokes equations. For me is the same consider the Stokes equations (maybe is easier to explain because is linear). Sep 16 '20 at 17:39

I have a paper on this which, as long as your boundary is flat and you don't expecct it to pass vortexes, should do you well: https://doi.org/10.1002/fld.1427.

The gist of it is that as long as the boundary is flat and you enforce no tangential flow, the normal traction is equal to the pressure in an incompressible flow. This is an OK BC for Poiseuille-like flows, but not a general BC where anything might flow out since you have to enforce no tangential flow at the boundary. I didn't save the reference, but there have been some developments in this area that solve this problem in the last few years.

In the Navier-Stokes equations, you can't prescribe the pressure on the boundary (or part of it). That's just not a physical thing, nor mathematically correct. The only thing you can prescribe is the traction, i.e., the normal component of the stress, which is given by $$\mathbf t = (-\nu \nabla \mathbf u + pI) \mathbf n.$$ For example, you could prescribe that the traction should be $$\mathbf t|_{\Gamma_\text{in}} = 20$$ and a corresponding value on the outflow part $$\Gamma_\text{out}$$.

Boundary conditions are tricky. If you want to learn more about it, you might want to watch lectures 21.5 and following here: https://www.math.colostate.edu/~bangerth/videos.html

• Typically you end up with an $n\cdot \mathbf{T}$ term for the boundary as shown above if you impose that tangential velocity is zero then for a fully developed flow you have a pressure like boundary condition when prescribing the traction. Though this isn't as strong as a Dirichlet condition and you may not actually see the exact pressure values imposed.
– wwfe
Sep 17 '20 at 4:23
• @wwfe That just isn't right. If you prescribe tangential flow, then you can additionally prescribe the normal component of the traction. But that's not the pressure, it's a combination of the pressure and the shear stress. As a consequence, whatever you prescribe affects the pressure, but it doesn't actually prescribe the pressure. Sep 17 '20 at 4:32
• that is correct it is a combination of pressure and shear stress, but for fully developed flow the normal component of the shear stress should be zero as well so in practice you can use it to apply a "pressure-like" boundary condition. Here is an example of Poiseuille flow with no slip on top and bottom, applying the traction BC of value 200 on the left and natural BC on the right, and no tangential velocity on left and right i.imgur.com/PwWSZfG.png
– wwfe
Sep 17 '20 at 12:49
• Thanks @WolfgangBangerth and @ wwfe, I understood perfectly (a better explanation is impossible). Sep 17 '20 at 15:04


text:
# Unity: Create large Terrain with accurate raycast detection?

I'm not using the Unity Terrain because it lacks certain features.

Amongst them, you cannot tile them:

You cannot create concave walls or make holes in it:

No custom textures, no detail textures, awful sculpting tools... the list goes on and on. So I imported my own Terrain as a Mesh. The collision works perfectly, however raycasting onto the Terrain is horribly inaccurate. Unity seems to compress the Mesh Collider depending on distance to player. See the video linked below. Since Unity is (by my knowledge) the only Game Engine that supports convex colliders, how do other game engines create Terrain colliders?

For a racing game or a RTS or RPG the colliders are no problem, but for a shooter it's unacceptable. Here's a video showing the problem:

## https://youtu.be/coiFS6IT4wI

I've researched long and hard and there seems to be no known solution for this. So my question remains, if it's possible at all, how can i create large scale Terrains for Unity? This problem makes it completely impossible for me to create outdoor scenes. There HAS to be some kind of solution.

## 1) Raycasting script:

//Spread

int i = 0;
totalShotDamage = 0; //Buckshot sends 8 rays down the range. totalShotDamage gets total damage done by all rays. Needed for displaying damage text

while (i < bulletCount) //Repeats Shooting Vector for bulletCount amount (needed for buckshot)
{
Vector3 shootDirection = shootOrigin.transform.forward; //Shoot Vector 100% accuracy

Ray ray = new Ray(shootOrigin.transform.position, shootDirection); //Ray from Shoot vector
RaycastHit hitInfo;

if (Physics.Raycast(ray, out hitInfo, 2000, shootLayerMask)) //Sets range of gun & sends ray
{
Vector3 hitPoint = hitInfo.point; //Point of impact with any object
GameObject go = hitInfo.collider.gameObject; //GameObject of impacted Object

string targetTag = hitInfo.collider.gameObject.tag; //Tag of GameObject of impacted Object

damageEnemy(targetTag, hitInfo, damage, damageRollOff); //Damage enemy
}
i++; //total bullet count (needed for buckshot)
}

## 3) LOD Settings

There are no LOD Settings (yet). Individual Planes of the whole Terrain and objects on top of it simply pop in and out of existence depending on the Players position.

• Can you show us 1) the code you're using for raycasting, 2) the inspector configuration for your terrain's meshcollider, 3) any level of detail settings you're applying to the terrain meshes? – DMGregory Feb 12 '18 at 16:22

(1) Notes on terrain systems

Outdoor scenes are always a challenge to render and interact with, given viewing distance and subsequent complexity involved. This is just a reality of outdoor terrain. One often has to create one's own LoD systems (or at least heavily adapt those available) to get what one wants.

There is no way they can be both general purpose (as Unity's is) and fast / efficient; especially given all the other factors involved: static vs dynamic, LoD structure, etc. etc. Custom (concave) mesh-based collision is a very slow check, which is undoubtedly (part of) the reason Unity uses a sort of LoD on the mesh itself.

Unity doesn't support overhangs in terrain, because it uses heightmaps, a very old and very efficient system for reducing complexity and thereby cost, in various areas from rendering to physics to networking. It's typically cheaper to use a planar heightmap and run through a list of n objects that act as overhangs, than to make the entire terrain suitable for creating overhangs.

Geometry-based raycasts against large meshes using (concave) MeshColliders are COSTLY, because the collider has to check against the triangle count of the underlying mesh. No wonder Unity applies it's own optimisations in the process... as you have found. Concave geometry checks are an order of magnitude more costly compared with convex checks.

(2) Solutions

I would voxelise each chunk into a low resolution grid (3D array) by sampling the point at the centre of each grid cell to see whether that point falls inside or outside the fine polygon chunk mesh. If you raycast that grid using a cheap 3D-DDA raycast (not the same as Unity raycasting) and score a hit, then you can perform a more costly check for the associated subsection of the chunk mesh, using a standard triangles-based Unity raycast. Grid & DDA provide broadphase collision detection.

The voxelisation sampling step would involve you sampling either:

• Each chunk of your custom mesh directly

OR

• The world heightmap AND
• The list of N objects sitting on the surface thereof (possibly creating overhangs).

It may be that others can give a better answer for Unity specifically, but I think you will find these are limitations inherent in any general purpose terrain system, with Unity being no exception.

One way or another, some sort of spatial acceleration structure is needed to solve these problems of cost without reducing the fidelity of your terrain. See octrees, quadtrees, KD-trees, and the like; however, having the data structure available and working (quickly) is one thing; inserting data into it according to your design needs is a whole other story that will need addressing.

Other than that I can only say, game design that is constrained often leads to better gameplay. You may be better off starting with smaller levels and working your way up to complex ones from there as you discover what is technically possible and feasible, in various areas.

• Thank you for your answer. I have managed to solve the problem. The solution might surprise you, see the answer below. – AzulShiva Aug 9 '18 at 9:25

First of all I have no idea how all this stuff works and why. But the answer was a lot simpler than ArcaneEngineer would suggest. The problem seemed to be here:

The Model was scaled to 32 in Blender. After scaling it down to 1 and reimporting to Unity, and scaling it back up inside Unity the Mesh Collider was very accurate.

I experimented with that and the result is: The higher the scale inside Blender when you export the model the less accurate the Mesh Collider is. The lower the scale (such as 0.01) the more accurate the Mesh Collider is. It had absolutely nothing to do with the amount of Polygons. Unity is not compressing the mesh for the MeshCollider.

And no the MeshCollider is not expensive at all. I was running hundreds of fps with a 200k Mesh Collider on the Model. Disabling the MeshCollider gave an increase of 2-3 fps. However I am using the MeshCollider against 10-20 Sphere or Capsule colliders and of course for RayCasting.


text:
(41CX/DM41)(17Bii) Date of the first Advent Sunday in a year
02-04-2020, 10:34 PM (This post was last modified: 02-04-2020 10:35 PM by jthole.)
Post: #1
 jthole Member Posts: 60 Joined: Nov 2017
(41CX/DM41)(17Bii) Date of the first Advent Sunday in a year
This small program is an adaptation of an equation I have in my HP 17Bii. One of the reasons for posting this here, is that it shows the elegance of the HP 17Bii solver. The other reason is that it's fun, and can be useful (if only because you know when to open the first window of the Advent calendar ;-) ).

First of all, here is the short and simple HP 17Bii Solver equation: (both the solver and program assume DD.MMYYYY).
Code:
 ADVDATE = DATE( L( XMAS : YEAR ÷ 1000000 + 25.12 ) : ( ( MOD( DDAYS( 1.0119 : G( XMAS ) : 1 ) : 7 ) + 22 ) x - 1 ) )

And here is the HP 41CX/DM41L program, which takes the year in the X register (just following the equation; maybe could be optimised further).
Code:
 LBL "ADVDATE" 1000000 / 25.12 + STO 00 1.0119 X<>Y DDAYS  ;XROM 26,14 7 MOD 22 + CHS RCL 00 X<>Y DATE+  ;XROM 26,13 END

Running on the 17Bii:
Enter YEAR: 2021

Running on the DM41L:
2021
28,112021

Of course, the program (and equation) only works for the Gregorian calendar. Monday Jan. 1, 1900 was chosen because I liked that date (any date works, as long as you adjust the offset (currently 22) in the equation.

BTW; I do not have a HP 41CX, but I do have a SwissMicros DM41L; I tested the program on the DM41L.
08-10-2020, 03:02 PM (This post was last modified: 08-10-2020 03:11 PM by ggauny@live.fr.)
Post: #2
 ggauny@live.fr Senior Member Posts: 539 Joined: Nov 2014
RE: (41CX/DM41)(17Bii) Date of the first Advent Sunday in a year
Hi,

I see your thread a little late but here is a little routine of mine I was using with my
HP 41c (+ time module) or my HP 41cx.

Instead of DDays I'm using DOW, but unfortunatly DOW gives 0 if the day is a sunday, (HP Prime gives 7). So we have to "adjust" in case of DOW gives a 0.

Code:
 01 LBL "DIMAVENT' 02 7                        //Here is the adjust. 03 x<>y 04 1e6 05 / 06 25.12 07 + 08 ENTER 09 DOW 10 x=0? 11 x<> Z                 // or RCL+ ST Z on HP 42s, FREE42, DM42 12 21 13 + 14 CHS 15 DATE+ 16 END

Of course runing on dm41, dm41x too and some other calculator.

2016 gives 27.112016 for example, 1582 gives 28.111582

In attachement I give 2 EXCEL calendars. May be usefull.

Have a good day.

Attached File(s)

Gérard.
08-11-2020, 08:03 AM (This post was last modified: 08-11-2020 02:29 PM by Werner.)
Post: #3
 Werner Senior Member Posts: 649 Joined: Dec 2013
RE: (41CX/DM41)(17Bii) Date of the first Advent Sunday in a year
If you use 12.12 instead of 25.12, and change the 21 to 8, it will work for M.DY format as well.
[update] not quite.. but if you use 12.12, then do 13 DAYS+, then proceed as before, it will ;-)
[update #2] and if you take the first of January of the next year (which is always the same Day of Week as Christmas), it's even simpler:
Code:
 1  +  1E6  /  1.01  +  ENTER  DOW  +/-  7  MOD  35  -  DATE+
Cheers, Werner
01-22-2021, 01:27 PM
Post: #4
 Wolfgang Junior Member Posts: 47 Joined: Jun 2014
RE: (41CX/DM41)(17Bii) Date of the first Advent Sunday in a year
(08-10-2020 03:02 PM)ggauny@live.fr Wrote:  Hi,

I see your thread a little late but here is a little routine of mine I was using with my
HP 41c (+ time module) or my HP 41cx.

Instead of DDays I'm using DOW, but unfortunatly DOW gives 0 if the day is a sunday, (HP Prime gives 7). So we have to "adjust" in case of DOW gives a 0.

Code:
 01 LBL "DIMAVENT' 02 7                        //Here is the adjust. 03 x<>y 04 1e6 05 / 06 25.12 07 + 08 ENTER 09 DOW 10 x=0? 11 x<> Z                 // or RCL+ ST Z on HP 42s, FREE42, DM42 12 21 13 + 14 CHS 15 DATE+ 16 END

Of course runing on dm41, dm41x too and some other calculator.

2016 gives 27.112016 for example, 1582 gives 28.111582

For HP Prime:

SHIFT Define <function> for user defined function

HP 33C 34C 11C 41CX 32S 28C HP71B 35s 50g Prime Rev. A, C, D. DM 41X, 42. TI 58C, 59, 74, 92-II, Voyage 200, nspire CX II-T, Sanyo ICC 82D and more
01-24-2021, 05:00 AM
Post: #5
 Albert Chan Senior Member Posts: 1,676 Joined: Jul 2018
RE: (41CX/DM41)(17Bii) Date of the first Advent Sunday in a year
(08-10-2020 03:02 PM)ggauny@live.fr Wrote:  Instead of DDays I'm using DOW, but unfortunatly DOW gives 0 if the day is a sunday, (HP Prime gives 7).
So we have to "adjust" in case of DOW gives a 0.

No need to adjust, just shift the reference to Christmas Eve.
Better yet, reference to Dec 3, eliminated the need to subtract 21 days.

1st Advent Sunday = (Dec 3) - DOW(Dec 3) days       // Nov 27 to Dec 3

Code below assumed date format MM.DDYYYY
Code:
00 { 29-Byte Prgm } 01▸LBL "DIMAVEN" 02 1ᴇ6 03 ÷ 04 12.03   ; Dec 3 05 + 06 ENTER 07 DOW 08 +/- 09 DATE+ 10 END

Since DOW(Dec 3) = DOW(Dec 31), we can even do this in the head, using facts below:

1. Gregorian calendar repeat itself every 400 years.
2. DOW(Dec 31, 2000) = 0 (Sunday)
3. 365 days = 52 weeks + 1 day

Example, Year 2016:

2016 % 400 = 16
leap years count = IP(16/4) - IP(16/100) = 4
DOW(Dec 31, 2016) = (4 + 16) % 7 = 6

(Dec 3, 2016) - 6 days = Nov 27, 2016

Example, Year 2021:

2021 % 400 = 21
leap years count = IP(21/4) - IP(21/100) = 5
DOW(Dec 31, 2021) = (5 + 21) % 7 = 5

(Dec 3, 2021) - 5 days = Nov 28, 2021
01-24-2021, 10:35 AM
Post: #6
 ggauny@live.fr Senior Member Posts: 539 Joined: Nov 2014
RE: (41CX/DM41)(17Bii) Date of the first Advent Sunday in a year
Hi Albert,

Thank for the optimisation !!!
Great.

Gérard.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)


text:
Q:

# What is 3 over 5 as a decimal?

A:

Three-fifths, otherwise written as 3/5, can also be written in decimal form as 0.6. Decimal form can be determined by dividing the numerator of a fraction by the denominator using a calculator.

## Keep Learning

While using a calculator is the easiest way to turn a fraction into a decimal number, certain numbers can be converted by manipulation and inspection. The fraction 3/5 can be transformed into 6/10 by multiplying the numerator and denominator by 2. Most people are able to calculate 6 divided by 10 by moving the decimal place one spot to the left, which results in the correct decimal number 0.6.

Sources:

## Related Questions

• A:

When teaching the multiplication tables, adding doubles can help young students comprehend  the principles of multiplying by two. A teacher can also demonstrate that learning the multiplication tables involves doing repeated addition.

Filed Under:
• A:

Numbers that multiply to give you a larger number are called factors. Use a factor tree for an easy way to factor larger numbers.

Filed Under:
• A:

The square root of 185 is 13.60. Although a square root function can sometimes be simplified by factoring out the square root of a whole number, 185 does not have any factors that are squares of whole numbers and cannot be reduced.


text:
# Distance between features

## Introduction

Calculating the distance between features (points, polygons, lines) is a common GIS task. Here I will use it to calculate the nearest sighting of mountain lions to Minnesota according to the Global Biodiversity Information Facility (GBIF) database. If you want to try this out, I have downloaded the GBIF data , and the state boundaries of Minnesota from the Global Administrative Areas (GADM).

## The data

The data is included in this GRASS GIS database. Download it and unzip it, and open the database (how to). Go to the data tab and open the mapset puma. Double click the layer PumaGBIF to display the layer. Next, open the layers Minnesota_boundary and CONUS.

## Find the nearest sightning

To compute the distance of each puma record to the state boundary, you first need to add the column to the attribute table. The distance between the points and the boundary of Minnesota will be written to this column. Figure 1 and 2 show you how to add the column using the v.db.addcolumn function.

You can also add a column using the attribute table manager. See the note for a short explanation how to do this .

### Compute the distance

Next, run v.distance function, which you can find in the Vector menu > Nearest feature (v.distance). In the From tab (see below) fill in the name of the layer with the features you want to calculate the distance from 1. You can leave the default settings for Feature type 2, select the minimum distance to nearest feature 3, and select the column to which the distances should be written 4. Note that you can upload multiple values at once. If you do, make sure to provide the respective column names to which these values need to be uploaded.

In the ‘To’ tab (see below), you fill in the name of the feature layer to which you want to calculate the distances To 5. For the other fields, keep the default values.

### Find the minimum distance

The last step is to identify the distance between the nearest sighting of the mountain lion and the Minnesota border. Open the attribute table again. Next, right click on the name of the column with the distances, and select the Statistics option in the context menu. The result will tell you that the nearest GBIF record for the mountain lion is 255 km away from Minnesota.

### Conclusion

According to the Minnesota Department of Natural Resources, there have been more than 30 confirmed sightings in Minnesota in the last 30 years (map), most likely from transient animals from the Western Dakotas . Clearly, these records have not found their way to the GBIF database yet, as the nearest GBIF record is from 255 km away.

You can also use the command line or even write a Python script. Especially if you are new, finding out the right syntax can be tricky though. The help files are pretty good, but if you are a more visually inclined persons, it might help to first run the function using the GUI, as shown above. The great thing about GRASS is that each time you run a function, you can simply copy the corresponding code using the copy button.

So for example, to carry out the steps above from the command line, you can run the two lines of code below from the command line.

# Add a new column to the point data set.
v.distance from=PumaGBIF from_type=point to=Minnesota_boundary upload=dist \
column=dist2minnesota

Running the code from the command line can be a convenient and quick way to run one or more functions. However, to automate your code, you better use Python. You can run Python code in the Python tab in GRASS GUI. Alternatively, you can open the simple python editor and run the code from there. In the example below, the wrapper code is used.

import grass.script as gs
columns="dist2minnesota double precision")
gs.run_command("v.distance", from="PumaGBIF", from_type="point",
to="Minnesota_boundary", upload="dist", column="dist2minnesota")

The v.distance fuctions has a number of other handy options, which you certainly should explore. And, if you are working with raster layers, check out the r.distance function. As a note to QGIS users. GRASS GIS functions are also available from the processing toolbox in QGIS, or via the GRASS GIS add-on. So instead of using the GRASS GIS interface, you can run this in QGIS if you like.

## References

Gbif.Org. 2021. “Occurrence Download Puma Concolor.” Darwin. The Global Biodiversity Information Facility. https://doi.org/10.15468/DL.6RTAUV.
MDNR. n.d. “Cougars in Minnesota.” Minnesota Department of Natural Resources. https://www.dnr.state.mn.us/mammals/cougar/index.html.
##### Paulo van Breugel
###### Lecturer & researcher

My interests range from biodiversity and ecology to spatial data analysis. I am also what one could describe as a lifelong learner; I enjoy to learn new things and widen my horizon, both professionally and personally.


text:
# Using Specs when testing the process of assigning offers to a customer

I am trying to spruce up my BDD skills using Specflow and Gherkin. Please see the classes below:

public class Concor : IProduct
{
private const decimal _expenditure = 100;
private const string _gender = "F";

public bool IsEligible(Customer customer)
{
if (customer.Expenditure < _expenditure)
{
return true;
}
else
{
return false;
}
}
}

public class Chestnut : IProduct
{
private const decimal _expenditure = 100;

public bool IsEligible(Customer customer)
{
if (customer.Expenditure >= _expenditure)
{
return true;
}
else
{
return false;
}
}
}

public interface IProduct
{
bool IsEligible(Customer customer);
}

public interface IOfferCalculator
{
//Passed a Customer object instead of Expenditure and Gender variables because these variables will be validated
//in the customer class.
IEnumerable<IProduct> CalculateEligibility(Customer customer, IList<IProduct> products);
}

public class Customer
{
public Guid Id { get; protected set; }
public string Gender { get; protected set; }
public decimal Expenditure { get; protected set; }
public IList<IProduct> _assignedProducts = new List<IProduct>();

public Customer(Guid id, string gender, decimal expenditure)
{
//Validation logic to go here.
Id = id;
Gender = gender;
Expenditure = expenditure;
}

//Refactored this method to only accept one product
public void AddOffer(IProduct eligibleProduct)
{
}
}

public class OfferCalculator : IOfferCalculator
{
public IEnumerable<IProduct> CalculateEligibility(Customer customer, IList<IProduct> products)
{
foreach (var product in products)
{
if (product.IsEligible(customer))
{
yield return product;
}
}
}
}

and the feature file below:

• Feature: OfferCalculator

• In order to calculate eligibility for offers
• As an offer calculator I
• want to be given a gender and expenditure
• Scenario: Calculate eligibility when given a gender of male and an expenditure of 101

• Given A customer with a gender of male and an axpenditure of 101
• And All available products
• When I calculate eligibility for products
• Then Eligible for Concor

and the step definitions below:

[Binding]
public class OfferCalculatorSteps
{
private Customer _customer;
private IOfferCalculator _offerCalculator;
private List<IProduct> _availableProducts;
private List<IProduct> _actualProduct;

[Given(@"A customer with a gender of (.*) and an axpenditure of (.*)")]
public void GivenACustomerWithAGenderOfMaleAndAnAxpenditureOf(string gender, int expenditure)
{
_customer = new Customer(Guid.NewGuid(), gender, expenditure);
_offerCalculator = new OfferCalculator();
}

[Given(@"All available products")]
public void GivenAllAvailableProducts()
{
_availableProducts = new List<IProduct>();
}

[When(@"I calculate eligibility for products")]
public void WhenICalculateEligibilityForProducts()
{
_actualProduct= _offerCalculator.CalculateEligibility(_customer, _availableProducts).ToList<IProduct>();
}

[Then(@"Eligible for Concor")]
public void ThenEligibleForConcor()
{
//Could use a Set here instead of a list.
var expectedCreditCard = new List<IProduct>();
Assert.Equal(expectedCreditCard, _actualProduct);
}
}

I would be grateful for comments with regards to the quality of this code (specifically the feature file and step definitions). I am specifically trying to follow the principle of least astonishment so that when other developers come on board; they can pick things up quickily. Here are some specific questions (though I am specifically asking for comments about the overall quality):

1. Should features and step definitions be in their own namespace?

2. Notice the scenario says: "And All available products". Would it be better to say: "And all the available products: Concor; Chestnut". I can't see a way of doing this as Concor and Chestnut are classes.

3. Am I abusing the use of instance variables (I have four instance variables in the step definitions)?

4. The feature says: "As an offer calculator". This is not a person. Is this normal?

5. Notice I have done: expectedCreditCard.Add(_availableProducts.OfType<Chestnut>().Single());. Is this normal?

6. Notice there are Guids referenced in the Step Definitions. Is this normal?

• Please do not update the code in your question to incorporate feedback from answers, doing so goes against the Question + Answer style of Code Review. This is not a forum where you should keep the most updated version in your question. Please see what you may and may not do after receiving answers. – Mast Mar 29 '18 at 16:51
• @t3chb0t You're right. Done. – Mast Mar 29 '18 at 16:57
• @Mast, I only edited the name of a variable as it was confusing me and would confuse me (and maybe others) when I look back at this question in the future. However, I guess an edit is an edit. Thanks. – w0051977 Mar 31 '18 at 14:36

I am specifically trying to follow the principle of least astonishment

this and that

public IList<IProduct> _assignedProducts = new List<IProduct>();

don't get along well. A public field with an _ underscore? I'm more then surprised ;-)

But not only by that. If I can access this field directly, there is actually no need for me to want to use this method:

public void AddOffer(IProduct eligibleProduct)
{
}

It would be a lot less surprising if the Customer class implemented the IEnumerable<IProduct> interface... it's also strange that you named the method AddOffer but the argument is IProduct.

public IEnumerable<IProduct> CalculateEligibility(Customer customer, IList<IProduct> products)
{
foreach (var product in products)
{
if (product.IsEligible(customer))
{
yield return product;
}
}
}

You'll have to rethink this design. Here's another surprise. The customer has a collection of products so why do I have to specify both parameters separately to use CalculateEligibility? Shouldn't the AddOffer, or rather AddProduct already check this? The other thing is that this method does not caculate anything, it filters products by eligibility...

I'm still not happy with this but at least something like this would be more acceptable:

    public void AddProduct(IProduct product)
{
if(!product.IsEligible(this)) throw ...

}

Since the product can by itself check the eligibility the OfferCalculator is completely unnecessary... but it wouldn't if it did its job propertly, this is, checking eligibility like the product currently does. You should move this logic to where it belongs and apparently it belongs to the OfferCalculator.

• I have added an Update section to the question (I have not amended the question itself). I would be grateful for your comments on my update. I would also be grateful for any comments about the Specflow scenarios. – w0051977 Mar 27 '18 at 16:44
• @w0051977 I'm not so sure your edit to the question is such a good idea. You should post them as comments under my answer... – t3chb0t Mar 27 '18 at 16:55
• fair enough I will remove them. – w0051977 Mar 27 '18 at 16:56
• I was actually asking for my Specflow tests to be reviewed. I am surprised that you have been so critical about the actual code as you seemed to approve of it when I had it reviewed here: codereview.stackexchange.com/questions/186148/…. Thanks for answering anyway. – w0051977 Mar 27 '18 at 16:58
• @w0051977 but I didn't say it was good... I only said it was better than before ;-) I know you asked about your Specflow and I think this tool is extremely verbose. Such automatic tests work only in academic scenarios. There is no place for it in complex real world applications with several dependencies and complex test preparations. – t3chb0t Mar 27 '18 at 17:11

Sloppy left hand formatting in general

public class Concor : IProduct
{
private const decimal _expenditure = 100;
private const string _gender = "F";

public bool IsEligible(Customer customer)
{
if (customer.Expenditure < _expenditure)
{
return true;
}
else
{
return false;
}
}
}

Does not use private const string _gender

Can just return (customer.Expenditure < _expenditure);

Silly name and can be set to null.
public IList<IProduct> _assignedProducts = new List<IProduct>();

I am not getting OfferCalculator as a class. Why not a static method?

products.where(x => c.IsEligible(customer))

• I have put the private variables in to help with readability. I have put OfferCalculator in there for testability and single responsibility. – w0051977 Mar 27 '18 at 16:52
• How does a private variable not used help readability? – paparazzo Mar 27 '18 at 16:54
• Thanks. I thought you were criticising the use of constants (I misread). I understand your point now. Does my reasoning about OfferCalculator make sense? – w0051977 Mar 27 '18 at 17:03
• It does not make sense to me. But that does not mean it is wrong. – paparazzo Mar 27 '18 at 17:06
• I think I am going to attempt this again without the OfferCalculator. Why would you have a static method? I am thinking about modifying Customer.AddProduct as per t3chbots suggestion. – w0051977 Mar 27 '18 at 19:28


text:
# 5.02 Exponential growth and decay

Lesson

Certain growth and decay situations arise that naturally lead to the formulation of a rule that can be used generally.

### Outcomes

#### A.CED.A.2'

Create equations in two or more variables to represent relationships between quantities; graph equations on coordinate axes with labels and scales. 'Linear and exponential (integer inputs only)

#### F.BF.A.1'

Write a function that describes a relationship between two quantities. 'Linear and exponential (integer inputs)

#### F.BF.A.1.A'

Determine an explicit expression, a recursive process, or steps for calculation from a context. 'Linear and exponential (integer inputs)

#### F.LE.A.2

Construct linear and exponential functions, including arithmetic and geometric sequences, given a graph, a description of a relationship, or two input-output pairs (include reading these from a table).

#### F.LE.B.5

Interpret the parameters in a linear or exponential function in terms of a context.


text:
Vol 7, No 2 (2015)

e-Version First

Journal of Mathematics Research, Vol. 7, No. 2, June 2015

Table of Contents

Articles

 Enumerations for Compositions and Complete Homogeneous Symmetric Polynomial PDF Soumendra Bera p1
 A Regularized Newton Method with Correction for Unconstrained Nonconvex Optimization PDF Heng Wang, Mei Qin p7
 The Distribution of Zeros of Quadratic Forms over Finite Fields PDF Ali H. Hakami p18
 Soliton Solutions of a General Rosenau-Kawahara-RLW Equation PDF Jin-ming Zuo p24
 The Construction of a New Kind of Weakening Buffer Operators PDF Rui Zhou, Jun-jie Li p29
 The Cyclic Groups via Bezout Matrices PDF Omur Deveci, Yesim Akuzum, Erdal Karaduman, Ozgur Erdag p34
 Metzlerian and Generalized Metzlerian Matrices: Some Properties and Economic Applications PDF Giorgi Giorgio, Cesare Zuccotti p42
 On Filter $(\alpha)$-convergence and Exhaustiveness of Function Nets in Lattice Groups and Applications PDF Antonio Boccuto, Xenofon Dimitriou p56
 On the $O(1/k)$ Convergence Rate of He's Alternating Directions Method for a Kind of Structured Variational Inequality Problem PDF Haiwen Xu p69

This work is licensed under a Creative Commons Attribution 3.0 License.

Journal of Mathematics Research   ISSN 1916-9795 (Print)   ISSN 1916-9809 (Online)

Copyright © Canadian Center of Science and Education

To make sure that you can receive messages from us, please add the 'ccsenet.org' domain to your e-mail 'safe list'. If you do not receive e-mail in your 'inbox', check your 'bulk mail' or 'junk mail' folders.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------


text:
# Thread: Power Series Solving Differencial Equation

1. ## Power Series Solving Differencial Equation

Solve the following by Power Series, then find a basic set of solutions:
(x-2)^2 y" + 2(x-2)y' - 6y = 0

There are two different sets of power series that y", y', and y can equal, so that is confusing, but I also do not really know how to work the problem, so your help would be great. Thanks.

2. Originally Posted by haleyGeorge
Solve the following by Power Series, then find a basic set of solutions:
(x-2)^2 y" + 2(x-2)y' - 6y = 0

There are two different sets of power series that y", y', and y can equal, so that is confusing, but I also do not really know how to work the problem, so your help would be great. Thanks.
Given that LaTeX is currently out on this site, I'm not even going to try to help you directly here. You might find this site helpful though.

You SHOULD have two different power series as solutions. This is a second order linear ODE and thus has two linearly independent solutions.

-Dan

3. I will solve this with series centered at x=0.
Note, x=0 is an ordinary point.

4. What you have done makes perfect sense and is helping me remember some of the class examples, but going back to the original problem, what else do I need to do to be able to completely answer the question?

5. If the power series is exactly 0 then the coefficients of all powers of x must also be 0. So:
8*a_2 + 4*a_1 - 6*a_0 - 6*a_1 = 0 <-- Constant terms
and
-8*a_2 + 24*a_3 + 2*a_1 - 8*a_2 = 0 <-- Linear coefficients of x

From the first equation:
a_2 = (1/8)*(6*a_0 + 2*a_1) = (1/4)*(3*a_0 + a_1)

So the second equation is:
24*a_3 -16*a_2 + 2*a_1 = 0

24*a_3 -16*[(1/4)*(3*a_0 + a_1)] + 2*a_1 = 0

a_3 = (1/24)*(12*a_0 + 2*a_1) = (1/12)*(6*a_0 + a_1)

So given values for a0 and a1 we can find a2 and a3.

Now look at the general term:
n(n-1)*a_n - 4(n+1)n*a_{n+1} + 4(n+2)(n+1)*a_n + 2n*a_n - 4(n+1)*a_{n+1} - 6*a_n = 0

Solving we get:
a_{n+1} = [-n(n+1) - 4(n+2)(n+1) - 2n + 6]/[-4(n+1)n - 4(n+1)] * a_n

a_{n+1} = [5n^2 + 15n + 2]/[4n^2 + 8n + 4]

a_n = [5n^2 + 5n - 8]/[4n^2] = (5/4)*(1 + 1/n - 8/n^2)

This will give you your a_n values for n > 3.

-Dan


text:
# Continuity of metric function

Let $X$ is a vector space and $d$ is a metric function on $X$ and $\|\cdot\|$ is a norm on $X$ and $\langle\cdot,\cdot\rangle$ is an inner product function on $X$

It is to easy to prove $\|\cdot\|$ and $\langle\cdot,\cdot\rangle$ are continuous functions on $X$ and there are many theorems prove that.

But can I say that the metric function $d$ is continuous on $X$? And how can I prove that?

Or I can't say that because it has no meaning ( continuity of metric function )

You could prove that the metric $d$ is a continuous function from $A\times A$ to $\mathbb{R}$ by considering the product topology on $A\times A$.

Let $M = \left({A, d}\right)$ be a metric space.

Let $\tau$ be the topology on $A$ induced by $d$.

Let $\left({A \times A, T}\right)$ be the topological product of $(A, \tau)$ and $(A, \tau)$. http://en.wikipedia.org/wiki/Product_topology

Then we can prove that $d: A \times A \to \mathbb{R}$ is continuous (using the topological definition).

Do you want to try proving it now that you've got the basic idea where to start or do you want the proof?

We can also use the $\epsilon$-$\delta$ way, I just prefer this.

EDIT:

OK, since any open set in $\mathbb{R}$ is a union of open intervals, it is sufficient to show that the inverse image under $d$ of any open interval in $\mathbb{R}$ is an open set in $\left({A \times A, T}\right)$. (So the inverse image of any open set is then the union of open sets, which is then open).

So take any $a, b ∈ ℝ$. Let $(x_1,x_2) ∈ d^{-1} ((a,b)) \subseteq A \times A$. Then $a < d(x_1,x_2) < b$. Now since $(a,b)$ is open in $\mathbb{R}$, there exists $\varepsilon>0$ such that the open ball of radius $2\varepsilon$ around $d(x_1, x_2)$, $B_{2\varepsilon} (d(x,y)) \subseteq (a,b)$. We want to show that $d^{-1} ((a,b))$ is open in the product topology.

Note:( $(a,b)$ is an open interval, which is a connected set, not two pairs of points, while $(x_1,x_2)$ and the rest are just pairs of points from $A$.)

So consider $B_\varepsilon (x_1) × B_\varepsilon (x_2) \subseteq A\times A$, the cartesian product of two open balls of radius $\varepsilon$ around $x_1$ and $x_2$. Then since in the product topology, the product of these two open balls is a neighborhood around $(x_1, x_2)$, we just need to show that this product is contained in $d^{-1} ((a,b))$, to show that $d^{-1} ((a,b))$ is open.

For any $(y_1,y_2) \in B_\varepsilon (x_1) \times B_\varepsilon (x_2)$, $d(y_1,y_2) \leq d(y_1,x_1) + d(x_1,x_2) + d(x_2,y_2) < d(x_1,x_2) + 2\varepsilon$.

Similarly $d(x_1,x_2) ≤ d(x_1,y_1) + d(y_1,y_2) + d(y_2,x_1) < d(y_1,y_2) + 2\varepsilon$.

Hence $a < d(x_1,x_2) - 2\varepsilon < d(y_1,y_2) < d(x_1,x_2) + 2\varepsilon < b$, i.e. $d(y_1, y_2) \in (a,b)$ so $(y_1, y_2) \in d^{-1}((a,b))$.

Therefore $B_\varepsilon (x_1) \times B_\varepsilon (x_2) \subseteq d^{-1} ((a,b))$, so $d^{-1} ((a,b))$ is open. So $d$ is continuous.

Since $$d:X\times X\to [0,\infty)$$ is a metric, it satisfies the triangle inequality: $$d(a_1,a_2)\le d(a_1,a_3)+d(a_3,a_2) \quad \forall a_1,a_2,a_3\in X.$$ Given $a=(a_1,a_2)\in X\times X$, we have for every $x=(x_1,x_2)\in X\times X$: $$d(x_1,x_2)\le d(x_1,a_1)+d(a_1,a_2)+d(a_2,x_2),$$ and therefore $$\tag{1} d(x_1,x_2)-d(a_1,a_2)\le d(x_1,a_1)+d(x_2,a_2).$$ Also, for every $x=(x_1,x_2)\in X\times X$ we have: $$d(a_1,a_2)\le d(a_1,x_1)+d(x_1,x_2)+d(x_2,a_2),$$ i.e. $$\tag{2} -\left[d(x_1,x_2)-d(a_1,a_2)\right]\le d(x_1,a_1)+d(x_2,a_2).$$ Combining (1) and (2) we get: $$\left|d(x_1,x_2)-d(a_1,a_2)\right|\le d(x_1,a_1)+d(x_2,a_2)\quad \forall x=(x_1,x_2)\in X\times X,$$ which shows that $d$ is continuous at $a=(a_1,a_2)\in X\times X$, and therefore $d$ is continuous on $X\times X$ because $a$ is arbitrary.


text:
## An Animal Contest 7 P5 - Squirrel Scheming

View as PDF

Points: 17 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

After foiling the squirrels' plans several times it is now time for the counterattack! From Julian's data it can be seen that there exists a big red button in the shape of an acorn — which possesses the ability to teleport them to who knows where — somewhere on the squirrel fleet (for emergency food stash purposes). William is currently trying to plot the shortest counter-invasion path through the squirrel armada; however, he has extreme difficulties doing math of any kind ...

Given is an unweighted tree with nodes. Define the cost of a permutation of the first integers to be where is the distance between nodes and in the tree. Among all permutations, find the one with the minimum cost. If there are multiple such permutations, output the lexicographically least one.

#### Input Specification

The first line of input will contain a single integer . The following lines will each contain spaced out integers , denoting an edge between nodes and .

#### Output Specification

Output one line with spaced out integers, the lexicographically least permutation that incurs the minimum cost.

#### Sample Input

6
1 2
2 6
2 3
3 4
3 5

#### Sample Output

1 2 6 3 4 5


text:
# Math Help - System Modeling and integration problem. Need help?

1. ## Distance between the plates: Integration problem

There are two plates, green and blue as shown in the diagram below.

The green plate can move, due to which the distance R between the plates changes.

R at a height of h will be

R=(H d2+∆d1 h)/H

What will be the equation for integral of R for complete height H. Please explain the solution. I tried to solve it but came up with log(H)-log(0) in the equation. Log 0 cannot be solved.

$\frac1H\int_{0}^{H}\left(d_2+\frac{\Delta d_1}{H}\:h\right)dh=d_2+\frac{\Delta d_1}{2}$


text:
# VESC BLDC Motor Control

The VESC Project, started in 2017, provides open source hardware and software for sensored brushless DC motor control. The Cheap FOCer 2 is a VESC version 6 derivative that focuses on affordability and design for manufacture.

I have further improved the latest Cheaper FOCer-2 version 1.0 board. I needed several for a project, but I also ordered some extras from LCSC.

If you would like to support my work:

Assembled, flashed, and tested CFOCer v1.0 BLDC Controllers can be purchased on Tindie: https://www.tindie.com/products/vertile/cfocer-v10-bldc-foc-controller-based-on-vesc-v6/

Add the case as an option when purchasing the CFOCer v1.0 Cases are also available for purchase on Tindie: https://www.tindie.com/products/vertile/cfocer-v10-case-with-integrated-aluminum-heatsink/

## Assembly

After ordering from LCSC, I followed the steps outlined in the assembly guide, to complete assembly of the hardware.

I built my own case, a combination CNC milled heatsink.

The sides are 3D printed out of PTEG.

You'll also need a silicon heat pad to electrically isolate the MOSFETs from the heatsink.

## Case

I designed an aluminum and 3D printed case that is easily assembled with M3 bolts. It also has a through-hole mounting pattern to make mounting the case easy. See the following drawing for details on the mounting pattern. The assembled width of the case is 23mm, so you'll want to use M3 bolts longer than 23mm for mounting on another surface.

Case design files are available on thingiverse under the Creative Commons Attribution-NonCommercial-ShareAlike license, if you have access to a CNC and a 3D printer and would like to make your own.

### Case Hardware

You'll need a few things to assemble the case, and optionally mount the case on another surface.

# Software

The following is how to build the necessary software on MacOS. There is a somewhat dated but perhaps still useful guide on setting up a linux build environment on the VESC site.

Updated repositories with support for the Cheaper FOC are:

## Dependencies

Install Version 7 of the GNU arm gcc toolchain by running:

./scripts/setup.sh

export PATH=$(pwd)/toolchain/bin:${PATH}

Note: Version 7 of the gnu arm toolchain must be used, lest you run into errors.

On mac, use brew and install stlink and openocd at the same time:

brew install arm-gcc-bin stlink openocd

Note, the bootloader is included with the main firmware, so no need to upload it separately

## Firmware

Edit conf_general.h to select the correct board (which is already done in my fork and build and upload with the following command.

export PATH=$(pwd)/toolchain/bin:${PATH} # make sure to use the right toolchain on MacOS!

Now you're ready to connect the speed controller to your computer with a micro USB cable.

You'll need to power the controller by connecting a supply of at least 10v to the main power leads. I also wired up a motor for testing.

### VESC Tool Configuration

Now we can configure the ESC with the VESC tool.

Walk through both the motor and the input setups to spin up the board and test it.

### Software Debugging Setup

If you're not so lucky to have the above just work, you can setup a debugging environment:

xattr -d com.apple.quarantine ~/Downloads/eclipse-embedcdt-*-macosx.cocoa.x86_64.tar.gz

Unzip:

tar xzf eclipse-embedcdt-2020-09-R-macosx.cocoa.x86_64.tar.gz

Move the application into your applications folder:

mv eclipse.app /Applications/

• Import projects -> C/C++ -> Existing Code as a Makefile Project

• Create a new Debug configuration

• Pick OpenOCD Debugging

• Specify your debug configuration with full paths to the binaries

A UART is available on the COMM port (J2) Pins 1 (GND), 5 (RX), and 6 (TX) should be used.

## Building the Configuration Tool

If you prefer to build your own copy of the configuration tool.

### Dependencies

Install qt5

brew install qt

### Building

The normal build script is ./build_macos, but this wasn't working for me, so I just ran some of the commands in the script:

export PATH=$(brew info qt|grep Cellar|awk '{print$1}')/bin:\$PATH
rm -rf build/macos/*
qmake -config release "CONFIG += release_macos build_original"
make clean
make -j8
open build/macos

Drag esc_tool_3.00.app into your Applications folder

## References

Check out the Cheaper FOCer 2 post on the esk8 forum for more info on the hardware.


text:
# Container class questions

This topic is 4158 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello. I started writing a dynamic array class, mostly as a learning experience (but also for possible future use). As it's how Flavian Brebion is doing it for Infinity, I'm using the C memory management functions. I thank him for his assistance. So far it looks like this:
template <typename _type> class DynamicArray
{
public:
DynamicArray<_type>(unsigned int reservedMemory = 0);
~DynamicArray();
void append(const _type& element);
_type operator[](int params){return *(arrayLocation+params);};

protected:
size_t objectSize;
_type* arrayLocation;
unsigned int maxSize;
unsigned int numElements;
};

template <typename _type> DynamicArray<_type>::DynamicArray(unsigned int reservedMemory) :
objectSize(sizeof(_type)),
arrayLocation((_type*) malloc(reservedMemory * objectSize)),
maxSize(reservedMemory),
numElements(0)
{}

template <typename _type> void DynamicArray< _type >::append(const _type& element)
{
if(numElements >= maxSize)
{
arrayLocation = (_type*) realloc((void*)arrayLocation, (numElements+1)*objectSize);
maxSize+=1;
}

new(arrayLocation + numElements) _type(element);
numElements++;
}

template <typename _type> DynamicArray<_type>::~DynamicArray()
{
_type* arrayLocationCopy = arrayLocation;

for(unsigned int x = 0; x < numElements; x++)
{
arrayLocationCopy->~_type();
arrayLocationCopy++;
};

free(arrayLocation);
}

It's incomplete. Anyway, at first I couldn't figure out how to destruct elements; integral types don't require destruction (I think?) while objects do. I tried this on a whim:
~_type();

and it surprisingly compiled without error. Is that syntax correct? Also, if you have any suggestions based on what I've shown, please share them. There's relatively little information out there on writing container classes.

##### Share on other sites
Yes, that's right - assuming you're using placement new, which you are.

For some reason, there have been a whole bunch of threads lately on people writing their own dynamic arrays. Scan down the thread list and you'll see them. At least one of them goes into this topic.

##### Share on other sites
Quote:
 arrayLocation = (_type*) realloc((void*)arrayLocation, (numElements+1)*objectSize);

Do remember that realloc basically finds a new buffer in memory, forcefully copies the bytes from the old buffer to the new one without any regard for what the memory actually represents, then brutally frees the old buffer without any form of contents destruction. So, if _type is not a POD type, your container will simply stop working for mysterious reasons at the worst possible moment.

Rule: non-POD objects cannot be copied byte-by-byte, they must be initialized in the new buffer as copies of the objects in the old buffer, and the originals must then be destructed. There is simply no way to achieve this using realloc: you will have to malloc a new buffer, do the copy, do the destruction, and free the old one.

##### Share on other sites
Quote:
 Original post by phil_tYes, that's right - assuming you're using placement new, which you are.For some reason, there have been a whole bunch of threads lately on people writing their own dynamic arrays. Scan down the thread list and you'll see them. At least one of them goes into this topic.

Ah, thanks for clearing that up, and informing me of the other topics. I'll have a look.
Quote:
 Original post by ToohrVykRule: non-POD objects cannot be copied byte-by-byte, they must be initialized in the new buffer as copies of the objects in the old buffer, and the originals must then be destructed. There is simply no way to achieve this using realloc: you will have to malloc a new buffer, do the copy, do the destruction, and free the old one.

Thanks. That's why I started this topic: something was bound to be wrong with my code.

However, that's not exactly what realloc() does, is it? If it can resize the memory block while retaining contiguity, it does (without affecting anything already in the block). So I guess I need to write a function that does either what you've described or realloc() as appropriate. Which necessitates a noob question. How do I check if a memory location is already allocated?

[Edited by - Baiame on July 25, 2007 3:07:02 PM]

##### Share on other sites
Quote:
 However, that's not exactly what realloc() does, is it? If it can resize the memory block while retaining contiguity, it does (without affecting anything already in the block). So I guess I need to write a function that does either what you've described or realloc() as appropriate. Which necessitates a noob question. How do I check if a memory location is already allocated?

Let's not go there.

Where and how memory is allocated is unknown - it's not specified or standardized - the compiler writers looked into it, and made it work on given platform. It has also received a lot of review (every application ever written) and works most of the time. But, what may work on XP Pro SP2 on AMD can break Vista, on Intel processor, or under gcc. There are zero guarantees, except what documentation for new states - it allocates a chunk of memory, or throws bad_alloc.

You have exactly two options for managing memory:
1) Pre-allocate buffer, then override new to provide pointers from there
2) Let new allocate it

That's it. malloc/realloc are bad. Unless you're overriding global new handler, you really really don't want to mess with them.

PS. 1) would be the option that allows you to check if area of memory is already allocated, since you'd be allocating chunks by yourself.

Your allocation code must also respect data alignment, so you'll need to possible over-allocate by 16 bytes to be able to align the memory on a boundary (and even that is considered a hack, since it can theoretically fail)

##### Share on other sites
Quote:
 Original post by BaiameHowever, that's not exactly what realloc() does, is it? If it can resize the memory block while retaining contiguity, it does (without affecting anything already in the block). So I guess I need to write a function that does either what you've described or realloc() as appropriate. Which necessitates a noob question. How do I check if a memory location is already allocated?

You can't know whether realloc can resize the buffer without moving its contents or not before you actually call the function. So, if your container contains non-POD objects, you have to move the contents of the buffer to a temporary buffer before calling realloc (just in case it moves the buffer), which kind of defeats the purpose. C++ provides no standard equivalent of realloc.

In short: have your generic class allocate-copy-destruct-deallocate, and then specialize your class for known POD types (int et al) to use realloc.

##### Share on other sites
Quote:
 Original post by AntheusWhere and how memory is allocated is unknown...

I thought that allocation checks would be more standardized. Can you please point to a couple ways of doing it? Overriding the new operator seems a bit excessive at this stage.
Quote:
 Original post by AntheusYour allocation code must also respect data alignment, so you'll need to possible over-allocate by 16 bytes to be able to align the memory on a boundary (and even that is considered a hack, since it can theoretically fail)

Quote:
 Original post by ToohrVykYou can't know whether realloc can resize the buffer without moving its contents or not before you actually call the function.

I know. But realloc() obviously does some kind of checks for memory occupation- that's what I want to do. Of course the program would end up basically doing the same thing twice, but it'd still be far faster than copying each element to a new buffer every time the array resizes. Flavian pointed to faster resizing as one of the advantages of his dynamic array over the STL vector (he definitely achieved it using realloc() in some way, but I'm not sure whether he overrided new).

##### Share on other sites
Quote:
 I know. But realloc() obviously does some kind of checks for memory occupation- that's what I want to do.

All the checks are internal to the library. realloc from a given standard C library implementation knows whether memory is occupied or not because that memory was allocated and handled by that very same library implementation. If you were to use realloc from a different implementation, it just wouldn't work, because it relies on implementation-specific helper functions. Since your program is not a part of the standard library, it can only use the public parts of it.

Even worse, the C++ memory models involves contiguous buffers. It has no concept of "memory being available past the end of a buffer". So, not only do the libraries not provide this checking functionality, but it is explicitly described as non-portable by the standard.

Quote:
 Of course the program would end up basically doing the same thing twice, but it'd still be far faster than copying each element to a new buffer every time the array resizes. Flavian pointed to faster resizing as one of the advantages of his dynamic array over the STL vector (he definitely achieved it using realloc() in some way, but I'm not sure whether he overrided new).

Sadly, you have no choice here: if you wish to use a realloc-like feature with non-POD objects (POD objects, again, are a breeze), you will have to keep track of memory yourself, by allocating a very large buffer from the OS or library, and then using this buffer to allocate sub-buffers to the rest of your program.

##### Share on other sites
By over-allocating and using placement new, you are already implementing what realloc tries to do, the only difference is you reserve the memory forever so you are guaranteed that after a reallocation you will have to add lots more elements before another reallocation occurs.

##### Share on other sites
Quote:
 I know. But realloc() obviously does some kind of checks for memory occupation- that's what I want to do. Of course the program would end up basically doing the same thing twice, but it'd still be far faster than copying each element to a new buffer every time the array resizes. Flavian pointed to faster resizing as one of the advantages of his dynamic array over the STL vector (he definitely achieved it using realloc() in some way, but I'm not sure whether he overrided new).

(POD types only):
Quote:
 Now it sounds obvious, but when I allocated memory in my CArray class, I used malloc/realloc/free, and there's no object constructor/destruction with those. I didn't have much trouble so far because as soon as my classes start to become complex, I prefer to store pointers to them. But every once in a while, I store an object itself, and that's where leaks and bugs appear.

(use standard library):
Quote:
 Second lesson learnt: the std::vector class is not slow. It is bug-free ( unlike mine ), and performs pretty much as fast.

(Copying is where you lose time, not re-allocating - also, constructors/destructors must be called)
Quote:
 The first one being: using malloc/realloc avoids the copy/fill mechanism used in std::vector, meaning no construction/destructions needed when the array grows. A first good point for me. Of course, this time I had to take care of correctly constructing/destructing objects, meaning playing with "placement new" and other goodies.. but no big deal.

Final lesson:
Quote:
 After this, I benchmarked my classes: the old ( buggy ) one, std::vector, and my new CArray class. Verdict: std::vector and my old class are on par as far as performance goes, but my new CArray class, in the context of appending millions of elements, is in average 2 to 3.5 times faster ! So I haven't wasted my time, finally.

Quote:
 Another good point: because I knew what is the most frequent usage I'm doing in my engine of my CArray class ( namely, appending data ), I could optimize the case and even create a special interface to append many elements to the array. I called this the "beginAppend/doAppend/endAppend" mechanism.

USE STANDARD LIBRARY, unless you're solving a particular, non-standard behaviour.

malloc/realloc are secondary in this story - it's different allocation strategy for batch additions that makes things fast - it also uses special interface - std::vector's performance is irrelevant, and couldn't be improved, only understanding of the problem solved helped.

You could achieve that with an accessor to std::vector, that would batch additions, and submit them to std::vector as a batch, after calling resize (or reserve, I forget).

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013612
×


text:
Hugh MacColl.

# Symbolic logic and its applications online

. (page 5 of 11)
Online LibraryHugh MacCollSymbolic logic and its applications → online text (page 5 of 11)
Font size

the traditional nineteen in which x, y, z are restricted as
in § 5 ; and four of these unrestricted syllogisms, namely,
(Darapti),,, (Felapton),,, (Bramantip),,, and (Fesapo),,, fail
in certain cases. (Darapti) w fails in the case y 7 '(".:)\
(Felapton),, and (Fesapo) w fail in the case y%ez / ) TI , and
(Bramantip ) u fails in the case &(x'yf.

55. It thus appears that there are two Barbaras, two
Celarents, two Dai'ii, &c, of which, in each case, the one
belongs to the traditional logic, with restricted values
of its constituents x, y, z; while the other is a more
general syllogism, of which the traditional syllogism is a
particular case. Now, as shown in § 45, when a general
law F w , with unrestricted values of its constituents, implies
a general law F,., with restricted values of its constituents,
if the former is true absolutely and never fails, the same
may be said of the latter. This is expressed by the
formula F„ : F*. But an exceptional case of failure in F„
does not necessarily imply a corresponding case of failure
in F,. ; for though F, e , : F;. is a valid formula, the implication
F M e : F; e (which is equivalent to the converse implica-
tion F e r : F e ,) is not necessarily valid. For example, the
general and non-traditional syllogism (Darapti),, implies
the less general and traditional syllogism (Darapti),..
The former fails in the exceptional case y\xzj i ; but
in the traditional syllogism this case cannot occur
because of the restrictions which limit the statement
y to the class 6 (see § 50). Hence, though this case of
failure necessitates the conclusion (Darapti);;*, we cannot,
from this conclusion, infer the further, but incorrect,
conclusion (Darapti); 6 . Similar reasoning applies to
forms of Felapton, Bramantip, and Fesapo.

56. All the preceding syllogisms, with many others not
recognised in the traditional logic may. by means of the
formulae of transposition a : j3 = /3 r : a! and a/3' \y' = ay:f\$,

52 SYMBOLIC LOGIC [§§ 56, 57

be shown to be only particular cases of the formula
(x'.y)(y:z):(x:z), which expresses Barbara. Two or
three examples will make this clear. Lut <j)(x, y, z)
denote this standard formula. Referring to the list in
§ 54, we get

Baroko = (z : y)(x : //)' : (x : z)' ; which, by transposition,
= (.« : z){z : y) : (x : y) = (f)(x, z, //).

Thus Baroko is obtained from the general standard
formula <p(x, y, z) by interchanging y and z.

Next, take the syllogism Darii. Transposing as before,
we get

Darii = (y : z)(x : yj : (x : z)' = (y : z)(x : z) : (x : if)

= (y : z){z : x) : (y : x') = (p(y, z, x).

Next, take (Darapti) r . We get (see § 54)
(Darapti),. = (// : z)(y : x) : (x : z')' = (y:zx): (xz : n)'

= (// : xz)(xz : >j) : n = (y : xz){xz : >/) : (y : »/) ;

for, in the traditional logic, (y:rf) = »/, since, by the con-
vention of S 5 0, y must always be a variable, and, there-
lore, always possible. Thus, finally (Darapti),. = (f)(y, xz, n).
Lastly, take (Bramantip),.. We get

(Bramantip), = (z : y)(y : x) : (x : z")' = (z : y)(y : x ){x : z) : i]
= (z : y){z : x')(y : x) : n = (z : yx)(y : x) : >i
= (z : yx')(yx' : >i) :i] = (z: yx')(yx : r,) : (z : //) ;

for, in the traditional logic, (z:r]) = r), since z must be a
variable and therefore possible. Hence, finally, we get

(Bramantip),. = <p(z, yx\ >/).

57. By similar reasoning the student can verify the
following list (see §§ 54-56):

(p(x, y, z) = Barbara ; (p(x, y, z') = Celarent = Cesare :
ip(y y z , x') = Darii = Datisi ; (p{x, z, y') = Ferio = Festino

= Ferison = Fresison ; (p(z, y, x) = Camestres

= Camenes ;

§§57-59] TESTS OF SYLLOGISTIC VALIDITY 53

<p(y, x, z) = Disamis = Dismaris ; <p(x, z, y) = Baroko :
(p(y } x , v) = Bokardo; <f>(y, xz, »/) = (Darapti),. ;
(p(y, xz, »/) = (Felapton) r = (Fesapo) r ;
<p(z, yx', n) = (Bramantip),..

58. It is evident (since x : y = y' : x) that (f)(x, y, z) =
cb(z,' y', x) in the preceding list ; so that all these
syllogisms remain valid when we change the order ot
their constituents, provided we, at the same time, change
their signs. For example, Camestres and Camenes may
each be expressed, not only in the form cp(z, y, x'), as in
the list, but also in the form (p(x, y, z).

59. Text-books on logic usually give rather compli-
cated rules, or " canons," by which to test the validity
of a supposed syllogism. These we shall discuss further
on (see §§ 62, 63); meanwhile we will give the following
rules, which are simpler, more general, more reliable, and
more easily applicable.

Let an accented capital letter denote a non-implication
(or " particular "), that is to say, the denial of an impli-
cation : while a capital without an accent denotes a
simple implication (or " universal "). Thus, if A denote
x : y, then A' will denote (x : y)' . Now, let A. B, C denote
any syllogistic implications, while A', B', C denote their
respective denials. Every valid syllogism must have
one or other of these three forms :

(1) AB:C; (2) AB r : C ; (3) AB : C ;

that is to say, either the two premises and the conclusion
are all three implications (or " universals ") as in (1);
or one premise only and the conclusion are both non-
implications (or "particulars") as in (2); or, as in (3),
both premises are implications (or " universals "), while
the conclusion is a non-implication (or " particular ").
If any supposed syllogism does not come under form (1)
nor under form (2) nor under form (3), it is not valid ;
that is to say, there will be cases in which it will fail.

54 SYMBOLIC LOGIC [§ 59

The second form may be reduced to the first form by
transposing the premise B' and the conclusion C, and
changing their signs ; for AB' : C is equivalent to AC : B,
each being equivalent to AB'C : >?. When thus trans-
formed the validity of AB' : C, that is, of AC : B, may be
tested in the same way as the validity of AB : C. The
test is easy. Suppose the conclusion C to be x : z, in
which z may be affirmative or negative. If, for example,
z — He is a soldier; then z' = He is not a soldier. But it
z—He is not a soldier; then z' — He is a soldier. The
conclusion C being, by hypothesis, x:z, the syllogism
AB : C, if valid, becomes (see § 11) either

(x :y:z):(x: z), or else {x : y' : z) : (x : z),

in which the statement y refers to the middle class (or
" term ") Y, not mentioned in the conclusion x : z. If any
supposed syllogism AB : C cannot be reduced to either
of these two forms, it is not valid ; if it can be reduced
to either form, it is valid. To take a concrete example,
let it be required to test the validity of the following
implicational syllogism :

If no Liberal approves of Protection, though some Liberals approve
of fiscal Retaliation, it follows that some person or persons who approve
of fiscal Retaliation do not approve of Protection.

Speaking of a person taken at random, let L = He is
a Liberal; let P = He approves of Protection; and let
R = He approves of fiscal Retaliation. Also, let Q denote
the syllogism. We get

Q=(L:P')(L:R'/:(R:P)'.

To get rid of the non-implications, we transpose them
(see § 56) and change their signs from negative to
affirmative, thus transforming them into implications.
This transposition gives us

Q = (L:P , )(R:P):(L:R').

§§59, 00] TESTS OF SYLLOGISTIC VALIDITY 55

Since in this form of Q, the syllogistic propositions are
all three implications (or " universale "), the combination
of premises, (L : P')(R:P), must (if Q be valid) be equi-
valent

either to L : P : R' or else to L : P' : R' ;

in which P is the letter left out in the new consequent
or conclusion L : R'. Now, the factors L : P and P : R'
of L : P : R' are not equivalent to the premises L : P' and
R : P in the second or transposed form of the syllogism
Q ; but the factors L : P' and P' : R' (which is equivalent
to R : P) of L : P' : R' are equivalent to the premises in
the second or transformed form of the syllogism Q.
Hence Q is valid.

As an instance of a non-valid syllogism of the form
AB : C, we may give

(x:y')(y:z'):(x:z');

for since the y's in the two premises have different signs,
the one being negative and the other affirmative, the
combined premises can neither take the form x:y:z nor
the form x : y' : z' , which are respective abbreviations for
(x>\y){y:z) and (x t y')(y' : /). The syllogism is there-
fore not valid.

00. The preceding process for testing the validity of
syllogisms of the forms AB : C and AB' : C apply to all
syllogisms without exception, whether the values of their
constituents x, y, z be restricted, as in the traditional
logic, or unrestricted, as in my general logic of state-
ments. But as regards syllogisms in general logic of the
form AB : C (a form which includes Darapti, Felapton,
Fesapo, and Bramantip in the traditional logic), with
two implicational premises and a non-implicational con-
clusion, they can only be true conditionally ; for in general
logic (as distinguished from the traditional logic) no
syllogism of this type is a formal certainty. It therefore
becomes an interesting and important problem to deter-

56 SYMBOLIC LOGIC [§§ GO, 61

mine the conditions on which syllogisms of this type can
be held valid. We have to determine two things, firstly,
the iveakest premise (see § 33, footnote) which, when
joined to the two premises given, would render the syllo-
gism a formal certainty ; and, secondly, the weakest con-
dition which, when assumed throughout, would render
the syllogism a formal impossibility. As will be seen, the
method we are going to explain is a general one, which may
be applied to other formulae besides those of the syllogism.

The given implication AB : C is equivalent to the
implication ABC : y, in which A, B, C are three impli-
cations (see § 59) involving three constituents x, y, z.
Eliminate successively x, y, z as in § 34, not as in
finding the successive limits of x, y, z, but taking each
variable independently. Let a denote the strongest con-
clusion deducible from ABC and containing no reference
to the eliminated x. Similarly, let /3 and y respectively
denote the strongest conclusions after the elimination of
y alone (x being left), and after the elimination of z alone
(x and y being left). Then, if we join the factor a or /3'
or y' to the premises (ix. the antecedent) of the given
implicational syllogism AB : C, the syllogism will become
a formal certainty, and therefore valid. That is to say,
ABa' : C will be a formal certainty ; and so will AB/3' : C
and AB?' : C. Consequently, AB (a +fi'+ y) : C is a
formal certainty ; so that, on the one hand, the weakest
premise needed to be joined to AB to render the given
syllogism AB : C valid {i.e. a formal certainty) is the
alternative a' + fi' + y', and, on the other, the weakest
datum needed to make the syllogism AB : C a formal
impossibility is the denied of a + /?' + y , that is, a(3y.

61. Take as an example the syllogism Darapti.
Here we have an implication AB : C in which A, B, C
respectively denote the implications (y : x), (y : z), (x : z).
By the method of § 34 we get

ABC = yx + yz' + xz : >; = M* + N./ + P : r,, say,

§61] CONDITIONS OF VALIDITY 57

in which M, N, P respectively denote the co-factor of x,
the co-factor of %', and the term not containing x. The
strongest consequent not involving x is MN + P : *), in which
hero M = z, N = y, and P = yz' ; so that we have

MN + P : n = zy + yz' : n = //( - + z') : 1
= ye : >/ = y : v\.

Thus we get a = y: >/, so that the premise required when
we eliminate x is (y : >;/ ; and therefore

( r .x)(y.z)(y.ri) f -(x:z , ) t

should be a formal certainty, which is a fact ; for, getting
rid of the non-implications by transposition, this complex
implication becomes

(y : x)(y : z){x : z) : (y : 17),
which = (y : xz)(xz : n) ■ (y ■ n) ;

and this is a formal certainty, being a particular case of
the standard formula (f)(x, y, z), which represents Barbara
both in general and in the traditional logic (see § 55).
Eliminating y alone in the same manner from AB : C,
we find that (3 = xz : *i = x : z' ; so that the complex
implication

{y:x)(y:z)(x:zy:(x:z')'

should be a formal certainty. That it is so is evident by
inspection, on the principle that the implication PQ : Q,
for all values of P and Q, is a formal certainty. Finally,
we eliminate z, and find that y = y: n- This is the same
result as we obtained by the elimination of x, as might
have been foreseen, since x and z are evidently inter-
changeable.

Thus we obtain the information sought, namely, that
« / + /3 / + 7 / , the weakest premise to be joined to the
premises of Darapti to make this syllogism a formal
certainty in general logic is

(y : >/) / + (xz : >/)' + (// : •?)', which = y*> + (xz)- 1 " ;

58 SYMBOLIC LOGIC [§§ 61, 62

and that a/3y, the Aveakest presupposed condition that
would render the syllogism Darapti a logical impossi-
bility, is therefore

/ ,p + (,,.,) - ; j ' t w hich = y\ocz)\

Hence, the Darapti of general logic, with unrestricted
values of its constituents x, y, z, fails in the case y\xzy ;
but in the traditional logic, as shown in § 50, this case
cannot arise. The preceding reasoning may be applied
to the syllogisms Felapton and Fesapo by simply chang-
ing z into z! .

Next, take the syllogism Bramantip. Here we get

ABC = yx' + zy' + xz : >i,

and giving u, /3, y the same meanings as before, we
get a = z r >, /3 = z\ y = (x'y)\ Hence, a^y — z\xyf, and
a' + ft' + y' = z~ n + (£c'y)~ r '. Thus, in general logic, Bra-
mantip is a formal certainty when we assume z~ v + {x'yY*,
and a formal impossibility when we assume &{x'yf ; but
sible, since z v is inadmissible by § 50, while the former is
obligatory, since it is implied in the necessary assump-
tion 2f.

62. The validity tests of the traditional logic turn
mainly upon the question whether or not a syllogistic
' term ' or class is ' distributed ' or ' undistributed.' In
ordinary language these words rarely, if ever, lead to
any ambiguity or confusion of thought ; but logicians
have somehow managed to work them into a perplexing
tangle. In the proposition " All X is Y," the class X is
said to be ' distributed,' and the class Y ' undistributed.'
In the proposition " No X is Y," the class X and the
class Y are said to be both ' distributed.' In the pro-
position " Some X is Y," the class X and the class Y are
said to be both 'undistributed.' Finally, in the pro-
position " Some X is not Y," the class X is said to be
' undistributed,' and the class Y ' distributed.'

§ 6 2] < DISTRIBUTED — < UNDISTRIBUTED , 59

Let us examine the consequences of this tangle of
technicalities. Take the leading syllogism Barbara, the
validity of which no one will question, provided it bo
expressed in its conditional form, namely, " If all Y is Z,
and all X is Y, then all X is Z." Being, in this form
(see § 52), admittedly valid, this syllogism must hold
good whatever values (or meanings) we give to its con-
stituents X, Y, Z. It must therefore hold good when
X, Y, and Z are synonyms, and, therefore, all denote the
same class. In this case also the two premises and the
conclusion will be three truisms which no one would
dream of denying. Consider now one of these truisms,
say " All X is Y." Here, by the usual logical convention,
the class X is said to be ' distributed,' and the class Y
1 undistributed.' But when X and Y are synonyms they
denote the same class, so that the same class may, at the
same time and in the same proposition, be both ' dis-
tributed' and 'undistributed.' Does not this sound like
a contradiction ? Speaking of a certain concrete collec-
tion of apples in a certain concrete basket, can we con-
sistently and in the same breath assert that " All the
apples are already distributed " and that " All the apples
are 'still undistributed " ? Do we get out of the dilemma
and secure consistency if on every apple in the basket we
stick a ticket X and also a ticket Y ? Can we then con-
sistently assert that all the X apples are distributed, but
that all the Y apples are undistributed ? Clearly not ; for
every X apple is also a Y apple, and every Y apple an X
apple. In ordinary language the classes which we can
respectively qualify as distributed and undistributed are
mutually exclusive ; in the logic of our text-books this
is evidently not the case. Students of the traditional
logic should therefore disabuse their minds of the idea
that the words ' distributed ' and ' undistributed ' neces-
sarily refer to classes mutually exclusive, as they do in
everyday speech ; or that there is anything but a forced
and fanciful connexion between the ' distributed ' and

60 SYMBOLIC LOGIC [§ 02

' undistributed ' of current English and the technical
' distributed ' and ' undisturbed ' of logicians.

Now, how came the words ' distributed ' and ' undis-
tributed ' to be employed by logicians in a sense which
plainly does not coincide with that usually given them ?
Since the statement " No X is Y " is equivalent to the
statement "All X is "Y," in which (see §§ 46-50) the
class Y (or non-Y) contains all the individuals of the
Symbolic Universe excluded from the class Y, and since
" Some X is not Y " is equivalent to " Some X is *Y," the
definitions of ' distributed ' and ' undistributed ' in text-
books virtually amount to this : that a class X is dis-
tributed with regard to a class Y (or *Y) when every
individual of the former is synonymous or identical with
some individual or other of the latter ; and that when
this is not the case, then the class X is undistributed with
regard to the class Y (or'Y). Hence, when in the state-
ment " All X is Y " we are told that X is distributed with
regard to Y, but that Y is undistribided with regard to X,
this ought to imply that X and Y cannot denote exactly
the same class. In other words, the proposition that
" All X is Y " ought to imply that " Some Y is not X."
But as no logician would accept this implication, it is
clear that the technical use of the words ' distributed '
and ' undistributed ' to be found in logical treatises is
lacking in linguistic consistency. In answer to this
criticism, logicians introduce psychological considerations
and say that the proposition " All X is Y " gives us infor-
mation about every individual, X 1; X 2 , &c, of the class X,
but not about every individual, Y v Y 2 , &c, of the class Y ;
and that this is the reason why the term X is said to be
'distributed' and the term Y 'undistributed.' To this
explanation it may be objected, firstly, that formal logic
should not be mixed up with psychology — that its for-
mulae are independent of the varying mental attitude of
individuals ; and, secondly, that if we accept this ' infor-
mation-giving ' or ' non-giving ' definition, then we should

§62] 'DISTRIBUTED'— < UNDISTRIBUTED 1 fil

say, not that X is distributed, and Y undistributed, but
that X is known or inferred to be distributed, while Y is
not known to be distributed — that the inference requires
further data.

To throw symbolic light upon the question we may
proceed as follows. With the conventions of 8 50 we
have

(1) All X is Y = x:y; (2) No X is Y = x : //
(3) Some X is Y = (x : //)'; (4) Some X is not Y = (x : //)'.

The positive class (or ' term ') X is usually spoken of by
logicians as the subject'; and the positive class Y as
the ' predicate.' It will be noticed that, in the above
examples, the non-implications in (3) and (4) are the
respective denials of the implications in (2) and (1). The
definitions of ' distributed ' and ' undistributed ' are as
follows.

(a) The class (or ' term ') referred to by the ante-
cedent of an implication is, in text-book language, said to
be ' distributed ' ; and the class referred to by the conse-
quent is said to be ' undistributed.'

(/\$) The class referred to by the antecedent of a non-
implication is said to be ' undistributed ' ; and the class
referred to by the consequent is said to be ' distributed.'

Definition (a) applies to (1) and (2); definition
(/3) applies to (3) and (4). Let the symbol X d assert
that X is ' distributed' and let X u assert that X is ' un-
distributed.' The class 'X being the complement of the
class X, and vice versa (see 8 46), we get (*X)* = X M ,
and (X)" = X d . From the definitions (a) and (/3), since
(Y) d = Y", and ( y Y) u = Y d , we therefore draw the following
four conclusions : —

In (1) X d Y u ; in (2) X d Y d ; in (3) X U Y U : in (4)
X u Y d . For in (2) the definition (a) gives us X d ( r Yf ,
and CY) u = Y d . Similarly, in (3) the definition (/3) gives
us X u CY) d , and ( , Y) d = Y M .

If we change y into x in proposition (1) above, we

62 SYMBOLIC LOGIC [§§ 62, 63

get " All X is X "=x:x. Here, by definition (a), we have
X d X" ; which shows that there is no necessary antagonism
between X rf and X" ; that, in the text-book sense, the
same class may be both ' distributed ' and ' undistri-
buted ' at the same time.

63. The six canons of syllogistic validity, as usually
given in text-books, are : —

(1) Every syllogism has three and only three terms,
namely, the ' major term,' the ' minor term,' and the
' middle term ' (see § 5 4).

(2) Every syllogism consists of three and only three
propositions, namely, the ' major premise,' the ' minor
premise,' and the 'conclusion' (see § 54).

(3) The middle term must be distributed at least
once in the premises ; and it must not be ambiguous.

(4) No term must be distributed in the conclusion,
unless it is also distributed in one of the premises.*

(5) We can infer nothing from two negative pre-
mises.

(6) If one premise be negative, the conclusion must
be so also ; and, vice versa, a negative conclusion requires
one negative premise.

Let us examine these traditional canons. Suppose
\//('', y, z) to denote any valid syllogism. The syllogism
being valid, it must hold good whatever be the classes to
which the statements x, y, z refer. It is therefore valid
when we change y into x, and also z into x ; that is to
say, \|/(.'", ,/', :>-,) is valid (§ 13, footnote). Yet this is
a case which Canon (1) appears arbitrarily and need-
lessly to exclude. Canon (2) is simply a definition, and
requires no comment. The second part of Canon (3)
applies to all arguments alike, whether syllogistic or not.

* Violation of Canon (4) is called "Illicit Process." When the term
illegitimately distributed in the conclusion is the major term, the fallacy
is called " Illicit Process of the Major " ; when the term illegitimately dis-
tributed in the conclusion is the minor term, the fallacy is called " Illicit
Process of the Minor " (see § 54).

§63] 'CANONS 1 OF TRADITIONAL LOGIC 63

It is evident that if we want to avoid fallacies, we must
also avoid ambiguities. The first part of Canon (3)
cannot be accepted without reservation. The rule about
the necessity of middle-term distribution does not apply
to the following perfectly valid syllogism, " If every X is
Y, and every Z is also Y, then something that is not X
is not Z." Symbolically., this syllogism may be expressed
in either of the two forms

(x-.y){z:y):{x :z)' (1)

{xy'nzyj'.ix'z'r (2)

Conservative logicians who still cling to the old logic ;
finding it impossible to contest the validity of this syllo-
gism, refuse to recognise it as a syllogism at all, on the
ground that it has four (instead of the regulation three)
terms, namely, X, Y, Z, % the last being the class con-
taining all the individuals excluded from the class X.
Yet a mere change of the three constituents, x, y, z, of
the syllogism Darapti (which they count as valid) into
their denials x', //, z' makes Darapti equivalent to the
above syllogism. For Darapti is

_ {y:x\y:z):{x:zy (3);

and by virtue of the formula a : (3 = /3' : a, the syllogism
(l) in question becomes

(/:*')(/ :*'):(*':*)' (4).

Thus, if \^(f;, y, z) denote Darapti, then y\s(x', //', ;')
will denote the contested syllogism (1) in its form (4);
and, vice versa, if ^(x, y, z) denote the contested syllo-
gism, namely, (1) or (4), then ^(a/, y ', z') will denote
Darapti. To assert that any individual is not in the
class X is equivalent to asserting that it is in the com-
plementary class 'X. Hence, if we call the class 'X the
non-X class, the syllogism in question, namely,

(/:./)(/:/) :(,/:*)' (4),

Online LibraryHugh MacCollSymbolic logic and its applications → online text (page 5 of 11)


text:
How do I use the vertex formula to determine the vertex of the graph for f(x)=3x^2-6x+1?

May 10, 2015

Vertex form: $y = a {\left(x + \frac{b}{2 a}\right)}^{2} + f \left(- \frac{b}{2} a\right)$.

-b/2a = 6/6 = 1

f(1) = 3 - 6 + 1 = -2

Vertex form $f \left(x\right) = 3 {\left(x - 1\right)}^{2} - 2.$

Check.
Develop: f(x) = 3(x^2 - 2x + 1) - 2 = 3x^2 - 6x + 3 - 2 =
f(x) = 3x^2 - 6x + 1. Correct.


text:
# Tag Info

9

Non-Euclidian geometry can be generally boiled down to the phrase the shortest path between 2 points isn't necessarily a straight line. Or, put in a way that lends itself very much to machine learning, things that are similar to each other are not necessarily close if one uses Euclidean distance as a metric (aka the triangle inequality doesn't hold). You ...

8

To complete the first answer that is rather graph oriented, I will write a little about deep learning on manifolds, which is quite general in terms of GDL thanks to the nature of manifolds. Note that the description of GDL through the explanation of what are DL on graphs and manifolds, in opposition to DL on euclidean domains, comes from the 2017 paper ...

3

I'm seeing recent trend of combining RNN/CNN with GNN(graph neural networks) so that both time dependency and topology are captured. I would suggest you to start by looking at DCRNN (Yaguang Li et al.), it's a strong baseline that everyone uses nowadays. Other good resources: Graph wavenet for deep spatial-temporal graph modeling (Zonghan Wu et al.) Spatio-...

3

Generally speaking a graph CNN is applied to data represented by graphs, not images. a graph is a collection of nodes and edges connecting them. an image is a 2D or 3D matrix, in which each element denotes a pixel in space If your data are just images, or something similar (e.g. some fMRI data), you usually cannot benefit from graph CNN compared with ...

2

You can flatten the graph into a matrix and then train it like a normal neural network input. Perhaps an adjacency graph or maybe simply a series of linear equations representing the nodes and convert it into matrix form.

2

The article Geometric deep learning: going beyond Euclidean data (by Michael M. Bronstein, Joan Bruna, Yann LeCun, Arthur Szlam, Pierre Vandergheynst) provides an overview of this relatively new sub-field of deep learning. It answers all the questions asked above (and more). If you are familiar with deep learning, graphs, linear algebra and calculus, you ...

2

Bioinformatics is an area that Graph Convolutional Neural Network is useful. Consider protein networks, or gene-gene networks. Surely, the biological networks can be represented as a graph. Now, you should see how GCN is useful for bioinformatics.

2

Yes, there are numerous, coming under the umbrella term Graph Neural Networks (GNN). The most common input structures accepted by these techniques are the adjacency matrix of the graph (optionally accompanied by its node feature matrix and/or edge feature matrix, if the graph has such information). A Comprehensive Survey on Graph Neural Networks, Wu et al (...

2

Graph Neural Networks The term Graph Neural Network, in its broadest sense, refers to any Neural Network designed to take graph structured data as its input: To cover a broader range of methods, this survey considers GNNs as all deep learning approaches for graph data. A Comprehensive Survey on Graph Neural Networks, Wu et al (2019) However the ...

2

A Comprehensive Survey on Graph Neural Networks (2019) presents a list of ConvGNN's. All of the following accept weighted graphs, and three accept those with edge weights as well: And below is a series of open source implementations of many of the above:

2

It's perfectly reasonable to apply 'traditional' Deep Learning approaches to try and learn an adjacency matrix (a matrix is just a vector of vectors, which can be flattened into a single output vector) but you might need a lot of training data as N gets larger. Your outputs could certainly have the form of an adjacency matrix, as you describe. Whether it's ...

1

The authors of your cited paper use the term graph-based semi-supervised learning (G-SSL) to refer to semi-supervised learning techniques which take graph structured data as their input. Given their main example, the MNIST dataset, is not graph structured, they detail a method for converting the raw Euclidean data $X$ into said form (represented by its ...

1

You can use Pytorch_Geometric library for your projects. Its supports weighted GCNs. It is a rapidly evolving open-source library with easy to use syntax. It is mentioned in the landing page of Pytorch. It is the most starred Pytorch github repo for geometric deep learning. Creating a GCN model which can process graphs with weights is as simple as: import ...

1

Low order/low level information refers to the most granular level of information. This is the most informative in terms of volume of information, but it can often be difficult to conceptualise for humans. High order/high level information refers to abstractions of the low level information to more intuitive but less easy to describe technically concepts. ...

1

Both study properties of a network. The literature under respective titles seems to focus on certain topics. Network analysis seems to focus on understanding the structure of a network. Centrality , modularity, assortativity etc are metrics used to study properties of networks. Key areas of research are for egs community detection, centrality measures, ...

1

Network analysis does not necessarily use deep learning techniques, while geometric deep learning (GDL) on graphs uses only deep learning techniques (that is, you train a neural network using gradient descent or other optimization methods). You can do some network analysis using GDL.

1

There are types of neural networks designed exactly for that purpose. For example, graph convolutional networks (GCN) by Thomas N. Kipf. The input to the network will be a matrix of size $N \times F$, where $N$ is the number of nodes and $F$ the number of features (for each node). You then can multiply the feature matrix with the adjacency matrix (each node ...

1

Your approach seems reasonable to me. The edges do not necessarily have to be numbers, but, if you wish, you could also encode the actions as numbers. For example, the weight of an edge could represent the "cost" of the corresponding action. If there's no natural cost associated with an action, then you can add a unit cost for each action.

1

I presume this question was prompted by the paper Geometric deep learning: going beyond Euclidean data (2017). If we look at its abstract: Many scientific fields study data with an underlying structure that is a non-Euclidean space. Some examples include social networks in computational social sciences, sensor networks in communications, functional ...

1

I doubt that this problem is a good application of NN. Take a look at this https://en.wikipedia.org/wiki/Force-directed_graph_drawing. And try Graphviz if you haven't already. Drawing graphs in a meaningful way is notoriously difficult. An alternative approach would be to embed all nodes into a 2d or 3d metric space. I.e. for each node you will have ...

1

Neural networks are used to visualize high dimensional data through the use of autoencoding. It's similar to Principal Component Analysis and is regarded to perform better then PCA. Autoencoding will take your data and convert it to a 2 or 3-dimensional representation. Since you have an array of data you might want to use LSTM. You will have to make sure you ...

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