Re: Summation Problem w/ 5.0
- To: mathgroup at smc.vnet.net
- Subject: [mg43815] Re: Summation Problem w/ 5.0
- From: andrea.knorr at engr.uconn.edu (Andrea)
- Date: Tue, 7 Oct 2003 02:40:54 -0400 (EDT)
- References: <blr1f1$3ge$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Bill Rowe <readnewscix at mail.earthlink.net> wrote in message news:<blr1f1$3ge$1 at smc.vnet.net>...
> On 10/4/03 at 2:05 AM, andrea.knorr at engr.uconn.edu (Andrea) wrote:
>
> > Has anyone else had this problem with the new version? I have created
> > multiple lists with multiple elements, and I am trying to sum all
> > elements of all lists. As output I don't get a single value; instead
> > I get several numbers separated by a plus sign. For example, instead
> > of Mathematica giving "2" as output, I get "1+1".
>
> I am using ver 5.0 under Max OSX version 10.2.8 and do not see this behavior. I or someone else here might be able to offer constructive suggestions if you post the code leading to this problem.
>
> To reply via email subtract one hundred and nine
I posted code Saturday morning, but it has not been added, so I will
try again. In my program I have created three lists, "virus",
"uninfected", and "infected" which are concentrations at a particular
time. "vtime", "xtime", and "ytime" are the time points that
correspond to the given concentration. The function "titer" solves
three differential equations that model a viral system. minfcn is a
part of nonlinear regression. The problem I am having occurs when I
evaluate minfcn, using the parameters published in a journal article,
at values above a particular element of "virus", "uninfected", and
"infected". Here's the code:
titer[lambda_, beta_, d_, k_, a_, u_] :=
Module[{soln, x, y, v, valueslist, xeval, yeval, veval},
soln = NDSolve[{
x'[t] == lambda - d x[t] - beta x[t] v[t],
y'[t] == beta x[t] v[t] - a y[t],
v'[t] == k y[t] - u v[t],
x[0] == 10^9, y[0] == 0, v[0] == 10^9},
{x, y, v}, {t, 0, 2500}];
xtiter = Evaluate[x[xtime] /. soln];
ytiter = Evaluate[y[ytime] /. soln];
vtiter = Evaluate[v[vtime] /. soln];
values = Table[Flatten[{xtiter, ytiter, vtiter}, 1]];
values
];
calcs = titer[10^7, 5*10^-10, 0.1, 500, 0.5, 5];
minfcn[lambda_, beta_, d_, k_, a_, u_] :=
Module[{i, j},
diffsum =
Sum[10000*(uninfected[[i, 2]] - calcs[[1, i]])^2 +
10000*(infected[[i, 2]] - calcs[[2, i]])^2, {i,
Length[uninfected]}] +
Sum[(virus[[j, 2]] - calcs[[3, j]])^2, {j, Length[virus]}];
diffsum
]
minfcn[10^7, 5*10^-10, 0.1, 500, 0.5, 5]
Here is the output:
(2.518473817923033*10^24 +
10000*(-1.80000521715242*10^7 + 20000)^2 +
10000*(-1.8*10^7 + 20000)^2 +
10000*(-1.*10^7 + 980000)^2 +
10000*(-9.99926182857273*10^6 + 980000)^2)
I need a single number to continue my calculations.
~Andrea
- Follow-Ups:
- Re: Re: Summation Problem w/ 5.0
- From: "Peter Pein" <petsie@arcor.de>
- Re: Re: Summation Problem w/ 5.0