How should I use the numerical method .n()?

asked 1 year ago

Morgan gravatar image

updated 0 years ago

dan_fulea gravatar image

If I want to numerically calculate an expression involving several terms and I am worried about efficiency should I numerically calculate each term? For example is there a difference between:

data = [ (sin(t)*exp(t)).n() for t in srange(0, 10, 0.01) ]

vs

data = [ sin(t).n()*exp(t).n() for t in srange(0, 10, 0.01) ]

?

Preview: (hide)

Comments

1

In response to the specific question at the end: [(sin(t)*exp(t)).n() for t in srange(0,10,0.01)] == [sin(t).n()*exp(t).n() for t in srange(0,10,0.01)] returns True.

John Palmieri gravatar imageJohn Palmieri ( 1 year ago )
1

This should not matter unless you expect some kind of precision loss (e.g., adding entities of significantly different magnitude).

Max Alekseyev gravatar imageMax Alekseyev ( 1 year ago )