Re: New to Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg126413] Re: New to Mathematica
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Tue, 8 May 2012 04:12:04 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jntga4$2c$1@smc.vnet.net>
Build one step at a time. For a given value of k (say k=2) use exact values (i.e., 1082/10 rather than 108.2) and restrict the domain of Solve to Reals With[{k = 2}, Solve[(x/Log[x]) (1 + 1/Log[x]) == 1082/10 + k, x, Reals]] {{x -> Root[{-551 Log[#1]^2 + 5 #1 + 5 Log[#1] #1 &, 0.91655356819195758220}]}, {x -> Root[{-551 Log[#1]^2 + 5 #1 + 5 Log[#1] #1 &, 1.11136974029598568569}]}, {x -> Root[{-551 Log[#1]^2 + 5 #1 + 5 Log[#1] #1 &, 611.73540466624378639}]}} Use N to convert Root objects to their values (last entry in Root object) With[{k = 2}, Solve[ (x/Log[x]) (1 + 1/Log[x]) == 1082/10 + k, x, Reals] // N] {{x -> 0.916554}, {x -> 1.11137}, {x -> 611.735}} Use ReplaceAll to extract values from rules With[{k = 2}, x /. Solve[ (x/Log[x]) (1 + 1/Log[x]) == 1082/10 + k, x, Reals] // N] {0.916554, 1.11137, 611.735} Use Part, Last, or Max to extract largest value With[{k = 2}, x /. Solve[ (x/Log[x]) (1 + 1/Log[x]) == 1082/10 + k, x, Reals][[-1]] // N] 611.735 Convert to a function of k with k restricted to Integers r[k_Integer] := x /. Solve[ (x/Log[x]) (1 + 1/Log[x]) == 1082/10 + k, x, Reals][[-1]] // N r[2] 611.735 Plot of r ListPlot[{#, r[#]} & /@ Range[-20, 20, 4], Frame -> True, Axes -> False] Define your Product as a function of kmax p[kmax_Integer] := Product[1 - 1/r[k], {k, 0, kmax}] p[10] 0.982714 This is quite slow so calculation for large values of kmax will take considerable time. Plot of p ListPlot[{#, p[#]} & /@ Range[0, 20, 2], Frame -> True, Axes -> False] Bob Hanlon On Sun, May 6, 2012 at 8:28 PM, J.Jack.J. <jack.j.jepper at googlemail.com> wr= ote: > Thanks for replying. Responses embedded: > > > On May 6, 8:24 am, Murray Eisenberg <mur... at math.umass.edu> wrote: >> First, perhaps folks were reluctant to respond because this looked like >> it could be a homework exercise. >> >> Second, you don't even have proper Mathematica syntax in your equation >> relating x and k. Did you even try to read the documentation to learn >> the very basics? > > I tried and tried for hours but couldn't so much as find any section > that would even tell me how to write the condition that k be an > integer. > > For example, proper syntax for the equation would be: >> >> (x/Log[x]) (1 + 1/Log[x]) == 108.2 + k >> >> Function arguments must be enclosed in brackets, not parentheses, and >> the equality is a doubled "=" sign. Moreover, your original expression >> had an unbalanced terminal parenthesis. >> > > Thanks. > >> Third, the equation itself looks really nasty. Aside from the fact that >> it mixes exact formulas with an approximate real (108.2), the left-hand >> side is transcendental. >> >> Fourth, the equation does not seem to uniquely define x as a function of >> k! For example, form the difference between the two sides... >> >> f[x_] := (x/Log[x]) (1 + 1/Log[x]) - 108.2 - k >> >> ... and plot f for, say, k = 2: >> >> Plot[Evaluate[f[x] /. k -> 2], {x, 0.5, 2}, Exclusions -> {x == = > = 1}, >> AxesOrigin -> {0, 0}, PlotRange -> {-5, 5}] >> >> The graph crosses the x-axis twice. And indeed, if you use FindRoot with >> initial guesses above and below 1, you'll see that this is so: >> >> FindRoot[Evaluate[f[x] /. k -> 2], {x, 0.9}] >> {x -> 0.916554} >> >> FindRoot[Evaluate[f[x] /. k -> 2], {x, 1.1}] >> {x -> 1.11137} >> > > Am sorry, I should have said "let r(k) be the highest x such that..." > > Can you give me the required inputs? That would help me immensely. >