text:
Summer is Coming! Join the Game of Timers Competition to Win Epic Prizes. Registration is Open. Game starts Mon July 1st.

 It is currently 23 Jul 2019, 06:51

### GMAT Club Daily Prep

#### Thank you for using the timer - this advanced tool can estimate your performance and suggest more practice questions. We have subscribed you to Daily Prep Questions via email.

Customized
for You

we will pick new questions that match your level based on your Timer History

Track

every week, we’ll send you an estimated GMAT score based on your performance

Practice
Pays

we will pick new questions that match your level based on your Timer History

# What is the remainder when a is divided by 4?

Author Message
TAGS:

### Hide Tags

Intern
Joined: 14 Jul 2010
Posts: 6
What is the remainder when a is divided by 4?  [#permalink]

### Show Tags

19 Dec 2010, 15:22
2
7
00:00

Difficulty:

5% (low)

Question Stats:

79% (01:04) correct 21% (01:36) wrong based on 255 sessions

### HideShow timer Statistics

What is the remainder when a is divided by 4?

(1) a is the square of an odd integer.
(2) a is a multiple of 3.

According to the book, the answer is A.

But according to me, the answer should be C since if we take the first statement and use the value 1 for a, it gives us 1 for the square of 1, what would be the remainder?
When we use 3 for a, the square of a will give us 9 which when divided by 4, gives us remainder of 1.

Thanks.
Kash.
Math Expert
Joined: 02 Sep 2009
Posts: 56373
Re: MGMAT's Number Properties Data Sufficiency Question  [#permalink]

### Show Tags

19 Dec 2010, 15:44
2
5
ksear wrote:
Hi everyone,

I'm a little confused regarding the correct answer for the below mentioned question:

What is the remainder when a is divided by 4?

(1) a is the square of an odd integer.
(2) a is a multiple of 3.

According to the book, the answer is A.

But according to me, the answer should be C since if we take the first statement and use the value 1 for a, it gives us 1 for the square of 1, what would be the remainder?
When we use 3 for a, the square of a will give us 9 which when divided by 4, gives us remainder of 1.

Thanks.
Kash.

Positive integer $$a$$ divided by positive integer $$d$$ yields a reminder of $$r$$ can always be expressed as $$a=qd+r$$, where $$q$$ is called a quotient and $$r$$ is called a remainder, note here that $$0\leq{r}<d$$ (remainder is non-negative integer and always less than divisor).

So according to above, when positive integer $$a$$ is less than divisor $$d$$ then remainder upon division $$a$$ by $$d$$ is always equals to $$a$$, for example 5 divided by 10 yields reminder of 5. So when 1 is divided by 4 remainder is 1.

Or algebraically: 1 divided by 4 can be expressed as $$1=0*4+1$$, so $$r=1$$.

Back to the original question:

What is the remainder when a is divided by 4?

(1) a is the square of an odd integer --> $$a=(2k+1)^2=4k^2+4k+1$$, first two terms (4k^2 and 4k) are divisible by 4 and the third term (1) when divided by 4 yields the remainder of 1. Sufficient.

Or you can try several numbers for $$a$$:
$$a=1^1=1$$ --> 1 divided by 4 yields remainder of 1;
$$a=3^1=9$$ --> 9 divided by 4 yields remainder of 1;
$$a=5^1=25$$ --> 25 divided by 4 yields remainder of 1;
...

(2) a is a multiple of 3 --> clearly insufficient as $$a$$ can as well be a multiple of 4, 12 for example, and in this case the remainder will be 0, and it also can not be a multiple of 4, 3 for example, and in this case the remainder will be 3. Not sufficient.

Questions on remainders:

PS:
remainder-101074.html
remainder-problem-92629.html
number-properties-question-from-qr-2nd-edition-ps-96030.html
remainder-when-k-96127.html
ps-0-to-50-inclusive-remainder-76984.html
good-problem-90442.html
remainder-of-89470.html
number-system-60282.html
remainder-problem-88102.html

DS:
remainder-problem-101740.html
remainder-101663.html
ds-gcd-of-numbers-101360.html
data-sufficiency-with-remainder-98529.html
sum-of-remainders-99943.html
ds8-93971.html
need-solution-98567.html
gmat-prep-ds-remainder-96366.html
gmat-prep-ds-93364.html
ds-from-gmatprep-96712.html
remainder-problem-divisible-by-86839.html
gmat-prep-2-remainder-86155.html
remainder-94472.html
remainder-problem-84967.html

Hope it helps.
_________________
##### General Discussion
SVP
Status: Three Down.
Joined: 09 Jun 2010
Posts: 1843
Concentration: General Management, Nonprofit
Re: MGMAT's Number Properties Data Sufficiency Question  [#permalink]

### Show Tags

19 Dec 2010, 15:50
ksear wrote:
Hi everyone,

I'm a little confused regarding the correct answer for the below mentioned question:

What is the remainder when a is divided by 4?

(1) a is the square of an odd integer.
(2) a is a multiple of 3.

According to the book, the answer is A.

But according to me, the answer should be C since if we take the first statement and use the value 1 for a, it gives us 1 for the square of 1, what would be the remainder?
When we use 3 for a, the square of a will give us 9 which when divided by 4, gives us remainder of 1.

Thanks.
Kash.

To answer your specific question, if you divide 1 by 4, the reminder is 1. So the answer is valid.
Intern
Joined: 14 Jul 2010
Posts: 6
Re: MGMAT's Number Properties Data Sufficiency Question  [#permalink]

### Show Tags

19 Dec 2010, 15:52
It does help. Thanks.
Intern
Joined: 11 Jul 2013
Posts: 36
What is the remainder when a is divided by 4?  [#permalink]

### Show Tags

Updated on: 08 Aug 2013, 00:10
1
What is the remainder when a is divided by 4?
(1) a is the square of a odd integer.
(2)a is a multiple of 3.

Originally posted by domfrancondumas on 08 Aug 2013, 00:02.
Last edited by Zarrolou on 08 Aug 2013, 00:10, edited 1 time in total.
VP
Status: Far, far away!
Joined: 02 Sep 2012
Posts: 1044
Location: Italy
Concentration: Finance, Entrepreneurship
GPA: 3.8
Re: What is the remainder when a is divided by 4?  [#permalink]

### Show Tags

08 Aug 2013, 00:10
2
What is the remainder when a is divided by 4?

(1) a is the square of a odd integer.
Method #1:
a=1 reminder=1; a=9 reminder=1, a=25 reminder=1; a=49 reminder=1... I see a pattern, I am convinced that this is sufficient.
Method #2: $$a=(2k+1)^2$$ (where k is an integer)
$$a=4k^2+4k+1$$, $$a=4(k^2+k)+1$$ $$a$$ is a multiple of four plus one, hence the reminder will be one.
Sufficient

(2)a is a multiple of 3.
a=3 reminder=3, a=9 reminder=1.
Not sufficient.
_________________
It is beyond a doubt that all our knowledge that begins with experience.
Kant , Critique of Pure Reason

Tips and tricks: Inequalities , Mixture | Review: MGMAT workshop
Strategy: SmartGMAT v1.0 | Questions: Verbal challenge SC I-II- CR New SC set out !! , My Quant

Rules for Posting in the Verbal Forum - Rules for Posting in the Quant Forum[/size][/color][/b]
Senior Manager
Joined: 10 Jul 2013
Posts: 300
Re: What is the remainder when a is divided by 4?  [#permalink]

### Show Tags

10 Aug 2013, 04:32
ksear wrote:
What is the remainder when a is divided by 4?

(1) a is the square of an odd integer.
(2) a is a multiple of 3.

According to the book, the answer is A.

But according to me, the answer should be C since if we take the first statement and use the value 1 for a, it gives us 1 for the square of 1, what would be the remainder?
When we use 3 for a, the square of a will give us 9 which when divided by 4, gives us remainder of 1.

Thanks.
Kash.

1^2/4 = (4-3)^2/4 = (4^2 - 2.4.3 + 9)/4 = 4 + 6 + 9/4 = 10 + 9/4
so the remainder from 9/4 we have is 1 .
That's how we can realize why 1 appears as the remainder when 1^2 is divided by 4.

_________________
Asif vai.....
Director
Joined: 13 Mar 2017
Posts: 731
Location: India
Concentration: General Management, Entrepreneurship
GPA: 3.8
WE: Engineering (Energy and Utilities)
What is the remainder when p is divided by 4  [#permalink]

### Show Tags

16 Jun 2017, 00:26
What is the remainder when p is divided by 4 ?
(1) p is the square of an odd integer.
(2) p is a multiple of 3.
_________________
CAT 2017 (98.95) & 2018 (98.91) : 99th percentiler
UPSC Aspirants : Get my app UPSC Important News Reader from Play store.

MBA Social Network : WebMaggu

Appreciate by Clicking +1 Kudos ( Lets be more generous friends.)

What I believe is : "Nothing is Impossible, Even Impossible says I'm Possible" : "Stay Hungry, Stay Foolish".
Director
Joined: 04 Dec 2015
Posts: 744
Location: India
Concentration: Technology, Strategy
WE: Information Technology (Consulting)
What is the remainder when p is divided by 4  [#permalink]

### Show Tags

16 Jun 2017, 00:31
shashankism wrote:
What is the remainder when p is divided by 4 ?
(1) p is the square of an odd integer.
(2) p is a multiple of 3.

(1) p is the square of an odd integer.

Lets try $$3^2, 7^2$$

$$3^2 = 9.$$
9 divided by 4 gives remainder 1.

$$7^2 = 49$$
49 divided by 4 gives remainder 1.

Any square of odd integer divided by 4 will give remainder 1. -------- (I is Sufficient)

(2) p is a multiple of 3.

12 is multiple of 4 hence will give remainder 0.
3 divided by 4 will give remainder 3.
6 divided by 4 will give remainder 2. etc...
Therefore multiple values. -------- (II is Not Sufficient)

Math Expert
Joined: 02 Sep 2009
Posts: 56373
Re: What is the remainder when a is divided by 4?  [#permalink]

### Show Tags

16 Jun 2017, 01:41
shashankism wrote:
What is the remainder when p is divided by 4 ?
(1) p is the square of an odd integer.
(2) p is a multiple of 3.

Merging topics. Please refer to the discussion above.
_________________
Director
Joined: 13 Mar 2017
Posts: 731
Location: India
Concentration: General Management, Entrepreneurship
GPA: 3.8
WE: Engineering (Energy and Utilities)
Re: What is the remainder when a is divided by 4?  [#permalink]

### Show Tags

18 Jun 2017, 23:18
ksear wrote:
What is the remainder when a is divided by 4?

(1) a is the square of an odd integer.
(2) a is a multiple of 3.

According to the book, the answer is A.

But according to me, the answer should be C since if we take the first statement and use the value 1 for a, it gives us 1 for the square of 1, what would be the remainder?
When we use 3 for a, the square of a will give us 9 which when divided by 4, gives us remainder of 1.

Thanks.
Kash.

(1) Let a = (2k+1)^2 as it is square of an odd integer = 4k^2 + 4k +1 . So when it is divided by 4, remainder =1. Sufficient
(2) a is a multiple of 3, i.e. 3,6,9,12,15,........ So when it is divided by 4, remainder = 3 , 2, 1, 0, So Not sufficient

_________________
CAT 2017 (98.95) & 2018 (98.91) : 99th percentiler
UPSC Aspirants : Get my app UPSC Important News Reader from Play store.

MBA Social Network : WebMaggu

Appreciate by Clicking +1 Kudos ( Lets be more generous friends.)

What I believe is : "Nothing is Impossible, Even Impossible says I'm Possible" : "Stay Hungry, Stay Foolish".
Non-Human User
Joined: 09 Sep 2013
Posts: 11759
Re: What is the remainder when a is divided by 4?  [#permalink]

### Show Tags

14 Aug 2018, 23:05
Hello from the GMAT Club BumpBot!

Thanks to another GMAT Club member, I have just discovered this valuable topic, yet it had no discussion for over a year. I am now bumping it up - doing my job. I think you may find it valuable (esp those replies with Kudos).

Want to see all other topics I dig out? Follow me (click follow button on profile). You will receive a summary of all topics I bump in your profile area as well as via email.
_________________
Re: What is the remainder when a is divided by 4?   [#permalink] 14 Aug 2018, 23:05
Display posts from previous: Sort by


text:
Most influential/illuminating papers/books/courses on lattice based cryptography?

I'm interested in some sort of "compendium" on lattice based crypto. There are a bunch of maths behind FALCON and other stuff. A lot of articles are devoted to lattice crypto, but not of them are of paramount importance. The other problem is that there are papers which are obviously influential, but they are hard to understand "from scratch".

GPV framework:

1. "How to Use a Short Basis: Trapdoors for Hard Lattices and New Cryptographic Constructions".

Cryptanalysis:

1. "Learning a Parallelepiped: Cryptanalysis of GGH and NTRU Signatures"

Basic courses :

1. winter school on lattice based crypto (https://cyber.biu.ac.il/event/the-2nd-biu-winter-school)
2. Regev course on lattices in CS (https://cims.nyu.edu/~regev/teaching/lattices_fall_2004/)
3. Vinod's course (http://people.csail.mit.edu/vinodv/6876-Fall2015/index.html)

Surveys :

1. "Lattice-based Cryptography" part from the book "Post-Quantum Cryptography".
2. "A Decade of Lattice Cryptography", Peikert.

Unfortunately i didn't find anything on discrete gaussian distributions and properties of continious gaussians (why is it "not far from" uniform over any "small" parallelopiped), how to generate them; on smoothing parameter and its "intuitive" meaning. Also reductions from average to worst case are somewhat tricky and uneasy to understand form Ajtai papers. And there is a direction of research on ideal lattices, which somehow related to integer rings of number fields ($$\mathbb{Z}_K$$), this is completely obscure..

• Did you check "a decade of lattice based crypto" by Chris Peikert? – Geoffroy Couteau Sep 16 at 7:42
• @GeoffroyCouteau nice, i will definitely check this source and will add to the list of "basics". However, a first glimpse gave me the feeling that this is just too terse to understand from scratch. – Kirill Tsar. Sep 16 at 10:08

format: plain


text:
# Spooky geometry III

Construct a path-connected metric space $X$ and a discontinuous function $f:X\to \Bbb{R}$ such that $f\circ \sigma$ is continuous for any continuous path $\sigma:[0,1]\to X$.

## 3 thoughts on “Spooky geometry III”

1. If $X$ is locally path-connected and first-countable, it is true that a function $f:X\to Y$ such that its composition with any path is continuous is itself continuous. We will show a counterexample where $X$ is locally path-connected but not first-countable.

Let $X$ be the subspace of $\ell^\infty$ of points of the form $\lambda e_n$ for some $\lambda\in[0,1]$ and natural $n$; that is, $X$ is the union of the unit segments corresponding to the “coordinate axes”.

Let $f:\ell^\infty\to\Bbb{R}$ be any linear functional such that $e_n\mapsto n$ and consider its restriction to $X$. Obviously this restriction is discontinuous at 0 since $f$ is unbounded. However, the image of any path $\sigma:[0,1]\to X$ is contained, by compactness, in a finite-dimensional subspace of the form $\langle e_1,\dots,e_k\rangle$, so the restriction of $f$ to this subspace is bounded, and therefore continuous.

Liked by 1 person

1. The above solution is wrong, since the example is both locally path-connected and first-countable (any metric space is first-countable!). In fact, it is not true that the image of a continuous path $\sigma$ is contained in a finite-dimensional subspace. For instance, consider a path $\sigma$ which goes from $0$ to $e_1/2$ and returns in $[0,1/2]$, then from $0$ to $e_2/4$ and returns in $[1/2, 3/4]$, and so on. This is continuous in $[0,1)$ by the pasting lemma, and if we set $\sigma(1)=0$, the fact that $e_n/2^{n+1}\longrightarrow 0$ implies $\sigma$ is continuous at $1$, too. What led to this mistake was the fact that the image of a compact set in a CW-complex intersects at most finitely many cells, but the obvious CW structure on the set $X$ does not induce the same topology we are considering: it is not even metrizable, since the complex is not locally finite!

Here is a correct solution, due to Pablo, which is a variation on the comb space. Let $X=([-1,1]\times \{0\})\cup(([-1,1]\cap\Bbb{R}\setminus\Bbb{Q}) \times [0,1])$ and define $f(x,y)=0$ if $x<0$ and $f(x,y)=y$ if $x\geq 0$. This is obviously discontinuous at any point $(0,y)$ with positive $y$, but $f\circ\sigma$ is continuous for any path $\sigma$. Notice that this space is not locally path-connected.

Like


text:
# Pull force on bolt

I am considering a part of a steel column. A horizontal force of 5 kN is acting on the top part of the column. The distance from top to bottom is 500 mm. The distance between the two bolts in the bottom is 100 mm. I wish to find the pull force on the bolts (please see attached picture).

The moment in the bottom is M = 5 kN × 500 mm = 2500 kNmm.

As the force acts on the column there appears a pull-force on the bolts (we call it T).

If I take moment in one of the bolts then I have:

M = T × 100 mm, 2500 kN = T × 100 mm, T = 2500 kNmm / 100 mm, T=25 kN.

I have the following questions:

1. Is the calculated moment of 2500 kNmm correct and where does is "act" specifically? In the bottom of the column, in the bolts?
2. Is it correct to say that the above moment acts in the bottom of the column and therefore there is a pull-force on the bolts of 25 kN?
3. Is there a pull-force on the left bolt and pressure-force on the right bolt?
4. Since I am interested in the pull-force I can take the moment around the right bolt. Right?

(All measure are in mm)

Appreciate the help.

1- Yes. It is correct.

2- Yes the above moment acts on the bottom of the column, but it also acts all along the length of the column $$M=5kN*H \quad \text{H= height from the base.} \$$ And it even acts beyond the embedment of the bolts into the concrete.

3- yes the left bolts are in tension. the torque they make with the right edge of the base plate compressive reaction counters the column's overturning moment.

4- Yes if you take the moment about the right bolt you get the approximate uplift force on the left bolt (s). You would need to allow for the complex forces of the base plate to be counted to get the exact result.

• For the sake of calculation, we will say the pivot is around the right bolt and 30 mm above the base. The torque at the pivot is (500mm-30mm) * 5 kN = 2350 NM. Since the bolts are 0.1 M apart, this works out to 23.5 kN on the left bolt. – user1683793 Mar 19 at 21:41

The moment calculation is correct, but without knowing the size and thickness of the base plate, it is no way to know the force in the anchor bolts, as there is compressive stress at the toe side of the base plate, that resists the moment, and renders the bolt ineffective (bolt is effective to resist tension only). Note in diagrams below, the distance between the force couple (T & C) varies.

• I don't agree. The right bolt is just keeping it in place for other forces, The baseplate pressing on the base provides the force labeled "C" in your diagram. For problems like this, since we were giving no data about the base, we can assume it is infinitely strong so that is an appropriate place to use as a pivot. If we had more information, we could say the pivot is not at the right bolt but the right edge of the baseplate. The distance between the bolts is 100 mm and we have torque of (500-30)MM * 5KN so the force on the left bolt is 23.5 KN. – user1683793 Mar 19 at 21:53
• @1683793 Without information on the baseplate, you can assume anything, but does it serve the purpose? This is a "design" question, not typical mechanics, that's how I see the problem, thus the response. – r13 Mar 19 at 22:07
• For practical design, I suggest to review methods provided by the AISC DG 1, if you are in the US. – r13 Mar 19 at 22:11


text:
# Tag

Sort by:

### Complete bipartite graph

A complete bipartite graph, sometimes also called a complete bicolored graph (Erdős et al. 1965) or complete bigraph, is a bipartite graph (i.e., a set of graph vertices decomposed into two disjoint sets such that no two graph vertices within the same set are adjacent) such that every pair of graph vertices in the two sets are adjacent. If there are and graph vertices in the two sets, the complete bipartite graph is denoted . The above figures show and . is also known as the utility graph (and is the circulant graph ), and is the unique 4-cage graph. is a Cayley graph. A complete bipartite graph is a circulant graph (Skiena 1990, p. 99), specifically , where is the floor function.Special cases of are summarized in the table below.path graph path graph claw graphstar graph square graph utility graphThe numbers of (directed) Hamiltonian cycles for the graph with , 2, ... are 0, 2, 12, 144, 2880, 86400, 3628800, 203212800, ... (OEIS A143248), where..

Check the price
we accept
Money back
guarantee
100% quality
Support
1-855-407-7728


text:
/ Data Science

# Linear regression.

Linear regression is used to predict an outcome given some input value(s). While machine learning classifiers use features to predict a discrete label for a given instance or example, machine learning regressors have the ability use features to predict a continuous outcome for a given instance or example. For example, a classifier might draw a decision boundary that can tell you whether or not a house is likely to sell at a given price (when provided with features of the house) but a regressor can use those same features to predict the market value of the house. Nonetheless, regression is still a supervised learning technique and you'll still need to train your model on a set of examples with known outcomes.

The basic premise behind linear regression is to provide a model which can observe linear trends in the data; you've probably encountered linear regression at some point in the past as finding the "line of best fit".

### The model

Our machine learning model is represented by the equation of a line.
[{h_\theta }\left( x \right) = {\theta _0} + {\theta _1}x]

In this case, we define our model as ${h _\theta }\left( x \right)$ where $h$ represents our predicted outcome as a function of our features, $x$. Typically, the model of a line is represented by $y=mx+b$. We use $h$ instead of $y$ to denote that this model is a hypothesis of the true trend. In a sense, we're attempting to provide our "best guess" for finding a relationship in the data provided. $\theta _0$ and $\theta _1$ are coefficients of our linear equation (analogous to $b$ and $m$ in the standard line equation) and will be considered parameters of the model.

So far, our model has only been capable of capturing one independent variable and mapping its relationship to one dependent variable. We'll now extend our linear model to allow for $n$ different independent variables (in our case, features) to predict one dependent variable (an outcome).

Thus, for each input $x$ we'll have a vector of values

$x=[ 1 x 1 x 2 ⋮ x n ]$

each with corresponding coefficients, $\theta$.

$[ θ 0 θ 1 θ 2 ⋮ θ n ]$

Note: $x _0 = 1$ by convention. This allows us to do matrix operations with $x$ and $\theta$ without deviating from our defined linear model.

Extending this model to account for multiple inputs, we can write it as

[{h _\theta }\left( x \right) = {\theta _0} + {\theta _1}{x _1} + {\theta _2}{x _2} + {\theta _3}{x _3} + ... + {\theta _n}{x _n}]

or more succinctly as

[{h_\theta }\left( x \right) = {\theta ^T}x]

when dealing with one example or

[{h _\theta }\left( x \right) = X\theta ]

when dealing with $i$ examples.

Note: this matrix, $X$, is also referred to as the design matrix and is usually capitalized by convention to denote it as a matrix as opposed to a vector.

If that doesn't quite make sense, let's take a step back and walk through the representation.

For a univariate model, we could write the model in matrix form as:

$h θ ( x )=[ θ 0 θ 1 ][ 1 x 1 ]= θ 0 + θ 1 x 1$

Go ahead and do the matrix multiplication to convince yourself.

Now that you're convinced, let's extend this to a multivariate model with $j$ features and $i$ examples.

$h θ ( x i )=[ 1 x 1,1 x 1,2 … 1 x 2,1 x 2,2 … 1 ⋮ ⋮ ⋮ 1 x i,1 x i,2 ⋯ x 1,j x 2,j ⋮ x i,j ][ θ 0 θ 1 θ 2 ⋮ θ j ]=[ y 1 y 2 y 3 ⋮ y n ]$

This is pretty useful because we can go ahead and calculate the prediction, ${{h _\theta }\left( {{x _i}} \right)}$, for every example in our data set using one matrix operation.

### The cost function

In order to find the optimal line to represent our data, we need to develop a cost function which favors model parameters that lead to a better fit. This cost function will approximate the error found in our model, which we can then use to optimize our parameters, $\theta _0$ and $\theta _1$, by minimizing the cost function. For linear regression, we'll use the mean squared error - the average difference between our guess, ${{h _\theta }\left( {{x _i}} \right)}$, and the true value, ${{y _i}}$ - to measure performance.

[\min \frac{1}{{2m}}\sum\limits_{i = 1}^m {{{\left( {{h _\theta }\left( {{x _i}} \right) - {y _i}} \right)}^2}} ]

Substituting in our definition of the model, ${{h _\theta }\left( {{x _i}} \right)}$, we'll update our cost function as:

[J\left( \theta \right) = \frac{1}{{2m}}\sum\limits _{i = 1}^m {{{\left( {\left( {\sum\limits _{j = 0}^n {{\theta _j}{x _{i,j}}} } \right) - {y _i}} \right)}^2}} ]

### Finding the best parameters

There's a number of ways to find the optimal model parameters. A few common approaches are detailed below.

We use gradient descent to perform the parameter optimization in accordance with our cost function. Remember, the cost function essentially will score how well our model is fitting the present data. A smaller cost function means less error, which means we have a better model.

We first start with an initial guess for what our parameter values should be. Gradient descent will then guide us through an iterative process of updating our parameter weights in search of an optimum solution.

Let's first look at the simplest example, where we fix $\theta _0 = 0$ and find the optimal slope value.

Using gradient descent, the weights will continue to update until we've converged on the optimal value. For linear regression, the cost function is always convex with only one optimum, so we can be confident that our solution is the best possible one. This is not always the case, and we'll need to be weary of converging on local optima using other cost functions.

As the picture depicts, gradient descent is an iterative process which guides the parameter values towards the global minimum of our cost function.

[{\theta _j}: = {\theta _j} - \eta \frac{\partial }{{\partial {\theta _j}}}J({\theta _0},{\theta _1})]

Gradient descent will update your parameter value by subtracting the current value by the slope of the cost function at that point multiplied by a learning rate, which basically dictates how far to step. The learning rate, $\eta$, is always positive.

Notice in the picture above how the first attempted value, $\theta _1 = 0$, has a negative slope on the cost function. Thus, we would update the current value by subtracting a negative number (in other words, addition) multiplied by the learning rate. In fact, every point left of the global minimum has a negative slope and would thus result in increasing our parameter weight. On the flip side, every value to the right of the global minimum has a positive slope and would thus result in decreasing our parameter weight until convergence.

One neat thing about this process is that gradient descent will automatically slow down as we're nearing the optimum. See how the initial iterations take relatively large steps in comparison to the last steps? This is because our slope begins to level off as we approach the optimum, resulting in smaller update steps. Because of this, there is no need to adjust $\eta$ during the optimization.

We can extend this idea to update both $\theta _0$ and $\theta _1$ simultaneously. In this case, our 2D curve has become a 3D contour plot.

While the gradient descent algorithm remains largely the same,

[{\theta _j}: = {\theta _j} - \alpha \frac{\partial }{{\partial {\theta _j}}}J\left( \theta \right)]

we now define the differential as

[\frac{\partial }{{\partial {\theta _j}}}J\left( \theta \right) = \frac{1}{m}\sum\limits _{i = 1}^m {\left( {\left( {\sum\limits _{j = 0}^n {{\theta _j}{x _{i,j}}} } \right) - {y _i}} \right)} {x _{i,j}}]

using the chain rule.

A few notes and practical tips on this process.

• Scaling your features (as mentioned in Preparing data for a machine learning model) to be on a similar scale can greatly improve the time it takes for your gradient descent algorithm to converge.
• It's important that your learning rate is reasonable. If it is too large it may overstep the global optimum and never converge, and if it's too small it will take a very long time to converge.
• Plot the $J\left( \theta \right)$ as a function of the number of iterations you have run gradient descent. If gradient descent is working properly it will continue to decrease steadily until leveling off, hopefully, close to zero. You can also use this plot to visually determine when your cost function has converged and gradient descent may be stopped.
• If $J\left( \theta \right)$ begins to increase as the number of iterations increases, something has gone wrong in your optimization. Typically, if this occurs it is a sign that your learning rate is too large.

Gradient descent is often the preferred method of parameter optimization for models which have a large number (think, over 10,000) of features.

###### Normal equation

Remember how we used matrices to represent our model? Using normal equation for linear regression you can solve for the optimal parameters analytically in one step.

[\theta = {\left( {{X^T}X} \right)^{ - 1}}{X^T}y]

You can find a good derivation for this equation here.

The benefit of using the normal equation to solve for our model parameters is that feature scaling is not necessary and it can be more effective than gradient descent for small feature sets.

A few notes and practical tips on this process.

• This method will occasionally give you problems when dealing with noninvertible or degenerate matrices. If this is the case, it is likely that your feature set has redundant (linearly dependent) features, or simply too many features with respect to the number of training examples given.

### Implementation

Linear regression is very simple to implement in sklearn. It can accommodate both univariate and multivariate models and will automatically handle one-hot encoded categorical data to avoid the dummy variable trap.

from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(features_train, labels_train)
predictions = model.predict(features_test)

import matplotlib.pyplot as plt

plt.scatter(features, labels, color = 'red')
plt.plot(features_test, predictions, color = 'blue')

#### Jeremy Jordan

Machine learning engineer. Broadly curious.


text:
## Intermediate Algebra (6th Edition)

The domain is all real numbers, except $4$ and $-4$.
To find the values of $x$ that create a zero in the denominator, set the denominator equal to zero and solve. $3x^{2}-48=0$ Factor $3(x^{2}-16)=0$ Using the Zero Product Property $3=0$ and $x^{2}-16=0$ The first equation is false. The second equation $x^{2}-16=0$ Add $16$ to both sides $x^{2}=16$ Square root both sides $x=4$ and $x=-4$ Therefore, the two values that $x$ cannot be are $4$ and $-4$. The domain is all real numbers EXCEPT these two values.


text:
# Can someone put up a tutorial on Integral Calculus?

## Recommended Posts

Can someone put up a tutorial on Integral Calculus just like there is one for differentiation? I need it.

##### Share on other sites

Thanks, but I need more text oriented and Khan Academy teach in videos, which take eons to load on my slow internet.

##### Share on other sites

One good resource is Paul's Online Math Notes. The last couple of sections of Calculus I introduce integration, substitution (one of several techniques of integration), and applications of the integral. Calculus II then continues with more integration techniques and applications before getting into other calculus topics. There are also notes for Calculus III (which is multivariable calculus, though some of that material is introduced at the end of Calculus II) and Differential Equations. PDFs of the notes are available if you prefer those over the website, and Calculus I and II (but not III or DE) also come with practice problems and solutions.

There's also William Chen's lecture notes, which cover quite a few different mathematical subjects, including calculus. The notes include exercises, but I don't think worked solutions are available.

As for tutorials here, there has been some talk (though not really recently, that I know of) of adding more tutorials, but with the huge number of resources already available online for pretty much any math topic, adding more tutorials here probably isn't a priority.

Edited by John

##### Share on other sites

Do you want someone on science forums to explain it to you? Or do you want a website?

##### Share on other sites

Well, I would prefer it here, and more if it was just like the previous one.

##### Share on other sites

Here will be a tutorial on integral calculus.

Part 1. Riemann Sums

An integral is the area under a curve. You can approximate an integral by adding together the area of a number of rectangles, each with a height of $f(x)$ and a length of $\Delta x$. They each have an area that is equal to $f(x)\Delta x$. You take this sum from $x = a$ to $x = b$, and since you are summing n rectangles, $\Delta x$ will be the length from a to b, or a - b divided by the number of rectangles. This is written as $\Delta x = \frac{a-b}{n}$ The sum of the areas of each rectangle will give you something close to the value of the integral. This is called a Riemann Sum. It is useful in approximations of integrals. As the rectangles have smaller and smaller lengths, the sum becomes more and more accurate, and you get a closer and closer approximation. This means that you have to use a limit. Therefore, the value of an integral is

$\lim_{n \to \infty} \sum_{i=1}^{n} f(x_i)\Delta x$

You can imagine a function as being made up of an infinite number of these rectangles, each with an infinitesimal length of dx and height of f(x). An integral is written as

$\int_a^b f(x) dx$

which represents the infinite sum from a to b of the areas of each infinitesimal area.

Part 2. The Second Part of The Fundamental Theorem of Calculus

There is another formula for the integral, which was worked out by Issac Newton. Issac Newton Found out that integrating is the inverse function of differentiating. Because the area under a curve is evaluated from a to b, this means that the exact value of the integral is

$\int_a^b f(x) dx = F(b) - F(a)$

Where F(b) and F(a) are the antiderivatives of the function f(x) with respect to a and b.

This lets you know the exact area under a curve without working out a Riemann Sum.

That is the introduction to integration. In the next tutorial, you will learn about integration techniques.

• 3

##### Share on other sites

@Endercreeper01 : That was what I wanted. Thanks!

##### Share on other sites

Your welcome. Do you also want a tutorial for the rest of integral calculus?

Edited by Endercreeper01

##### Share on other sites

Yes, why not? This was exactly in the format and language which I wanted.

Edited by Abhi_KS

##### Share on other sites

Ok, so let's continue.

Part 3: Integral properties

Before we move on, you must know the properties of integrals.

$\int_a^b f(x) + g(x) dx = \int_a^b f(x) dx + \int_a^b g(x) dx$

$\int_b^a f(x) dx = -\int_a^b f(x) dx$

$\int_a^b cf(x) dx = c\int_a^b f(x) dx$ where c is a constant

$\int_a^b f(x) dx = \int_a^c f(x) dx + \int_c^b f(x) dx$ where c is a number.

Part 4: Antiderivatives

Antiderivatives are the opposite of derivatives. It's like being given $f'(x)$ and trying to figure out $f(x)$. Usually, they are written as $\int f(x) dx$, and this type of integral is called an improper integral. They are also written as $F(x)$. You find antiderivatives by figuring out which function's derivative would be your original function, and that function would be the antiderivative. For example, if we wanted to find the antiderivative of $sin(x)$, we know that the derivative of $cos(x)$ is $-sin(x)$, so therefore, the derivative of $-cos(x)$ is $sin(x)$. This means that the antiderivative of $sin(x)$ is cos(x).

We can do this with much more functions. The antiderivatives of simple functions will be in the next section, and you will need these for more complex integration. This method of antidifferentiating is how mathematicians found these antiderivatives.

Part 5: Simple Antiderivatives

Here will be a list of simple antiderivatives. You will need to know these before we learn more complex integration.

$\int x^n dx = \frac {x^{n+1}}{n+1}$ (except for n = -1)

$\int e^x dx = e^x$

$\int a^x dx = \frac{a^x}{ln(a)}$

$\int ln(x) = xln(x) - x$

$\int \frac{1}{x} dx = ln|x|$

$\int sin(x) dx = -cos(x)$

$\int cos(x) dx = sin(x)$

$\int tan(x) dx = ln|sec(x)|$

$\int sec(x) dx = ln|sec(x) + tan(x)|$

Part 6. U subsitution

U substitution is a useful integration technique for complex integrals.

For example, say you wanted to find $\int sin(3x + 8) dx$. You could easily solve his problem with u substitution. You would need to set a value to u, and then integrate with respect to u. In this example, we would set $u = 3x + 8$, making this $\int sin(u) dx$. What we need to do now is make this integral with respect to u. If you imagine $\frac{du}{dx}$ as being the ratio between 2 infinitesimals, you can multiply this by dx to get du. In this case, since $u = 3x + 8$, this means $\frac{du}{dx} = 3$ , and $du=3dx$. Because we need to take the integral with respect to u, we change $dx$ to $\frac{1}{3} du$, since $\frac{1}{3} du = dx$. We bring the 1/3 out front, and this becomes $\frac{1}{3} \int sin(u) du$.

This gives you $-\frac{1}{3} cos(u) + C$. We now have to plug in the value of u, and because $u = 3x + 8$, the integral works out to be $-\frac{1}{3}cos(3x+8)+C$. Don't forget the constant of integration, since you always need to add that.

The next lesson will be on u substitution practice.

Remember, if you need help with any of this, you can just ask our calculus forum.

Edited by Endercreeper01
• 1
• 1

##### Share on other sites

Ok, so let's continue.

...We now have to plug in the value of u, and because $u = 3x + 8$, the integral works out to be $\frac{1}{3}cos(3x+8)$.

The next lesson will be on u substitution practice.

Remember, if you need help with any of this, you can just ask our calculus forum.

surely the integral works out as -1/3 cos(3x+8) . Also you need to add a constant - or explain why you should add one

Edited by imatfaal
horrid horrid editor
• 2

##### Share on other sites

surely the integral works out as -1/3 cos(3x+8) . Also you need to add a constant - or explain why you should add one

The post has been edited. For some reason, the negative didn't show up. Also, I explained the constant of integration and why there should be one in the part about antiderivatives.

• 1

##### Share on other sites

I don't see it. Also, another slight edit: In the antiderivatives section, you refer to the antiderivative as an "improper" integral. This should be "indefinite" integral. I'm assuming you'll discuss improper integrals later.

Edited by John
• 1

##### Share on other sites

Because I am unable to edit the post now, I will add a short part about the constant of integration:

Part 4.5:The constant of integration

When you take antiderivatives, you need to add something called a constant of integration. During differentiation, you get rid of any constant terms, so when you antidifferentiate, you must add something called a constant of integration to include any constant terms lost when differentiating. This is only for indefinite integrals. If you have a definite integral, you do not need to include the constant of integration, since when you work out $F(b) - F(a)$, F(b) and F(a) have the same constant of integration. Because of this, the two constants of integration would cancel out when you are subtracting, and this means there is no constant of integration in definite integrals.

• 1

##### Share on other sites

When you take antiderivatives, you need to add something called a constant of integration. During differentiation, you get rid of any constant terms, so when you antidifferentiate, you must add something called a constant of integration to include any constant terms lost when differentiating. This is only for indefinite integrals. If you have a definite integral, you do not need to include the constant of integration, since when you work out , F(b) and F(a) have the same constant of integration. Because of this, the two constants of integration would cancel out when you are subtracting, and this means there is no constant of integration in definite integrals.

There is more to it than this.

Others have already said that you should be comparing the indefinite integral and the definite integral.

The anti-derivative is something else again.

The definite integral is a pure number it is not a function.

The indefinite integral is a function.

I suggest accepting these for now until the significance of this distinction really becomes apparent when you proceed to the applications of calculus.

And well done (+1) to endercreeper for being prepared to put up the work.

Edited by studiot
• 2

##### Share on other sites

Oh yes, thanks for reminding me. I will make sure to mention that when we get to the applications of integral calculus.

I have decided to skip the practice problems. Upon request, I will provide them, but I have decided to skip them for now.

Part 7. Integration By Parts

Integration by parts is like the product rule for integrals. Let's define f(x) as being $f(x) = uv$, where u and v are both functions of x. We know that the derivative of this function will be $f'(x) = (uv)' = u'v + v'u$. Because of this, we can integrate u'v + v'u to get the original function, i.e $\int {u'v + v'u} dx = uv$. Integrals are distributive, so we can write the previous equation as $uv = \int u'v dx + \int v'u dx$. In order to integrate uv', you have to subtract the integration of vu' from the equation, and this would have to be from both sides of the equation. We find that $\int uv' dx = uv - \int vu' dx$. Using the fact that $u' dx = du$ and $v' dx = dv$, we obtain the equation for integration by parts:

$\int u dv = uv - \int v du$

For example, let's integrate $2x ln(x)$. We can set the value of dv to 2x dx, and therefore, $v = x^2$. From here, you can see that $u = ln(x)$, since that is the only other part of the function. We now need to plug the value of u and v into the equation. Because u = ln(x) and v = x2, we find that $\int 2x ln(x) dx = x^2 ln(x) - \frac{x^2}{2}$, since du = 1/x dx and $\frac{x^2}{x}=x$. Because of that, the integral turns into $\int x dx$, which turns out to be x2/2.

Edited by Endercreeper01
• 2

##### Share on other sites

Endercreeper01 rulez!

I think now this thread can be counted in Tutorial Section.

• 1

##### Share on other sites

Thanks for the support!
Now, we will discuss improper integrals.
Part 8. Improper integrals

An improper integral is when one or two limit(s) of a definite integral is infinity. For example, $\int_{-\infty}^{5} \frac{1}{e^x} dx$ and $\int_0^\infty x^{3x} dx$ are both improper integrals.

Of course, you can't work this out by just plugging in infinity. For improper integrals, you have to use a limit. You could write the above integral as $\lim_{n \to \infty} \int_0^n x^{3x} dx.$, and this would mean you would have to take the limit as n approaches infinity or negative infinity for that function. Improper integrals are categorized 2 ways: divergent and convergent. It is convergent if the integral exists and is not infinite, and divergent if it is infinite or it doesn't exist. For instance, let's work out the integral $\int_0^\infty \frac{1}{x}$. We know the antiderivative of this function is $ln(x)$. We also know that $ln(x)$ approaches infinity as x approaches infinity. Therefore, this integral is divergent.

That concludes the tutorial on calculating integrals. Next, you will learn about the applications of integrals.

Part 9. Average Function Value

We know that in order to calculate the average of a set of numbers, you must add together all of the parts of the set and divide by the number of numbers in the set. If you had an infinite number of numbers in a set, such as function values from a to b, you would have to use a different formula. The equation for the average function value from a to b is that $f_{avg}=\frac{\int_a^b f(x) dx}{b-a}$. This is because we know that in a Riemann sum, $\Delta x = \frac{b-a}{n}$, and when n is infinity, we represent it by dx (an infinitesimal). Dividing by b-a in the denominator gets rid of the b-a in the dx, and so, it is the infinite sum of the infinitesimals of $\frac{f(x)}{\infty}$. For example, let's try $\frac{\int_1^5 x^2 dx}{4}$. The denominator is 4, since the difference between the top and bottom limit is 4, and because the antiderivative is $\frac{x^3}{3}$, we find the difference between this at x = 5 and x = 1, then divide by 4. Working this out, we find that $f_{avg} = 10 + 1/3$.

Next, you will learn about calculating arc length.

Remember, if you need any help with this, you can ask our calculus forum.

Edited by Endercreeper01
• 1

##### Share on other sites

Part 10. Arc Length of A Curve

The arc length of a curve from a to b is how long the function graph from a to b would be. To approximate the arc length, we can break the function up into n lines, each with length $\Delta s$. An estimate for the arc length would be to write it as the sum of the lengths of these lines, I.e $s \approx \sum_{i=1}^{n} \Delta s_i$. As we have more and more lines, the approximation becomes more and more accurate, and so we take the limit as n approaches infinity of the above sum. We find that $s = \lim_{n \to \infty} \sum_{i=1}^{n} \Delta s_i$. We know that an integral is an infinite sum, so we have to integrate over all of the infinitesimal lengths. We now obtain the equation for arc length of a curve:

$s=\int_a^b ds$

Because we know that $ds=\sqrt {dx^2+dy^2}$ and that ds is also $\sqrt {1 + \left( \frac {dy} {dx} \right)^2} dx$ we can rewrite the previous equation as

$s=\int_a^b \sqrt {1 + \left( \frac {dy} {dx} \right) ^2} dx$

which gives us the equation for arc length. You can also define x = f(y) and use the equation:

$s=\int_a^b \sqrt {1 + \left( \frac {dx} {dy} \right) ^2} dy$

as this would also work.

For example, we will work out the arc length from 1 to 3 of $y=\frac{2\sqrt {x^3}}{3}$.

The derivative of this function will be $\sqrt x$. When we square this derivative, we obtain x.

The integral now becomes $\int_1^3 \sqrt {1+x} dx$. The substitution will be u = 1+x, and so du = dx. This integral now becomes $\int_1^3 \sqrt u du$. The antiderivative of this function is $\frac{2}{3}u^{3/2}$, which is equal to $\frac{2}{3}(1+x)^{3/2}$. In order to get the answer, we must work this out at x=3, then subtract by the antiderivative value at x=1.

Our final answer ends up as $\int_1^3 \sqrt {1+x} dx = \frac{16}{3} - \frac{4\sqrt 2}{3}$.

The next tutorial will be on the area between two curves.

Remember, if you need any help with this, you can just ask our calculus forum.

• 1

##### Share on other sites

Also, I might not post tutorials as often because of school, as school gives me less time to post tutorials. I will still post tutorials, just not as often.

##### Share on other sites

I will now be able to continue posting tutorials. I now have more free time then I did before, so now I will continue to make tutorials.

Part 11. Area Between Two Curves

Today, you will learn about the area between two curves.

If you had 2 functions f(x) and g(x), you can determine the area between them by finding the difference between the top function area and the bottom function area, i.e $\int_a^b (f(x) - g(x)) dx$, since the integral distributes to both f(x) and g(x). Because it distributes, it is the same as the integral over the top function minus the integral over the integral over the bottom function. For example, we will work out the area between ex and x2 from 3 to 7. First, we have to determine the integral. The integral becomes $\int_3^7 (e^x - x^2) dx$. We find that this will be $e^x - \frac{1}{3}x^3$ at x = 7 minus this value at x = 3. This is because the antiderivative (not including the constant of integration) of ex is ex, and this minus the antiderivative of x2 will be $e^x - \frac{1}{3}x^3$. Working this out, we find that this is about 971 square units.

In the next tutorial, you will learn about the volumes of solids of revolutions.

Remember, if you need any help with this, you can just ask our calculus forum.

• 1

##### Share on other sites

That concludes the 2 dimensional part of our tutorial. We will move on to 3 dimensions.

Part 12. Volumes of Solids of Revolution

A solid of revolution is simply a function wrapped around an axis. In order to get the volume, we need to sum all of the infinitesimal volumes from x = a to x = b. Each infinitesimal volume is represented by $dV=A(x) dx = A(y) dy$, where A is area and V is volume, and it can be taken with respect to dx or dy. We will have to do an integral, which can be written as $V=\int_a^b A(x) dx=\int_c^d A(y) dy$, where a and b are the limits for the x axis, and c and d are the limits for the y axis. Because each cross-sectional area is circular, we can define the cross sectional areas as being $A=\pi r^2$. The radius would be f(x) if you are finding A(x) and f(y) if you are finding A(y), so we can write this as $A(x)=\pi f^2(x)$ and $A(y) = \pi f^2(y)$, depending on which axis the function is wrapped around. The radius is the original function because the function is rotated, and it is rotated among each function value. Therefore, the radius will be the original function. This is only if the solid of revolution is not the result of wrapping the difference in 2 functions around an axis. It would still be considered a solid of revolution if you have f(x) (or f(y)) and g(x) (or g(y)) and you wrap the change between them around an axis. In that case, $A=\pi (f^2(x) - g^2(x)$, since it would be the difference in the cross sectional areas of f(x) and g(x), and this is the same for f(y). This gives us the equation for volume of a solid of revolution:

$V = \pi \int_a^b f^2(x) - g^2(x) dx = \pi \int_c^d f^2(y) - g^2(y) dy$

For example, we will work out the volume from 2 to 9 of $f(x)=e^{5x+7}$ and $g(x) = 0$. In this case, the square of this function will be $e^{10x+14}$. Using u substitution, we find that the volume is $\frac{\pi}{10}e^{10x+14}$ evaluated from x = 9 to x = 2. Our final answer for the volume is that

V = 1.2204033 x 1039 units3

Our next tutorial will be on the surface area of solids of revolution.

Remember, if you need any help with this, you can just ask our calculus forum.

Edited by Endercreeper01
• 1

##### Share on other sites

Part 13. Surface Areas of Solids of Revolution

To find the surface area of a solid of revolution, we must sum all of the infinitesimal areas $dA$ among the length of the solid, written as $A=\int_a^b dA$. The infinitesimal dA is the circumference times ds, i.e $dA=Cds$ where C is the circumference and s is length. The circumference is $2\pi y$, making $A_s=2 \pi \int_a^b y ds$ when we plug in the value of C. Since $ds=\sqrt{1+\left(\frac{dy}{dx}\right)^2}dx$, we plug in the value of ds, giving us the equation for surface area of a solid of revolution:

$A_s=2\pi \int_a^b y\sqrt{1+\left(\frac{dy}{dx}\right)^2}dx$

If it is rotated about the y axis, it will be:

$A_s=\int_a^b x\sqrt{1+\left(\frac{dx}{dy}\right)^2}dy$

Our next tutorial will be on double integrals.

Remember, if you need any help with this, you can just ask our calculus forum.

• 1

##### Share on other sites

Part 14. Integrals over n dimensions

Let's start with a function z = f(x, y).

To find the volume under this region, we need to have 2 limits of this integral, an x limit and a y limit. Because of this, we must integrate over both the x and y regions. Since we integrate over 2 regions, we have to integrate with respect to 2 variables, x and y. This is called a double integral. Therefore, the volume under a function f(x, y) is:

$V=\int_a^b \int_c^d f(x, y) dx dy$

If you are finding the volume between 2 areas, you would use the equation:

$V=\int_a^b \int_c^d f(x, y) - g(x, y) dx dy$

since you would be finding the difference between 2 volumes.

In order to calculate definite integrals, we need to first find the antiderivative with respect to all the variables. In this case, there are 2 possible orders it can be done in: You could do it with respect to x first, hen y, or take the antiderivative with respect to y, then x. There are n! possible ways you could find the antiderivative, where n is the number of dimensions you are integrating over. I will take all antiderivatives in multiple dimensions in the order of the variables, just to avoid confusion.

After the antiderivative is found, we need to evaluate it at x = d and y = b and then subtract from the antiderivative evaluated at x = c and y = a.

For example, we are going to compute

$\int_1^3 \int_5^9 e^{xy} + sin(7x+2y) - 4xy dx dy$

The antiderivative of this function (not including C) is $\frac{e^{xy}}{xy} - x^2 y^2 - \frac{cos(7x+2y)}{14xy}$.

Substituting the values of the limits and evaluating gives us our answer:

$V = 19705489659$
This can be extended to n dimensions. Generally, the n volume over an n dimensional region is:

$V_n = \int_a^b \int_c^d \int_e^f ... f(x, y, z... x_n) dx dy dz... dx_n$

Our next tutorial will be on the surface area of functions in n dimensions.

Remember, if you need any help with this, you can just ask our calculus forum.

• 1

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account


text:
## Rocky Mountain Journal of Mathematics

The Rocky Mountain Journal of Mathematics is published by the Rocky Mountain Mathematics Consortium. The journal publishes both research and expository articles in mathematics, and particularly invites well-written survey articles. In addition, the journal publishes specialized conference proceedings.

Contractions of del Pezzo surfaces to $P^2$ or $P^1xP^1$Forthcoming articles (2015)
A triangle-based $C^1$ interpolation methodVolume 14, Number 1 (1984)
The automorphism group of an extraspecial $p$-groupVolume 2, Number 2 (1972)


text:
## Elementary Geometry for College Students (6th Edition)

m$\angle$ABD=56$^{\circ}$
Given: support system of a bridge which has AC=6ft m$\angle$ABC=28$^{\circ}$ m$\angle$CBD=m$\angle$ABC=28$^{\circ}$ because they are corresponding angles of congruent triangles therefore, m$\angle$ABD=m$\angle$ABC+m$\angle$CBD m$\angle$ABD=28$^{\circ}$+28$^{\circ}$ m$\angle$ABD=56$^{\circ}$


text:
# What is the equation of the line with slope  m= -5/17  that passes through  (-2,-11) ?

Dec 14, 2015

$\textcolor{w h i t e}{\times} y = - \frac{5}{17} x - \frac{197}{17}$

#### Explanation:

$\textcolor{w h i t e}{\times} y = m x + c$

$\implies y = \textcolor{red}{- \frac{5}{17}} x + c$

For $x = - 2$ and $y = - 11$,
$\textcolor{w h i t e}{\times} \textcolor{b l u e}{- 11} = - \frac{5}{17} \times \textcolor{b l u e}{- 2} + c$
$\implies - 11 \textcolor{red}{- \frac{10}{17}} = \frac{10}{17} + c \textcolor{red}{- \frac{10}{17}}$
$\implies c = \frac{- 187 - 10}{17}$
$\implies c = - \frac{197}{17}$

$\implies y = - \frac{5}{17} x - \frac{197}{17}$


text:
# More Elementary Proof for Euler’s Sine Expansion

Our goal in this post is to provide an elementary proof for the real version of Euler’s famous Sine expansion.

I first prove that for any $n$ that is a power of $2$ and for any $x\in\mathbb R$,

$\displaystyle{\sin(x)=n p_n(x)\sin\left(\frac x n\right)\cos\left(\frac x n\right),~p_n(x)=\prod_{k=1}^{\frac n 2-1}\left(1-\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}\right)}~~~~~(1)$

by using the following more familiar identity

$\displaystyle\sin(x)=2\sin\frac x 2\sin\frac{\pi+x}2$

we can easily arrive to the following identity that is valid for $n$ equal to any power of $2$,

$\displaystyle\sin(x)=2^{n-1}\prod_{k=0}^{n-1}\sin\frac{k\pi+x}n$

$\displaystyle=2^{n-1}\sin\frac x n\sin\frac{\frac n 2\pi+x}n\prod_{k=1}^{\frac n 2-1}\sin\frac{k\pi+x}n\sin\frac{k\pi-x}n$

$\displaystyle=2^{n-1}\sin\frac x n\cos\frac x n\prod_{k=1}^{\frac n 2-1}\left(\sin^2\frac{k\pi}n-\sin^2\frac x n\right)~~~~~~~~~~(2)$

By considering what happens as $x\to0$ in the recent formula, we can obtain that for $n$ a power of $2$

$\displaystyle n=2^{n-1}\prod_{k=1}^{\frac n 2-1}\sin^2\frac{k\pi}n~~~~~~~~~~(3)$

and then I replace $(3)$ in $(2)$ and prove $(1)$.

Now I choose $m<\frac n 2-1$ and break up $p_n(x)$ as follows

$\displaystyle p_n(x)=\prod_{k=1}^m\left(1-\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}\right)\prod_{k=m+1}^{\frac n 2-1}\left(1-\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}\right)~~~~~~~~~~(4)$

Since for $0<\theta<\frac{\pi}2$, $\sin(\theta)>\frac2{\pi}\theta$, we have

$\displaystyle\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}<\frac{x^2}{4k^2}$

and if I choose $m$ and $n$ large enough such that $\frac{x^2}{4m^2}<1$, then

$\displaystyle0<1-\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}<1,k=m+1,...,\frac n 2-1$

which implies that

$\displaystyle0<\prod_{k=m+1}^{\frac n 2-1}\left(1-\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}\right)<1$

Therefore from $(4)$ we have

$\displaystyle p_n(x)\le\prod_{k=1}^m\left(1-\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}\right)$

Also we have

$\displaystyle{\prod_{k=m+1}^{\frac n 2-1}\left(1-\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}\right)\ge1-\sum_{k=m+1}^{\frac n 2-1}\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}\ge1-\frac{x^2}4\sum_{k=m+1}^\infty\frac1{k^2}=1-s_m}$

and once again by $(4)$, we get

$\displaystyle p_n(x)\ge(1-s_m)\prod_{k=1}^m\left(1-\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}\right)$

To summarize, I have shown that

$\displaystyle{(1-s_m)\prod_{k=1}^m\left(1-\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}\right)\le p_n(x)\le\prod_{k=1}^m\left(1-\frac{\sin^2\frac x n}{\sin^2\frac{k\pi}n}\right)}~~~~~~~~~~(5)$

Now taking $n\to\infty$ in $(5)$ I arrive to

$\displaystyle(1-s_m)\prod_{k=1}^m\left(1-\frac{x^2}{k^2\pi^2}\right)\le\frac{\sin(x)}x\le\prod_{k=1}^m\left(1-\frac{x^2}{k^2\pi^2}\right)$

After rearrangement and then taking absolute values, we get

$\displaystyle\left|\frac{\sin(x)}x-\prod_{k=1}^m\left(1-\frac{x^2}{k^2\pi^2}\right)\right|\le|s_m|\left|\prod_{k=1}^m\left(1-\frac{x^2}{k^2\pi^2}\right)\right|$

but since we have

$\displaystyle{\left|\prod_{k=1}^m\left(1-\frac{x^2}{k^2\pi^2}\right)\right|\le\prod_{k=1}^m\left(1+\frac{x^2}{k^2\pi^2}\right)\le\prod_{k=1}^me^{\frac{x^2}{k^2\pi^2}}\le e^{\sum_{k=1}^\infty\frac{x^2}{k^2\pi^2}}=e^{\ell}}$

I can write

$\displaystyle\left|\frac{\sin(x)}x-\prod_{k=1}^m\left(1-\frac{x^2}{k^2\pi^2}\right)\right|\le|s_m|e^{\ell}$

Finally since $\lim_{m\to\infty}s_m=0$, this inequality implies our goal, indeed

$\boxed{\displaystyle\prod_{k=1}^{\infty}\left(1-\frac{x^2}{k^2\pi^2}\right)=\frac{\sin(x)}x}$


text:
#### Label consistency in overfitted generalized $k$-means

Bibtek download is not available in the pre-proceeding

#### Authors

Linfan Zhang, Arash Amini

#### Abstract

We provide theoretical guarantees for label consistency in generalized $k$-means problems, with an emphasis on the overfitted case where the number of clusters used by the algorithm is more than the ground truth. We provide conditions under which the estimated labels are close to a refinement of the true cluster labels. We consider both exact and approximate recovery of the labels. Our results hold for any constant-factor approximation to the $k$-means problem. The results are also model-free and only based on bounds on the maximum or average distance of the data points to the true cluster centers. These centers themselves are loosely defined and can be taken to be any set of points for which the aforementioned distances can be controlled. We show the usefulness of the results with applications to some manifold clustering problems.


text:
# Formula for Area of Overlapping Rings?

1. Mar 27, 2009

### jpg15

Could anyone direct me to a formula for the area enclosed by two overlapping rings? Sketch below...

Thanks...
-jg

2. Mar 27, 2009

### jpg15

I realize my question was a little bit ambiguous... specifically, the area in terms of the radius of the two circles and the distance between their centers. The rings are identical.

-jg

3. Mar 27, 2009

### HallsofIvy

Staff Emeritus


text:
# Rcpp 0.8.6

September 10, 2010
By

(This article was first published on dirk.eddelbuettel, and kindly contributed to R-bloggers)

After a somewhat longer than usual break, we now have a new release of Rcpp on CRAN and in Debian.

This release adds quite few things. The main one may be the addition of density, distribution, quantile and random number functions for a rather large number of statistical distribution. Usage is pretty much as it would be in R, yet it is vectorised at the C++ level. A fair number of unit tests were added too, but some work is left to do there too.
Support for complex number was enhanced both in the expressive 'sugar' context and via a few binary operators that had been missing. We also started a new vignette to provide a 'quick reference'; unfortunately this is not quite complete yet.

The NEWS entry follows below:

0.8.6 2010-09-09 o	new macro RCPP_VERSION and Rcpp_Version to allow conditional compiling based on the version of Rcpp #if defined(RCPP_VERSION) && RCPP_VERSION >= Rcpp_Version(0,8,6) ... #endif o new sugar functions for statistical distributions (d-p-q-r functions) with distributions : unif, norm, gamma, chisq, lnorm, weibull, logis, f, pois, binom, t, beta. o new ctor for Vector taking size and function pointer so that for example NumericVector( 10, norm_rand ) generates a N(0,1) vector of size 10 o added binary operators for complex numbers, as well as sugar support o more sugar math functions: sqrt, log, log10, exp, sin, cos, ... o	started new vignette Rcpp-quickref : quick reference guide of Rcpp API (still work in progress) o	various patches to comply with solaris/suncc stricter standards o	minor enhancements to ConvolutionBenchmark example o	simplified src/Makefile to no longer require GNU make; packages using Rcpp still do for the compile-time test of library locations

As always, even fuller details are in Rcpp Changelog page and the Rcpp page which also leads to the downloads, the browseable doxygen docs and zip files of doxygen output for the standard formats. A local directory has source and documentation too. Questions, comments etc should go to the rcpp-devel mailing list off the R-Forge page


text:
# Recent questions and answers in CO & Architecture

Which is true for typical RISC architecture? A.Micro Programmed Control Unit B.Instruction takes multiple clock cycles. C.Have few register in CPU D.Emphasis on optimising instruction pipelines
consider a direct mapped cache of 8 blocks used to implement the following program segment float a[10][10]; int i; for(i=0;i<10;i++) for(j=0;j<10;j++) a[i][j]=8.0; float element occupies 4 bytes, the block size is 12 bytes and array is stored in row-major form. Find the number of hits. also, if the array was stored in coloumn-major, What the number of hits would’ve been?
Suppose our computer requires 2048x16 bytes of RAM and 512x16 bytes of ROM. Design the necessary hardware using 512x16 byte RAM and 256x16 byte ROM chips
The value represented by the following 32-bits in IEEE-754 standard is? 0100000111100000……00
Suppose we are using the paging concept. The CPU generates an logical address Now suppose in the memory page table for the page required by the CPU the presence bit is 0 then how does the CPU get the required page from the secondary memory?
Consider a machine with a byte addressable main memory of 2^16 bytes. Assume that a direct mapped data cache consisting of 32 lines of 64 bytes each is used in the system. A 50 x 50 twodimensional array of bytes is stored in the main memory starting from memory location 1100 H. Assume that the data ... array (a) line 4 to line 11 (b) line 4 to line 12 (c) line 0 to line 7 (d) line 0 to line 8
1 vote
i need to study COA . can somebody tell me good resources and how to progress with subject
A three level memory system having cache access time 15ns and disk access time 80ns cache hit ratio is 0.96 and main memory hit ratio is 0.9 What should be v main memory access time to achieve effective access time of 25ns
The clock rate of a machine depends on: a. Cpu Organisation b. Instruction set Architecture. c. Implementation Technology. d. Assembler
A PC-relative mode branch instruction is 3 bytes long. The address of the instruction in decimal is 342038. What is the branch address, if the base and index register contains the value 480220 and 9 respectively (Assume base with index addressing mode is used) Answer key says 480198, why?
Consider a set-associative cache of size $\text{2KB (1KB} =2^{10}$ bytes$\text{)}$ with cache block size of $64$ bytes. Assume that the cache is byte-addressable and a $32$ -bit address is used for accessing the cache. If the width of the tag field is $22$ bits, the associativity of the cache is _________
Consider a computer system with $\text{DMA}$ support. The $\text{DMA}$ module is transferring one $8$-bit character in one $\text{CPU}$ cycle from a device to memory through cycle stealing at regular intervals. Consider a $\text{2 MHz}$ processor. If $0.5 \%$ processor cycles are used for $\text{DMA}$, the data transfer rate of the device is __________ bits per second.
1 vote
Assume a two-level inclusive cache hierarchy, $L1$ and $L2$, where $L2$ is the larger of the two. Consider the following statements. $S_1$: Read misses in a write through $L1$ cache do not result in writebacks of dirty lines to the $L2$ $S_2$: Write allocate policy must be ... $S_2$ is false $S_1$ is false and $S_2$ is true $S_1$ is true and $S_2$ is true $S_1$ is false and $S_2$ is false
Consider a pipelined processor with $5$ stages, $\text{Instruction Fetch} (\textsf{IF})$, $\text{Instruction Decode} \textsf{(ID)}$, $\text{Execute } \textsf{(EX)}$, $\text{Memory Access } \textsf{(MEM)}$ ... $\textit{Speedup}$ achieved in executing the given instruction sequence on the pipelined processor (rounded to $2$ decimal places) is _____________
Consider a computer system with a byte-addressable primary memory of size $2^{32}$ bytes. Assume the computer system has a direct-mapped cache of size $\text{32 KB}$ ($\text{1 KB}$ = $2^{10}$ bytes), and each cache block is of size $64$ bytes. The size of the tag field is __________ bits.
1 vote
A five-stage pipeline has stage delays of $150, 120, 150, 160$ and $140$ nanoseconds. The registers that are used between the pipeline stages have a delay of $5$ nanoseconds each. The total time to execute $100$ independent instructions on this pipeline, assuming there are no pipeline stalls, is _______ nanoseconds.
Consider the following instruction sequence where registers $R1, R2$ and $R3$ are general purpose and $\text{MEMORY}[X]$ denotes the content at the memory location $X$ ... format. Assume that the memory is byte addressable. After the execution of the program, the content of memory location $3010$ is ____________
Hi, my concepts regarding cache memory is weak. Please let me know that where (book or online source) to read Cache memory concepts ? If you have any knowledge about it please share ? Please try to share only standard sources.
How to know when to use simultaneous average time formula and when to use hierarchical average time formula for the calculation of tavg questions?
1 vote
https://gateoverflow.in/3622/gate2006-it-78 with reference to the concept used in previous year question the answer for the true data dependencies in the following question should be 5 ?? but solution is given as 3... M[100<-r1 r2<-M[700] r1<-r2 / r1 r2<-r1+r2 M[500]<-r2 M[200]<-r1
Could someone tell why option C and D are wrong A) B ) C ) D ) Correct Answer: A,B Your Answer: A,B,C,D
In RAW dependency , does we consider only adjacent instructions for RAW or we check every instruction present to check for RAW dependency just like WAW and war
Basic pipelining. Use the following code fragment: Loop: LD R2,4(R1) ; load R2 from address 4+R1 LD R3,0(R2) ; load R3 from address 0+R2 DADD R3,R1,R2 ; R3=R1+R2 BNEZ R3,Loop ; branch to loop if R3 != 0 Use the classic MIPS five- ... complete the given sequence of instructions are___ i am getting 9 as answer bit in answer 10 is given can someone explain execution of instruction 4? solution given
1 vote
Consider a 4 stage pipeline processor. The number of cycles needed by the four instructions S1 S2 S3 S4 I1 2 1 3 1 I2 1 1 1 3 I3 1 3 2 1 I4 3 1 1 2 What is the number of cycles needed to execute the following loop? For (i=1 to 2) {I1; I2; I3; I4;} I am getting answer (20 cycles ) but they gave the answer (23 cycles)
What is the Half Carry in the addition of the two n-bit binary numbers? Suppose two numbers are 00000010 and 00000011 . What is the value of the Half Carry?
1 vote
Consider a hypothetical system that uses Direct Memory mode access(DMA) mode to transfer the data from the hard disk to the main memory. If the size of the DMA controller's data count register is 32 bits. A file of 1024 GB needs to transfer from disk to memory. ... the DMA controller needs to get the control of the system bus if the system is byte-addressable? Please explain, the answer was 256.
Consider a cache of 2y blocks, and the main memory of 2y blocks. At what set location (y+4)th block will be mapped in 2-way set associative? In this question, it is asking about (y+4)th block of main memory, then it would be numbered (y+3) in the main memory, so it should get mapped at set location 3. But answer in made easy test is given 4. Is it correct??
1 vote
1 vote
A pipeline with 4 stages :- IF, ID, EX, WB. IF, ID, WB all take 1 cycle each. EX takes 1 cycle for ADD, 1 for SUB, 3 for MUL. Pipeline cycle time is 3 ns. Out of 1000 instructions, 300 are for ADD, 500 are for SUB and 200 are for MUL. Calculate pipeline efficiency Can someone please explain me its solution?
1 vote
Consider a write through cache memory having the hit ratio for read operation 80% and access time of 50 ns. Main Memory access time is 200 ns. CPU generates 70% read requests and remaining are used for write operations. What is the average memory ... simultaneous organization and showing answer as 116 ns. I am confused when to use hierarchial organization and when to use simultaneous access)
A 5 stage pipelined processor has the following stages: IF : Instruction fetch, ID : Instruction decode, EX : Execute, MA : Memory access, WB : Write back Number of cycles, using operand forwarding ?
How to calculate memory reference taken by any instruction in the "instruction decode(ID) phase??
Which of the following statements are true? S1: Doubling the line size halves the number of tags in the cache. S2 : Doubling the associativity increases the number of tags in the cache. S3 : Doubling the line size usually reduce compulsory misses. How to approach such kind of question?
1 vote
Consider a RISC processor with an ideal CPI, where 25% of the total instructions are load and store instruction. Time to accessing main memory is 100 clock cycles and accessing of the cache memory required 2 clock cycles and cache miss rate is 2%. Which of the following are correct? ( ... cache misses is 2.9. D CPI for the handling cache hits is 2.45. How to solve this, unable to get any option...


text:
#### Archived

This topic is now archived and is closed to further replies.

# ...too.......much.......code.......can't.....concentrate...

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

## Recommended Posts

I''ve come upon an unanticipated problem as my largest program written nears completion. What''s depressing is that my largest program written is about a thousandth the size of your average Useful or Fun program. My general question is... without referring to c++ classes or general OOP - How on Earth does one write a 60,000 line program?

##### Share on other sites
One line at a time

The trick is to separate it into different parts that need completing, and doing each part separately. How you do that is entirely up to you - it can range from simple structured programming, to OO, to full-fledged component-based programming.

The project I''m currently working on professionally has reached about 200.000 lines of code, of which the part that I''m doing takes up a significant amount (20-30.000 lines I think). Its perfectly possible to manage this, as long as you stay organised and focused.

##### Share on other sites
I make notes. If I know that there''s something I''m not going to remember in 2 months when I have to tweak this code again, I make comments as to why I did what I did in the code (especially if it''s something kind of odd). Listen well, fledgling coders... comments will save your life when you have 4 hours to get a patch out on something you haven''t even looked at in 3 months.

I also keep diagrams of my hierarchies and how they interact and what files correspond to what areas, for quick reference. For instance, currently on my bulletin board is a copy of my current project''s hierarchical setup, which basically has 5 data hierarchies with some overlap and 4 or 5 layers per hierarchy, which spawn 4 subhierarchies for graphical use (speed reasons). I have the class name for each layer listed, the type enum (they all derive from the same base class to allow me to cast back up after generic message processing using just the pointer) for each layer, and the file for each hierarchy listed. This helps a lot, because though I can hold the concept of what I''m doing, there''s no way I''m going to remember all those class names, files, and enums, and rather than searching I just have to glance to the right and I have it.

-fel

##### Share on other sites
For me the biggest problem is the "reflection" effect.. when you change something it affects to other parts, and they in turn can affect.. etc.. it''s annoying to write code again and again.

##### Share on other sites
Try to keep functions to less than 100 lines. If it grows beyond that, you need to split it up into separate functions.

Comment, comment, comment.

Like the others said, organize your code into a hierarchy. I find it most useful to have a good awareness of the way different parts of your code communicate, what are the different interfaces.

Only put in the header files what other modules need to operate on the given module. Do not put every function and all constants in the header. Keep everything as hidden (file-local scope) as possible so that each interface has only what it needs to operate.

##### Share on other sites
Do you mean that you''ve only written 60 lines of code? (= 60,000 / 1000)

In my experience (around 10-20k lines for personal projects, around 50k for work projects), it really makes no difference if you''re using objects or not. The question is whether files are tightly or loosely coupled; the more two files interact with each other, the more work you''ll have to do with file B each time you work on file A. So hierarchies are good, but the crucial thing is that your file hierarchy doesn''t represent "inheritence" or whatever, but groups of related functionality.

##### Share on other sites
Also, what''s the accepted way of measuring lines? My own method is to measure only NON-COMMENT lines. I''ve seen some people be stricter (they don''t count lines that are just "}", for example), and others who count comments or even blank lines! It makes a big difference, especially when you read statistics such as that Europeans produce more lines per hour than Americans (could it be because Europeans more fond of putting the opening brace on the following line, whereas most Americans seem to prefer putting the open brace at the end of lines?)

##### Share on other sites
Comment well. Because you will forget what each function does when you have thousands of them.

Plan ahead on paper.

Use meaningful and memorable naming conventions.

Split your code into separate files, also with meaningful names.

Use as few global functions and variables as possible. This means you have less to remember.

##### Share on other sites
It is all about the design and not about the coding so much when you get to that point.

First you will need to decide which methodology you are going to use to design your application. Is it going to be structured (C) or object-oriented (C++). There really is no correct general-purpose organizational scheme. You have to put things where they fit.

If it is structured you probably want flowcharts and entity-relationship diagrams, data dictionaries, etc...

If it is object-oriented you probably want to use a class hierarchy diagram (yes you want it to be organized in order of inheritance with notation for containment), object-property/interaction diagrams and class dictionaries.

If it is really complex and you have alot of tricky algorithms you might want to think about writing Psuedo-Code with standard mathematical formulas as well.

Just make sure anytime you make a significant change to your code that you update your documentation nso nothing gets lost between the cracks. This is assuming that you don''t beat out the design 100% before starting the project (unless you have a team of designers on a large project that is probably not a realistic option).

But you don''t necessarily have to stick with one set of tools. Use whatever is to your advantage and whatever seems to fit properly. You can mix object-oriented and structured design to an extent as long as you understand and define where the line is drawn.

Seeya
Krippy

##### Share on other sites
I love VC++ for that... I like the way it structures the files and when you add a new class, it automatically makes a new .cpp and .h file.. (I sometimes stick 2 classes in one .cpp/.h pair though..). I don''t do strictly OO nor do I do Structed programming.. I just mix it.. I''ve got global function just as well... It really depends on what you need.. somethimes global functions just seem to fit better to the design. My current (and first) project is something like 25k lines (46 .cpp / 48 .h). I guess it''ll end up somewhere at like 50k maybe 60k, that''s just a guess... could end at a 100 k too, who knows :o)
I count all of the lines, wheter they''re just "}" or even empty.. I go down to the botteom of each file and look what line it is.. I don''t need and I don''t have the time to count them soo precisley :O)

cya,
Phil

Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states

##### Share on other sites
That leads to another thing I was wondering about - being that global variables and function were mentioned. With DX (especially games), is it generally accepted that you can use lots of globals? I heard it was, but geese, what a mess!

I think general planning and tighter function/file interaction is what I really need to work on. Previously, I''d just sit down and start writing a new program as it came. For example, in my game, I have a lot of objects flying around - spaceships, asteroids, bullets, etc. What I would''ve seen had I planned was that they all have a lot in common - position, velocity, physical properties, size, etc. So now I have about 10 different classes, each of which is about 50% identical to the other classes. There''s obvious room for improvement there!

Thanks for all the advice - will be much heeded!

##### Share on other sites
Get yerself some teammates.

Funny anecdote about how never to comment, from one of Ultima Underworld''s developers:
http://www.dfan.org/writing/comment.html
And another anecdote on a similar topic:
http://www.dfan.org/writing/coding.html

##### Share on other sites
quote:
Original post by Verso
That leads to another thing I was wondering about - being that global variables and function were mentioned. With DX (especially games), is it generally accepted that you can use lots of globals? I heard it was, but geese, what a mess!

No, it''s not generally accepted Sometimes examples use globals just to show more easily how something works. But you never need globals really. My current game has just 1 global: and that is ''int main()''.

The fewer globals you have, the cleaner your code gets. The extra effort you spend in putting things in neat little modules and sections is repaid several times over when your code is so much easier to read.

quote:

I think general planning and tighter function/file interaction is what I really need to work on. Previously, I''d just sit down and start writing a new program as it came.

I''ll be honest with you: that''s how I go along too. At least to begin with. I start with 1 file, often with the main() function doing everything... initialising the graphics, drawing the map, and shutting it all down. Then, I clean it up as I go along, before it has a chance to get unwieldy. If I find myself doing something twice, I make it into a function. If I find 2 things having similar properties, I invent a class to contain those properties. If I find 2 classes being similar, but not exactly, I move information into a single base class. If a function operates mainly on a class, I make it into a class member function. If I find myself using a number more than once in the same context, I make it into a constant. And so on.

The benefit of my approach is that I start off with something working, and keep refining it as I go along. This is a nice compromise between the "Everything is a global variable and the code is a repetitive mess" and the "I have 100 classes in my hierarchy, but I''ll never finish implementing them" camps. Of course, my method doesn''t escape the need to learn good design habits: I have to be able to recognise what makes a good class, what features are good candidates to go into the base classes, and so on. And this recognition has to happen early, or you lose the benefits.

For example, if I was doing your game, I might have started off with a Spaceship class, and tweaked that until I got it working, moving across the screen, and so on. Then when it came to adding an Asteroid class, I would think "hmm, lots of stuff shared here with Spaceships. Maybe I can factor it out into a base class." So I''d make a SpaceObject class or something, and move the position, velocity, size etc from SpaceShip and into SpaceObject. Then I just make sure that SpaceShip and Asteroid both derive from SpaceObject. This way, I''ve implemented 90% of Asteroid using existing working code, SpaceShip still works just as before, and I''ve drastically cut down the time it will take for me to develop a Bullet or Projectile class in the future. Rather than a ''top-down'' or ''bottom-up'' approach, this is more of an ''outside-in'' design! I start with bottom-up, then shift to top-down whenever possible. For me personally, it provides a good compromise between quick prototyping of technology and effective design considerations and frameworks.

Good luck with the game, anyway!

##### Share on other sites
quote:
Original post by GayleSaver
Funny anecdote about how never to comment, from one of Ultima Underworld''s developers:
http://www.dfan.org/writing/comment.html
And another anecdote on a similar topic:
http://www.dfan.org/writing/coding.html

LOL!!! Oh, those were great, especially the second one. I can never get enough funny coding stories.

My favorite piece of code (that I didn''t write) in a multi-threaded windows MFC app, the "OnClose" message handler:

  // exit gracefullyexit (1);

##### Share on other sites
I think just having lots of "modules" in files like graphics.c, input.c keeps it managable. Currently I''m on about 10,000 lines.

What I''ve found though is that most of making a game seems to be just loads of list managment, like textures, entities, sounds, bla bla... and it''s all pretty much the same for each.

Am I missing out here or is this what it really is?

##### Share on other sites
Yea, coding stories are the best^^
I need to make my engine less boring. I always use error messages like "Function() failed". Here''s one (sorta) funny clip I wrote a long time ago though:
switch(dxType)
{
case ''d'':
MessageBox(hwnd, "Direct Draw init screwed up.", TITLE, MB_OK);
case ''i'':
MessageBox(hwnd, "Direct Input init went to hell.", TITLE, MB_OK);

And another (even less funny) one (both of there are from when I was first learning DirectX from the MSDNtutorials):

char szFrontMsg[] = "Front buffer: I''m better than you. (F12 to exit)";
char szBackMsg[] = "Back buffer: I ''da bak buffa'' (F12 to exit)";

And on the original topic, I just checked and my current project is at 5094 lines (including blank ones), and now it seems insignificant. Especially cause about 1000 of those are ASM, which, if I didn''t have multiple copies of functions to do slightly different things, would probably be more like 200, which written in C++ would probably fit into 100. Oh well. Basically the way I keep it under control is to make a bunch of files, and group related classes into them (like, tiles, layers, and maps all have to have eachother to work, so they go together). Then give each class a bunch of functions (usually an Init, UpdateFrame, Cleanup and whatever else is needed), only use globals for things like setting up the program, the main UpdateFrame function, the active map (it''s easier than passing a pointer all the time), and the video/input/sound control objects.
I don''t think it''s really that great of a style though, especially since I rarely comment, and do things the fastest way I can, not the easiest to read.

Anyway, good luck on getting your project in order. If it gets too confusing, try to reorganize everything into seperate files, but don''t actually do anything until you''ve though about it first or you''ll end up going around in circles trying to decide where to put something^_^

-Deku-chan

DK Art (my site, which has little programming-related stuff on it, but you should go anyway^_^)

##### Share on other sites
Just to quickly fill in to DekuTree64''s reply, I played Dune 2000 with my brother over DCC. Then suddenly the thing bombed out showing "xxxxxxx.cpp" at the title and the error message states "Error ### - Unit doesn''t know it''s a unit". Man I cracked myself for 10 minutes. Well you''ve got to admit, it was funny.

Actually that hierarchy stuff, when you draw it on paper (or write, whatever), does it look like a tree (You know, the main node with the branch nodes, etc.) or do you just write the code descriptions?

I''m just a bit interrested in what you guys said about all those lines of code and all that confusement. Well will some one please explain it to me some time (just for the interresting fact of hierarchies. Who knows if I''ll be living on it to use it.)

------------------------------
-Last Attacker
ICQ: 120585863
E-mail: laextr@icqmail.com

##### Share on other sites
Well you want to draw your heirarchy as a tree, and probably have class descriptions seperate. Just use the name of the class in your heirarchy and show which are your base classes and which classes are derived from them. If it provides no other benefit to you, atleast you have all of your classes listed in one place so you don''t have to knock your head to remember what you named that class that you haven''t used in a couple of weeks, they are all in one document.

Then you can create the individual class documents. Here you list the public data and methods and show which classes interact with which other classes and which methods they use.

If you have groups of classes which are designed primarily to interact with each other, then you can draw them all on the same document and use line-arrows from class to class to show the relationship. You can break this down to multiple levels.

If you want to get really into it, you can then create a class dictionary for each class. This will describe everything about the class. You will have a seperate page for each member variable and method. You will describe it''s purpose in life, what it does exactly (if it''s a method), the data type, min-max values, how often you expect to use the member, etc...

In my experience this is mostly only done religiously on large mission-critical applications. Just mix and match whatever works best for you Despite Booch and everything else, OOD is still in it''s infancy and nobody can say what is the ''best method''.

But any design documents are better than no design documents

Seeya
Krippy

##### Share on other sites
I actually wrote a console application that allowed me to enter in all my project source files and it counted the number of lines and gave the option to exclude comments and space. It also gave line percentages of comments used, function calls, etc. Don''t know why I made it, just got bored one night. Pretty cool to see the exact size of my projects though.

• ### Forum Statistics

• Total Topics
628707
• Total Posts
2984310

• 23
• 10
• 9
• 13
• 13


text:
• # question_answer A line makes an obtuse angle with the positive x-axis and angles $\frac{\pi }{4}$ and $\frac{\pi }{3}$ with the positive y and z axes respectively. Its direction cosine are A)  $\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}},\frac{1}{2}$ B)  $\frac{1}{\sqrt{2}},-\frac{1}{2},\frac{1}{2}$ C)  $-\frac{1}{2},\frac{1}{\sqrt{2}},\frac{1}{2}$ D)  $\frac{1}{2},\frac{1}{\sqrt{2}},\frac{1}{2}$

Let $m=\cos \frac{\pi }{4}=\frac{1}{\sqrt{2}}$ and    $n=\cos \frac{\pi }{3}=\frac{1}{2}$ $\because$ ${{l}^{2}}+{{m}^{2}}+{{n}^{2}}=1$ $\Rightarrow$   $l=\sqrt{1-({{m}^{2}}+{{n}^{2}})}=\sqrt{1-\left( \frac{1}{2}+\frac{1}{4} \right)}$ $=\sqrt{1-\frac{3}{4}}$ $\Rightarrow$ $l=\pm \frac{1}{2}$ Since, line makes an obtuse angle, so we angle $l=-\frac{1}{2}$ $\therefore$   Direction cosines are $-\frac{1}{2},\frac{1}{\sqrt{2}},\frac{1}{2},$


text:
# Changing \eqref colors in Beamer

I want to change my equation reference color to \usebeamercolor[fg]{structure}. I use it as {\usebeamercolor[fg]{structure}\ref{eqn1}} but I want to make this as my default color and just use \eqref{eqn1} to get the same output.

Also, where can I find the list of colors that beamer uses? For example, for example block header, alert block header, theorem block header.

\documentclass[10pt]{beamer}

\usepackage{amsfonts}

\usetheme{Warsaw}
\usecolortheme{whale}

\begin{document}

\begin{frame}{}

$$y^{\prime}=p(x)y\label{eqn1}$$
{\usebeamercolor[fg]{structure}\eqref{eqn1}} is a linear differential equation of first order.

\end{frame}

\end{document}

• Can you make a minimal example to play with? – egreg Feb 28 '15 at 21:18

Just redefine \eqref to incorporate the color change:

\documentclass[10pt]{beamer}

\usepackage{amsfonts}

\usetheme{Warsaw}
\usecolortheme{whale}

\makeatletter
\renewcommand\eqref[1]{%
\textup{\usebeamercolor[fg]{structure}\tagform@{\ref{#1}}}%
}

\begin{document}

\begin{frame}{}

$$y'=p(x)y\label{eqn1}$$
\eqref{eqn1} is a linear differential equation of first order.

\end{frame}

\end{document}

• Can I also edit this for \ref and \cite? – bkarpuz Feb 28 '15 at 22:00
• @bkarpuz That's more difficult, because \ref and \cite are not really supported by beamer. And \cite may depend on the bibliography package manager you use, for instance natbib or biblatex. In my opinion \ref and \cite should be used very sparingly in a beamer document. – egreg Feb 28 '15 at 22:04

You could redefine the internal macro \tagform@ to tell it to render its output in blue (or whatever color you prefer).

I'd consult chapter 17, "Colors", of the beamer user guide for information about all colors that beamer and its various styles use.

\documentclass{beamer}
\makeatletter   % add "\color{blue}" to argument of "\maketag@@@"
\def\tagform@#1{\maketag@@@{\color{blue}(\ignorespaces#1\unskip\@@italiccorr)}}
\makeatother
\usetheme{Warsaw}
\usecolortheme{whale}

\begin{document}

\begin{frame}{}
$$\label{eqn1} y'=p(x)y$$

\eqref{eqn1} is a linear differential equation of the first order.
\end{frame}
\end{document}

• I just want to change \eqref color not the equation color. Is that possible? – bkarpuz Feb 28 '15 at 21:53
• @bkarpuz - Visual cues are least likely to be misinterpreted if they are used consistently: If you want to color an equation number in a cross-reference, it's helpful to your audience if the original equation number uses the same color. – Mico Feb 28 '15 at 22:05
• My idea is just to make clickable links colored. – bkarpuz Mar 1 '15 at 7:06
• To make all cross-references colored, you're better off simply loading the hyperref package with the option colorlinks. – Mico Mar 1 '15 at 7:20


text:
College Physics (4th Edition)

The magnitude of the force of the stone on the man's hand is $22.6~N$
We can find the force $F$ that the man applies on the stone: $F - mg = ma$ $F = m~(a+g)$ $F = (2.0~kg)(1.5~m/s^2+9.80~m/s^2)$ $F = 22.6~N$ By Newton's third law, the stone applies a force with a magnitude of $22.6~N$ on the man's hand.


text:
# Linux gcc编译error:"collect2: ld returned 1 exit status"

bmeta_info.cpp:4280: undefined reference to crypt’
collect2: ld returned 1 exit status

Undefined reference to 错误:这类错误是在连接过程中出现的，可能有两种原因∶一是使用者自己定义的函数或者全局变量所在源代码文件，没有被编译、连接，或者干脆还没有定义，这 需要使用者根据实际情况修改源程序，给出全局变量或者函数的定义体；二是未定义的符号是一个标准的库函数，在源程序中使用了该库函数，而连接过程中还没有 给定相应的函数库的名称，或者是该档案库的目录名称有问题

GNU EXTENSION
The glibc2 version of this function has the following additional features.  If salt is a character string starting with the three characters "$1$" followed by at most eight characters, and optionally terminated by "$", then instead of using the DES machine, the glibc crypt function uses an MD5-based algorithm, and outputs up to 34 bytes, namely "$1$<string>$", where "<string>" stands for the up to 8 characters following "$1$" in the salt, followed by 22 bytes chosen from the set [a–zA–Z0–9./].  The entire key is significant here (instead of only the first 8 bytes).
Programs using this function must be linked with -lcrypt.`

©2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客