Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13836 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2013-03-14 11:12 +0000 |
| Last post | 2013-03-14 11:12 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Noob requests help with recursive formula Bob Hanlon <hanlonr357@gmail.com> - 2013-03-14 11:12 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2013-03-14 11:12 +0000 |
| Subject | Re: Noob requests help with recursive formula |
| Message-ID | <khsbbq$36d$1@smc.vnet.net> |
g[a_?VectorQ, b_?VectorQ] := Module[
{c, n = Length[a]},
c = Table[0, {n}];
Table[c[[k]] =
f[a[[k]]/(b[[k]] - Total[
a[[1 ;; k - 1]]/c[[1 ;; k - 1]]])],
{k, n}];
c] /; Length[a] == Length[b]
Clear[a, b, f];
c = With[{n = 3}, g[Array[a, n], Array[b, n]]]
{f[a[1]/b[1]], f[a[2]/(b[2] - a[1]/f[a[1]/b[1]])],
f[a[3]/(b[3] - a[1]/f[a[1]/b[1]] -
a[2]/f[a[2]/(b[2] - a[1]/f[a[1]/b[1]])])]}
f[x_] = x;
a = RandomReal[1, 10];
b = RandomReal[1, 10];
c = g[a, b]
{1.67559, 1.14738, -1.68319, -3.93066, -1.94426, 0.996524, -1.32233, \
0.339927, -1.09966, 1.12554}
Bob Hanlon
On Wed, Mar 13, 2013 at 4:19 AM, <Garcia5529@yahoo.fr> wrote:
> I appreciate any tips on how to code this in Mathematica.
> I have two lists, each with 99 elements; A and B. Real numbers.
> I want to form a list, C, whose elements are functions (F[]) of A and B, and also previous elements of C itself.
>
> C ={F[A1/B1], F[A2/(B2-A1/C1)], F[A3/(B3-A1/C1-A2/C2)],..F[A99/(B99-A1/C1...-A98/C98.)}
>
> ...where the integers after A,B, and C, are element indices.
> Thanks for any suggestions.
> HG
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web