Re: Math Problem in Mathematica
- To: mathgroup@smc.vnet.net
- Subject: [mg10357] Re: Math Problem in Mathematica
- From: Paul Abbott <paul@physics.uwa.edu.au>
- Date: Mon, 12 Jan 1998 04:09:54 -0500
- Organization: University of Western Australia
- References: <694bda$kp6@smc.vnet.net>
Daniel wrote: > The problem I would like to formulate in Mathematica is: Let f[i,j] = > Abs[Sqrt[1-(i/n)^2]-j/n]. i and j run from 1 to n, and n is a fixed > integer >=1. I want to find the sum S of the minimum of f over j, for > each i for given n. > > Example: n=7. Min (i=1, j from 1 to 7)= .01 > Min (i=2, """ )= .04 > Min (i=3, ... = .05 > etc. > > and the sum S = 0.20. > > FindMinimum seemed like the right idea, but I don't know how to make it > work for a function of discrete values. A direct implementation works fine: In[1]:= f[i_, j_, n_] = Abs[Sqrt[1 - (i/n)^2] - j/n]; In[2]:= S[n_] := Sum[Min[Table[f[i, j, n], {j, n}]], {i, 1, n}] In[3]:= S[7] Out[3]= 24 4 Sqrt[3] 3 Sqrt[5] 2 Sqrt[6] 2 Sqrt[10] -- - --------- - --------- - --------- + ---------- - 7 7 7 7 7 Sqrt[13] Sqrt[33] -------- - -------- 7 7 Note that Mathematica gives you the exact answer to this problem rather than a numerical approximation: In[4]:= N[%] Out[4]= 0.348436 This does not agree with the answer above. If the sum over is restricted to 1<=i<n then you do get an answer of approximately 0.20. Cheers, Paul ____________________________________________________________________ Paul Abbott Phone: +61-8-9380-2734 Department of Physics Fax: +61-8-9380-1014 The University of Western Australia Nedlands WA 6907 mailto:paul@physics.uwa.edu.au AUSTRALIA http://www.pd.uwa.edu.au/~paul God IS a weakly left-handed dice player ____________________________________________________________________