Message Boards Message Boards

0
|
7092 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Evaluate numerically trigonometric functions?

Posted 7 years ago

SpecificQuestion (V11) How to force numerical evaluation of trig functions? I have tried multiple variants of below process ( only showing first output of loop The process stops with the conversion of the degree to radians Feeding the angle in as numeric didn't change the outcome

N[N[expr,10],10] 

doesn't produce numeric output Adding the second list and trying to apply N across the list also fails **If I copy one single sub expression from the output to a separate cell it is not truncated to 10 digits cos[0.62831853071795864769252867665590057686`10. it will still not evaluate with "N"** if manually truncated it will finally produce a numerical result

General Questions , does N force numeric evaluation up through all levels of a compound expression? does N pass through list element by element?

IN:

For[i=0, i<rws, i++;

magangle=N[(2*i)*(360/rws),10];

Print[magangle];

magvec={N[cos[magangle Degree],10],N[sin[magangle Degree],10],0};

magveceval=N[magvec,10];

Print[magvec];

Print[magveceval]]

Out;

36.00000000

{cos[0.6283185307],sin[0.6283185307],0}

{cos[0.6283185307],sin[0.6283185307],0}
POSTED BY: Jon Frey
2 Replies
Posted 7 years ago

Thank you

I am working simultaneously with 4 programs

a 2d finite element program interfaced for scripting in Matlab/Octave

and a 3d counterpart

whose exclusive interface is Mathmatica

Switching back and forth is proving to be a nightmare due to simple things like this. The syntax variations can become invisible,since they aren't wrong on the "other side ".

Has anyone produced a comparison chart with common function and syntax comparisons and /or pitfalls?

Besides initial letter in CAPS and SQUARE brackets for functions :)

POSTED BY: Jon Frey
Posted 7 years ago

Mathematica is fiercely case sensitive.

rws = 10;
For[i = 0, i < rws, i++,
 magangle = N[(2*i)*(360 Degree/rws), 10];
 Print[magangle];
 magvec = {Cos[magangle], Sin[magangle], 0};
 Print[magvec];
 ]
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract