Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2197

Re: for loop in mathematica help

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: for loop in mathematica help
Date 2011-05-08 11:35 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iq5v5a$phl$1@smc.vnet.net> (permalink)

Show all headers | View raw


On 5/7/11 at 7:33 AM, arda1404@gmail.com (Arda Akal=C4=B1n) wrote:

>i want to creat this equation V=(0.08303+0.4709j)*l*3.89610+154
>l 0 from 1100

>how can i do this

>For[l = 0, l < 1100, i + 10,
>V = Abs[(0.08303 + I 0.4709)*l*3.89610 + 154]]

>I write this but i cant get solution

First, a single = in Mathematica is Set and is not used to
define an equation. To define an equation you need Equal which
in Mathematica is a double =. Additionally, using For here is a
non-preferred way of doing things since For is a notoriously
slow function. Compare

In[16]:= Timing[For[sum = n = 0, n <= 100000, sum += n; n++]; sum]

Out[16]= {0.284941,5000050000}

In[17]:= Timing[Sum[n, {n, 100000}]]

Out[17]= {0.039917,5000050000}

Your particular equation can be created as follows:

In[18]:= v = Sum[(0.08303 + 0.4709 j)*n*38.9610 + 154, {n,
110}] + 154

Out[18]= v=237857. (0.4709 j+0.08303)+17094

Note, I simplified a few things. Since all values are positive
and are summed, Abs does nothing. For n = 0 the first term
reduces to 154 and since you are using steps of 10, I've
absorbed the factor of 10 in the multiplicative constant and
decreased the range by a factor of 10. These changes allow the
default step size of 1 in Sum

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: for loop in mathematica help Bill Rowe <readnews@sbcglobal.net> - 2011-05-08 11:35 +0000

csiph-web