how to evaluate with certain conditions and how to use arrays instead of separate variables
Subject: how to evaluate with certain conditions and how to use arrays instead of separate variables
From: Robert Dodier
Date: Sun, 2 Dec 2012 02:37:17 +0000 (UTC)
On 2012-12-01, =?utf-8?Q?foelsche at sbcglobal.net?= <foelsche at sbcglobal.net> wrote:
> I?m trying to avoid writing conditions (values of variables) repeatedly.
>
> And I?m trying to avoid having to write n^2 lines of code for getting n^2 number of results
OK, I've reorganized the program to compute lists of derivatives for the
variables of interest, and evaluate them. I get the same numerical
results as the original program (with rationals subsituted for floats).
I've also simplified the derivative calculations a little by computing
all the derivatives, then doing the evaluation afterward -- that way I
can obviate the need for at(diff(..., %x), %x=x).
Hope this helps,
Robert Dodier
PS. This code replaces lines 53 and following in the original program.
variables : [b1, c1, d1, b2, c2, d2, b3, c3, d3];
int1_ : int1 (t0, h, a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3,
omega);
dint1 : map (lambda ([x], diff (int1_, x, 1)), variables);
dint2 : map (lambda ([x], diff (int1_, x, 2)), variables);
dint1_ : ev (dint1, t0=0, h=10^-8, a1=0, b1=0, c1=0, d1=0, a2=0, b2=0,
c2=0, d2=0, a3=0, b3=0, c3=0, d3=0) $
dint2_ : ev (dint2, t0=0, h=10^-8, a1=0, b1=0, c1=0, d1=0, a2=0, b2=0,
c2=0, d2=0, a3=0, b3=0, c3=0, d3=0) $
values1:[rs:rat(10.000000000000000),
vte:rat(0.025864186384551461),
csat:rat(1.0000000000000000e-014),
ckt__CKTgmin:rat(9.9999999999999998e-013),
here__DIOtBrkdwnV:rat(-0.65509939013317497),
here__DIOtDepCap:rat(0.50000000000000000),
model__DIOjunctionPot:rat(1.0000000000000000),
model__DIOgradingCoeff:rat(0.50000000000000000),
model__DIOtransitTime:rat(9.9999999999999998e-013),
model__DIOf2:rat(0.35355339059327379),
here__DIOtF1:rat(0.58578643762690485),
czero:rat(2.0000000000000000e-012),
model__DIOf3:rat(0.25000000000000000),
omega:2*%pi*10^6]$
for e in join (dint1_, dint2_) do print (float (ev (e, nouns)));