Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Mathematica 1) a) Looking at the average distance of two points within a u

ID: 3866408 • Letter: U

Question

Using Mathematica

1) a) Looking at the average distance of two points within a unit sqaure, produce a table of ordered pairs n, dav, where n is the dimension of the ”square” (n = 2, for 2-d, n = 3 for 3-d) and dav is the average distance between the points for that n dimensional space using the Monte Carlo Method for 10,000 points per n. (Use 10,000 points to find the average distance for the 3-d case, the 4-d case, etc.) Make a table from n = 1 to n = 100.

b) Plot the result in a part a) using axis labels and a plot label.

c) Try to fit that plot/data to a function of n, so that this can be generalized (approximately) for any n-d hypercube.

d) To test how well your fit works in part c), produce a table of the relative error between your calcuated values in part a) and the fitted function. Plot this table as well.

Please include screenshots of the coding used thank you.

Explanation / Answer

ANSWER::

Any least squares curve- or line-fitting algorithm optimizes the constants of a fitting equation by minimizing the sum of the squares of the deviations of the actual (data) values from the values predicted by the equation. You probably know how to do linear least squares fitting of a straight line already, since most scientific calculators and graphing software packages do this automatically for you. Nevertheless, I will present it here so that: (1) you will be aware of assumptions inherent in use of the canned programs, (2) you can verify with your own calculations that you get the same answers as the canned programs, and (3) I can build on this base for cases where some of the "canned" assumptions are not valid. 2 Given: A set of n experimental data points, x1, y1 x2, y2 : : : : xn, yn where x is the independent variable (i.e., the thing you fix or consider fixed, such as time when you are measuring reaction kinetics, or voltage when you are using a pressure transducer), and y is the dependent variable (i.e., the thing that you want to determine, such as extent of reaction or pressure). The xi values are assumed to be listed from lowest to highest. (It is not really necessary here to list the points in order of increasing xi, but it will be in a later part of this document.) Furthermore, let's assume that the relationship between x and y is a linear one (if it's not, fitting a line to the points is worthless). Let y = ax + b be the equation of the best fit line to the data. We wish to determine the values of both the slope a and the intercept b. If we assume that each data point carries equal weight, i.e., each yi point has exactly the same actual (not relative) error associated with it, then we find a and b by minimizing the sum of the squares of the deviations of the actual values of yi from the line's calculated value of y. The formulas for a and b are: == 2 2 )()( ))(()( i i ii i i xxn yxyxn SLOPEa (1) 2 2 2 )()( ))(())(( = = i i i i iii xxn yxxyx b INTERCEPT (2) In all equations, the summation sign is assumed to be from i=1 to i=n. 3 For example, consider this actual calibration data for the vortex flowmeter from the frictional losses experiment in junior lab: Voltage (xi) Flow rate, liter/s (yi) 1.01 0.00 1.27 0.19 1.85 0.58 2.38 0.96 2.83 1.26 3.13 1.47 3.96 2.07 4.91 2.75 The linear least squares fit to this data gives the line: yi = 0.70303729738 xi -0.7153519908 (liters/sec) (It is always a good idea to carry along as many significant figures as possible during statistical calculations because truncation errors may be significant when subtracting two nearly equal values. I've included all these figures above so you may check the calculation yourself, if you wish.) If you use the linear curve-fitting routine in Excel, you get: yi = 0.703 xi -0.7154 (liters/sec) with a correlation coefficient R2 = 0.9999.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote