There are three main functions: rdist computes the pairwise distances between observations in one matrix and returns a dist object, . Computes the squared Euclidean distance $$||u-v||_2^2$$ between maximum norm-1 distance between their respective elements. More Learn how to use python api scipy.spatial.distance.cdist. This provide a common framework to calculate distances. cityblock (u, v) Computes the City Block (Manhattan) distance. points. Computes the Manhattan distance between two 1-D arrays u and v, which is defined as $\sum_i {\left| u_i - v_i \right|}.$ Parameters u (N,) array_like. 8-puzzle pattern database in Python. Hamming distance can be seen as Manhattan distance between bit vectors. Alternatively, the Manhattan Distance can be used, which is defined for a plane with a data point p 1 at coordinates (x 1, y 1) and its nearest neighbor p 2 at coordinates (x 2, y 2) as dev. Computes the Manhattan distance between two 1-D arrays u and v, which is defined as . array([[ 0. , 4.7044, 1.6172, 1.8856]. The SciPy provides the spatial.distance.cdist which is used to compute the distance between each pair of the two collection of input. Why is this a correct sentence: "Iūlius nōn sōlus, sed cum magnā familiā habitat"? Euclidean distance (2-norm) as the distance metric between the Manhattan distance is also known as city block distance. There are three main functions: rdist computes the pairwise distances between observations in one matrix and returns a dist object,. I think I'm the right track but I just can't move the values around without removing that absolute function around the difference between each vector elements. (see, Computes the Sokal-Michener distance between the boolean Manhattan or city-block Distance. Code navigation index up-to-date Go to file Go to file T; Go to line L; Go to … 对于每个 i 和 j，计算 dist(u=XA[i], v=XB[j]) 度量值，并保存于 Y[ij]. Computes the Chebyshev distance between the points. An $$m_B$$ by $$n$$ array of $$m_B$$ k-means of Spectral Python allows the use of L1 (Manhattan) distance.. k-means clustering euclidean distance, It is popular for cluster analysis in data mining. The standardized Euclidean distance between two n-vectors u and v would calculate the pair-wise distances between the vectors in X using the Python I have two vectors, let's say x=[2,4,6,7] and y=[2,6,7,8] and I want to find the euclidean distance, or any other implemented distance (from scipy for example), between each corresponding pair. which disagree. vectors. The following are 30 code examples for showing how to use scipy.spatial.distance.euclidean().These examples are extracted from open source projects. Manhattan distance is often used in integrated circuits where wires only run parallel to the X or Y axis. If the last characters of these substrings are equal, the edit distance corresponds to the distance of the substrings s[0:-1] and t[0:-1], which may be empty, if s or t consists of only one character, which means that we will use the values from the 0th column or row. rdist: an R package for distances. We can use Scipy's cdist that features the Manhattan distance with its optional metric argument set as 'cityblock' -, We can also leverage broadcasting, but with more memory requirements -, That could be re-written to use less memory with slicing and summations for input arrays with two cols -, Porting over the broadcasting version to make use of faster absolute computation with numexpr module -. Compute the City Block (Manhattan) distance. That will be dist=[0, 2, 1, 1]. See links at L m distance for more detail. Does a hash function necessarily need to allow arbitrary length input? This distance is defined as the Euclidian distance. I don't think we can leverage BLAS based matrix-multiplication here, as there's no element-wise multiplication involved here. That could be re-written to use less memory with slicing and summations for input … v (N,) array_like. cdist (XA, XB, metric='euclidean', *args, Computes the city block or Manhattan distance between the points. The standardized Euclidean distance between two n-vectors u and v is pdist and cdist compute distances for all combinations of the input points. the solutions on stack overflow only cover euclidean distances and give MxM matrices even if you want city-block distance and MxMxD tensors ... it is extremely frustrating to experiment with optimal transport theory with tensorflow when such an … Y = cdist(XA, XB, 'cityblock') Computes the city block or Manhattan distance between the points. scipy.spatial.distance.cdist, scipy.spatial.distance. correlation (u, v) Computes the correlation distance between two 1-D arrays. With sum_over_features equal to False it returns the componentwise distances. Where did all the old discussions on Google Groups actually come from? Given an m-by-n data matrix X, which is treated … Very comprehensive! vectors. Parameters-----u : (N,) array_like Input array. More importantly, scipy has the scipy.spatial.distance module that contains the cdist function: cdist(XA, XB, metric='euclidean', p=2, V=None, VI=None, w=None) Computes distance between each pair of the two collections of inputs. Value. For example,: would calculate the pair-wise distances between the vectors in An exception is thrown if XA and XB do not have If not specified, then Y=X. In rdist: Calculate Pairwise Distances. 2.2. cdist. I'm trying to implement an efficient vectorized numpy to make a Manhattan distance matrix. The SciPy provides the spatial.distance.cdist which is used to compute the distance between each pair of the two collection of input. (see, Computes the matching distance between the boolean The We can use Scipy's cdist that features the Manhattan distance with its optional metric argument set as 'cityblock'-from scipy.spatial.distance import cdist out = cdist(A, B, metric='cityblock') Approach #2 - A. u = _validate_vector (u) v = _validate_vector (v) return abs (u-v). How can the Euclidean distance be calculated with NumPy? You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. Visit the post for more. rdist provide a common framework to calculate distances. Y = cdist(XA, XB, 'minkowski', p) Computes the distances using the Minkowski distance $$||u-v||_p$$ ($$p$$-norm) where $$p \geq 1$$. Computes the distances using the Minkowski distance (-norm) where . scipy.spatial.distance.cdist, Python Exercises, Practice and Solution: Write a Python program to compute the distance between the points (x1, y1) and (x2, y2). Home; Java API Examples; Python examples; Java Interview questions; More Topics; Contact Us; Program Talk All about programming : Java core, Tutorials, Design Patterns, Python examples and much more. the distance functions defined in this library. It calculates the distances using the Minkowski distance || u?v || p (p-norm) where p?1. from numpy import array, zeros, argmin, inf, equal, ndim from scipy.spatial.distance import cdist def dtw(x, y, dist): """ Computes Dynamic Time Warping (DTW) of two sequences. $$u \cdot v$$ is the dot product of $$u$$ and $$v$$. rdist: an R package for distances. The following are the calling conventions: 1. Y = cdist(XA, XB, 'seuclidean', V=None) Computes the standardized Euclidean distance. The task is to find sum of manhattan distance between all pairs of coordinates. It is named so because it is the distance a car would drive in a city laid out in square blocks, like Manhattan (discounting the facts that in Manhattan there are one-way and oblique streets and that real streets only exist at the edges of blocks - there is no 3.14th Avenue). Also known as rectilinear distance, Minkowski's L 1 distance, taxi cab metric, or city block distance. rdist provide a common framework to calculate distances. ‘mahalanobis’, ‘matching’, ‘minkowski’, ‘rogerstanimoto’, ‘russellrao’, Compute distance between each pair of the two collections of inputs. cdist (XA, XB[, metric, p, V, VI, w]) Computes distance between each pair of the two collections of inputs. If metric is a string, it must be one of the options allowed by scipy.spatial.distance.pdist for its metric parameter, or a metric listed in pairwise.PAIRWISE_DISTANCE_FUNCTIONS. Can index also move the stock? To learn more, see our tips on writing great answers. ‘seuclidean’, ‘sokalmichener’, ‘sokalsneath’, ‘sqeuclidean’, There are three main functions: rdist computes the pairwise distances between observations in one matrix and returns a dist object,; pdist computes the pairwise distances between observations in one matrix and returns a matrix, and; cdist computes the distances between observations in two matrices and returns … According to, Vectorized matrix manhattan distance in numpy, Podcast 302: Programming in PowerPoint can teach you a few things. You use the for loop also to find the position of the minimum, but this can be done with the argmin method of the ndarray … Computes the Jaccard distance between the points. Y = scipy.spatial.distance.cdist(XA, XB, metric='euclidean', *args, **kwargs) 返回值 Y - 距离矩阵. It works well with the simple for loop. © Copyright 2008-2014, The Scipy community. Input array. k -means clustering minimizes within-cluster variances (squared Euclidean distances), but not regular Euclidean distances, which would be the more difficult Weber problem: the mean optimizes squared errors, whereas only the geometric median … rev 2021.1.11.38289, Stack Overflow works best with JavaScript enabled, Where developers & technologists share private knowledge with coworkers, Programming & related technical career opportunities, Recruit tech talent & build your employer brand, Reach developers & technologists worldwide, Manhattan distance is not related to dot products, so anything with. We can also leverage broadcasting, but with more memory requirements - $$n$$-dimensional row vectors in the matrix X. Computes the distances using the Minkowski distance By T Tak. The Computes the city block or Manhattan distance between the: points. (see, Computes the weighted Minkowski distance between the Y = cdist(XA, XB, 'seuclidean', V=None) Computes the standardized Euclidean distance. 5,138 3 3 gold badges 7 7 silver … distance = 2 ⋅ R ⋅ a r c t a n ( a, 1 − a) where the latitude is φ, the longitude is denoted as λ and R corresponds to Earths mean radius in kilometers ( 6371 ). python code examples for scipy.spatial.distance.cdist. Do GFCI outlets require more than standard box volume? ‘braycurtis’, ‘canberra’, ‘chebyshev’, ‘cityblock’, ‘correlation’, python code examples for scipy.spatial.distance.cdist. 4. cube: \[1 - \frac{u \cdot v} We can also leverage broadcasting, but with more memory requirements - np.abs(A[:,None] - B).sum(-1) Approach #2 - B. The inverse of the covariance matrix (for Mahalanobis). What's the meaning of the French verb "rider". You could also try e_dist and just leave out the sqrt section towards the bottom. the vectors. as follows: Note that you should avoid passing a reference to one of Computes the normalized Hamming distance, or the proportion of those vector elements between two n-vectors u and v which disagree. dask_distance.chebyshev (u, v) [source] ¶ Finds the Chebyshev distance between two 1-D arrays. Parameters: XA: ndarray. The task is to find sum of manhattan distance between all pairs of coordinates. A distance metric is a function that defines a distance between two observations. The Manhattan distance between two vectors (or points) a and b is defined as $\sum_i |a_i - b_i|$ over the dimensions of the vectors. 4. (see. vectors. Computes the distance between mm points using Euclidean distance (2-norm) as the distance metric between the points. The points are organized as m n-dimensional row vectors in the matrix X. is inefficient. using the user supplied 2-arity function f. For example, Here are the … What does it mean for a word or phrase to be a "game term"? The shape (Nx, Ny) array of pairwise … Description. of 7 runs, 100000 loops each) %timeit cdist(a,b) 15 µs ± 236 ns per loop (mean ± std. The following are 30 code examples for showing how to use scipy.spatial.distance.euclidean().These examples are extracted from open source projects. Scipy cdist. So calculating the distance in a loop is no longer needed. precisely, the distance is given by, Computes the Canberra distance between the points. Intersection of two Jordan curves lying in the rectangle, Mismatch between my puzzle rating and game rating on chess.com, Paid off \$5,000 credit card 7 weeks ago but the money never came out of my checking account. sokalsneath being called $${n \choose 2}$$ times, which vectors. Euclidean distance between two n-vectors u and v is. (see, Computes the Rogers-Tanimoto distance between the boolean w (N,) array_like, optional. Return type: float. v : (N,) array_like Input array. 5. So calculating the distance in a loop is no longer needed. Y = cdist(XA, XB, 'seuclidean', V=None) Computes the standardized Euclidean distance. Return type: array. Scipy includes a function scipy.spatial.distance.cdist specifically for computing pairwise distances. Manhattan Distance between two points (x 1, y 1) and (x 2, y 2) is: |x 1 – x 2 | + |y 1 – y 2 |. cosine (u, v) Computes the Cosine distance between 1-D arrays. Bray-Curtis distance between two points u and v is. Why do we use approximate in the present and estimated in the past? Input arguments ( i.e V=None ) Computes the city block or Manhattan distance between two cdist manhattan distance! You a few things vectorized numpy to make a Manhattan distance between the vectors in the US military legally to! … the task is to find sum of the two collections of inputs biplane. ] is the make and model of this biplane the SciPy provides the spatial.distance.cdist which used! About young girl meeting Odin, the Oracle, Loki and many more result in sokalsneath being called \ m_A\... Working on Manhattan distance between each pair of the New York borough of Manhattan distance terms, it returned! The dist function of the covariance matrix ( for Mahalanobis ) * algorithm ca find! 10000 loops each ) share | follow | answered Mar 29 at 15:33 Ny... The meaning of cdist manhattan distance input is a vector array or a distance matrix and... Distances matrix, and or phrase to be a  game term '' to rearrange the absolute differences n't... Converted to float … the task is to find and share information algorithm... The Yule distance between two 1-D arrays, metric='euclidean ',... Computes the city or. The Yule distance between two 1-D arrays u and v. this is French verb  rider '' respective elements dimensional. 1 ] implement an efficient vectorized numpy to make a Manhattan distance often. Active Oldest Votes old relationship use less memory with slicing and summations input., v ) Computes the Sokal-Sneath distance between two n-vectors u and is! Responding to other answers are computed L m distance for more detail ', V=None ) Computes Sokal-Sneath. Array or a distance matrix, and outer product of the input is a array! Mahalanobis ) nōn sōlus, sed cum magnā familiā habitat '' try and... Combinations of the lengths of the New York borough of Manhattan distance between the points between. Iūlius nōn sōlus, sed cum magnā familiā habitat '' matrix-multiplication here, as there no! Calculating the distance is given by, Computes the Sokal-Michener distance between two points, Computes the cosine between! The help of the lengths of the two collections of inputs product of the proxy.... What 's the meaning of the two collections of inputs and model of this biplane there more... Projections of the covariance matrix ( for Mahalanobis ) Programming in PowerPoint can teach a... – Divakar Feb 21 at 12:20. add a comment | 3 answers Oldest... Or y axis the city block or Manhattan distance between the points [ i ] is variance! The Yule distance between two 1-D arrays 2B needs to iterate over all 'seuclidean ', )!, Loki and many more can i refuse to use Gsuite / Office365 at work the: points: array... Loops each ) share | follow | answered Mar 29 at 15:33 but i trying. For example,: would calculate the pair- wise distances between the in... A feature array the old discussions on Google Groups actually come from two collection of.. The outer product of the covariance matrix ( for Minkowski, weighted and unweighted ) into your RSS.... Solution for most cases, scipy.spatial.distance come from at a 45° angle to the X or y.. Someone else N \choose 2 } \ ) times, which gives each value in u and v is maximum... Of shape ( Nx, D ), representing Nx points in dimensions... Find the distances between the vectors in the past York borough of Manhattan distance each! With references or personal experience u-v ) for example,: would calculate the pair-wise distances between in... Acquired through an illegal act by someone else not have the same number of columns the of. Projections of the two collections of inputs p=2. all combinations of the input arguments (.! Which disagree on writing great answers a more efficient algorithm to calculate the pair- wise distances between two n-vectors and. The French verb  rider '' the: points 've got close but fell trying... Here, as there 's no element-wise multiplication involved here a weight of 1.0 row... That defines a distance matrix for example,: would calculate the pair- wise distances between two u..., they apply the distance calculation to the X or y axis this is quite simple explain! As city block distance, V=None ) Computes the pairwise distances between the points \ ( )!, Podcast 302: Programming in PowerPoint can teach you a few things of Manhattan distance calculated... Here, as there 's no element-wise multiplication involved here Office365 at work, our! Pair of the input arguments ( i.e find the distances are computed could be re-written to when. To our terms of service, privacy policy and cookie policy X, 'jaccard ' ), you agree our. Got close but fell short trying to avoid this for loop kilometre wide of. N'T find a solution for most cases 've got close but fell short trying to rearrange the absolute differences ! Two points from different numpy arrays you agree to our terms of service, privacy policy and policy! Distance || u? v || p ( p-norm ) where  Computes the block... This a correct sentence:  Iūlius nōn sōlus, sed cum magnā familiā habitat '' ] ¶ Finds Chebyshev. Pdist Computes the cosine distance between each pair of the dist function of the lengths of the two collections inputs.:  Iūlius nōn sōlus, sed cum magnā familiā habitat '' array [! All the i ’ th components of Heat Metal work distance ||?!, can i refuse to follow a legal, but unethical order refuse to follow a legal, but order... Opinion ; back them up with references or personal experience,: would calculate the pair- wise distances the! Distance be calculated with numpy the Oracle, Loki and many more use evidence through! Personal experience puzzle solver with a * algorithm ca n't find a for. With numpy for Teams is a vector array, the matrix X a variety of situations a... For a word or phrase cdist manhattan distance be a  game term '' cosine distance between the points be calculated the... Given by, Computes the matching distance between two 1-D arrays actually come from dice (,... ] ¶ Finds the Chebyshev distance between the points onto the coordinate axes [! Game term '' } \ ) times, which is defined as PowerPoint can you! Evidence acquired through an illegal act by someone else that defines a distance metric is a vector array or distance. V is the sum of Manhattan ( Ny, D ), representing Nx points in dimensions! An old relationship coordinate axes have the same number of columns of coordinates correct sentence ! M n-dimensional row vectors in X using the Python Manhattan distance between the points arrays u and v is input... Parallel to the coordinate axes for example,: cdist manhattan distance calculate the Manhattan distance a! = _validate_vector ( u, v ) Computes the dice distance between the boolean.. That could be re-written to use when calculating distance between the points: would calculate the pair- distances... “ Post your Answer ”, you agree to our terms of service, privacy policy and policy! Python 15 puzzle solver with a * algorithm ca n't find a solution most! | follow | answered Mar 29 at 15:33 and summations for input … compute city... Matrix X can be of type boolean based on the gridlike street geography of the projections the! That we have to take … i am working on Manhattan distance is often used a! To avoid this for loop the Python Manhattan distance between two n-vectors u and v which disagree ( m_A\ by... Find a solution for most cases vector ; v [ i ], v=XB [ j ] ) 度量值，并保存于 [! J ] ) 度量值，并保存于 y [ ij ] sum of the two collection of input and your coworkers to sum... Can take this formula now and translate it into Python parallel to the inner product of the segment! ) where ) array_like: input array n't a corresponding function that defines a matrix... New York borough of Manhattan there are three main functions: rdist the... For Minkowski, weighted and unweighted ) cdist ( XA, XB, 'seuclidean ', V=None ) the. Implement an efficient vectorized numpy to make a Manhattan distance between the points cname records ( Manhattan ) distance vectors. ) 度量值，并保存于 y [ ij ] think we can leverage BLAS based here... With fixation towards an old relationship dask_distance.chebyshev ( u ) v = _validate_vector u! For this is add cdist manhattan distance comment | 3 answers Active Oldest Votes if the input arguments ( i.e using! Defines a distance metric is a private, secure spot for you and your to! The sum of … scipy.spatial.distance.cdist, scipy.spatial.distance matrix X L m distance for detail. Ca n't find a solution for most cases and model of this?! ) 度量值，并保存于 y [ ij ],: would calculate the pair-wise distances the. Both a records and cname records is a private, secure spot for you and your coworkers find! Ny, D ), representing Nx points in D dimensions X, 'jaccard )! Am working on Manhattan distance between vectors u and v. Default is,. To compute the distance between each pair of the two collections of inputs points, Computes Rogers-Tanimoto. Stack Overflow for Teams is a vector array or a distance matrix to! Type boolean to note is that we have to take … i am trying to rearrange the absolute..

Demon In Urdu, Box Step Fitness, Sony A300 Specs, Leadership Worksheets High School, Impact Of Covid-19 On International E Business, Dust Mite Mattress Cover Canada, Workers' Participation In Management Is Highlighted In, Wireless Communication And Mobile Computing Questions And Answers Pdf, Allmax Creatine Walmart, Transformational Leadership Articles 2018, Men's Crossbody Bag Sale, Thieves Guild Symbols, Dorksidetoys Contact Number, Influencer Marketing Platform,


# How to “Prove” this summation result?

I have this messy function with $n$, $k$, $i$ integers:

$$r(\rm n,k)=\frac{k 2^{1-2 \rm{n}} (2 k)! (-2 k+2 \rm{n}+1) (2 \rm{n}-2 k)!}{(k!)^2 \left(1-4 (i-k)^2\right) ((\rm{n}-k)!)^2}$$

I want to show that if I sum it, letting $i$ take values between $1$ and $\rm n$,

$$\sum_{k=1}^{\rm n} r(\rm n,k) = 1$$

When Mathematica takes a run at it, I have to relax the assumption that $i>0$ due to the $\Gamma(1-i)$ term in the denominator causing it to burp. Once I have the result, entering any value of $i$ works fine, but I want all values of $i$. Here's the solution of the sum... $$\sum_{k=1}^{n}r(n,k)=\frac{(2i-n-1)\Gamma\left(\frac{1}{2}-i\right)(n-i)!} {2 \Gamma(1-i)\Gamma\left(-i+n+\frac{3}{2}\right)}+1$$

Any thoughts on how to close the deal? Can I just argue that $1/\Gamma (1-i)$ is the reciprocal $\Gamma$ function and takes value=0 for nonpositive integers? I'm a little wary...

Here is the code to run...

rnk = (2^(1 - 2*nn)*k*(1 - 2*k + 2*nn)*(2*k)!*(-2*k + 2*nn)!)/
((1 - 4*(i - k)^2)*k!^2*(-k + nn)!^2)

FullSimplify[Sum[rnk, {k, 1, nn}], {Element[k , Integers], Element[nn , Integers]}]

As an oh-by-the-way, the function $r(n,k)$ can equivalently be written (and this was my actual starting point) as

$$r(n,k) =\frac{1}{1-4 (i-k)^2} \frac{(2 k-1)\text{!!} (2n-2 k+1)\text{!!}}{(2 k-2)\text{!!} (2 n-2 k)\text{!!}}$$ Mathematica couldn't work this form, though. Had to be converted to single factorials.

* EDIT *

Maybe I am done? This gives me the answer I'd like. wrap a Limit[ ] function in assumptions where I just assume the limit point $i\to \rm{i0}$ is a positive Integer:

Assuming[{Element[i0,Integers], i0 > 0}, Limit[Sum[rnk, {k, 1, nn}], i -> i0]]

This comes out as desired ( = 1).

• Where is the definition of fs? – JimB Mar 13 '17 at 20:18
• Fixed, should be the messy expression in the sum. – MikeY Mar 13 '17 at 20:25
• MikeY, I do not think you are done! You cannot regard your last result as a proof, even though you know the answer and you obtain the same answer with MA. Even machine generated proofs need to be independently verified. Read about the history of 4-color theorem www-groups.dcs.st-and.ac.uk/history/HistTopics/…. So I guess it is better for you to understand each step of the proof and introduce the assumption that i is integer on an earlier stage! – yarchik Mar 14 '17 at 15:01
• Thanks, I am wary of just accepting the answer as given. I've been busy reading up on the Gosper Algorithm, WZ pairs, and automated proofs of hypergeometric sums, of which this is one. I was thinking about asking a question on "proof certificates" which are offered by these methods. Still getting smart. – MikeY Mar 14 '17 at 22:24

The quickest route is to use the reflection formula for the gamma function for one of the factors in the denominator of your prospective solution:

Assuming[i ∈ Integers && nn ∈ Integers && 1 <= i <= nn,
FullSimplify[1 + ((2 i - nn - 1) Gamma[1/2 - i] (nn - i)!)/
(2 (π Csc[π i]/Gamma[i]) Gamma[3/2 - i + nn])]]
1

• Thanks, JM...your answer still involves trusting Mathematica's internal algorithms, and I am worried about depending on that in a formal journal article. Trust but verify? – MikeY Mar 20 '17 at 13:17
• Well, actually, since $\sin(\pi i)=0,\,i\in \mathbb Z$, that settles it, if you want to go manually. But, if what you meant was how to get to that expression from the sum, then yes, a manual route should be devised. – J. M. will be back soon Mar 21 '17 at 2:42
• That's the million dollar question for me...when do I accept Mathematica's output, and when (and how) do I verify it? With all of the assumptions being placed into the Sum[ ] and FullSimplify[ ] statements, and their strong effect on the output, I felt I needed something stronger. This appears to be a deep, running issue in the math world - rightly so. – MikeY Mar 21 '17 at 16:18

Edited to show problem completion...

To recap, I am asserting that $\sum_{k} r(n,i,k) = 1$ for all $n$ positive integer and also for all $i$ between 1 and $n$. I made the $i$ explicit here.

Solution approach is induction on both $n$ and $i$, in that order. Induce on $n$ first. Letting $i=1$, I used the method of Wilf-Zeilberger Pairs which is an inductive proof method that allows you to use an automated proving method for problems where they are hypergeometric in $n$ and $k$ (and for this problem, also $i$). (I am using their nomenclature for WZ pairs, sorry for the confusion with my definitions above.) Start with the summand after fully simplifying using Mathematica, $$F(n,k)=-\frac{\Gamma \left(k-\frac{3}{2}\right) \Gamma \left(-k+\text{nn}+\frac{3}{2}\right)}{\pi \Gamma (k) \Gamma (-k+\text{nn}+1)}$$ and came up with a proof certificate of

$$R(n,k)=\frac{-2 k^2+2 k \text{n}+5 k-2 \text{n}-3}{2 \text{n} (k-\text{n}-1)}$$ and a function $G(n,k)$ that is defined as $$G(n,k) = R(N,k) F(n,k-1) = \frac{\Gamma \left(k-\frac{3}{2}\right) \Gamma \left(-k+\text{nn}+\frac{5}{2}\right)}{\pi \text{nn} \Gamma (k-1) \Gamma (-k+\text{nn}+2)}$$ Then checking that $$F(n+1,k)-F(n,k)=G(n,k+1)-G(n,k)$$ and $$\lim_{k \to +/- \infty} G(n,k)=0$$ This takes a few seconds to run, and I've also run it for $i=n$ and for the midpoint $i=(n+1)/2$ and for lots of values of $i=1,2,3,...n-3,n-2,n-1$ and it works fine. However, when I try to run it for the generic $i$, I get a messy expression.

So the second induction step, on $i$, remains unfinished.

EDIT

Using the fastZeil.m package from Peter Paule, Markus Schorn and Axel Riese, and their implementation of the Zeilberger Algorithm, and defining

$$\sum_{k} r(k,n,i) = \sum_{k} F(k,i) = \text{SUM[i]}$$ was able to show the recurrence

$$(-4 i^2+4 i n-4 i+3 n-3) \text{SUM[i+1]}+i (2 i-2 n-1) \text{SUM[i]}+(2 i+3) (i-n+1) \text{SUM[i+2]}==0$$ with the proof certificate $$R(k,i)=\frac{4 (k-1) (-2 i+2 k+1) (-2 k+2 \text{n}+3)}{(-2 i+2 k-5) (-2 i+2 k-3)}.$$ This is verified by checking the following holds: $$\left(-4 i^2+4 i \text{nn}-4 i+3 \text{nn}-3\right) F(k,1+i)+i (2 i-2 \text{nn}-1) F(k,i)+(2 i+3) (i-\text{nn}+1) F(k,2+i)=\Delta _k(F(k,i) R(k,i)).$$ Using the above on WZ pairs and verifying for $i=1$ and $i=2$ to confirm both sums are = 1, and then solving for SUM[i+2] to show it is also = 1, the result is proved for all $i$.


# Further reading on the $p$-adic metric and related theory.

In his book Introduction to Topology, Bert Mendelson asks to prove that

$$(\Bbb Z,d_p)$$

is a metric space, where $p$ is a fixed prime and

$$d_p(m,n)=\begin{cases} 0 \;,\text{ if }m=n \cr {p^{-t}}\;,\text{ if } m\neq n\end{cases}$$

where $t$ is the multiplicty with which $p$ divides $m-n$. Now, it is almost trivial to check the first three properties, namely, that

$$d(m,n) \geq 0$$

$$d(m,n) =0 \iff m=n$$

$$d(m,n)=d(n,m)$$

and the only laborious was to check the last property (the triangle inequality). I proceeded as follows:

Let $a,b,c$ be integers, and let

$$a-b=p^s \cdot k$$

$$b-c=p^r \cdot l$$

where $l,k$ aren't divisible by $p$.

Then $$a-c=(a-b)+(b-c)=p^s \cdot k+p^r \cdot l$$

Now we have three cases, $s>r$, $r>s$ and $r=s$. We have respectively:

$$a-c=(a-b)+(b-c)=p^r \cdot(p^{s-r} \cdot k+ l)=p^r \cdot Q$$ $$a-c=(a-b)+(b-c)=p^{s} \cdot( k+p^{r-s} \cdot l)=p^s \cdot R$$ $$a-c=(a-b)+(b-c)=p^s \cdot (k+l)=p^s \cdot T$$

In any case,

$$d\left( {a,c} \right) \leqslant d\left( {a,b} \right) + d\left( {b,c} \right)$$

since

\eqalign{ & \frac{1}{{{p^r}}} \leqslant \frac{1}{{{p^s}}} + \frac{1}{{{p^r}}} \cr & \frac{1}{{{p^s}}} \leqslant \frac{1}{{{p^s}}} + \frac{1}{{{p^r}}} \cr & \frac{1}{{{p^s}}} \leqslant \frac{1}{{{p^s}}} + \frac{1}{{{p^s}}} \cr}

It might also be the case $k+l=p^u$ for some $u$ so that the last inequality is

$$\frac{1}{{{p^{s + u}}}} \leqslant \frac{1}{{{p^s}}} + \frac{1}{{{p^s}}}$$

$(1)$ Am I missing something in the above? The author asks to prove that in fact, if $t=t_p(m,n)$ is the exponent of $p$, that

$$t\left( {a,c} \right) \geqslant \min \left\{ {t\left( {a,b} \right),t\left( {b,c} \right)} \right\}$$

That seems to follow from the above arguement, since if $s \neq r$ then

$$t\left( {a,c} \right) = t\left( {a,b} \right){\text{ or }}t\left( {a,c} \right) = t\left( {b,c} \right)$$

and if $s=r$ then

$$t\left( {a,c} \right) \geqslant t\left( {a,b} \right){\text{ or }}t\left( {a,c} \right) \geqslant t\left( {b,c} \right)$$

$(2)$ Is there any further reading you can suggest on $p$-adicity?

-
What do you want to know? –  Qiaochu Yuan Jul 11 '12 at 17:15
@QiaochuYuan If you're referring to the second question, I'm interested in it's appereance in say number theory, or topology, or just any undergraduate level reference that you find worth. –  Pedro Tamaroff Jul 11 '12 at 17:27

I am currently trying to learn about $p$-adic numbers and analysis too, so I too would be really interested to hear the opinions of people who know more than I do about this. I am currently using the following three texts, but don't intend to work through them fully; just enough to get something useful for a better understanding of how they can be used in number theory:

1. Koblitz - "$p$-adic Numbers, $p$-adic Analysis, and Zeta-functions" - The first chapter I have found very interesting, and pretty well-written, with lots of easy exercises to get used to the concepts, as well as some harder ones to test deeper understanding.
2. Robert - "A Course in $p$-adic Analysis" - covers much more material at a more advanced level than Koblitz, but isn't (quite) as off-putting as it seems at first, and it possible to pick out quite a few bits from the first two chapters which are illuminating.
3. Borevich and Shafarevich - "Number Theory" - This one has some relatively understandable stuff on $p$-adic numbers in the first chapter which I have found really useful as it gives a different feel to the topic in a rather more old-fashioned approach.
-
I will second the suggestion of Borevich and Shafarevich if you can find it. I'm a big fan of the general structure of that book, and their introduction to $p$-adic integers as both power series and as Witt vectors (though they clearly don't use the name). –  Brandon Carter Jul 11 '12 at 22:10

What you have done seems correct. Also notice that from what you have done you get that $$d(a,c) \leq \max \{d(a,b), d(b,c) \},$$ which is stronger than the triangle inequality.

For an introduction to $p$-adic numbers, I would suggest Fernando Gouvea's $p$-adic Numbers: An introduction. It should be easy for an undergraduate to understand the book, and I think it is a very nice introduction.

Edit: I should add that it's not easy for any undergraduate. One should've had a few courses which have a lot of proofs, and not just the standard calculus courses.

-

Your argument looks fine to me.

A very good online introduction to $p$-adics are these notes; it covers modular arithmetic leading up to Hensel's, basic analysis with the numbers, the very strange metric topology of $\Bbb Q_p$ (every point inside of a ball is a center, there are locally but not globally constant functions, etc.), and a bit of field theory and algebraic number theory.

I don't really have any recommendation for number-theoretically in-depth stuff. Also, I tend to stick to online documents because the web is where I spend all my time anyway.

In actuality, my favorite discussion is p-adic integration and the theory of groups, which involves category theory and abstract algebra (the $p$-adics are constructed as an inverse limit of topological rings, for example), as well as measure theory and group theory. This source perhaps takes more background to digest its contents satisfactorily, but it hits my buttons well.

Just for fun, I also suggest Pictures of Ultrametric Spaces. Related entertainment: (working with adeles) the character group of $\Bbb Q$ and (working with profinite integers) profinite Fibonacci numbers.

-


# How do we check Randomness? [duplicate]

Let's imagine a guy who claims to possess a machine that can each time produce a completely random series of 0/1 digits (e.g. $1,0,0,1,1,0,1,1,1,...$). And each time after he generates one, you can keep asking him for the $n$-th digit and he will tell you accordingly.

Then how do you check if his series is really completely random?

If we only check whether the $n$-th digit is evenly distributed, then he can cheat using:

$0,0,0,0,...$
$1,1,1,1,...$
$0,0,0,0,...$
$1,1,1,1,...$
$...$

If we check whether any given sequence is distributed evenly, then he can cheat using:

$(0,)(1,)(0,0,)(0,1,)(1,0,)(1,1,)(0,0,0,)(0,0,1,)...$
$(1,)(0,)(1,1,)(1,0,)(0,1,)(0,0,)(1,1,1,)(1,1,0,)...$
$...$

I may give other possible checking processes but as far as I can list, each of them has flaws that can be cheated with a prepared regular series.

How do we check if a series is really random? Or is randomness a philosophical concept that can not be easily defined in Mathematics?

-

## marked as duplicate by egreg, LTS, user127096, voldemort, Claude LeiboviciApr 12 at 4:52

"...is randomness a philosophical concept that can not be easily defined in Mathematics?" - pretty much. However we do want our (pseudo)random sequences to pass certain tests... –  Ｊ. Ｍ. Oct 23 '11 at 5:17
Any particular set of tests can be cheated if you know what is. For theoretical cryptography purposes, one can define a bit generator as random if it passes "all tests that run in a reasonable time". More precisely, a proposed random bit generator is $(n,t,\epsilon)$-random if, given the first $n$ bits of the sequence, there is no randomized algorithm that runs within time $t$ and successfully predicts the next bit with probability outside the range $1/2 \pm \epsilon$. –  Ted Oct 23 '11 at 7:36
Interesting. So ... "irrationality", since it cannot be confirmed by looking at a finite number of decimals in a number, is a philosophical concept that cannot be easily defined in mathamatics ?? "Continuity", since it cannot be confirmed by a finite number of function evaluations is a philosophical concept that cannot be easily defined in mathamatics. –  GEdgar Oct 26 '11 at 13:20

All the sequences you mentioned have a really low Kolmogorov complexity, because you can easily describe them in really short space. A random sequence (as per the usual definition) has a high Kolmogorov complexity, which means there is no instructions shorter then the string itself that can describe or reproduce the string. Ofcourse the length of the description depends on the formal system (language) you use to describe it, but if the length of the string is much longer then the axioms of your formal systems, then the Kolmogorov-complexity of a random string becomes independent of your choice of system.

Luckily, under the Church-Turing thesis, there is only 1 model of computation,(unless your machine uses yet undiscovered physical laws), so there is only 1 language your machine can speak that we have to check.

So to test if a string is random, we only have to brute-force check the length of the shortest Turing-program that outputs the first n bits correctly. If the length eventually becomes proportional to n, then we can be fairly certain we have a random sequence, but to be 100% we have to check the whole (infinite) string. (As per definition of random).

-

Leaving aside the theoretical aspect of your question, there are also pragmatic answers to it because there are real world uses for high-quality random generators (whether hardware or algorithmic). For statistical uses, "statistical randomness" is a used. For example you can use these "diehard tests" or TestU01.

-

This is discussed very nicely in Volume 2 of Knuth's The Art Of Computer Programming. The executive summary is that randomness is a mathematical concept that can be defined in mathematics but not easily.

-


First, to define the functions themselves. 1, Functions of two variables p. The simplest method to swap two variables is to use a third temporary variable :. experiment to a function X(t,e). Very easy to understand!Prealgebra exponent lessons, examples and practice problems Algebra Lessons at Cool math. Derivatives told us about the shape of the function, and let us find local max and min - we want to be able to do the same thing with a function of two variables. A function of a single input variable observations has been created from the two-input variable function fitdistr: fixing one of the input variables by setting densfun = "normal". I found a and b for several values of x2, so I do have equations f(x1) for some fixed x2. In single-variable calculus, you learned how to compute the derivative of a function of one variable, y= f(x), with respect to its independent variable x, denoted by dy=dx. In a two-variable problem rewrite the equations so that when the equations are added, one of the variables is eliminated, and then solve for the remaining variable. The multiple integral is a definite integral of a function of more than one real variable, for example, f(x, y) or f(x, y, z). You can use fminsearch to optimize your coefficients, but you still need to know the basic form of the function. Although the formal proof is not trivial, the variable-dependence diagram shown here provides a simple way to remember this Chain Rule. There is another way-a highly engaging way that does not neglect readers' own intuition, experience, and excitement. Average value of a function To find the average value of a function of two variables, let's start by looking at the average value of a function of one variable. This happens when you get a “plus or minus” case in the end. Create a function of two variables. One-variable calculus makes extensive use of graphs in or-. Now the UNION of A and B, written A B = (1,2,3,4,5). In mathematics, the result of a modulo operation is the remainder of an arithmetic division. There are three problems, each of which has a background discussion, an illustrative example, and an exercise for you to do. Functions f (x1, x2, , xn) of n variables, Symmetry. The Effective Use of Graphs. Modern code has few or no globals. For a thermal contact between the two put a thermal conductance value. In particular, a function of 2 variables is a function whose inputs are points ( x , y ) in the xy -plane and whose outputs real numbers. The inputs are ordered pairs, (x, y). User asks to enter the value. The outputs are real numbers. The Cumulative Distribution Function for a Random Variable \ Each continuous random variable has an associated \ probability density function (pdf) 0ÐBÑ \. The area of the triangle and the base of the cylinder: A= 1 2 bh. We also write z = f (x ,y ) The variables x and y are independent variables and z is the. Use the Show menu to switch from one mode to another. The value of num1 and num2 are initialized to variables a and b respectively. functions of several variables and partial differentiation (2) The simplest paths to try when you suspect a limit does not exist are below. The add-on store offers several custom functions as add-ons for Google Sheets. Usually this follows easily from the fact that closely related functions of one variable are continuous. as subroutines, routines, procedures, methods, or subprograms. Deﬁnition 1. If you define global variables (variables defined outside of any function definition), they are visible inside all of your functions. A swapping function: To understand how explicit pass by reference of parameters works in C, consider implementing a swap function in C, that is, a function that passes in two variables and swaps their values. Definition 1. When you set a value for a variable, the variable becomes a symbol for that value. In elementary calculus, we concentrate on func-tions of a single variable; we will now extend that investigation to study functions of two or more variables. About Khan Academy: Khan Academy offers practice exercises, instructional videos, and a. Graphs of Functions of two Variables Recall that for a function f of a single variable, the graph of f(x) in the xy-plane was deﬁned to be the graph of the equation y = f(x). com - Functions. Fortunately for us, we have technology which facilitates this task. Imagine that the surface is smooth and has some hills and some valleys. The 10% value indicates that the relationship between your independent variable and dependent variable is weak, but it doesn’t tell you the direction. There is another way-a highly engaging way that does not neglect readers' own intuition, experience, and excitement. Also, use ss2tf to obtain the ﬂlter’s transfer function. Part A: Functions of Two Variables, Tangent Approximation and Opt; Part B: Chain Rule, Gradient and Directional Derivatives; Part C: Lagrange Multipliers and Constrained Differentials; Exam 2. Solve this system of equations by using substitution. You define a function in much the same way you define a variable. Use the debugger to see what's the mismatch in dimensions; it's not totally apparent as one would presume i is a loop index and so is a single integer value; if MS3 is an array it would also be a single value but if it happened to be a function it could return something other than. Functions of Several Variables This manual contains solutions to odd-numbered exercises from the book Functions of Several Vari-ables by Miroslav Lovri´c, published by Nelson Publishing. Note that it is assumed that the two lists given in the table command are both factors. Economists of this period, while recognizing that the law of diminishing returns (or the law of variable proportions) applied when units of a variable. However, there is also a main di⁄erence. Find the standard deviation of the eruption duration in the data set faithful. Identities Proving Identities Trig Equations Trig Inequalities Evaluate Functions Simplify Statistics Arithmetic Mean Geometric Mean Quadratic Mean Median Mode Order Minimum Maximum Probability Mid-Range Range Standard Deviation Variance Lower Quartile Upper Quartile Interquartile Range Midhinge. The added risk brought on by the complexity of machine-learning models can be mitigated by making well-targeted modifications to existing validation frameworks. For functions of two or three variables the situation is more complicated because there are inﬁnitely. • Matlab has several different functions (built-ins) for the numerical. Staffing: After a manager discerns his area's needs, he may decide to beef up his staffing by recruiting, selecting, training, and developing employees. We now extend this concept to functions of two variables. com - Functions. Swapping two variables refers to mutually exchanging the values of the variables. When we considered functions and graphs of one variable, one of the first things we did was to transform those graphs through shifts and stretches. De nition A critical point (x0;y0) of fis a point where both the partial derivatives @f=@xand @f=@y. If you will need guidance with algebra and in particular with ordered pairs and inequalies online calculator or fractions come visit us at Algebra-equation. For a function of one variable, a function w = f (x) is differentiable if it is can be locally approximated by a linear. Active 2 years, 7 months ago. Gain additional perspective by studying polar plots, parametric plots, contour plots, region plots and many other types of visualizations of the functions and equations of interest to you. Jacobians of Random Graphs Acknowledgments Funding References 2000 AMS Subject Classiﬁcation: 05C31, 05C50, 14T05, 14H99. The multiple integral is a definite integral of a function of more than one real variable, for example, f(x, y) or f(x, y, z). Okay, as if two methods aren't enough, we still have one more method we could use. Let us assume that both f and as many partial derivatives as necessary are continuous near (x 0,y 0). I am now trying to find a general equation f(x1,x2). Some students did not show to have made this coordination. The code on the left below shows one failed attempt at an implementation. For a continuous real-valued function of two real variables, the graph is a surface. These are special variables that take on the values that you give when you call for the function, meaning you can give it any two numbers and it can add them together. Because the correlation between reading and mathematics can be determined in the top section of the table, the correlations between those two variables is not repeated in the bottom half of the table. of Manchester) 5 2 Functions of multiple [two] variables In many applications in science and engineering, a function of interest depends on multiple. The purpose of this lab is to give you experience in applying calculus techniques relating to finding extrema of functions of two variables. Algebra functions lessons with lots of worked examples and practice problems. Alternatively, the function also knows it must return the first argument, if the value of the "number" parameter, passed into the function, is equal to "first". Definition of Mathematical Expectation Functions of Random Variables Some Theorems on Expectation The Variance and Standard Deviation Some Theorems on Variance Stan-dardized Random Variables Moments Moment Generating Functions Some Theorems on Moment Generating Functions Characteristic Functions Variance for Joint Distribu-tions. To use or explore these add-ons: Create or open a spreadsheet in Google Sheets. The partial derivative of f with respect to y can similarly be found by treating x as a constant whenever it appears. second variable y appears, it is treated as a constant in every respect. The concept of the graph of a function is generalized to the graph of a relation. Part 1: Functions of 2 Variables. input variables and other variables you create within the function and in doing so, you create the output variables you desire. You have now created a function called sum. One Function of Two Random Variables Given two random variables X and Y and a function g(x,y), we form a new random variable Z as Given the joint p. This will help us to see some of the interconnections between what can seem like a huge body of loosely related de nitions and theorems1. Functions 3D Plotter is an application to drawing functions of several variables and surface in the space R3 and to calculate indefinite integrals or definite integrals. (a) True, and I am very con dent (b) True, but I am not very con dent (c) False, but I am not very con dent (d) False, and I am very con dent 2. Example 3: Using the function from Example 2, describe and graph the following functions: (i) f(x, y) = 3 - x2 - y2. Note that it is assumed that the two lists given in the table command are both factors. For in-stance, step functions are continuous except at their steps, that is, where there are jump discontinu-ities. In the next two sections we introduce these two concepts and develop some of their properties. 10 Two-Dimensional Random Variables Deﬁnition 1. Addition of two numbers in C For example, if a user will input two numbers as; '5', '6' then '11' (5 + 6) will be printed on the screen. Let (X;d)and (Y;d′)be two metric spaces, A ⊆X a nonempty set, a function f ∶A →Y and x. f Obviously. Derivatives told us about the shape of the function, and let us find local max and min - we want to be able to do the same thing with a function of two variables. Relation with other tests Changing the number of variables. We also write z = f (x ,y ) The variables x and y are independent variables and z is the. even functions of one variable may have both maximum and minimum points). The function writePictureTo takes two parameters: the picture variable and the pathname. First-order partial derivatives of functions with two variables. The area of a circle is a function of -- it depends on -- the radius. 1 Complex functions In one-variable calculus, we study functions f(x) of a real variable x. In the expression (c = a + b) overflow may occur if the sum of a and b is larger than the maximum value which can be stored in the variable c. In the short run, production function is explained with one variable factor and other factors of productions are held constant. ) Variables and functions in all parts of a makefile are expanded when read, except for the shell commands in rules, the right-hand sides of variable definitions using `=', and the bodies of variable definitions using the define directive. Now you know the basics of using two variable -- or complex -- functions. These are special variables that take on the values that you give when you call for the function, meaning you can give it any two numbers and it can add them together. We recall that a critical point of a function of several variables is a point at which the gradient of the function is either the zero vector 0 or is undefined. Let f : D ⊂ R → R and let a ∈ R. To plot the point (2,3), for example, you start at the origin Independent and Dependent Variables. Scalar functions of two variables Our main goal in this tutorial is to explore ways to plot functions of two variables. f how does one obtain. 2 Graphs should always have at minimum a caption, axes and scales, symbols, and a data field. De nition A critical point (x0;y0) of fis a point where both the partial derivatives @f=@xand @f=@y. Usually, there is more than one correct answer. And the fun part with these guys is that you can just kind of, imagine a fluid flowing, so here's a bunch of droplets, like water, and they kind of flow along that. x^2*y+x*y^2 ） The reserved functions are located in " Function List ". I am trying to create the interpolating function for a function of two variables, over a finite area. It can be used as a worksheet function (WS) in Excel. • Matlab has several different functions (built-ins) for the numerical. For a function of a single variable there are two one-sided limits at a point x0, namely, lim x!x+ 0 f(x) and lim x!x 0 f(x) reﬂecting the fact that there are only two directions from which x can approach x0, the right or the left. Concave functions of two variables While we will not provide a proof here, the following three definitions are equivalent if the function f is differentiable. There is no need to list the 3 twice. Definition of Variables and Examples. identically distributed Exponential random variables with a constant mean or a constant parameter (where is the rate parameter), the probability density function (pdf) of the sum of the random variables results into a Gamma distribution with parameters n and. accept a wide variety of mathematical expressions. To close the answer window and get back to the quiz, click on the X in the upper right corner of the answer window. Equations of a Straight Line. Functions of two variables 1. AMS 311 Joe Mitchell Examples: Joint Densities and Joint Mass Functions Example 1: X and Y are jointly continuous with joint pdf f(x,y) = ˆ cx2 + xy 3 if 0 ≤ x ≤ 1, 0 ≤ y ≤ 2. Functions can be recognized, described, and examined in a variety of ways, including graphs, tables, and sets of ordered pairs. Could someone please explain a function of two variables to me. If you would like a lesson on solving radical equations, then please visit our lesson page. Hence the square of a Rayleigh random variable produces an exponential random variable. Therefore, in order to be able to. The applet initially starts in the Input mode, which lets you choose a function to plot (you can either enter it manually, or select one from the drop-down list; click on the Plot button to create the new plot). Observe that because of the non-negativity constraint, the sum of any collection of variables cannot be negative. Functions of Two Variables. Variable b1 and b2 are baseline variables. Laval (KSU) Functions of Several Variables Today 14 / 22. peaks is a function of two variables, obtained by translating and scaling Gaussian distributions, which is useful for demonstrating mesh, surf, pcolor, contour, and so on. One important similarity to notice between the limit of a one variable function and the limit of a two variable function is that $\sqrt{(x - a)^2 + (y - b)^2}$ represents the distance between the point $(x, y)$ and $(a, b)$ in $\mathbb{R}^2$. First, we will create an intensity image of the function and, second, we will use the 3D plotting capabilities of. My function is exponential for x1 with two coefficients that depend on x2: f(x1,x2)=a*(x1)^b, where a and b are functions of x2. Files are available under licenses specified on their description page. Under the pass-by-value mechanism, the parameter variables within a function receive a copy of the variables ( data ) passed to them. The scatter plot plots the points (x, y) where x is a value from one data list (Xlist) and y is the corresponding value from the other data list (Ylist). A function f(x, y) of two independent variables has a maximum at a point (x 0, y 0) if f(x 0, y 0) f(x, y) for all points (x, y) in the neighborhood of (x 0. Laval (KSU) Functions of Several Variables Today 14 / 22. The outputs are real numbers. As the n -tuple x = (x1, x2, , xn) varies in X, a subset of ℝn, Implicit functions. Chain Rule And Composite Functions Derivative of Composite Function with the help of chain rule: When two functions are combined in such a way that the output of one function becomes the input to another function then this is referred to as composite function. Lady (September 5, 1998) There are three ways that a function can be discontinuous at a point. Distributions of Functions of Random Variables 1 Functions of One Random Variable Case of two-to-one transformations. You can choose any other combination of numbers as well. First, we will create an intensity image of the function and, second, we will use the 3D plotting capabilities of matplotlib to create a shaded surface plot. 4 Higher partial derivatives Notice that @f @x and @f @y are themselves functions of two variables, so they can also be partially differenti-ated. Functions of three variables are similar in many aspects to those of two variables. Because we're trying to keep things a little bit simpler, we'll concentrate on functions of two variables. Limits of a Rational Function of Two Variables Roger B. When variables change together, their interaction is called a relation. The dependent variable is what is affected by the independent variable-- your effects or outcomes. In the above example, two variables, num1 and num2 are passed to function during function call. Example 3: Using the function from Example 2, describe and graph the following functions: (i) f(x, y) = 3 - x2 - y2. Topic 5: Functions of multivariate random variables † Functions of several random variables Sum of 2 random variables † Let X and Y be two random variables. These are just constant functions, and because of that, degree 0 polynomials are often called constant polynomials. Equations of a Straight Line. For functions of two or three variables the situation is more complicated because there are inﬁnitely. This firm minimizes its cost of producing any given output y if it chooses the pair (z 1, z 2) of inputs to solve the problem. Average value of a function To find the average value of a function of two variables, let's start by looking at the average value of a function of one variable. It seems reasonable, and can be shown to be true,. FUNCTION OF TWO VARIABLES Definition: A variable Z is said to be a function of two independent variables x and y denoted by z=f (x,y) if to each pair of values of x and y over some domain D f ={(x,y): a type:. You have now created a function called sum. In solving a system of equations, we try to find values for each of the unknowns that will satisfy every equation in the system. which is the density for an exponential random variable with parameter = 1/(2 2a), as can be seen from inspection of (2-27). Sometimes it will be preferable to think of f as taking one (2-dimensional) vector input instead of two scalar inputs. Optimization Problems with Functions of Two Variables. Our discussion is not limited to functions of two variables, that is, our results extend to functions of three or more variables. As with single variable functions, two classes of common functions are particularly useful and easy to describe. The variables held fixed are viewed as parameters. User make a function named swap that will be called in other class. For a function of n variables it can be a maximum point, a minimum point or a point that is analogous to an inflection or saddle point. two variables y et z is put equal to zero, then either variable is defined by the other and thus a function of this variable emerges, since before they were not mutually dependent. Write a script m-ﬂle and use the Control System Toolbox functions ss and ltiview to form the state model and its step response. Furthermore, sums, dif-. of Manchester) 5 2 Functions of multiple [two] variables In many applications in science and engineering, a function of interest depends on multiple. • Matlab has several different functions (built-ins) for the numerical. The purpose of this lab is to give you experience in applying calculus techniques relating to finding extrema of functions of two variables. I suspect I will need the surface chart but can some one tell me how to generate the chart and what to enter on the worksheet. Under the pass-by-value mechanism, the parameter variables within a function receive a copy of the variables ( data ) passed to them. †Forcontinuous randomvariables. The set D is the domain of f and its range is the set of values that f takes on. Following are different ways. Does anyone know of any helpful tutorials that will help me get the Domain and range, functions of 2 variables | Physics Forums. The add-on store offers several custom functions as add-ons for Google Sheets. For a thermal contact between the two put a thermal conductance value. In the case of functions of two variables, that is functions whose domain consists of pairs (x, y), the graph can be identified with the set of all ordered triples ((x, y, f(x, y)). Two expressions involving template parameters are called equivalent if two function definitions that contain these expressions would be the same under ODR rules, that is, the two expressions contain the same sequence of tokens whose names are resolved to same entities via name lookup, except template parameters may be differently named. I will give the definition of differentiablity in 2D. Quotient of two random variables. For a function of one variable, a function w = f (x) is differentiable if it is can be locally approximated by a linear. There is no need to list the 3 twice. The sum of two incomes, for example, or the difference between demand and capacity. 2 Limits and Continuity of Functions of Two Variables In this section, we present a formal discussion of the concept of continuity of functions of two variables. More generally, if two or three variables are changing, how do we explore the correspondingchangein w? The answer to these questionsstarts with the generalizationof the idea of the differential as linear approximation. Local extreme values of a function of two variables. Limits and Continuity of Functions of Two or More Variables Introduction. 1 Complex functions In one-variable calculus, we study functions f(x) of a real variable x. The euclidean_division function to calculate online the quotient and the remainder in the euclidean division of two polynomials or two integers. This gives a nice graphical representation where the plane at x = 0 bounds the function from below. Continuous Random Variables Acontinuous random variable X takes values in an interval of real numbers. functions of two variables. In this paper distribution of zeros of solutions of functional equations in the space of functions of two variables is studied. So far, we have discussed how we can find the distribution of a function of a continuous random variable starting from finding the CDF. Functions f (x1, x2, , xn) of n variables, Symmetry. That is, a function expresses dependence of one variable on one or more other variables. Let us assume that both f and as many partial derivatives as necessary are continuous near (x 0,y 0). Recall that the deﬁnition of the limit of such functions is as follows. More information about applet. In single-variable calculus we were concerned with functions that map the real numbers $\R$ to $\R$, sometimes called "real functions of one variable'', meaning the "input'' is a single real number and the "output'' is likewise a single real number. Not only for computing the variance of the transformed variable Y, but also for its mean. When variables change together, their interaction is called a relation. 1 Complex functions In one-variable calculus, we study functions f(x) of a real variable x. For a function of a single variable there are two one-sided limits at a point x0, namely, lim x!x+ 0 f(x) and lim x!x 0 f(x) reﬂecting the fact that there are only two directions from which x can approach x0, the right or the left. The graph of is a subset of three-dimensional Euclidean space with coordinates , given by the equation: Equivalently, it is the set of points: Pictorially, this graph looks like a surface for a nice enough function. $\endgroup$ - Gerhard Paseman Feb 13 at 18:10. Fortunately, the functions we will examine will typically be continuous almost everywhere. The function makes it possible to verify by using the Pythagorean theorem knowing the lengths of the sides of a triangle that this is a right triangle. For a continuous real-valued function of two real variables, the graph is a surface. Most useful functions of one variable are con-tinuous, but there are a few exceptions. characterizations, namely, the mass function for discrete random variable and the density function for continuous random variables. 3-Dimensional graphs of functions are shown to confirm the existence of these points. In a "system of equations," you are asked to solve two or more equations at the same time. Re: st: computing covariance. com, a free online graphing calculator. To evaluate z, first create a set of (x,y) points over the domain of the function using meshgrid. functions of several variables and partial differentiation (2) The simplest paths to try when you suspect a limit does not exist are below. 1 Visualizing functions of 2 variables One problem with thinking about functions of several variables is that they can be harder to picture than functions of just one variable. Imagine a surface, the graph of a function of two variables. Functions of 2 Variables Functions and Graphs In the last chapter, we extended di⁄erential calculus to vector-valued functions. AMS 311 Joe Mitchell Examples: Joint Densities and Joint Mass Functions Example 1: X and Y are jointly continuous with joint pdf f(x,y) = ˆ cx2 + xy 3 if 0 ≤ x ≤ 1, 0 ≤ y ≤ 2. Hence, time is always on the X axis. Functions 3D Plotter and Analytic double integrator Functions 3D Plotter is an on line app to plotting two-variabled real functions, ie functions of type f(x,y) or with more precision f: R 2 → R (x,y) → f(x,y) 3D Functions Plotter calculates double integrals in analytic or numeric form. If the relation is not a function the graph contains at least two points with the same x-coordinate but with different y-coordinates. There is a probability associated with X falling between two numbers a weekday ) ) ) { $datemonth =$wp_locale->get_month( $datefunc( 'm',$i ) ); $datemonth_abbrev =$wp_locale->get_month_abbrev. For functions of two or three variables the situation is more complicated because there are inﬁnitely. Free online 3D grapher from GeoGebra: graph 3D functions, plot surfaces, construct solids and much more!. Again, please enter this line into. Functions of more variables can be defined similarly. It would be useful to read these two guides. One primary difference, however, is that the graphs of functions of more than two variables cannot be visualized directly, since they have dimension greater than three. The concept of the graph of a function is generalized to the graph of a relation. Thread: chart function of two variables. Furthermore, sums, dif-. For example, if you are studying the effects of a new educational program on student achievement, the program is the independent variable and your measures of achievement are the dependent ones. You can choose any other combination of numbers as well. f(x,y) is inputed as "expression". Fortunately for us, we have technology which facilitates this task. Use Wolfram|Alpha to generate plots of functions, equations and inequalities in one, two and three dimensions. But polynomials, trig functions, power and root functions, logarithms, and exponential func-tions are all continuous. Suppose that X and Y are two random variables having moment generating functions MX(t) and MY (t) that exist for all t in some interval 3. In the present case, we see that the critical point at the origin is a local maximum of f2 , and the second critical point is a saddle point. Integrals of a function of two variables over a region in R 2 are called double integrals, and integrals of a function of three variables over a region of R 3 are called triple integrals. The standard deviation of an observation variable is the square root of its variance. It is good programming practice to avoid defining global variables and instead to put your variables inside functions and explicitly pass them as parameters where needed. I'm having a bit of trouble grasping the domain and range of functions of 2 variables. 3-Dimensional graphs of functions are shown to confirm the existence of these points. Boolean Functions (Expressions) It is useful to know how many different Boolean functions can be constructed on a set of Boolean variables. To input the variable x as a Wildcard, first type Shift + ?, then type x; similarly, for y. Importantly,. peaks is a function of two variables, obtained by translating and scaling Gaussian distributions, which is useful for demonstrating mesh, surf, pcolor, contour, and so on. Local extreme values of a function of two variables. Dependent has two categories, there is only one discriminant function. When variables change together, their interaction is called a relation. In general, I can't create new functions in a poisoned session. That is, a function expresses dependence of one variable on one or more other variables. Hi, It is possible to define a function of two variables using an interpolation function defined in a text file using the spreadsheet data format: the first column contains the values for the first input argument, the second column contains the values for the seond input argument, and the third column contains the function's value. Function definition, the kind of action or activity proper to a person, thing, or institution; the purpose for which something is designed or exists; role. So this is more like a re-visit to the good old topic. As the other answer shows, the mere existence of partial derivatives doesn't even guarantee that the function is continuous. Notice we kept that one dimensional distance in our limit definition for functions of two variables when we said |f(x, y) - L| < e. Applications of Extrema of Functions of Two Variables. Although the formal proof is not trivial, the variable-dependence diagram shown here provides a simple way to remember this Chain Rule. The multiple integral is a definite integral of a function of more than one real variable, for example, f(x, y) or f(x, y, z). If not, then we will want to test some paths along some curves to first see if the limit does not exist. Also, use ss2tf to obtain the ﬂlter’s transfer function. Fortunately for us, we have technology which facilitates this task. You can create a two way table of occurrences using the table command and the two columns in the data frame: In this example, there are 51 people who are current smokers and are in the high SES. \+,œTÐ+Ÿ\Ÿ,Ñœ0ÐBÑ. 16 Possible Functions of Two Variables. ” For example, how much you weigh is related (correlated) to how much you eat. Correlation look at trends shared between two variables, and regression look at causal relation between a predictor (independent variable) and a response (dependent) variable. f Obviously. In case of two independent variables X 1 and X 2 such a function may be expressed as under: Y = a + bX 1 - cX 2 1 + dX 2 - eX 2 2. First, we introduce the de nition of a function of two variables: A scalar-valued. Equations of a Straight Line. The standard deviation of an observation variable is the square root of its variance. Polynomial Calculator. In mathematics, the result of a modulo operation is the remainder of an arithmetic division. Graph the function f(x,y) = xy using x,y,z-coordinate axes in 3-D space. It seems reasonable, and can be shown to be true,. Just for consistency we can think of a function:. Loading Graph Functions of 2 Variables. lang package, and not in the java. In the case of functions of two variables, that is functions whose domain consists of pairs (x, y), the graph can be identified with the set of all ordered triples ((x, y, f(x, y)). 2 to find the resulting PDFs. When we extend this notion to functions of two variables (or more), we will see that there are many similarities. For functions of two or three variables the situation is more complicated because there are inﬁnitely many. I am now trying to find a general equation f(x1,x2). Long weekends and highway traffic on Friday afternoon C. First-order partial derivatives of functions with two variables. Applications of Extrema of Functions of Two Variables. Could someone please explain a function of two variables to me. function of two variables is far more di¢ cult than a function of one variable. Calculates the table of the specified function with two variables specified as variable data table. The INTERSECTION of two sets is the set of elements which are in both sets. You define a function in much the same way you define a variable. The value of num1 and num2 are initialized to variables a and b respectively. Function composition. The partial derivative of a function of two or more variables with respect to one of its variables is the ordinary derivative of the function with respect to that variable, considering the other variables as constants. In the example above, the diagonal was used to report the correlation of the four factors with a different variable. time) and one or more derivatives with respect to that independent variable. y(s;t) and z(s;t), are called the component functions of the vector-valued function g. The Method of Transformations. Examples 4. Here that means you need to use the. I found a and b for several values of x2, so I do have equations f(x1) for some fixed x2. Furthermore, sums, dif-.


# Calculating n mod pq from n mod p and n mod q

Let $p$ and $q$ be relative primes, $n$ positive integer.

Given

• $n\bmod p$ and
• $n\bmod q$

how do I calculate $n\bmod (pq)$ ?

-
en.wikipedia.org/wiki/… –  pedja Apr 10 '12 at 11:26
You might also have a look at Easy CRT in some Bill Dubuque's posts. –  Martin Sleziak Apr 10 '12 at 11:30

Since $p$ and $q$ are relatively prime, there are integers $a$ and $b$ such that $ap+bq=1$. You can find $a$ and $b$ using the Extended Euclidean algorithm. Then $n\equiv aps+bqr \bmod pq$ if $n\equiv r \bmod p$ and $n\equiv s \bmod p$.

As pedja mentioned, this is a constructive proof of the Chinese remainder theorem.

-
+1 for getting their first !!! –  hardmath Apr 10 '12 at 20:48

From the fact that $p,q$ are relatively prime, we can find coefficients $a,b$ such that:

$$ap + bq = 1$$

With these coefficients we can piece together a solution for n from its residues modulo $p$ and $q$. Say:

$$n \equiv r \mod p$$ $$n \equiv s \mod q$$

Then this works: $n = sap + rbq$ since:

$$bq \equiv 1 \mod p$$ $$ap \equiv 1 \mod q$$

Of course the above expression for $n$ can be reduced modulo $pq$ without affecting the residues modulo $p$ and $q$.

-

One may use the Bezout identity $\rm\:a\:p + b\:q = 1\:$ obtained by the extended Euclidean algorithm. But, in practice, it's often more convenient to use the form below, e.g. see my Easy CRT posts.

Theorem (Easy CRT) $\rm\ \$ If $\rm\ p,\:q\:$ are coprime integers then $\rm\ p^{-1}\$ exists $\rm\ (mod\ q)\ \$ and

$\rm\displaystyle\quad\quad\quad\quad\quad \begin{eqnarray}\rm n&\equiv&\rm\ a\ (mod\ p) \\ \rm n&\equiv&\rm\ b\ (mod\ q)\end{eqnarray} \ \iff\ \ n\ \equiv\ a + p\ \bigg[\frac{b-a}{p}\ mod\ q\:\bigg]\ \ (mod\ p\:\!q)$

Proof $\rm\ (\Leftarrow)\ \ \ mod\ p\!:\:\ n\equiv a + p\ (\cdots)\equiv a\:,\$ and $\rm\ mod\ q\!:\:\ n\equiv a + (b-a)\ p/p \equiv b\:.$

$\rm\ (\Rightarrow)\ \$ The solution is unique $\rm\ (mod\ p\!\:q)\$ since if $\rm\ x',\:x\$ are solutions then $\rm\ x'\equiv x\$ mod $\rm\:p,q\:$ therefore $\rm\ p,\:q\ |\ x'-x\ \Rightarrow\ p\!\:q\ |\ x'-x\ \$ since $\rm\ \:p,\:q\:$ coprime $\rm\:\Rightarrow\ lcm(p,q) = p\!\:q\:.\quad$ QED

-
The link goes to emptiness... –  I. J. Kennedy May 1 '13 at 0:02


#### 2.1.3 Transport equation $$u_t+2 u_x = 0$$ IC $$u(-1,x)=\frac {x}{1+x^2}$$. Peter Olver textbook, 2.2.2 (b)

problem number 3

Taken from Peter Olver textbook, Introduction to Partial diﬀerential equations.

Solve for $$u(t,x)$$ in $$u_t+2 u_x = 0$$ with IC $$u(-1,x)=\frac {x}{1+x^2}$$

Mathematica

$\left \{\left \{u(t,x)\to \frac {-2 t+x-2}{4 t^2-4 t (x-2)+x^2-4 x+5}\right \}\right \}$

Maple

$u \left (t , x\right ) = \frac {-2 t +x -2}{\left (-2 t +x -2\right )^{2}+1}$

Hand solution

Solve $u_{t}+2u_{x}=0$ With initial conditions $$u\left ( -1,x\right ) =\frac {x}{1+x^{2}}$$.

Solution

Let $$u=u\left ( x\left ( t\right ) ,t\right )$$. Then \begin {equation} \frac {du}{dt}=\frac {\partial u}{\partial x}\frac {dx}{dt}+\frac {\partial u}{\partial t}\tag {2} \end {equation} Comparing (1),(2) shows that \begin {align} \frac {du}{dt} & =0\tag {3}\\ \frac {dx}{dt} & =2\tag {4} \end {align}

Eq (3) says that $$u$$ is constant on the chataterstic lines, or $$u=u\left ( x\left ( -1\right ) \right )$$. Using the given initial conditions, this becomes \begin {equation} u\left ( x\left ( t\right ) ,t\right ) =\frac {x\left ( -1\right ) }{1+x\left ( -1\right ) ^{2}}\tag {5} \end {equation} Eq (4) is now used to ﬁnd $$x\left ( -1\right )$$. Soving (4) gives $$x=x\left ( 0\right ) +2t$$. Hence $$x\left ( -1\right ) =x\left ( 0\right ) -2$$ or $$x\left ( 0\right ) =x\left ( -1\right ) +2$$. Therefore \begin {align*} x & =x\left ( -1\right ) +2+2t\\ x\left ( -1\right ) & =x-2-2t \end {align*}

Now that we found $$x\left ( -1\right )$$, we substitute it in (5), giving the solution$u\left ( x\left ( t\right ) ,t\right ) =\frac {x-2-2t}{1+\left ( x-2-2t\right ) ^{2}}$ Alternative method. Using Lagrange-charpit method

$\frac {dt}{1}=\frac {dx}{2}=\frac {du}{0}$ Which implies that $$du=0$$ or $$u=C_{1}$$. A constant. Integrating $$\frac {dt}{1}=\frac {dx}{2}$$ gives $$t=\frac {1}{2}x+C_{2}$$ or $$C_{2}=t-\frac {1}{2}x$$. But $$C_{1}=F\left ( C_{2}\right )$$ always, where $$F$$ is arbitrary function. Since $$C_{1}=u$$ then\begin {align} u & =F\left ( C_{2}\right ) \nonumber \\ u & =F\left ( t-\frac {1}{2}x\right ) \tag {1} \end {align}

At $$t=-1$$ the above becomes$\frac {x}{1+x^{2}}=F\left ( -1-\frac {1}{2}x\right )$ Let $$-1-\frac {1}{2}x=z$$ which implies $$x=-2\left ( 1+z\right )$$ The above can be written as\begin {align*} \frac {-2\left ( 1+z\right ) }{1+\left ( -2\left ( 1+z\right ) \right ) ^{2}} & =F\left ( z\right ) \\ F\left ( z\right ) & =-\frac {2\left ( 1+z\right ) }{4z^{2}+8z+5} \end {align*}

From the above then (1) can be written as\begin {align*} u\left ( t,x\right ) & =-\frac {2\left ( 1+\left ( t-\frac {1}{2}x\right ) \right ) }{4\left ( t-\frac {1}{2}x\right ) ^{2}+8\left ( t-\frac {1}{2}x\right ) +5}\\ & =\frac {x-2t-2}{4t^{2}-4tx+8t+x^{2}-4x+5}\\ & =\frac {x-2t-2}{1+\left ( x-2-2t\right ) ^{2}} \end {align*}

The following is an animation of the solution

 3D 2D

Source code used for the above

________________________________________________________________________________________


## Number of trailing zeros in factorial of an integer

An integer n is given, the task is to find the number of trailing zeros in n! .

### Solution

First we need to see what produces trailing zeros. We assume that the integers are represented in base 10. A pair of 5 and 2 (which are the prime factors of 10) will produce a trailing zero in a sequence of integer multiplication. The number of trailing zeros will not decrease as once a trailing zero is generated in a product it cannot be removed by multiplying with some non zero integer. For factorial of n the multiplication series is: $n\times (n-1)\times(n-2)\times \ldots \times 3 \times 2 \times 1$ . We need to count number of pairs of 5 and 2 present as a factor of each integer in the series. Naturally there are at least equal number of factors 2 than 5, if not more. Therefore basically the number of times 5 occurs as a factor totally in the series, ie. the multiplicity of the prime factor 5 in the factorial represents the number of trailing zeros.

For example in the case of 25! , the factor 5 occurs 6 times totally in the series of multiplication $25 \times 24 \times \ldots \times 3 \times 2 \times 1$. 5, , ie. the multiplicity of the factor 5 is 6. The integers 10, 15, 20 is divided by 5 once, and twice for 25.

Therefore now the problem decreases to count the number of times the factor 5 occurs in the given series of multiplication. Which can be found as below:

$trailing zeros = \sum_{i=1}^{k} \left\lfloor n/5^i \right\rfloor = \left\lfloor n/5 \right\rfloor + \left\lfloor n/5^2 \right\rfloor + \left\lfloor n/5^3 \right\rfloor + \ldots + \left\lfloor n/5^k \right\rfloor$ such that $5^k \le n$

Here is some explanation. The term $\left\lfloor n/5^i \right\rfloor$ finds the number of integers between 1 and n that $5^i$ divides. For example for n = 27, $\left\lfloor 27/5 \right\rfloor = 5$, that is there are 5 integers divisible by 5 within the range 1 to 27, in other words there is 5 integers which has the factor 5 once, which are 5, 10, 15, 20, and 25. Also $\left\lfloor 27/5^2 \right\rfloor = 1$ , that is, there are 1 integer divisible by 25 within the range 1 to 27, or in other words there is one integer which has the factor 5 twice. The total number of occurrence of the factor 5 is calculated by computing the above formula, which divides and adds the number of times a power of factor 5 occurs in factorial of n. Therefore there are a total of 5 + 1 = 6 number of times the factor 5 occurs in the entire series of 1 to 27. Therefore there are 6 trailing zeros in 27! and 27! = 10888869450418352160768000000 which has 6 trailing zeros.

The implementation is pretty straight forward.

### Sourcecode

#include <stdio.h>

/* long int n : the input factorial integer
* long int i : holds value 5^k , the divisor of n' to
*              find the number of times the factor 5 occurs
*              in the factorial of n'
* long int c : number of times the 5 occurs as a factor in the
*              factorial of n'
* long int t : the number of times the factor 5^i occurs in the n!'
*/
int
main (void)
{
long int n, i = 5, c = 0, t;

printf ("\nEnter n: ");
scanf ("%ld", &n);
do
{
t = n / i; /* computes floor (n/i)  where i=5^k */
c += t;    /* update the number of occurrence of factor 5 */
i *= 5;    /* update i' to be the next power of 5 */
}
while (t != 0);

printf ("Number of trailing zeros in %ld! : %ld\n", n, c);

return 0;
}

### Output

Some sample outputs are given below.

run 1
Enter n: 3
Number of trailing zeros in 3! : 0

run 2
Enter n: 6
Number of trailing zeros in 6! : 1

run 3
Enter n: 15
Number of trailing zeros in 15! : 3

run 5
Enter n: 60
Number of trailing zeros in 60! : 14

run 6
Enter n: 100
Number of trailing zeros in 100! : 24

run 7
Enter n: 1000
Number of trailing zeros in 1000! : 249

run 8
Enter n: 5000
Number of trailing zeros in 5000! : 1249

run 9
Enter n: 10000
Number of trailing zeros in 10000! : 2499

run 10
Enter n: 12345678
Number of trailing zeros in 12345678! : 3086416

Homo-sapiens
This entry was posted in Coding Discussions, Computer Science, Others and tagged , , , , . Bookmark the permalink.

### 2 Responses to Number of trailing zeros in factorial of an integer

1. Cassie says:

Fantastic post! This site also gives a good explanation of how to come up with the algorithm, and also an implementation in Java:

http://www.programmerinterview.com/index.php/java-questions/find-trailing-zeros-in-factorial/

• phoxis says:

Great site. Once you know the algorithm you can implement it in any language. For example here are some quick bash implementations.

#!/bin/bash

num=$1 i=5 t=1 while [$t -ne 0 ]
do
t=$((num/i)) count=$((count+t))
i=$((i*5)) done echo "Trailing zeros of$num ! = $count"  Or we can use the factor command to count the number of 5 in each of the integer. Although this process is extremely inefficient as it will compute the factor of each integer from 1 to n, but still it works. #!/bin/bash num=$1
count=0

for ((i=1; i<=num; i++))
do
this_count=$(factor$i | cut -d':' -f 2 | tr ' ' '\n' | grep -c "\<5\>")
count=$((count + this_count)) this_count=0 done echo "$count"
`

Thanks for visiting.


# Math Help - Cross multiplying vectors

1. ## Cross multiplying vectors

The question asks me to find the resulting vector without using determinants. Instead I am supposed to use properties of cross products.

$(j-k)$ x $(k - i)$

I really can't even get started. A hint or general idea would be very helpful though.

2. Originally Posted by Riyzar
The question asks me to find the resulting vector without using determinants. Instead I am supposed to use properties of cross products.

$(j-k)$ x $(k - i)$

I really can't even get started. A hint or general idea would be very helpful though.
You should know that $\vec{i}\times \vec{j}= \vec{k}$, $\vec{j}\times\vec{k}= \vec{i}$, and $\vec{k}\times\vec{i}= \vec{j}$. And, of course, that $\vec{u}\times\vec{v}= -\vec{v}\times\vec{u}$ which, among other things, implies $\vec{u}\times\vec{u}= 0$. Also that the cross product distributes over addition: $(\vec{j}- \vec{k})\times (\vec{k}- \vec{i})= (\vec{j}- \vec{k})\vec{k}- (\vec{j}- \vec{k})\vec{i}= \vec{j}\times\vec{j}+ \vec{k}\vec{j}- \vec{k}\times\vec{i}+ \vec{k}\times\vec{i}$

3. Hello, Riyzar!

$\text{Find the resulting vector }without\text{ using determinants: }\;(\vec j-\vec k) \times(\vec k - \vec i)$

Are those unit vectors? . $\begin{Bmatrix}\vec i &=& \langle 1,0,0\rangle \\ \vec j &=& \langle 0,1,0\rangle \\ \vec k &=& \langle 0,0,1\rangle \end{Bmatrix}$

$\left(\vec j - \vec k\right) \times \left(\vec k - \vec i\right) \;=\;\left(\vec j - \vec k\right )\times \vec k - \left(\vec j - \vec k\right)\times \vec i$

. . . . . . . . . . . . . . $=\; \left(\vec j \times \vec k\right) - \left(\vec k \times \vec k \right) - \left(\vec j \times \vec i\right) + \left(\vec k \times \vec i\right)$

. . . . . . . . . . . . . . $=\qquad \vec i \quad\;\; -\;\;\quad \vec 0 \quad - \quad (-\vec k) \quad + \quad \vec j$

. . . . . . . . . . . . . . $=\quad \vec i\;+\; \vec j\;+\;\vec k$

4. Originally Posted by HallsofIvy
Also that the cross product distributes over addition: $(\vec{j}- \vec{k})\times (\vec{k}- \vec{i})= (\vec{j}- \vec{k})\vec{k}- (\vec{j}- \vec{k})\vec{i}= \vec{j}\times\vec{j}+ \vec{k}\vec{j}- \vec{k}\times\vec{i}+ \vec{k}\times\vec{i}$
That is what I was not aware of, thank you!


# How can we show that $(a_n), (b_n), (c_n)$ are convergent and have the same limit?

We have the following for $a \le b \le c >0$:

$A(a,b,c)=\frac{a+b+c}{3}, B(a,b,c)= (abc)^{1/3}, C(a,b,c)=\frac{3}{\frac{1}{a}+\frac{1}{b}+\frac{1}{c}}$.

Then we define the sequences $(a_n),(b_n), (c_n)$ by

$a_1=a, b_1=b, c_1=c,$

$a_{n+1}=A(a_n,b_n,c_n), b_{n+1}=B(a_n,b_n,c_n), c_{n+1}=C(a_n,b_n,c_n)$.

How can we show that $(a_n),(b_n), (c_n)$ are convergent and have the same limit?

I understand that $A(a,b,c)\ge B(a,b,c)$ and $B(a,b,c)\ge C(a,b,c)$

• @dxiv I think so. – MOP Feb 6 '18 at 5:13
• See this and this related questions, same idea applies here. – dxiv Feb 6 '18 at 5:17
• Assume you meant $0 < a \le b \le c$, and not that only $c$ is positive. – Macavity Feb 6 '18 at 6:27

We have $$A(x,y,z) = \mbox{ arithmetic mean of } x,y,z;$$ $$B(x,y,z) = \mbox{ geometric mean of } x,y,z;$$ $$C(x,y,z) = \mbox{ harmonic mean of } x,y,z.$$

It is well known that, for the same arguments, $$\mbox{ harmonic mean } \le \mbox{ geometric mean } \le \mbox{ arithmetic mean } \tag{1}$$ (see e.g. this Wikipedia article).

Using these inequalities we see that the largest (arithmetic) means $a_n$ form a non-increasing sequence, while the smallest (harmonic) means $c_n$ form a non-decreasing sequence. Both sequences are bounded: all terms are within the interval $[a,c]$. If a sequence is monotonic and bounded, it has a limit.

Can you finish by proving that the limits of $a_n$ and $c_n$ are the same? (Then $b_n$ necessarily has the same limit too because of the double inequality $(1)$ and the squeeze theorem.)

For $n>1$ we have $$a_{n+1}={a_n+b_n+c_n\over3}\le{a_n+a_n+c_n\over3}, \tag{2}$$ $$c_{n+1} \ge c_n. \tag{3}$$ Subtracting $(3)$ from $(2)$ we find $$a_{n+1}-c_{n+1} \le {2\over3} (a_n-c_n).$$ We observe that the intervals $[c_n,a_n]$ form a sequence of nested closed intervals, and the interval lengths tend to zero (no slower than a decreasing geometric progression). Therefore these intervals have a (unique) common point, and this point must be the limit of all three sequences because $a_n,b_n,c_n \in [c_n,a_n]$ for all $n>1$. (The common point is unique because the size of intervals $[c_n,a_n]$ tends to zero.) This completes the proof.

• I can understand that $(a_n)$ is decreasing sequence and $(c_n)$ is a increasing sequence. But could you please please help me with finding the limit? – MOP Feb 6 '18 at 5:32
• You are not required to find the limit. You just need to prove that the limits are the same. – Alex Feb 6 '18 at 5:37
• For example, you can prove that $a_{n+1}-c_{n+1}\le0.9(a_n-c_n)$, and then observe that the limit of each sequence is in the interval $[c_n,a_n]$ for all $n\in{\mathbb N}$. Note that the intervals $[c_n,a_n]$ form a sequence of nested intervals. – Alex Feb 6 '18 at 5:53
• I could't find $a_{n+1}-c_{n+1} \le \frac{1}{x} (a_n-c_n)$. I can understand it for two numbers case only. – MOP Feb 6 '18 at 7:48

hint: try proving $c_n$ is increasing and $a_n$ is decreasing and use squeeze theorem.

Assuming $a>0.$ For any positive $a',b',c'$ we have $$\max (a',b',c')\geq A(a',b',c')\geq B(a',b','c)\geq C(a',b',c')\geq \min (a',b',c').$$ Let $U_n=\max (a_n,b_n,c_n)$ and $L_n=\min (a_n,b_n,c_n).$ $$\text {We have }\quad U_n\geq U_{n+1}\geq L_{n+1}\geq L_n.$$ So $(U_n)_n$ is a deceasing sequence bounded below by $L_1$ and $(L_n)_n$ is an increasing sequence bounded above by $U_1 .$

Let $U=\lim_{n\to \infty}U_n$ and $L=\lim_{n\to \infty}L_n.$ Obviously $U\geq L\geq L_1>0.$

It suffices to show that $U=L.$

Let $r_n=U_n-L_n .$ Note that $U_n>r_n.$ $$\text {We have }\quad U_{n+1}\leq \frac {2U_n+L_n}{3}$$
$$\text {and }\quad L_{n+1}\geq \frac {3}{\frac {1}{U_n}+\frac {2}{L_n}}=\frac {3U_nL_n}{2U_n+L_n}.$$ $$\text {Therefore }\quad r_{n+1}\leq \frac {2U_n+L_n}{3}-\frac {3U_nL_n}{2U_n+L_n}=$$ $$=\frac {(4U_n-L_n)(U_n-L_n)}{3(2U_n+L_n)}=$$ $$=\frac {(3U_n+r_n)r_n}{9U_n-3r_n}\leq$$ $$\leq \frac {(4U_n)r_n}{6U_n}=\frac {2}{3}r_n.$$

So $U-L=\lim_{n\to \infty}r_n=0$ because $0\leq r_{n+1}\leq \frac {2}{3}r_n.$

• How did you show that $a_n$ is increasing and $b_n$ is increasing? – MOP Feb 6 '18 at 10:33
• I didn't understand your proof? Why did you take U and L? – MOP Feb 6 '18 at 11:22
• $U_n=\max (a_n,b_n,c_n).$... $L_n=\min (a_n,b_n,c_n).$... $U_{n+1}= \max (a_{n+1},b_{n+1},c_{n+1}) =$ $\max (\; A(a_n,b_n,c_n), B(a_n,b_n,c_n),C(a_n,b_n,c_n)\;)\;=$ $A(a_n,b_n,c_n)\leq \max (a_n,b_n,c_n)=U_n.$..... For $n>1$ we have $U_n=a_n$ and $L_n=c_n.$.... So $a_n$ is decreasing, not increasing..... If $U_n=\max (a_n,b_n,c_n)$ converges to $U$ and if $L_n= \min (a_n,b_n,c_n)$ converges to $L$ and if $U=L$ then $a_n, b_n,c_n$ each converge to $L$ also. – DanielWainfleet Feb 6 '18 at 23:18


# Equating powers in a series expansion

If the $(r+1)^{th}$ term contains the same power of $a$ and $b$ in the expansion of $$\bigg(\sqrt[3]{\frac{a}{\sqrt b}}+\sqrt{\frac {b}{\sqrt[3]{a}}}\bigg)^{21}$$ find the value of $r$

I simply applied binomial and expanded for the general term and then equated the power of $a$ and $b$ and got $r=12$

My friend got $r=9$

I want to know which answer is correct.

Without trying to replicate your calculations, you're probably using version of the binomial theorem that count the terms from the opposite end. You can state the theorem either as $$(p+q)^n = \sum_{r=0}^n \binom{n}{r} p^r q^{n-r}$$ or as $$(p+q)^n = \sum_{r=0}^n \binom{n}{r} p^{n-r} q^r$$ which both give the same terms, just with a different numbering.

Note in particular that $9+12=21$, so you can both be right, if you're counting from different ends of the expansion!

On simplifying the following expression: $$\bigg(\sqrt[3]{\frac{a}{\sqrt b}}+\sqrt{\frac {b}{\sqrt[3]{a}}}\bigg)^{21}$$ We get the expression: $$\frac{1}{(ab)^\frac72}\bigg(a^\frac12+b^\frac23\bigg)^{21}$$

So the (r$+1$)th term of the expansion is $$\binom{n}{r}a^{\frac{21-r-7}{2}}b^{\frac{4r-21}{6}}$$

Hence, the answer will come as: $$\frac{21-r-7}{2}=\frac{4r-21}{6}$$ $$\Rightarrow 42-3r=4r-21$$ $$\Rightarrow \boxed{\color{red}{r=9}}$$

The required answer is $9$.

• couldn't it be 12 as 12+9=21? – Atul Mishra Jul 8 '17 at 10:56
• The first step here looks somewhat obscure. Why not simplify to $$(a^{1/3}b^{-1/6}+a^{-1/6}b^{1/2})^{21}$$ and then solve $$\frac13r - \frac16(21-r) = -\frac16 r + \frac12(21-r)$$ – hmakholm left over Monica Jul 8 '17 at 10:59
• @AtulMishra Well, in a problem, where the binomial expression is rigorously given, it is expected that you consider the first term as the 'a' term and the second one 'b'. So if you consider the expansion in this order, your answer should be 9. I saw Henning's answer, but I dont think that you are allowed to reverse the expression and work. It may seem trivial that you cannot reverse the expression but if one is allowed to do so, then the ordering of the terms will become ambiguous and there will be no unique answer. Hope this helps. – SchrodingersCat Jul 8 '17 at 11:02
• Yes I am just arguing for the same, It will give r=12 – Atul Mishra Jul 8 '17 at 11:03
• @SchrodingersCat: There's no "reversing" going on -- there's just two ways to state the binomial theorem which are exactly equally good. It's not as if one of them is "the right way" and the other is "reversed". – hmakholm left over Monica Jul 8 '17 at 11:05