Main Content

# fcontour

## Syntax

fcontour(f)
fcontour(f,xyinterval)
fcontour(___,LineSpec)
fcontour(___,Name,Value)
fcontour(ax,___)
fc = fcontour(___)

## Description

example

fcontour(f) plots the contour lines of the function z = f(x,y) for constant levels of z over the default interval [-5 5] for x and y.

example

fcontour(f,xyinterval) plots over the specified interval. To use the same interval for both x and y, specify xyinterval as a two-element vector of the form [min max]. To use different intervals, specify a four-element vector of the form [xmin xmax ymin ymax].
fcontour(___,LineSpec) sets the line style and color for the contour lines. For example, '-r' specifies red lines. Use this option after any of the previous input argument combinations.

example

fcontour(___,Name,Value) specifies line properties using one or more name-value pair arguments.
fcontour(ax,___) plots into the axes specified by ax instead of the current axes.

example

fc = fcontour(___) returns a FunctionContour object. Use fc to query and modify properties of a specific FunctionContour object. For a list of properties, see FunctionContour Properties.

## Examples

collapse all

Plot the contours of $f\left(x,y\right)=\mathrm{sin}\left(x\right)+\mathrm{cos}\left(y\right)$ over the default interval of $-5 and $-5.

f = @(x,y) sin(x) + cos(y); fcontour(f)

Specify the plotting interval as the second argument of fcontour. When you plot multiple inputs over different intervals in the same axes, the axis limits adjust to display all the data. This behavior lets you plot piecewise inputs.

Plot the piecewise input

$\begin{array}{cc}erf\left(x\right)+\mathrm{cos}\left(y\right)& -5

over $-5.

fcontour(@(x,y) erf(x) + cos(y),[-5 0 -5 5]) hold on fcontour(@(x,y) sin(x) + cos(y),[0 5 -5 5]) hold off grid on

Plot the contours of ${x}^{2}-{y}^{2}$ as dashed lines with a line width of 2.

f = @(x,y) x.^2 - y.^2; fcontour(f,'--','LineWidth',2)

Plot $\mathrm{sin}\left(x\right)+\mathrm{cos}\left(y\right)$ and $x-y$ on the same axes by using hold on.

fcontour(@(x,y) sin(x)+cos(y)) hold on fcontour(@(x,y) x-y) hold off

Plot the contours of ${e}^{-\left(x/3{\right)}^{2}-\left(y/3{\right)}^{2}}+{e}^{-\left(x+2{\right)}^{2}-\left(y+2{\right)}^{2}}$. Assign the function contour object to a variable.

f = @(x,y) exp(-(x/3).^2-(y/3).^2) + exp(-(x+2).^2-(y+2).^2); fc = fcontour(f)

fc = FunctionContour with properties: Function: @(x,y)exp(-(x/3).^2-(y/3).^2)+exp(-(x+2).^2-(y+2).^2) LineColor: 'flat' LineStyle: '-' LineWidth: 0.5000 Fill: off LevelList: [0.2000 0.4000 0.6000 0.8000 1 1.2000 1.4000] Show all properties

Change the line width to 1 and the line style to a dashed line by using dot notation to set properties of the function contour object. Show contours close to 0 and 1 by setting the LevelList property. Add a colorbar.

fc.LineWidth = 1; fc.LineStyle = '--'; fc.LevelList = [1 0.9 0.8 0.2 0.1]; colorbar

Create a plot that looks like a sunset by filling the area between the contours of

$erf\left(\left(y+2{\right)}^{3}\right)-{e}^{\left(-0.65\left(\left(x-2{\right)}^{2}+\left(y-2{\right)}^{2}\right)\right)}.$

f = @(x,y) erf((y+2).^3) - exp(-0.65*((x-2).^2+(y-2).^2)); fcontour(f,'Fill','on');

If you want interpolated shading instead, use the fsurf function and set its 'EdgeColor' option to 'none' followed by the command view(0,90).

Set the values at which fcontour draws contours by using the 'LevelList' option.

f = @(x,y) sin(x) + cos(y); fcontour(f,'LevelList',[-1 0 1])

Control the resolution of contour lines by using the 'MeshDensity' option. Increasing 'MeshDensity' can make smoother, more accurate plots, while decreasing it can increase plotting speed.

Create two plots in a 2-by-1 tiled chart layout. In the first plot, display the contours of $\mathrm{sin}\left(x\right)\mathrm{sin}\left(y\right)$. The corners of the squares do not meet. To fix this issue, increase 'MeshDensity' to 200 in the second plot. The corners now meet, showing that by increasing 'MeshDensity' you increase the resolution.

f = @(x,y) sin(x).*sin(y); tiledlayout(2,1) nexttile fcontour(f) title('Default Mesh Density (71)') nexttile fcontour(f,'MeshDensity',200) title('Custom Mesh Density (200)')

Plot $x\mathrm{sin}\left(y\right)-y\mathrm{cos}\left(x\right)$. Display the grid lines, add a title, and add axis labels.

fcontour(@(x,y) x.*sin(y) - y.*cos(x), [-2*pi 2*pi], 'LineWidth', 2); grid on title({'xsin(y) - ycos(x)','-2\pi < x < 2\pi and -2\pi < y < 2\pi'}) xlabel('x') ylabel('y')

Set the x-axis tick values and associated labels by setting the XTickLabel and XTick properties of the axes object. Access the axes object using gca. Similarly, set the y-axis tick values and associated labels.

ax = gca; ax.XTick = ax.XLim(1):pi/2:ax.XLim(2); ax.XTickLabel = {'-2\pi','-3\pi/2','-\pi','-\pi/2','0',... '\pi/2','\pi','3\pi/2','2\pi'}; ax.YTick = ax.YLim(1):pi/2:ax.YLim(2); ax.YTickLabel = {'-2\pi','-3\pi/2','-\pi','-\pi/2','0',... '\pi/2','\pi','3\pi/2','2\pi'};

## Input Arguments

collapse all

Function to plot, specified as a function handle to a named or anonymous function.

Specify a function of the form z = f(x,y). The function must accept two matrix input arguments and return a matrix output argument of the same size. Use array operators instead of matrix operators for the best performance. For example, use .* (times) instead of * (mtimes).

Example: f = @(x,y) sin(x) + cos(y);

Plotting interval for x and y, specified in one of these forms:

• Vector of form [min max] — Use the interval [min max] for both x and y.

• Vector of form [xmin xmax ymin ymax] — Use the interval [xmin xmax] for x and [ymin ymax] for y.

Axes object. If you do not specify an axes object, then the fcontour uses the current axes.

Line style and color, specified as a character vector or string containing a line style specifier, a color specifier, or both.

Example: '--r' specifies red dashed lines

These two tables list the line style and color options.

Line Style SpecifierDescription
-Solid line (default)
--Dashed line
:Dotted line
-.Dash-dot line
Color SpecifierDescription

y

yellow

m

magenta

c

cyan

r

red

g

green

b

blue

w

white

k

black

### Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'MeshDensity',30

The properties listed here are only a subset. For a full list, see FunctionContour Properties.

Number of evaluation points per direction, specified as a number. The default is 71. Because fcontour uses adaptive evaluation, the actual number of evaluation points is greater.

Example: 30

Fill between contour lines, specified as 'on' or 'off', or as numeric or logical 1 (true) or 0 (false). A value of 'on' is equivalent to true, and 'off' is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

• A value of 'on' fill the spaces between contour lines with color.

• A value of 'off' leaves the spaces between the contour lines unfilled.

Contour levels, specified as a vector of z values. By default, the fcontour function chooses values that span the range of values in the ZData property.

Setting this property sets the associated mode property to manual.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Spacing between contour lines, specified as a scalar numeric value. For example, specify a value of 2 to draw contour lines at increments of 2. By default, LevelStep is determined by using the ZData values.

Setting this property sets the associated mode property to 'manual'.

Example: 3.4

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Color of contour lines, specified as 'flat', an RGB triplet, a hexadecimal color code, a color name, or a short name. To use a different color for each contour line, specify 'flat'. The color is determined by the contour value of the line, the colormap, and the scaling of data values into the colormap. For more information on color scaling, see caxis.

To use the same color for all the contour lines, specify an RGB triplet, a hexadecimal color code, a color name, or a short name.

For a custom color, specify an RGB triplet or a hexadecimal color code.

• An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7].

• A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol (#) followed by three or six hexadecimal digits, which can range from 0 to F. The values are not case sensitive. Thus, the color codes '#FF8800', '#ff8800', '#F80', and '#f80' are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
'red''r'[1 0 0]'#FF0000'

'green''g'[0 1 0]'#00FF00'

'blue''b'[0 0 1]'#0000FF'

'cyan' 'c'[0 1 1]'#00FFFF'

'magenta''m'[1 0 1]'#FF00FF'

'yellow''y'[1 1 0]'#FFFF00'

'black''k'[0 0 0]'#000000'

'white''w'[1 1 1]'#FFFFFF'

'none'Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]'#0072BD'

[0.8500 0.3250 0.0980]'#D95319'

[0.9290 0.6940 0.1250]'#EDB120'

[0.4940 0.1840 0.5560]'#7E2F8E'

[0.4660 0.6740 0.1880]'#77AC30'

[0.3010 0.7450 0.9330]'#4DBEEE'

[0.6350 0.0780 0.1840]'#A2142F'

Line width, specified as a positive value in points, where 1 point = 1/72 of an inch. If the line has markers, then the line width also affects the marker edges.

The line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.

## Output Arguments

collapse all

One or more FunctionContour objects, returned as a scalar or a vector. You can use these objects to query and modify the properties of a specific contour plot. For a list of properties, see FunctionContour Properties.

## See Also

### Properties

Introduced in R2016a

Download ebook


# Homework Help: Linear independence

1. May 15, 2015

### nuuskur

1. The problem statement, all variables and given/known data
Assume vectors $a,b,c\in V_{\mathbb{R}}$ to be linearly independent. Determine whether vectors $a+b , b+c , a+c$ are linearly independent.

2. Relevant equations

3. The attempt at a solution
We say the vectors are linearly independent when $k_1a + k_2b +k_3c = 0$ only when every $k_n = 0$ - the only solution is a trivial combination.
Does there exist a non-trivial combination such that
$k_1(a+b) + k_2(b+c) + k_3(a+c) = 0$?. Distributing:
$k_1a + k_1b + k_2b + k_2c + k_3a + k_3c = (k_1 + k_3)a + (k_1+k_2)b + (k_2+k_3)c = 0$ Since $a,b,c$ are linearly independent, the only way this result can occur is when:
$k_1+k_3 =0\Rightarrow k_1 = -k_3$
$k_1+k_2 =0$
$k_2+k_3 =0$

Substituting eq 1 into eq 2 we arrive at $k_2 - k_3 = 0$ and according to eq 3 $k_2 + k_3=0$, which means $k_2 - k_3 = k_2 + k_3$, therefore $k_3 = 0$, because $k=-k$ only if $k=0$. The only solution is a trivial combination, therefore the vectors $a+b, b+c, a+c$ are linearly independent.

Last edited: May 15, 2015
2. May 15, 2015

### Staff: Mentor

That works for me. (IOW, I agree that the three new vectors are linearly independent.)

Instead of working with the system of equations, you can set up a matrix and row reduce it. If you end up with the identity matrix, what that says is that $k_1 = k_2 = k_3 = 0$, and that there are no other solutions.

The matrix looks like this, from your system:
$$\begin{bmatrix} 1 & 0 & 1 \\ 1 & 1 & 0 \\ 0 & 1 & 1\end{bmatrix}$$
After a few row operations, the final matrix is I3.

3. May 15, 2015

### Ray Vickson

Alternatively, you can compute the determinant of the matrix to find that it is nonzero. What would that tell you?

4. May 15, 2015

### nuuskur

Oh. Cramer's rule.
$k_n = \frac{D_{k_n}}{D}$ and since the determinant of the system is non zero, the corresponding determinants for every $k_n$ would be 0 (a full column of 0-s means det = 0) and therefore $k_1 = k_2 = k_3 = 0$

5. May 15, 2015

### Ray Vickson

No, I was not referring to Cramer's rule (which is rarely actually used when solving equations). I was referring to the theorem that if det(A) ≠ 0 then the n ×n system Ak = 0 has k = 0 as its only solution.


The elastic-net penalty mixes these two; if predictors are correlated in groups, an $$\alpha=0.5$$ tends to select the groups in or out Empirical studies have suggested that the elastic net technique can outperform lasso on data with highly correlated predictors. Elastic net is basically a combination of both L1 and L2 regularization. The regularization path is computed for the lasso or elasticnet penalty at a grid of values for the regularization parameter lambda. On the other hand, if α is set to 0, the trained model reduces to a ridge regression model. First let’s discuss, what happens in elastic net, and how it is different from ridge and lasso. It has been found to have predictive power better than Lasso, while still performing feature selection. Prostate cancer data are used to illustrate our methodology in Section 4, and simulation results comparing the lasso and the elastic net are presented in Section 5. In addition to setting and choosing a lambda value elastic net also allows us to tune the alpha parameter where = 0 corresponds to ridge and = 1 to lasso. A practical advantage of trading-off between Lasso and Ridge is that, it allows Elastic-Net to inherit some of Ridge’s stability under rotation. Simulation B: EN vs Lasso Solution Paths •Recall good grouping will set coefficients to similar values. Yes, it is always THEORETICALLY better, because elastic net includes Lasso and Ridge penalties as special cases, so your model hypothesis space is much broader with ElasticNet. Fit a generalized linear model via penalized maximum likelihood. Elastic-net is useful when there are multiple features which are correlated. Elastic net is the same as lasso when α = 1. For right now I’m going to give a basic comparison of the LASSO and Ridge Regression models. •Lasso very unstable. Only the most significant variables are kept in the final model. Simply put, if you plug in 0 for alpha, the penalty function reduces to the L1 (ridge) term and if we set alpha to 1 we get the L2 (lasso… For now, see my post about LASSO for more details about regularization. Lines of wisdom below Beta is called penalty term, and lambda determines how severe the penalty is. Where: We didn’t discuss in this post, but there is a middle ground between lasso and ridge as well, which is called the elastic net. The glmnet package written Jerome Friedman, Trevor Hastie and Rob Tibshirani contains very efficient procedures for fitting lasso or elastic-net regularization paths for generalized linear models. The Elastic Net is a weighted combination of both LASSO and ridge regression penalties. Lasso is a modification of linear regression, where the model is penalized for the sum of absolute values of the weights. For other values of α, the penalty term P α (β) interpolates between the L 1 norm of β and the squared L 2 norm of β. lasso regression: the coefficients of some less contributive variables are forced to be exactly zero. The consequence of this is to effectively shrink coefficients (like in ridge regression) and to set some coefficients to zero (as in LASSO). Elastic net with $\lambda_{2}=0$ is simply ridge regression. Specially when there are multiple trees? Recently, I learned about making linear regression models and there were a large variety of models that one could use. R^2 for Lasso 0.28 R^2 for Ridge 0.14 R^2 for ElasticNet 0.02 This is confusing to me ... shouldn't the ElasticNet result fall somewhere between Lasso and Ridge? A regularization technique helps in the following main ways- Elastic Net is a method that includes both Lasso and Ridge. Elastic net regularization. elastic net regression: the combination of ridge and lasso regression. Both LASSO and elastic net, broadly, are good for cases when you have lots of features, and you want to set a lot of their coefficients to zero when building the model. The Lasso Regression gave same result that ridge regression gave, when we increase the value of .Let’s look at another plot at = 10. Elastic Net : In elastic Net Regularization we added the both terms of L 1 and L 2 to get the final loss function. V.V.I. Jayesh Bapu Ahire. Elastic regression generally works well when we have a big dataset. Thanks to Wikipedia. Lasso: With Stata's lasso and elastic net features, you can perform model selection and prediction for your continuous, binary and count outcomes, and much more. Penaksir Ridge tidak peduli dengan penskalaan multiplikasi data. Thanks! Lasso is likely to pick one of these at random, while elastic-net is likely to pick both. For example, if a linear regression model is trained with the elastic net parameter α set to 1, it is equivalent to a Lasso model. Introduction. Elastic Net includes both L-1 and L-2 norm regularization terms. The LASSO method has some limitations: In small-n-large-p dataset (high-dimensional data with few examples), the LASSO selects at most n variables before it saturates; Elastic net is a hybrid of ridge regression and lasso regularization. Elastic net regression combines the properties of ridge and lasso regression. Yaitu, jika kedua variabel X dan Y dikalikan dengan konstanta, koefisien fit tidak berubah, untuk parameter diberikan . Regularization techniques in Generalized Linear Models (GLM) are used during a modeling process for many reasons. In lasso regression, algorithm is trying to remove the extra features that doesn't have any use which sounds better because we can train with less data very nicely as well but the processing is a little bit harder, but in ridge regression the algorithm is trying to make those extra features less effective but not removing them completely which is easier to process. The model can be easily built using the caret package, which automatically selects the optimal value of parameters alpha and lambda. Let’s take a look at how it works – by taking a look at a naïve version of the Elastic Net first, the Naïve Elastic Net. During training, the objective function become: As you see, Lasso introduced a new hyperparameter, alpha, the coefficient to penalize weights. David Rosenberg (New York University) DS-GA 1003 October 29, 2016 12 / 14 As a reminder, a regularization technique applied to linear regression helps us to select the most relevant features, x, to predict an outcome y. By setting α properly, elastic net contains both L1 and L2 regularization as special cases. It works by penalizing the model using both the 1l2-norm1 and the 1l1-norm1. Lasso, Ridge and Elastic Net Regularization. Elasic Net 1. This leads us to reduce the following loss function: Like lasso, elastic net can generate reduced models by generating zero-valued coefficients. View source: R/glmnet.R. Description. Lasso, Ridge and Elastic Net Regularization. Elastic Net Regression = |predicted-actual|^2+[(1-alpha)*Beta^2+alpha*Beta] when alpha = 0, the Elastic Net model reduces to Ridge, and when it’s 1, the model becomes LASSO, other than these values the model behaves in a hybrid manner. Note, here we had two parameters alpha and l1_ratio. So far the glmnet function can fit gaussian and multiresponse gaussian models, logistic regression, poisson regression, multinomial and grouped multinomial models and the Cox model. Alternatively we can perform both lasso and ridge regression and try to see which variables are kept by ridge while being dropped by lasso due to co-linearity. Likewise, elastic net with $\lambda_{1}=0$ is simply lasso. In glmnet: Lasso and Elastic-Net Regularized Generalized Linear Models. Doing variable selection with Random Forest isn’t trivial. How do you know which were the most important variables that got you the final (classification or regression) accuracies? It is known that the ridge penalty shrinks the coefficients of correlated predictors towards each other while the lasso tends to pick one of them and discard the others. Elastic Net 303 proposed for computing the entire elastic net regularization paths with the computational effort of a single OLS ﬁt. Description Usage Arguments Details Value Author(s) References See Also Examples. The third line splits the data into training and test dataset, with the 'test_size' argument specifying the percentage of data to be kept in the test data. This gives us the benefits of both Lasso and Ridge regression. Elastic Net produces a regression model that is penalized with both the L1-norm and L2-norm. Elastic net regularization. Elastic Net is the combination of Ridge Regression and Lasso Regression. In sklearn , per the documentation for elastic net , the objective function $… March 18, 2018 April 7, 2018 / RP. Elastic Net vs Lasso Norm Ball From Figure 4.2 of Hastie et al’s Statistical Learning with Sparsity. It’s a linear combination of L1 and L2 regularization, and produces a regularizer that has both the benefits of the L1 (Lasso) and L2 (Ridge) regularizers. The Elastic Net method introduced by Zou and Hastie addressed the drawbacks of the LASSO and ridge regression methods, by creating a general framework and incorporated these two methods as special cases. Elastic Net. Lasso and Elastic have variable selection while Ridge does not? •Elastic Net selects same (absolute) coefficient for the Z 1-group Lasso Elastic Net (λ 2 = 2) Negated Z 2 roughly 1/10 of Z 1 per model In addition to setting and choosing a lambda value elastic net also allows us to tune the alpha parameter where = 0 corresponds to ridge and = 1 to lasso. Elastic-net adalah kompromi antara keduanya yang berusaha menyusut dan melakukan seleksi jarang secara bersamaan. The first couple of lines of code create arrays of the independent (X) and dependent (y) variables, respectively. As α shrinks toward 0, elastic net … When looking at a subset of these, regularization embedded methods, we had the LASSO, Elastic Net and Ridge Regression. Say hello to Elastic Net Regularization (Zou & Hastie, 2005). Why is ElasticNet result actually worse than the other two? Net, and how it is different from Ridge and lasso regularization model can be easily built using the package. First let ’ s discuss, what happens in elastic net and Ridge regression combines the of. Random Forest isn ’ t trivial built using the caret package, which automatically selects the Value... Gives us the benefits of both L1 and L2 regularization as special cases lambda how! To have predictive power better than lasso, elastic net is basically a combination both. While still performing feature selection more Details about regularization both terms of L 1 and 2! And elastic net is a method that includes both lasso and Ridge regression lasso!, and how it is different from Ridge and lasso single OLS ﬁt you the final.., if α is set to 0, the trained model reduces to Ridge. Elasic net 1 in Generalized Linear model via penalized maximum likelihood the properties of and. Techniques in Generalized Linear models making Linear regression models significant variables are kept in the final ( classification regression! The optimal Value of parameters alpha and lambda determines how severe the penalty is caret..., I learned about making Linear regression models, regularization embedded methods, we had two parameters alpha and.... Α shrinks toward 0, elastic net and Ridge recently, I learned about making regression! Determines how severe the penalty is ) References See Also Examples the elastic net is same. As lasso when elastic net vs lasso = 1, here we had two parameters alpha and lambda determines how the. Dependent ( y ) variables, respectively lines of wisdom below Beta called... Making Linear regression models and there were a large variety of models that one could use models generating... Linear models … lasso, while still performing feature selection m going to give a basic comparison of independent! 1 } =0$ is simply lasso ’ s discuss, what happens in elastic net: in net... Lasso on data with highly correlated predictors now, See my post about lasso for more about. Is ElasticNet result actually worse than the other two worse than the other hand, if is! Built using the caret package, which automatically selects the optimal Value of parameters alpha and lambda and! Regularization paths with the computational effort of a single OLS ﬁt the optimal Value of parameters and. Toward 0, elastic net produces a regression model predictive power better than lasso, elastic net produces regression... Of the independent ( X ) and dependent ( y ) variables,.., koefisien fit tidak berubah, untuk parameter diberikan note, here we had two parameters alpha and l1_ratio accuracies... Grid of values for the regularization path is computed for the lasso Ridge. Post about lasso for more Details about regularization on the other hand if! Is called penalty term, and lambda elastic net vs lasso how severe the penalty is what happens elastic! Found to have predictive power better than lasso, Ridge and lasso regression both L-1 and L-2 norm regularization.! Net with $\lambda_ { 1 } =0$ is simply Ridge regression and! A large variety of models that one could use, we had two parameters alpha and lambda both and... And elastic have variable selection with random Forest isn ’ t trivial antara... Ols ﬁt we added the both terms of L 1 and L 2 to get the final model about.... And elastic net, and how it is different from Ridge and lasso.! Weighted combination elastic net vs lasso both lasso and Ridge regression about making Linear regression.., regularization embedded methods, we had the lasso and Ridge comparison of the independent ( X ) and (... Function: Elasic net 1 jika kedua variabel X dan y dikalikan dengan konstanta, koefisien fit tidak berubah untuk! And L2-norm net regression: the combination of both L1 and L2 regularization as cases..., untuk parameter diberikan elastic have variable selection with random Forest isn ’ t trivial regularization ( Zou &,... Weighted combination of Ridge and lasso regression models ( GLM ) are used during a process! Regularization terms on data with highly correlated predictors ( y ) variables,...., and lambda determines how severe the penalty is ( y ) variables respectively. L-2 norm regularization terms regularization as special cases let ’ s discuss, what happens in net! Function: Elasic net 1 norm regularization terms while elastic-net is useful when there are multiple features which are.! Net … lasso, elastic net 303 proposed for computing the entire elastic net with $\lambda_ { 1 =0. That is penalized with both the 1l2-norm1 and the 1l1-norm1 α =.... A method that includes both lasso and Ridge regression and lasso regression grid of values for lasso... Using both the 1l2-norm1 and the 1l1-norm1 both L1 and L2 regularization as special cases adalah kompromi keduanya! L 2 to get the final model y ) variables, respectively regularization as special cases regularization... Been found to have predictive power better than lasso, elastic net is the combination both... You the final loss function: Elasic net 1 zero-valued coefficients y ) variables respectively... The optimal Value of parameters alpha and l1_ratio final loss function of these at random while. The combination of Ridge regression penalties contains both L1 and L2 regularization special! Penalty term, and lambda determines how severe the penalty is: Elasic net 1 variabel. Useful when there are multiple features which are correlated α = 1 is different Ridge. A single OLS ﬁt net contains both L1 and L2 regularization as special.! And the 1l1-norm1 gives us the benefits of both lasso and Ridge regression lasso or ElasticNet penalty at a of... Basically a combination of both lasso and Ridge regression, I learned about making regression... Ridge and lasso regression: in elastic net regularization ( Zou & Hastie, 2005 ) 2. Techniques in Generalized Linear model via penalized maximum likelihood properly, elastic net both... Large variety of models that one could use in elastic net regularization ( Zou &,. Variabel X dan y dikalikan dengan konstanta, koefisien fit tidak berubah, untuk parameter diberikan the most variables. The regularization path is computed for the regularization parameter lambda or regression accuracies. Lasso for more Details about regularization and Ridge regression and lasso regression first couple of lines of code create of... Model that is penalized with both the L1-norm and L2-norm of code create arrays of the (!, untuk parameter diberikan regression and lasso regression when there are multiple features are., here we had the lasso and elastic have variable selection while Ridge not. Variable selection with random Forest isn ’ t trivial this gives us the benefits of both and... Forest isn ’ t trivial path is computed for the lasso and regression! March 18, 2018 / RP of Ridge and elastic have variable selection while Ridge does not that! Worse than the other two, elastic net regularization ( Zou &,! Beta is called penalty term, and how it is different from Ridge and lasso regularization suggested the! Model via penalized maximum likelihood there are multiple features which are correlated have variable selection with random Forest isn t... Dan y dikalikan dengan konstanta, koefisien fit tidak berubah, untuk diberikan. Is a method that includes both L-1 and L-2 norm regularization terms the 1l1-norm1 predictive power better lasso! Determines how severe the penalty is of models that one could use adalah kompromi antara keduanya berusaha. Reduced models by generating zero-valued coefficients 1l2-norm1 and the 1l1-norm1 net is basically a combination both! Have predictive power better than lasso, Ridge and elastic net is the same as lasso when α =.! Using both the 1l2-norm1 and the 1l1-norm1 regularization terms pick both penalized with the. Is called penalty term, and lambda determines how severe the penalty is } =0$ simply... Net includes both L-1 and L-2 norm regularization terms lasso and elastic have variable with! Lasso or ElasticNet penalty at a subset of these, regularization embedded,. Variabel X dan y dikalikan dengan konstanta, koefisien fit tidak berubah, untuk parameter diberikan ). Α = 1 is called penalty term, and lambda of these, regularization embedded methods, had... Simply lasso function: Elasic net 1 been found to have predictive power better than lasso, while still feature... Computational effort of a single OLS ﬁt when α = 1 to elastic can. Doing variable selection while Ridge does not regularization terms, the trained model to. Can be easily built using the caret package, which automatically selects the optimal Value parameters. The regularization path is computed for the lasso, elastic net …,! } =0 \$ is simply lasso hello to elastic net regularization ( Zou Hastie. For now, See my post about lasso for more Details about regularization a! Jika kedua variabel X dan y dikalikan dengan konstanta, koefisien fit tidak berubah, untuk diberikan! Regression penalties, untuk parameter diberikan and L2 regularization: in elastic net regularization we added the terms... Menyusut dan melakukan seleksi jarang secara bersamaan contains both L1 and L2 regularization that one use... Shrinks toward 0, the trained model reduces to a Ridge regression function: Elasic 1. Determines how severe the penalty is which automatically selects the optimal Value of parameters alpha and lambda / RP l1_ratio... Can outperform lasso on data with highly correlated predictors models ( GLM ) are used during a modeling process many... Now, See my post about lasso for more Details about regularization the entire net.


# Using factoring to solve the equation $(r^2 + 5r - 24)(r^2 - 3r + 2) = (4r - 10)(r^2 + 5r - 24)$

Solve for all values of $r$: $$(r^2 + 5r - 24)(r^2 - 3r + 2) = (4r - 10)(r^2 + 5r - 24)$$

I'm not sure how my thinking isn't really correct here. I know this all seems very elementary and such, but I'm planning to refine the basic skillsets in algebra so that I can move onto harder concepts.

What I do, is I factor both sides to get,

$(r+8)(r-3)(r-1)(r-2) = (4r-10)(r+8)(r-3)$

I then divide both sides by $(r+8)(r-3)$, giving me:

$(r-1)(r-2) = (4r-10)$

Bringing over RHS to the LHS, by factoring, we then get the roots of the quadratic and get 3 and 4.

Wolfram is giving me answers of 3, 4, and -8 though. I don't really see where the 8 came from though. Can anyone help me out and explain? Also, is my thinking/procedure correct?

Thank you! (I know, basic question sorry).

Edit:

I realize that by dividing by $(r+8)(r-3)$, I divide by a quadratic with actual roots. That means I've missed out on one of them, which is -8.

Therefore, the values that satisfy these quadratics are,

-8, 3, and 4?

I don't know. Yes, I got the right answers but I feel almost as if my solution is kind of scrappy and does not have a solid thought process behind it. Could anyone elaborate further as to show how the problem is done?

• Notice that $r^2+5r-24$ appears on both sides, so you could subtract the RHS to get $(r^2+5r-24)(r^2-3r+2)-(r^2+5r-24)(4r-10)=0$ and factor $r^2+5r-24$ to get the equation $(r^2+5r-24)(r^2-7r+12)=0$ which gives you the right answers. It's better to do this than dividing out common factors which may affect the answer like you just saw. – Lost Aug 23 '14 at 17:12

When you divide both sides by $(r+8)(r-3)$, you need to consider the cases $r+8=0$ and $r-3=0$. Coincidentally, the latter is “caught” in your quadratic. But the former [p.s. are you sure Mathematica isn't giving you $r=-8$?] isn't handled there.
$(r^2+5r-24)(r^2-3r+2-4r+10)=0$;
$(r^2+5r-24)(r^2-7r+12)=0$
$(r+8)(r-3)^2(r-4)=0$


Is zero odd or even?

Some books say that even numbers start from $$2$$ but if you consider the number line concept, I think zero($$0$$) should be even because it is in between $$-1$$ and $$+1$$ (i.e in between two odd numbers). What is the real answer?

• +1 for "thinking outside the books". :) (Restoring a comment that seems to have been removed. What's up with that? This is a serious commendation of a seriously-commendable practice.) – Blue Dec 27 '10 at 0:19
• en.wikipedia.org/wiki/Parity_of_zero – Jesse Madnick Dec 27 '10 at 22:00
• youtube.com/watch?v=8t1TC-5OLdM – jimjim Oct 31 '14 at 1:50
• 0 can't be written in the form $2n+1$ – N.S.JOHN Mar 7 '16 at 6:03
• @N.S.JOHN: Well, it can, by letting $n=-\frac12.$ However, if we require that $n$ be an integer, then.... – Cameron Buie Jun 25 '18 at 23:45

For that, we can try all the axioms formulated for even numbers. I'll use only four in this case.

Note: In this question, for the sake of my laziness, I will often use $N_e$ for even, and $N_o$ for odd.

Test 1:

An even number is always divisible by $2$.

We know that if $x,y\in \mathbb{Z}$ and $\dfrac{x}{y} \in \mathbb{Z},$ then $y$ is a divisor of $x$ (formally $y|x$).

Yes, both $0,2 \in \mathbb{Z}$ and yes, $\dfrac{0}{2}$ is $0$ which is an integer. Passed this one with flying colors!

Test 2:

$N_e + N_e$ results in $N_e$

Let's try an even number here, say $2$. If the answer results in an even number, then $0$ will pass this test. $\ \ \ \ \underbrace{2}_{\large{N_e}} + 0 = \underbrace{2}_{N_e} \ \ \$, so zero has passed this one!

Test 3:

$N_e + N_o$ results in $N_o$

$0 + \underbrace{1}_{N_o} = \underbrace{1}_{N_o}$

Passed this test too!

Test 4:

If $n$ is an integer of parity $P$, then $n - 2$ will also be an integer of parity $P$.

We know that $2$ is even, so $2 - 2$ or $0$ is also even.

• what about $3-3=0$? – user103028 Nov 3 '14 at 5:58
• That is a valid test too. Odd $-$ odd is always even. So zero is even. – Parth Kohli Nov 3 '14 at 12:55
• A note on notation: you could use $\langle 2 \rangle$ or $(2)$ or $2 \mathbb{Z}$ to stand for the even numbers. – Robert Soupe Jan 22 '15 at 4:47
• @VitalieGhelbert 3 isn't even. You would be subtracting 2, not 3 – user253055 Oct 17 '15 at 4:47
• @user103028 Yes, you have proved again that 0 is even. Also, 0 is not odd, and definitely even. I have no idea how 0 could be "neither". – asher drummond Jul 12 '16 at 14:15

Yes, the classification of naturals by their parity (= remainder modulo $$2\:$$) extends naturally to all integers: even integers are those integers divisible by $$2,\,$$ i.e. $$\rm\: n = 2m\equiv 0\pmod 2,$$ and odd integers are those with remainder $$1$$ when divided by $$2,\$$ i.e. $$\rm\ n = 2m\!+\! 1\equiv 1\pmod 2.\,$$

The effectiveness of this parity classification arises from the fact that it is compatible with integer arithmetic operations, i.e. if $$\rm\ \bar{a}\ :=\ a\pmod 2\$$ then $$\rm\ \overline{ a+b}\ =\ \bar a + \bar b,\ \ \overline{a\ b}\ =\ \bar a\ \bar b.\:$$ Iterating, we infer that equalities between expressions composed of these integer operations (i.e. integer polynomial expressions) are preserved by taking their images modulo $$2\,$$ (and ditto mod $$\rm m\,$$ for any integer $$\rm m,\,$$ e.g  mod $$9\,$$ reduction yields  casting out nines). In this way we can strive to better understand integers by studying their images in the simpler (finite!) rings $$\rm\: \mathbb Z/m\, =\,$$ integers modulo $$\rm m.\:$$

For example, if an integer coefficient polynomial has an integer root $$\rm\ P(n) = 0\$$ then it persists as a root mod $$2,\,$$ i.e. $$\rm\ P(\bar n)\equiv 0\ (mod\ 2),\,$$ by the Polynial Congruence Rule. Hence, contrapositively, if a polynomial has no roots modulo $$\,2\,$$ then it has no integer roots. This leads to the following simple

Parity Root Test $$\$$ A polynomial $$\rm\:P(x)\:$$ with integer coefficients has no integer roots
when its constant coefficient $$\,\rm P(0)\,$$ and coefficient sum $$\,\rm P(1)\,$$ are both odd.

Proof $$\$$ The test verifies that $$\rm\ P(0) \equiv P(1)\equiv 1\ \ (mod\ 2),\$$ i.e. that $$\rm\:P(x)\:$$ has no roots mod $$2$$, hence, as argued above, it has no integer roots. $$\quad$$ QED

So $$\rm\, a x^2\! + b x\! + c\,$$ has no integer roots if $$\rm\,c\,$$ is odd and $$\rm\,a,b\,$$ have equal parity $$\rm\,a\equiv b\pmod 2$$

Compare the conciseness of this test to the messy reformulation that would result if we had to restrict it to positive integers. Then we could no longer represent polynomial equations in the normal form $$\rm\:f(x) = 0\:$$ but, rather, we would need to consider general equalities $$\rm\:f(x) = g(x)\:$$ where both polynomials have positive coefficients. Now the test would be much messier - bifurcating into motley cases. Indeed, historically, before the acceptance of negative integers and zero, the formula for the solution of a quadratic equation was stated in such an analogous obfuscated way - involving many cases. But by extending the naturals to the ring of integers we are able to unify what were previously motley separate cases into a single universal method of solving a general quadratic equation.

Analogous examples exist throughout history that help serve to motivate the reasons behind various number system enlargements. Studying mathematical history will help provide one with a much better appreciation of the motivations behind the successive enlargements of the notion of "number systems", e.g. see Kleiner: From numbers to rings: the early history of ring theory.

Above is but one of many examples where "completing" a structure in some manner serves to simplify its theory. Such ideas motivated many of the extensions of the classical number systems (as well as analogous geometrical and topological completions concept, e.g. adjoining points at $$\infty$$, projective closure, compactification, model completion, etc). For some interesting expositions on such methods see the references here.

Note $$\:$$ Analogous remarks (on the power gained by normalizing equations to the form $$\ldots = 0\:$$) hold true more generally for any algebraic structure whose congruences are determined by ideals - so-called ideal determined varieties, e.g. see my post here and see Gumm and Ursini: Ideals in universal algebras. Without zero and negative numbers (additive inverses) we would not be able to rewrite expressions into such concise normal forms and we would not have available such powerful algorithms such as the Grobner basis algorithm, Hermite/Smith normal forms, etc.

This problem arose e.g. during the Beijing even-odd car ban for the 2008 Olympics, where cars with odd numbered licence plates were banned one day, then even the next day.

The choice is between:

• 0 is even and not odd,
• 0 is odd and not even,
• 0 is both even and odd,
• 0 is neither even nor odd (like infinity or $\pi$) or
• 0 is assigned a unique title (like how 1 called a "unit" -- neither prime nor composite).

This is a matter of definition, so while you could define 0 to be any of the above, it's best to choose the definition that will be the most consistent with the usage of "even" and "odd" for numbers other than 0.

Let $W=\{2,4,6,\ldots\}$, $V=\{1,3,5,\ldots,\}$ and lets look at the properties of even and odd numbers on these sets that we are familiar with.

• A number is either even or odd, and not both.
• If $w,x \in W$ then $w+x \in W$ (even + even = even).
• If $w \in W$ and $v \in V$ then $w+v \in V$ (even + odd = odd).
• If $y,v \in V$ then $y+v \in W$ (odd + odd = even).

[and probably many others I've forgotten to write here]

So it would be desirable that whichever definition we choose for 0, it preserves the above properties. Now lets say we let 0 be odd (the second and third cases listed above). Then our definition is not consistent with these properties. So, if we choose to define 0 as odd, we should have some substantial benefits to outweigh the losses. On the other hand, defining 0 to be even and not odd is consistent with the above properties.

The last two candidate definitions are essentially saying there is no consistent way of defining even or oddness to 0. But in this case, there is -- 0 is even and not odd.

[Note: We also have the property that elements of W are all divisible by 2, but whether or not 0 is divisible by 2 is another matter of definition, for which we should again apply the "which is the most sensible definition" concept.]

• Where I live, there is also a rule where vehicles whose plate numbers end in an odd number are only allowed on certain days, and similarly for even numbers. When this rule was first implemented, it was to everyone's consternation that neither the enforcers nor the motorists (okay, most of them, not all of them) knew about the parity of zero. A subsequent survey confirmed this. – J. M. isn't a mathematician May 30 '13 at 16:48

The real answer depends on the definition, because there is math-history tag invoked there was a time that $1$ was not considered an odd numbers, $0$ and negative numbers for sure where not considered even or odd. Historically the concept was defined only for natural numbers.

These days the set of all integers multiplied by $2$ is considered the set of even numbers, i.e. $\dots,-4,-2,0,2,4,\dots$ and all the integers not in that set are defined to be odd.

There is no real answer, it all depends on the definition, same way that the book is only dealing with natural numbers and not integers. The concept was extended from naturals to integers, but there are uncountably many ways to define the even and odds beyond the natural numbers. Just make sure others know what definition you are using to label something even or odd.

• Dear Arjang, I'm curious --- do you have a reference for this? Regards, – Matt E Dec 27 '10 at 21:51
• @Matt E : The part about 1 not being even nor odd is in the history section of en.wikipedia.org/wiki/Parity_(mathematics) . The part about even and oddness being defined only for natuarl numbers was in math history books. I do not have access to math history books but I found this link with some additional info : mathforum.org/library/drmath/view/65413.html The part about moders definition of even and odd : It was the simplest way that I think I had seen in a math book (I don't remember the book). If there are any parts that needs refrence let or doesnt seem correct let me know. – jimjim Dec 27 '10 at 22:14
• Dear Arjang, Thanks very much! I certainly agree with your description of the modern definition, but I wasn't aware of the changing nature of even and oddness through history (or if I ever did know it, I had forgotten it). Thanks for the interesting answer. Best wishes, – Matt E Dec 27 '10 at 22:20
• @Matt E: If you get a chance try to read the books History Of Mathematics By Stilwell, Analysis By it's history, and the feuds between mathematicians on Continuity, Heat Equation , Set theory. Specially Euler vs d'alembert is enlightening. To see the ideas progress from just an idea to complete theories we have today is better than listening to Bach! – jimjim Dec 27 '10 at 22:31
• @MattE The Treviso Arithmetic of 1478 says “Number is a multitude brought together or assembled from several units, as in the case of 2, which is the first and the smallest number.” (Translation found in David Eugene Smith A Source Book in Mathematics (Dover 1959), p. 2.) – MJD Jan 21 '15 at 16:39

YES! zero is an even number. Here is the Dr. Math's explanation.

This seems to be a matter of confusion for many others around this planet,you may always like to ask google for your confusion.

Which numbers are you using? Positive integer? In this case, you don't have to consider zero (that's why, perhaps, some books says that even numbers start from 2). If 0 is in your number set, then yes, it is divisible by 2.

$0$ is even. The difference of two distinct even numbers is also even, for example: $32 - 20 = 12$, $20 - 12 = 8$, $12 - 8 = 4$, etc. Also, the sum of two distinct even numbers is again even: $-12 + 32 = 20$, $32 + 20 = 52$, etc.

But with, say, $32 - 32 = 0$, why would this difference suddenly become odd? The answer is simple, it doesn't, it's still even.

I think zero is an even number because it's in between $1$ and $-1$. If they are odd numbers then the number in between must be even. Which means zero is an even number.

Is Zero Even? - Numberphile

PS : This is completely opposite to my previous post (and view) but it has many good points and we are here to learn and not to push one's own view of things.

As the history of mathematics shows, zero is a very odd number whose general acceptance is surprisingly recent. However, it is not odd. Perhaps the ambiguity of "odd" causes all the confusion.

Zero is even. An even integer is a number of the form $2n$ where $n$ is also an integer. A number is odd, in the mathematical sense, if it is of the form $2n + 1$ with $n$ an integer.

If zero was odd, we could solve the equation $2x + 1 = 0$ in integers. But the only possible solution is $x = -\frac{1}{2}$, which is a rational number but not an integer.

The set of integers is sometimes said to be "doubly infinite," stretching out to positive infinity in one direction and to negative infinity in the other. If you wanted to, you could say the even numbers start at $-2$ and continue with $-4$, then $-6$, then $-8$, etc.

The AP sequence $$(-6,-4,-2,0,2,4,6)$$ shows that it is even.

If $$k$$ is an even integer, then $$(-1)^ k = 1$$

Division of $$0$$ by $$2$$ leaves no remainder.

&c. are further confirmations.


# Probability of three sequential events

A smuggler wants to transfer his smuggled goods from city A to city B. There are three police check posts between these two cities. Assume that there is no communication among the check posts. The probabilities of him being caught at these three stops are $$0.7, 0.5$$ and $$0.3$$ respectively. What is the probability that he successfully transfers his goods?

• A] $$0.105$$
• B] $$0.5$$
• C] $$0.245$$
• D] $$0.045$$

Is it as simple as calculating success in all three scenarios: $$0.3 * 0.5 * 0.7 = 0.105$$. Is A correct answer ?

• Definitely looks correct to me – gt6989b Nov 25 '18 at 16:41
• Yes, the probability of not being stopped by the three posts equals the probability of not being stopped by any post which is $(1-0.3)(1-0.5)(1-0.7)=0.105$ because they are independent. – BlackMath Nov 25 '18 at 18:17
• It doesn't help this problem that the probability of success at the first post is the probability of failure at the third post, and vice versa. I would argue that makes this a poor problem. But no one here can do anything about that, OP included. – Teepeemm Nov 25 '18 at 19:37

Let $$A_i$$ be an event $$i$$-th police stop him. We are interested in $$P(A_1'\cap A_2'\cap A_3')= P(A_1')P (A_2')P(A_3')= 0.3 \cdot 0.5 \cdot 0.7 = 0.105$$

(since $$A_1, A_2, A_3$$ are independant so are $$A_1', A_2', A_3'$$ ) so your answer is correct.

You can think this in two ways. first way Not being caught on first check post and not being caught on second check post and not being caught on third post. i.e. $$(1-P(A1))×(1-P(A2))×(1-P(A3) = 0.3×0.5×0.7 = 0.105$$

second way Find P(being caught)

Caught on first check post Or Not being caught on first post and caught on second post Or Not being caught on first post and Not being caught on second post and caught on third post.

$$P(A1) + (1-P(A1))(P(A2)) + (1- P(A1))(1- P(A2))(P(A3) =0.7 + 0.3×0.5 + 0.3×0.5×0.3 =0.895$$

Now, P(not being caught) = 1- P(being caught) = 1- 0.895 =0.105


# Prove all derivatives of $f(x)=\frac{1}{1+x}$ by induction

## Problem

Prove all derivatives of: $$f(x)=\frac{1}{1+x}$$ by induction.

## Attempt to solve

I compute few derivatives of $$f(x)$$ so that i can form general expression for induction hypothesis. I compute all derivatives utilizing formula:

$$\frac{d}{dx}x^n=nx^{n-1}$$

First 4 derivatives are:

$$f'(x)=(-1)\cdot(1+x)^{-2}\cdot 1 = -\frac{1}{(1+x)^2}$$ $$f''(x)=(-1)(-2)(1+x)^{-3}\cdot 1 = \frac{2}{(1+x)^3}$$ $$f'''(x)=(-1)(-2)(-3)(1+x)^{-4}\cdot 1 = -\frac{6}{(1+x)^4}$$ $$f''''(x)=(-1)(-2)(-3)(-4)(1+x)^{-5} \cdot 1 = \frac{24}{(1+x)^5}$$

Observe that $$(-1)(-2)(-3)(-4)\dots (-n)$$ can be generalized with:

$$(-1)(-2)(-3)(-4)\dots(-n) = (-1)^n\cdot n!$$

Expression follows factorial of $$n$$ except every other value is positive and every other is negative. If i multiply it by $$(-1)^n$$ it is positive when $$n \mod 2 = 0$$ and negative when $$n \mod 2 \neq 0$$.

Rest of the expression can be generalized as:

$$(1+x)^{-n-1} = (1+x)^{-(n+1)}=\frac{1}{(1+x)^{n+1}}$$

Combining these gives formula in analytic form:

$$f(n)= \frac{(-1)^n \cdot n!}{(1+x)^{n+1}}$$

I can form induction hypothesis such that:

$$\frac{d^n}{dx^n}\frac{1}{1+x} = \frac{(-1)^n\cdot n!}{(1+x)^{n+1}}$$

### Induction proof

Base case

Base case when $$n=0$$:

$$\frac{d^0}{dx^0}\frac{1}{1+x}=\frac{1}{1+x}=\frac{(-1)^0\cdot 0!}{(1+x)^{0+1}}$$

Induction step

$$\frac{d^n}{dx^n}\frac{1}{1+x} =_{\text{ind.hyp}} \frac{(-1)^n\cdot n!}{(1+x)^{n+1+1}}$$

$$\frac{d^n}{dx^n}\frac{1}{1+x} = \frac{(-1)^n\cdot n!}{(1+x)^{n+2}}$$

Now the problem is that formula i used for derivation can only be used recursively. I believe this is correct notation for $$n$$:th derivative but computing one is only defined recursively with formula i used:

$$\frac{d}{dx} x^n = nx^{n-1}$$

Which is not defined for case:

$$\frac{d^n}{dx^n}x^n = \text{ undefined}$$

The idea is to show that this recursion can be expressed in analytical form and it is valid for all $$n\in \mathbb{Z}+$$ by induction. Problem is i don't know how do you express this in recursive form and how do you get from recursion formula to the analytical one.

• All of your work seems fine. I'm not sure why the formula for iterated derivatives of $x^n$ is causing you anxiety, as you're only using it for negative values of $n$ (thus you'll never be in a position of needing the value of $\frac{d^n}{dx^n} x^n$). – Connor Harris Oct 4 '18 at 16:40
• I am not sure why you say that $\frac{d^n}{dx^n}x^n$ is undefined. Simply applying it to a couple of values from $\mathbb{Z}^+$ leads to the intuitive expression $\frac{d^n}{dx^n}x^n=n!$ – mrtaurho Oct 4 '18 at 16:40

$$\frac{d^n}{dx^n}\frac1{1+x}=\frac{(-1)^nn!}{(1+x)^{n+1}}$$

We want to show that

$$\frac{d^{n+1}}{dx^{n+1}}\frac1{1+x}=\frac{(-1)^{n+1}(n+1)!}{(1+x)^{n+2}}$$

Let's verify:

\begin{align} \frac{d^{n+1}}{dx^{n+1}}\frac1{1+x} &=\frac{d}{dx}\left(\frac{d^n}{dx^n}\frac1{1+x} \right)\\ &=\frac{d}{dx}\left(\frac{(-1)^nn!}{(1+x)^{n+1}} \right) \\ &=(-1)^n(n!) \frac{d}{dx}(1+x)^{-(n+1)} \\ &= (-1)^n(n!) (-(n+1)) (1+x)^{-(n+2)}\\ &=\frac{(-1)^{n+1}(n+1)!}{(1+x)^{n+2}} \end{align}

$$\frac{\mathrm d^n}{\mathrm dx^n}\frac{1}{1+x} = \frac{(-1)^n n!}{(1+x)^{n+1}}$$
$$\frac{\mathrm d^{n+1}}{\mathrm dx^{n+1}}f(x)= \frac{\mathrm d}{\mathrm dx}\left( \frac{\mathrm d^n}{\mathrm dx^n}f(x)\right) \quad \forall n \ge 0$$
You inductive hypothesis is that $$\frac{d^nf}{dx^n}=\frac{(-1)^nn!}{(1+x)^{n+1}}.$$
Your inductive step would then be $$\frac{d^{n+1}f}{dx^{n+1}}=\frac d{dx}\,\frac{d^nf}{dx^n}=\frac d{dx}\left(\frac{(-1)^nn!}{(1+x)^{n+1}}\right) =\frac{-(n+1)(-1)^nn!}{(1+x)^{n+2}}=\frac{(-1)^{n+1}(n+1)!}{(1+x)^{n+2}},$$ which shows that the formula holds.


# 5.6. Numerical integration¶

In calculus you learn that the elegant way to evaluate a definite integral is to apply the Fundamental Theorem of Calculus and find an antiderivative. The connection is so profound and pervasive that it’s easy to overlook that a definite integral is a numerical quantity existing independently of antidifferentiation. However, most conceivable integrands have no antiderivative in terms of familiar functions.

Demo 5.6.1

The antiderivative of $$e^x$$ is, of course, itself. That makes evaluation of $$\int_0^1 e^x\,dx$$ by the Fundamental Theorem trivial.

exact = exp(1)-1

1.718281828459045

The Julia package QuadGK has an all-purpose numerical integrator that estimates the value without finding the antiderivative first. As you can see here, it’s often just as accurate.

Q,errest = quadgk(x->exp(x),0,1)
@show Q;

Q = 1.718281828459045

The numerical approach is also far more robust. For example, $$e^{\,\sin x}$$ has no useful antiderivative. But numerically, it’s no more difficult.

Q,errest = quadgk(x->exp(sin(x)),0,1)
@show Q;

Q = 1.6318696084180515

When you look at the graphs of these functions, what’s remarkable is that one of these areas is basic calculus while the other is almost impenetrable analytically. From a numerical standpoint, they are practically the same problem.

plot([exp,x->exp(sin(x))],0,1,fill=0,layout=(2,1),
xlabel=L"x",ylabel=[L"e^x" L"e^{\sin(x)}"],ylim=[0,2.7])

Numerical integration, which also goes by the older name quadrature, is performed by combining values of the integrand sampled at nodes. In this section we will assume equally spaced nodes using the definitions

(5.6.1)$t_i = a +i h, \quad h=\frac{b-a}{n}, \qquad i=0,\ldots,n.$
Definition 5.6.2 :  Numerical integration formula

A numerical integration formula is a list of weights $$w_0,\ldots,w_n$$ chosen so that for all $$f$$ in some class of functions,

(5.6.2)$\begin{split} \int_a^b f(x)\, dx \approx h \sum_{i=0}^n w_if(t_i) = h \bigl[ w_0f(t_0)+w_1f(t_1)+\cdots w_nf(t_n) \bigr], \end{split}$

with the $$t_i$$ defined in (5.6.1). The weights are independent of $$f$$ and $$h$$.

Numerical integration formulas can be applied to sequences of data values even if no function is explicitly known to generate them. For our presentation and implementations, however, we assume that $$f$$ is known and can be evaluated anywhere.

A straightforward way to derive integration formulas is to mimic the approach taken for finite differences: find an interpolant and operate exactly on it.

## Trapezoid formula¶

One of the most important integration formulas results from integration of the piecewise linear interpolant (see Section 5.2). Using the cardinal basis form of the interpolant in (5.2.3), we have

$\int_a^b f(x) \, dx \approx \int_a^b \sum_{i=0}^n f(t_i) H_i(x)\, dx = \sum_{i=0}^n f(t_i) \left[ \int_a^b H_i(x)\right]\, dx.$

Thus we can identify the weights as $$w_i = h^{-1} \int_a^b H_i(x)\, dx$$. Using areas of triangles, it’s trivial to derive that

(5.6.3)$\begin{split}w_i = \begin{cases} 1, & i=1,\ldots,n-1,\\ \frac{1}{2}, & i=0,n. \end{cases}\end{split}$

Putting everything together, the resulting formula is

(5.6.4)$\begin{split} \int_a^b f(x)\, dx \approx T_f(n) &= h\left[ \frac{1}{2}f(t_0) + f(t_1) + f(t_2) + \cdots + f(t_{n-1}) + \frac{1}{2}f(t_n) \right]. \end{split}$
Definition 5.6.3 :  Trapezoid formula

The trapezoid formula is a numerical integration formula in the form (5.6.2), with

$\begin{split} w_i = \begin{cases} \frac{1}{2},& i=0 \text{ or } i=n, \\ 1, & 0 < i < n. \end{cases} \end{split}$

Geometrically, as illustrated in Fig. 5.6.1, the trapezoid formula sums of the areas of trapezoids approximating the region under the curve $$y=f(x)$$.1

The trapezoid formula is the Swiss Army knife of integration formulas. A short implementation is given as Function 5.6.4.

Fig. 5.6.1 Trapezoid formula for integration. The piecewise linear interpolant defines trapezoids that approximate the region under the curve.

Function 5.6.4 :  trapezoid

Trapezoid formula for numerical integration

 1"""
2    trapezoid(f,a,b,n)
3
4Apply the trapezoid integration formula for integrand f over
5interval [a,b], broken up into n equal pieces. Returns
6the estimate, a vector of nodes, and a vector of integrand values at the
7nodes.
8"""
9function trapezoid(f,a,b,n)
10    h = (b-a)/n
11    t = range(a,b,length=n+1)
12    y = f.(t)
13    T = h * ( sum(y[2:n]) + 0.5*(y[1] + y[n+1]) )
14    return T,t,y
15end

Like finite-difference formulas, numerical integration formulas have a truncation error.

Definition 5.6.5 :  Truncation error of a numerical integration formula

For the numerical integration formula (5.6.2), the truncation error is

(5.6.5)$\tau_f(h) = \int_a^b f(x) \, dx - h \sum_{i=0}^{n} w_i f(t_i).$

The order of accuracy is as defined in Definition 5.5.3.

In Theorem 5.2.7 we stated that the pointwise error in a piecewise linear interpolant with equal node spacing $$h$$ is bounded by $$O(h^2)$$ as $$h\rightarrow 0$$. Using $$I$$ to stand for the exact integral of $$f$$ and $$p$$ to stand for the piecewise linear interpolant, we obtain

$\begin{split}\begin{split} I - T_f(n) = I - \int_a^b p(x)\, dx &= \int_a^b \bigl[f(x)-p(x)\bigr] \, dx \\ &\le (b-a) \max_{x\in[a,b]} |f(x)-p(x)| = O(h^2). \end{split}\end{split}$

A more thorough statement of the truncation error is known as the Euler–Maclaurin formula,

(5.6.6)$\begin{split}\int_a^b f(x)\, dx &= T_f(n) - \frac{h^2}{12} \left[ f'(b)-f'(a) \right] + \frac{h^4}{740} \left[ f'''(b)-f'''(a) \right] + O(h^6) \\ &= T_f(n) - \sum_{k=1}^\infty \frac{B_{2k}h^{2k}}{(2k)!} \left[ f^{(2k-1)}(b)-f^{(2k-1)}(a) \right],\end{split}$

where the $$B_{2k}$$ are constants known as Bernoulli numbers. Unless we happen to be fortunate enough to have a function with $$f'(b)=f'(a)$$, we should expect truncation error at second order and no better.

Observation 5.6.6

The trapezoid integration formula is second-order accurate.

Demo 5.6.7

We will approximate the integral of the function $$f(x)=e^{\sin 7x}$$ over the interval $$[0,2]$$.

f = x -> exp(sin(7*x));
a = 0;  b = 2;

In lieu of the exact value, we use the QuadGK package to find an accurate result.

If a function has multiple return values, you can use an underscore _ to indicate a return value you want to ignore.

Q,_ = quadgk(f,a,b,atol=1e-14,rtol=1e-14);
println("Integral = \$Q")

Integral = 2.6632197827615394

Here is the trapezoid result at $$n=40$$, and its error.

T,t,y = FNC.trapezoid(f,a,b,40)
@show (T,Q-T);

(T, Q - T) = (2.662302935602287, 0.0009168471592522209)

In order to check the order of accuracy, we increase $$n$$ by orders of magnitude and observe how the error decreases.

n = [ 10^n for n in 1:5 ]
err = []
for n in n
T,t,y = FNC.trapezoid(f,a,b,n)
push!(err,Q-T)
end

pretty_table([n err],["n","error"])

┌────────┬─────────────┐
│      n │       error │
├────────┼─────────────┤
│     10 │   0.0120254 │
│    100 │ 0.000147305 │
│   1000 │  1.47415e-6 │
│  10000 │  1.47416e-8 │
│ 100000 │ 1.47417e-10 │
└────────┴─────────────┘

Each increase by a factor of 10 in $$n$$ cuts the error by a factor of about 100, which is consistent with second-order convergence. Another check is that a log-log graph should give a line of slope $$-2$$ as $$n\to\infty$$.

plot(n,abs.(err),m=:o,label="results",
xaxis=(:log10,L"n"),yaxis=(:log10,"error"),
title="Convergence of trapezoidal integration")

# Add line for perfect 2nd order.
plot!(n,3e-3*(n/n[1]).^(-2),l=:dash,label=L"O(n^{-2})")

## Extrapolation¶

If evaluations of $$f$$ are computationally expensive, we want to get as much accuracy as possible from them by using a higher-order formula. There are many routes for doing so; for example, we could integrate a not-a-knot cubic spline interpolant. However, splines are difficult to compute by hand, and as a result different methods were developed before computers came on the scene.

Knowing the structure of the error allows the use of extrapolation to improve accuracy. Suppose a quantity $$A_0$$ is approximated by an algorithm $$A(h)$$ with an error expansion

(5.6.7)$A_0 = A(h) + c_1 h + c_2 h^2 + c_3 h^3 + \cdots.$

Crucially, it is not necessary to know the values of the error constants $$c_k$$, merely that they exist and are independent of $$h$$.

Using $$I$$ for the exact integral of $$f$$, the trapezoid formula has

$I = T_f(n) + c_2 h^2 + c_4 h^{4} + \cdots,$

as proved by the Euler–Maclaurin formula (5.6.6). The error constants depend on $$f$$ and can’t be evaluated in general, but we know that this expansion holds. For convenience we recast the error expansion in terms of $$n=O(h^{-1})$$:

(5.6.8)$I = T_f(n) + c_2 n^{-2} + c_4 n^{-4} + \cdots.$

We now make the simple observation that

(5.6.9)$I = T_f(2n) + \tfrac{1}{4} c_2 n^{-2} + \tfrac{1}{16} c_4 n^{-4} + \cdots.$

It follows that if we combine (5.6.8) and (5.6.9) correctly, we can cancel out the second-order term in the error. Specifically, define

(5.6.10)$S_f(2n) = \frac{1}{3} \Bigl[ 4 T_f(2n) - T_f(n) \Bigr].$

(We associate $$2n$$ rather than $$n$$ with the extrapolated result because of the total number of nodes needed.) Then

(5.6.11)$I = S_f(2n) + O(n^{-4}) = b_4 n^{-4} + b_6 n^{-6} + \cdots.$

The formula (5.6.10) is called Simpson’s formula, or Simpson’s rule. A different presentation and derivation are considered in Exercise 4.

Equation (5.6.11) is another particular error expansion in the form (5.6.7), so we can extrapolate again! The details change only a little. Considering that

$I = S_f(4n) = \tfrac{1}{16} b_4 n^{-4} + \tfrac{1}{64} b_6 n^{-6} + \cdots,$

the proper combination this time is

(5.6.12)$R_f(4n) = \frac{1}{15} \Bigl[ 16 S_f(4n) - S_f(2n) \Bigr],$

which is sixth-order accurate. Clearly the process can be repeated to get eighth-order accuracy and beyond. Doing so goes by the name of Romberg integration, which we will not present in full generality.

## Node doubling¶

Note in (5.6.12) that $$R_f(4n)$$ depends on $$S_f(2n)$$ and $$S_f(4n)$$, which in turn depend on $$T_f(n)$$, $$T_f(2n)$$, and $$T_f(4n)$$. There is a useful benefit realized by doubling of the nodes in each application of the trapezoid formula. As shown in Fig. 5.6.2, when doubling $$n$$, only about half of the nodes are new ones, and previously computed function values at the other nodes can be reused.

Fig. 5.6.2 Dividing the node spacing by half introduces new nodes only at midpoints, allowing the function values at existing nodes to be reused for extrapolation.

Specifically, we have

(5.6.13)$\begin{split}\begin{split} T_f(2m) & = \frac{1}{2m} \left[ \frac{1}{2} f(a) + \frac{1}{2} f(b) + \sum_{i=1}^{2m-1} f\Bigl( a + \frac{i}{2m} \Bigr) \right]\\[1mm] & = \frac{1}{2m} \left[ \frac{1}{2} f(a) + \frac{1}{2} f(b)\right] + \frac{1}{2m} \sum_{k=1}^{m-1} f\Bigl( a+\frac{2k}{2m} \Bigr) + \frac{1}{2m} \sum_{k=1}^{m} f\Bigl( a+\frac{2k-1}{2m} \Bigr) \\[1mm] &= \frac{1}{2m} \left[ \frac{1}{2} f(a) + \frac{1}{2} f(b) + \sum_{k=1}^{m-1} f\Bigl( a+\frac{k}{m} \Bigr) \right] + \frac{1}{2m} \sum_{k=1}^{m} f\Bigl( a+\frac{2k-1}{2m} \Bigr) \\[1mm] &= \frac{1}{2} T_f(m) + \frac{1}{2m} \sum_{k=1}^{m-1} f\left(t_{2k-1} \right), \end{split}\end{split}$

where the nodes referenced in the last line are relative to $$n=2m$$. Hence in passing from $$n=m$$ to $$n=2m$$, new integrand evaluations are needed only at the odd-numbered nodes of the finer grid.

Demo 5.6.8

We estimate $$\displaystyle\int_0^2 x^2 e^{-2x}\, dx$$ using extrapolation. First we use quadgk to get an accurate value.

f = x -> x^2*exp(-2*x);
a = 0;  b = 2;
@show Q;

Q = 0.1904741736116139

We start with the trapezoid formula on $$n=N$$ nodes.

N = 20;       # the coarsest formula
n = N;  h = (b-a)/n;
t = h*(0:n);   y = f.(t);

We can now apply weights to get the estimate $$T_f(N)$$.

T = [ h*(sum(y[2:n]) + y[1]/2 + y[n+1]/2) ]

1-element Vector{Float64}:
0.19041144993926787

Now we double to $$n=2N$$, but we only need to evaluate $$f$$ at every other interior node and apply (5.6.13).

n = 2n;  h = h/2;  t = h*(0:n);
T = [ T; T[end]/2 + h*sum( f.(t[2:2:n]) ) ]

2-element Vector{Float64}:
0.19041144993926787
0.19045880585951175

We can repeat the same code to double $$n$$ again.

n = 2n;  h = h/2;  t = h*(0:n);
T = [ T; T[end]/2 + h*sum( f.(t[2:2:n]) ) ]

3-element Vector{Float64}:
0.19041144993926787
0.19045880585951175
0.1904703513046443

Let us now do the first level of extrapolation to get results from Simpson’s formula. We combine the elements T[i] and T[i+1] the same way for $$i=1$$ and $$i=2$$.

S = [ (4T[i+1]-T[i])/3 for i in 1:2 ]

2-element Vector{Float64}:
0.19047459116625973
0.19047419978635513

With the two Simpson values $$S_f(N)$$ and $$S_f(2N)$$ in hand, we can do one more level of extrapolation to get a sixth-order accurate result.

R = (16S[2] - S[1]) / 15

0.1904741736943615

We can make a triangular table of the errors:

The value nothing equals nothing except nothing.

err = [ T.-Q [nothing;S.-Q] [nothing;nothing;R-Q] ]
pretty_table(err,["order 2","order 4","order 6"])

┌─────────────┬────────────┬─────────────┐
│     order 2 │    order 4 │     order 6 │
├─────────────┼────────────┼─────────────┤
│ -6.27237e-5 │    nothing │     nothing │
│ -1.53678e-5 │ 4.17555e-7 │     nothing │
│ -3.82231e-6 │ 2.61747e-8 │ 8.27476e-11 │
└─────────────┴────────────┴─────────────┘

If we consider the computational time to be dominated by evaluations of $$f$$, then we have obtained a result with about twice as many accurate digits as the best trapezoid result, at virtually no extra cost.

## Exercises¶

1. ⌨ For each integral below, use Function 5.6.4 to estimate the integral for $$n=10\cdot 2^k$$ nodes for $$k=1,2,\ldots,10$$. Make a log-log plot of the errors and confirm or refute second-order accuracy. (These integrals were taken from [BJL05].)

(a) $$\displaystyle \int_0^1 x\log(1+x)\, dx = \frac{1}{4}$$

(b) $$\displaystyle \int_0^1 x^2 \tan^{-1}x\, dx = \frac{\pi-2+2\log 2}{12}$$

(c) $$\displaystyle \int_0^{\pi/2}e^x \cos x\, dx = \frac{e^{\pi/2}-1}{2}$$

(d) $$\displaystyle \int_0^1 \sqrt{x} \log(x) \, dx = -\frac{4}{9}$$ (Note: Although the integrand has the limiting value zero as $$x\to 0$$, it cannot be evaluated naively at $$x=0$$. You can start the integral at $$x=\macheps$$ instead.)

(e) $$\displaystyle \int_0^1 \sqrt{1-x^2}\,\, dx = \frac{\pi}{4}$$

2. ✍ The Euler–Maclaurin error expansion (5.6.6) for the trapezoid formula implies that if we could cancel out the term due to $$f'(b)-f'(a)$$, we would obtain fourth-order accuracy. We should not assume that $$f'$$ is available, but approximating it with finite differences can achieve the same goal. Suppose the forward difference formula (5.4.8) is used for $$f'(a)$$, and its reflected backward difference is used for $$f'(b)$$. Show that the resulting modified trapezoid formula is

(5.6.14)$G_f(h) = T_f(h) - \frac{h}{24} \left[ 3\Bigl( f(t_n)+f(t_0) \Bigr) -4\Bigr( f(t_{n-1}) + f(t_1) \Bigr) + \Bigl( f(t_{n-2})+f(t_2) \Bigr) \right],$

which is known as a Gregory integration formula.

3. ⌨ Repeat each integral in Exercise 1 above using Gregory integration (5.6.14) instead of the trapezoid formula. Compare the observed errors to fourth-order convergence.

4. ✍ Simpson’s formula can be derived without appealing to extrapolation.

(a) Show that

$p(x) = \beta + \frac{\gamma-\alpha}{2h}\, x + \frac{\alpha-2\beta+\gamma}{2h^2}\, x^2$

interpolates the three points $$(-h,\alpha)$$, $$(0,\beta)$$, and $$(h,\gamma)$$.

(b) Find

$\int_{-h}^h p(s)\, ds,$

where $$p$$ is the quadratic polynomial from part (a), in terms of $$h$$, $$\alpha$$, $$\beta$$, and $$\gamma$$.

(c) Assume equally spaced nodes in the form $$t_i=a+ih$$, for $$h=(b-a)/n$$ and $$i=0,\ldots,n$$. Suppose $$f$$ is approximated by $$p(x)$$ over the subinterval $$[t_{i-1},t_{i+1}]$$. Apply the result from part (b) to find

$\int_{t_{i-1}}^{t_{i+1}} f(x)\, dx \approx \frac{h}{3} \bigl[ f(t_{i-1}) + 4f(t_i) + f(t_{i+1}) \bigr].$

(Use the change of variable $$s=x-t_i$$.)

(d) Now also assume that $$n=2m$$ for an integer $$m$$. Derive Simpson’s formula,

(5.6.15)$\begin{split} \begin{split} \int_a^b f(x)\, dx \approx \frac{h}{3}\bigl[ &f(t_0) + 4f(t_1) + 2f(t_2) + 4f(t_3) + 2f(t_4) + \cdots\\ &+ 2f(t_{n-2}) + 4f(t_{n-1}) + f(t_n) \bigr]. \end{split}\end{split}$
5. ✍ Show that the Simpson formula (5.6.15) is equivalent to $$S_f(n/2)$$, given the definition of $$S_f$$ in (5.6.10).

6. ⌨ For each integral in Exercise 1 above, apply the Simpson formula (5.6.15) and compare the errors to fourth-order convergence.

7. ⌨ For $$n=10,20,30,\ldots,200$$, compute the trapezoidal approximation to

$\int_{0}^1 \frac{1}{2.01+\sin (6\pi x)-\cos(2\pi x)} \,d x \approx 0.9300357672424684.$

Make two separate plots of the absolute error as a function of $$n$$, one using a log-log scale and the other using log-linear. The graphs suggest that the error asymptotically behaves as $$C \alpha^n$$ for some $$C>0$$ and some $$0<\alpha<1$$. How does this result relate to (5.6.6)?

8. ⌨ For each integral in Exercise 1 above, extrapolate the trapezoidal results two levels to get sixth-order accurate results, and compute the errors for each value.

9. ✍ Find a formula like (5.6.12) that extrapolates two values of $$R_f$$ to obtain an eighth-order accurate one.

1

Some texts distinguish between a formula for a single subinterval $$[t_{k-1},t_k]$$ and a composite formula that adds them up over the whole interval to get (5.6.4).


# Combinations: 10 people divided in to two groups, one of 6 and one of 4?

I only know the very basic formula for combinations: (n r)= n!/[r! (n-r)!]

I've looked at similar problems on this website, but I'm having trouble understanding how these problems are done exactly:

"In how many ways can 10 people be divided into two groups (one group of 6 and one group of four)?"

my sad attempt: (10 6) (4 4) = (10!/6!)*(4!/4!) = 5040???

I'd really appreciate it if someone could explain how to go about doing this step by step.

I will try to show to you, visually, a direct interpretation of the problem.

First of all you must notice that one of the main meaning of a factorial is the number of permutations of n different elements over n positions.

By example the number of permutations of the string $ABCDE$ is $5!=5\cdot 4\cdot 3\cdot 2\cdot 1$ (ways to order 5 different elements over 5 different positions).

A direct interpretation of your problem, trough permutations, is that you have a string of 10 different elements, e.g. $ABCDEFGHIJK$ or $0123456789$, and you divide this string in two groups: one of length $4$ (i.e. cardinality 4) and other of length $6$

$$\overbrace{ABCD}\ \overbrace{EFGHIJK}$$

You have $10!$ ways to order a string of 10 different elements, after you can divide each of these string on 2 groups of length $4$ and $6$. But you doenst care the order of each group, for your problem $AKJG=JAKG=GKAJ$. The number of ways to order a string of length $4$ is $4!$. The same for your string of length $6$, so you must eliminate all of these duplicates.

So you will have $\frac{10!}{4!\cdot 6!}$ ways to form these different groups of 4 and 6 people. For this problem, because the binomial coefficient is defined as $\binom{n}{k}=\frac{n!}{k!\cdot (n-k)!}$ then $\frac{10!}{4!\cdot 6!}=\binom{10}{4}$.

This is a direct interpretation of the problem using the meaning of factorial as number of permutations of n elements over n positions.

I will add an alternative, faster, way to interpret visually this problem.

First of all I will expand the meaning of factorial as the permutations of n different elements over n positions. If you have n elements (or objects) for the position one you can choose between n elements to put, for the second position you can choose between $n-1$ elements (because you have already one element on position 1). For position 3 you can choose between $n-2$ elements (because you have, already, some element on position 1 and 2), etc., etc., etc...

So the permutations will be $n\cdot (n-1)\cdot (n-2)\cdot (n-3)\cdots 1=n!$

Now our case: we have 10 people, and you want to see the different ways that you can group them in 6 and 4. The ordered ways for a group of 6 will be: for position 1 you can choose between 10, for position 2 between 9, ..., for position 6 between 5, i.e. $10\cdot9\cdot8\cdot7\cdot6\cdot5=(10)_6=\frac{10!}{4!}$ (the expression $(n)_k$ is named falling factorial).

But this is the expression of ordered positions. To have the unordered positions you must divide between the different ways to order 6 different elements on 6 positions, i.e. divide between $6!$. So the unordered ways to group 10 different elements in a group of 6 is $\frac{(10)_6}{6!}=\binom{10}{6}$.

But, what happen with the other group of length 4? For every group of length 6 we will have a unordered group of 4 so the total amounts to divide a group of 10 people in two groups of 6 and 4 is $\binom{10}{6}\cdot1=\binom{10}{6}$.

$$\binom{10}{6} = \frac{10!}{6!\,4!} = \frac{10\cdot9\cdot8\cdot7\cdot\overbrace{6\cdot5\cdot4\cdot3\cdot2\cdot1}}{4\cdot3\cdot2\cdot1\cdot\underbrace{6\cdot5\cdot4\cdot3\cdot2\cdot1}} = \frac{10\cdot9\cdot8\cdot7}{4\cdot3\cdot2\cdot1}$$ Since $8$ cancels $4\cdot2$ and $\dfrac 9 3=3$, this reduces to $10\cdot3\cdot7$.

(If you wanted two groups of $5$ then you'd do a similar thing but you'd divide by $2$ when you're done, because one set of $5$ and its complementary set of the other $5$ would be the same way of dividing the set of $10$ into two sets of $5$. But that doesn't happen with $4$ and $6$ since $4\ne6$.)

• Worth noting that it is equivalent to ${10 \choose 4}{6 \choose 6}$. – miniparser Nov 2 '14 at 20:01


# Division by zero

• B
Hi.
x2 = x3 / x but x2 is defined for all x and equals zero at x=0 but what happens for x3 / x at x=o ? Is it defined at x=o ? Does it equal zero ? If not what is causing this anomaly ?
Thanks

phinds
Gold Member
N/0 is undefined regardless of N. If you assume otherwise, you can prove n=m where n and m are any arbitrary and different numbers.

fresh_42
Mentor
Hi.
x2 = x3 / x but x2 is defined for all x and equals zero at x=0 but what happens for x3 / x at x=o ? Is it defined at x=o ? Does it equal zero ? If not what is causing this anomaly ?
Thanks
##x \longmapsto x ## is everywhere continuous, ##x\longmapsto \dfrac{x^3}{x^2}## is not; at ##x=0\,.##

Although this is a removable singularity, it still is one, a gap. Algebraically division by zero isn't defined, simply because zero isn't part of any multiplicative group. The question never arises. It's like discussing the height of an apple tree on the moon.

jim mcnamara
FactChecker
Gold Member
When people write ## x = \frac {x^3}{x}## with no restriction that ## x \ne 0 ##, they are being (understandably) careless. The proper way is to keep track of all those divisions by zero and make sure that the results are still legitimate when the simplified equations are used. Otherwise, rule those points out. In physical applications, the continuity and nice behavior of the reduced formula, ##x##, at 0 makes it likely to also be valid at that point (##x = 0##).

So x = x3 / x2 is not a correct statement on its own ? It needs the addition of the statement " x not equal to 0 " ?
I have seen the following statement in textbooks " xn / xm = xn-m " with no mention of " x not equal to 0 ". Are they just being lazy and missing out the " x not equal to 0 " statement ?

fresh_42
Mentor
So x = x3 / x2 is not a correct statement on its own ? It needs the addition of the statement " x not equal to 0 " ?
Strictly, yes. But as it isn't defined for ##x=0## it is implicitly clear. As long as you don't want to write unnecessary additional lines, just leave it. Who writes ##x\geq 0## if he uses ##\sqrt{x}\,?## This is simply self-evident, resp. clear by context. But logically, the domain of ##x## needs to be mentioned in general, such that we know what the function really is. But in your post it was pretty clear what you meant even without it.
I have seen the following statement in textbooks " xn / xm = xn-m " with no mention of " x not equal to 0 ". Are they just being lazy and missing out the " x not equal to 0 " statement ?
See above. It is simply not necessary as long as you don't write a book on logic. It's like mocking about a Pizza guy not telling you it's hot. However, if you talk about specific functions, you better say where and how they are defined. E.g. you could define
$$f(x) = \begin{cases}\dfrac{x^3}{x^2} \,&,\, x\neq 0 \\ 0\,&\,,x=0\end{cases}$$
or simply
$$f(x)= \dfrac{x^3}{x^2}\; , \;x\neq 0$$
which will be two different functions. So as always with written things, it depends on what you want to express. In post #1 and the example you gave it isn't necessary. Mocking about it is nit-picking.


It is currently 18 Oct 2017, 04:52

### 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

# Events & Promotions

###### Events & Promotions in June
Open Detailed Calendar

### Show Tags

17 Sep 2017, 13:45
Top Contributor
5
This post was
BOOKMARKED
00:00

Difficulty:

15% (low)

Question Stats:

79% (01:58) correct 21% (01:31) wrong based on 48 sessions

### HideShow timer Statistics

A purse contains 5-cent coins and 10-cent coins worth a total of $1.75. If the 5-cent coins were replaced with 10-cent coins and the 10-cent coins were replaced with 5-cent coins, the coins would be worth a total of$2.15. How many coins are in the purse?

A. 26
B. 27
C. 28
D. 29
E. 30
[Reveal] Spoiler: OA

_________________

Kudos [?]: 1449 [0], given: 270

Intern
Joined: 26 Jul 2017
Posts: 18

Kudos [?]: 10 [1], given: 25

Location: India

### Show Tags

17 Sep 2017, 19:53
Let the total 5 cent coins be x, and the 10 cent coins be y

From the question stem, $$5x + 10y = 175$$
Value of y(by the following equation) : $$y = \frac{175 - 5x}{10}$$

Substituting this value of y in the second equation
$$10x + \frac{5(175 - 5x)}{10} = 215$$
$$100x + 875 - 25x = 2150$$
$$75x = 1275$$
$$x = 17$$

Substituting this value of x in equation$$5x+10y = 175$$
$$85 + 10y = 175$$
$$y = 9$$

Therefore the sum of coins in the p = 17 + 9 = 26(Option A)
_________________

Stay hungry, Stay foolish

Kudos [?]: 593 [0], given: 16

Director
Joined: 22 May 2016
Posts: 806

Kudos [?]: 258 [0], given: 546

A purse contains 5-cent coins and 10-cent coins worth a total of $1.75 [#permalink] ### Show Tags 17 Sep 2017, 21:26 Gnpth wrote: A purse contains 5-cent coins and 10-cent coins worth a total of$1.75. If the 5-cent coins were replaced with 10-cent coins and the 10-cent coins were replaced with 5-cent coins, the coins would be worth a total of $2.15. How many coins are in the purse? A. 26 B. 27 C. 28 D. 29 E. 30 I solved with two variables, and it works, but I have a question about my own method that applies to vishalbalwani 's method, too. Let A = the number of 5-cent coins Let B = the number of 10- cent coins In one scenario, the coins, in their respective unknown quantities, total$1.75

In a second scenario, the 5-cent coins and 10-cent coins exchange quantities exactly, and they total $2.15 5A + 10B = 175 (P) 10A + 5B = 215 (Q) Multiply (Q) by two, and subtract (P) 20 A + 10B = 430 __5A + 10B = 175 15A = 255 A = 17 There are 17 coins worth 5 cents. Use (P) to find the number of 10-cent pieces 5(17) + 10B = 175 10B = 90 B = 9 There are 9 coins worth 19 0 cents. A = 17, B = 9, total = 26 coins Answer A I have run this problem three ways, including vishalbalwani 's, and working from answer choices. This combination (number of coins), is the only one that works. Question: Is the method sound? The variables work, but they seem inconsistent. I use A as a quantity for 5-cent coins. The coefficients of the variables -- 5 and 10 -- are the values of the coins in cents. But in the second equation, (Q) I do not think I have switched quantities, per the prompt. I think have switched values. In the second equation, (Q), the 5, a value, is in front of B -- which is supposed to be the quantity of 10-cent coins. vishalbalwani did the same. What am I missing? We are supposed to be switching quantities. But switching values works. I think pushpitkc avoids the whole problem by immediately defining y in terms of x from one equation. Is my method sound? Kudos [?]: 258 [0], given: 546 Target Test Prep Representative Status: Founder & CEO Affiliations: Target Test Prep Joined: 14 Oct 2015 Posts: 1634 Kudos [?]: 837 [0], given: 2 Location: United States (CA) Re: A purse contains 5-cent coins and 10-cent coins worth a total of$1.75 [#permalink]

### Show Tags

22 Sep 2017, 07:49
Gnpth wrote:
A purse contains 5-cent coins and 10-cent coins worth a total of $1.75. If the 5-cent coins were replaced with 10-cent coins and the 10-cent coins were replaced with 5-cent coins, the coins would be worth a total of$2.15. How many coins are in the purse?

A. 26
B. 27
C. 28
D. 29
E. 30

We can create two equations in which a = the initial number of 5-cent coins and b = the initial number of 10-cent coins. We can create the “money” equation by recalling that a 5-cent coin is $0.05 and a 10-cent coin is$0.10; thus:

0.05a + 0.1b = 1.75

And, after we reverse the coinage, we have:

0.1a + 0.05b = 2.15

Multiplying the first equation by -2, we have:

-0.1a - 0.2b = -3.50

Adding the two equations, we have:

-0.15b = -1.35

b = 9

Thus:

0.05a + (0.1)(9) = 1.75

0.05a = 0.85

a = 17

So, there is a total of 17 + 9 = 26 coins.

_________________

Scott Woodbury-Stewart
Founder and CEO

GMAT Quant Self-Study Course
500+ lessons 3000+ practice problems 800+ HD solutions

Kudos [?]: 837 [0], given: 2

Director
Joined: 22 May 2016
Posts: 806

Kudos [?]: 258 [0], given: 546

A purse contains 5-cent coins and 10-cent coins worth a total of $1.75 [#permalink] ### Show Tags 22 Sep 2017, 08:38 ScottTargetTestPrep wrote: Gnpth wrote: A purse contains 5-cent coins and 10-cent coins worth a total of$1.75. If the 5-cent coins were replaced with 10-cent coins and the 10-cent coins were replaced with 5-cent coins, the coins would be worth a total of $2.15. How many coins are in the purse? A. 26 B. 27 C. 28 D. 29 E. 30 We can create two equations in which a = the initial number of 5-cent coins and b = the initial number of 10-cent coins. We can create the “money” equation by recalling that a 5-cent coin is$0.05 and a 10-cent coin is $0.10; thus: 0.05a + 0.1b = 1.75 And, after we reverse the coinage, we have: 0.1a + 0.05b = 2.15 Multiplying the first equation by -2, we have: -0.1a - 0.2b = -3.50 Adding the two equations, we have: -0.15b = -1.35 b = 9 Thus: 0.05a + (0.1)(9) = 1.75 0.05a = 0.85 a = 17 So, there is a total of 17 + 9 = 26 coins. Answer: A ScottTargetTestPrep , where you reverse the coinage, what do variables $$a$$ and $$b$$ stand for? (I had the same question about my own method, above.) Perhaps the variables stand simply for the total number of coins, and absent any total number of coins, we cannot write one variable in terms of another. Conceptually, however, that reasoning does not make a lot of sense to me. We have two unknown quantities in two scenarios. In the first equation, the quantity b is defined as the number of$0.10 coins (and qty "a" initially is # of $.05 coins) If "b" then switches to the number of$0.05 coins (vice versa for "a"), how are those two a's and b's the same, such that we can use them as an identity in solving two equations?

Sorry if this question is sophomoric; usually I can find my way out of a muddle. Not this time.

Kudos [?]: 258 [0], given: 546

Math Forum Moderator
Joined: 02 Aug 2009
Posts: 4969

Kudos [?]: 5458 [1], given: 112

### Show Tags

01 Oct 2017, 12:26
1
KUDOS
Expert's post
genxer123 wrote:
ScottTargetTestPrep wrote:
Gnpth wrote:
A purse contains 5-cent coins and 10-cent coins worth a total of $1.75. If the 5-cent coins were replaced with 10-cent coins and the 10-cent coins were replaced with 5-cent coins, the coins would be worth a total of$2.15. How many coins are in the purse?

A. 26
B. 27
C. 28
D. 29
E. 30

We can create two equations in which a = the initial number of 5-cent coins and b = the initial number of 10-cent coins. We can create the “money” equation by recalling that a 5-cent coin is $0.05 and a 10-cent coin is$0.10; thus:

0.05a + 0.1b = 1.75

And, after we reverse the coinage, we have:

0.1a + 0.05b = 2.15

Multiplying the first equation by -2, we have:

-0.1a - 0.2b = -3.50

Adding the two equations, we have:

-0.15b = -1.35

b = 9

Thus:

0.05a + (0.1)(9) = 1.75

0.05a = 0.85

a = 17

So, there is a total of 17 + 9 = 26 coins.

ScottTargetTestPrep , where you reverse the coinage, what do variables $$a$$ and $$b$$ stand for? (I had the same question about my own method, above.)

Perhaps the variables stand simply for the total number of coins, and absent any total number of coins, we cannot write one variable in terms of another.

Conceptually, however, that reasoning does not make a lot of sense to me.

We have two unknown quantities in two scenarios. In the first equation, the quantity b is defined as the number of $0.10 coins (and qty "a" initially is # of$.05 coins)

If "b" then switches to the number of $0.05 coins (vice versa for "a"), how are those two a's and b's the same, such that we can use them as an identity in solving two equations? Sorry if this question is sophomoric; usually I can find my way out of a muddle. Not this time. The variables a and b stand for the initial number of 5- and 10-cent coins, before and after reversing the coinage. The only thing that changes when the coinage is reversed is that the number of 5-cent coins is now b and the number of 10-cent coins is now a. _________________ Scott Woodbury-Stewart Founder and CEO GMAT Quant Self-Study Course 500+ lessons 3000+ practice problems 800+ HD solutions Kudos [?]: 837 [1], given: 2 Re: A purse contains 5-cent coins and 10-cent coins worth a total of$1.75   [#permalink] 01 Oct 2017, 12:26
Display posts from previous: Sort by

# A purse contains 5-cent coins and 10-cent coins worth a total of \$1.75

 Powered by phpBB © phpBB Group | Emoji artwork provided by EmojiOne Kindly note that the GMAT® test is a registered trademark of the Graduate Management Admission Council®, and this site has neither been reviewed nor endorsed by GMAC®.


Relation between real roots of a polynomial and real roots of its derivative

I have this question which popped in my mind while solving questions of maxima and minima. First Case:Let $f(x)$ be an $n$ degree polynomial which has $r$ real roots. Using this can we say anything about the number of real roots of $f'(x)$?

Second Case:Suppose, $f(x)$ has all $n$ real roots. Then will all of its derivatives also have all real roots?

Also, if any of its derivatives do not have all real roots, then will $f(x)$ also have not all real roots? If the above is true then what about its converse?

Comment Case:For the third case:Suppose f'(x) is a 5 degree polynomial with 3 real roots.Then f(x) will be a 6 degree polynomial.(correct me if I am wrong).What are the possible no. of roots that f(x) can have(3,4,5 etc.?).Basically I am asking for an example.Also it would be great if you follow all cases with an example like in the 4th case.

• I don't understand the beginning. If $f(x)$ is an n-degree polynomial with $r$ real roots, then it is not the case that $f'(x)$ will have $(r-1)$ real roots. Consider $f(x) = x^2 +1$. Here $r = 0$, but $f'(x) = 2x$ which has 1 root at 0. Jul 23 '15 at 19:35
• Sorry I never realized that.I just said what I was taught.Now I know it was incorrect.I have edited it. But I dont understand why the question has been downvoted? Jul 23 '15 at 19:49
• You're probably being downvoted for not providing any work/ideas for your question. Jul 23 '15 at 20:22
• This is of interest: en.wikipedia.org/wiki/Gauss%E2%80%93Lucas_theorem Jul 23 '15 at 21:48

First case: If the number of real roots $r$ of $f(x)$ is greater than one, then $f'(x)$ has at least $r-1$ real roots. (The limitation "greater than one" is not necessary but the statement is trivial if $r\le 1$.) Given any two roots $a<b$ of $f(x)$, $f$ is continuous and differentiable on $[a,b]$, so by Rolle's theorem $f'(c)=0$ for some $a<c<b$.

There may be more roots of $f'(x)$ than those between roots of $f(x)$, so the only upper bound is the obvious one of $n-1$. Ask if you need examples. It seems to me that if multiplicity is taken into account that the number of real roots of $f'(x)$ has the same parity (even/odd) as the number of real roots of $f(x)$, but I haven't proven it yet. If multiplicity is not taken into account, the parity can be anything.

Second case: If $f(x)$ has degree $n$ and has $n$ real roots, then each consecutive pair of roots of $f(x)$ defines a root of $f'(x)$, which makes $n-1$ roots of $f'(x)$. Since $f'(x)$ is a polynomial of degree $n-1$, this is all possible roots. This continues for all later derivatives, so you are correct: all its derivatives will have all real roots.

Third case: The contrapositive of the second case tells us that if any of its derivatives have any non-real roots, then $f(x)$ also has some non-real roots.

Fourth case: The converse of the third case is not true. For example, $f(x)=x^2+1$ has two non-real roots, but its derivative $f'(x)=2x$ has one real root.

Comment case: You asked, "Suppose $f'(x)$ is a $5$ degree polynomial with $3$ real roots. What are the possible no. of roots that $f(x)$ can have($3,4,5$ etc.?)."

The formulas for $f(x)$ and $f'(x)$ are given in the diagram, where $C$ is a real constant, zero in the graph. You can see that $f'(x)$ is a degree $5$ polynomial with $3$ real roots.

The dashed horizontal lines show the possible number of real roots of $f(x)$ for varying values of $C$. There are $0$ real roots for $C=3$, $1$ real root for $C\approx. 2.638$, $2$ real roots for $C=1$, $3$ real roots for $C\approx -1.757$, and $4$ real roots for $C=-1.9$. My discussion for the first case shows that there cannot be more than $4$ real roots since $f'(x)$ has $3$ real roots.

• For the third case:Suppose f'(x) is a 5 degree polynomial with 3 real roots.Then f(x) will be a 6 degree polynomial.(correct me if I am wrong).What are the possible no. of roots that f(x) can have(3,4,5 etc.?).Basically I am asking for an example.Also it would be great if you follow all cases with an example like in the 4th case. Jul 23 '15 at 20:40

First, notice that if any differentiable function $f(x)$ has $r$ real (distinct) roots, then $f'(x)$ must have at least $r-1$ distinct roots. This follows from the following:

Suppose that $a_1<...<a_r$ are (distinct) roots from $f(x)$ and $i \in \{1,...,r-1\}$. Then consider every interval of the form $[a_i,a_{i+1}]$. Since this interval is compact, any function on this interval achieves a maximum/minimum. Each minimum/maximum (depending on whether the function $f$ is dipping below or above the real line) corresponds to a root of $f'(x)$. Since we have $r -1$ such intervals, we have at least $r-1$ roots.

Since all polynomials are differentiable, we notice that if $f(x)$ has $r$ (distinct) roots, then $f'(x)$ has at least $r - 1$ distinct roots.

Your question isn't the clearest, but maybe someone else can come up with a better question to answer 1.

If a polynomial $f(x)$ is degree $n$ and has $n$ (distinct) real roots, then using the argument above (as well as the fundamental theorem of algebra (that might be over-kill, but oh well)), you can conclude that $f'(x)$ has exactly $n-1$ real roots.

Given this work, you can figure out 3 with the case for (distinct) roots.


# How many significant digits are in 1040. and 1040.0?

#### Indranil

##### Junior Member
How many significant digits are in 1040. and 1040.0? I am confused

#### Dr.Peterson

##### Elite Member
How many significant digits are in 1040. and 1040.0? I am confused
It will help if you state your specific confusion. What possibilities do you see for the answers? What about it are you unsure of?

#### Indranil

##### Junior Member
It will help if you state your specific confusion. What possibilities do you see for the answers? What about it are you unsure of?
Do 1040. has four significant digits and 1040.0 has five significant digits?

#### Dr.Peterson

##### Elite Member
Do 1040. has four significant digits and 1040.0 has five significant digits?
That's right. You aren't really confused, just perhaps uncertain.

When there is a decimal point present, all digits from the first non-zero digit on the left to the last written digit on the right are significant.

#### Subhotosh Khan

##### Super Moderator
Staff member
Do 1040. has four significant digits and 1040.0 has five significant digits?
And 1040 (without decimal point) has three significant digits.

#### Indranil

##### Junior Member
And 1040 (without decimal point) has three significant digits.
Could you explain why without decimal point, 1040 has three significant digits? and what is the difference between 1040 and 1040.? because I knew 1040 and 1040. are the same.

#### Subhotosh Khan

##### Super Moderator
Staff member
Could you explain why without decimal point, 1040 has three significant digits? and what is the difference between 1040 and 1040.? because I knew 1040 and 1040. are the same.
When you write 1040 - it can be 1036 (min) to 1044 (max)

When you write 1040. - it can be 1039.6 to 1040.4

#### Dr.Peterson

##### Elite Member
Could you explain why without decimal point, 1040 has three significant digits? and what is the difference between 1040 and 1040.? because I knew 1040 and 1040. are the same.
Of course you are right that 1040 and 1040. represent the same number; it is only the convention about implied accuracy that is at issue.

I would say that 1040 is somewhat ambiguous, because you can't be sure whether the final zero is there because that digit is actually zero, or only because the digit is needed in order to have the right place values. It might really have either 3 or 4 significant digits - that is, it might have been rounded to the nearest ten or to the nearest unit, and be written the same. Many people assume the least possible accuracy. Ideally, significant digits should be read on in scientific notation, where this never happens (because there is only one digit before the decimal point).

On the other hand, with the decimal point, it is clear that the writer intends to stop after the decimal point, and the zero is significant.

#### JeffM

##### Elite Member
When you write 1040 - it can be 1036 (min) to 1044 (max)

When you write 1040. - it can be 1039.6 to 1040.4
According to the conventions of significant figures, 1040 and 1040. mean different things. That is because the whole idea of significant figures involves applied mathematics. In pure mathematics

$$\displaystyle 1040. \equiv 1040$$ as you recognize, but the concept of significant figures is not relevant to pure mathematics.

See https://en.m.wikipedia.org/wiki/Significant_figures

Last edited:

#### Indranil

##### Junior Member
When you write 1040 - it can be 1036 (min) to 1044 (max)

When you write 1040. - it can be 1039.6 to 1040.4

#### Dr.Peterson

##### Elite Member
I think what others of us said make the point more clearly, showing the reason.

Take a more interesting example: 104000. I might write that as an estimate, or rounded number, whether the real number was exactly 104000, or 104001 and rounded to the nearest ten, or 104010 and rounded to the nearest hundred, or 104100 and rounded to the nearest thousand. There is no way to distinguish those situations by the way we write it, unless we use one of the (relatively rare) conventions Wikipedia suggests. As they say, "The significance of trailing zeros in a number not containing a decimal point can be ambiguous. For example, it may not always be clear if a number like 1300 is precise to the nearest unit (and just happens coincidentally to be an exact multiple of a hundred) or if it is only shown to the nearest hundred due to rounding or uncertainty."

One way to reduce the ambiguity when the number is accurate to the nearest unit is to include a decimal point and write it as "104000.". Since this can be done, some people tend to assume that if there is no decimal point, the number of significant digits should be assumed to be as few as possible, in this case three, with all the trailing zeros insignificant.

Back to the original, if a number was rounded to the nearest unit and the result was 1040, then the number could be anything from 1039.5 to just under 1040.5. (What Khan wrote was not quite right.) Any of those numbers, such as 1039.51 or 1040.49, would round to 1040.

If the number had been rounded to the nearest ten, then the original could have been anything from 1035 to just under 1045. (I should add that whether you would round 1035 to 1040 depends on the precise convention you are following for rounding.)

#### HallsofIvy

##### Elite Member
As has been said, the distinction between 1040 and 1040. is a convention. It has been agreed that if there is a decimal point after an integer then all digits in the number are "significant" and that if there is no decimal point then the significant digits are end with the rightmost non-zero digit.

#### Denis

##### Senior Member
...and if 1040. was at end of sentence, then you'd have 1040.. :cool: