[R-SIG-Mac] Is this an approximation I should expect, or a sign of a problem in the Universal Binary?

James J. Ramsey jjramsey_6x9eq42 at yahoo.com
Thu Feb 16 03:43:25 CET 2006


As a test, I ran a test file in R that was a rewrite
of a very simple Octave/Matlab problem.

Here's the Octave/Matlab script:

sigma_tf = 60e6; % N/m^2
sigma_cf = 500e6; % N/m^2

P = -1200e3; % N
T = 10e3; % N*m
SF = 3;

diary Prob3Hw2.txt
format long

r = sqrt(roots([(sigma_cf*sigma_tf/(SF*(sigma_cf -
sigma_tf)))^2 ... 
                -P*sigma_cf*sigma_tf/(SF*pi*(sigma_cf
- sigma_tf)) ...
                0 ...
                -(2*T/pi)^2]))

format

r_in_mm = r(3)*1e3

diary off

Both Octave and Matlab, as far as I can tell, treat
r(3) as a real number, not a complex number with a
really small imaginary part. Octave gave the value of
r(3) as 0.045170515826988, and Matlab gave it as
0.04517051582699. The other two values of R are
complex.

Here's the R program:

sigma_tf <- 60e6 # N/m^2
sigma_cf <- 500e6 # N/m^2

P <- -1200e3 # N
T <- 10e3 # N*m
SF <- 3

r <- sqrt(polyroot(c(-(2*T/pi)^2, 0,
         -P*sigma_cf*sigma_tf/(SF*pi*(sigma_cf -
sigma_tf)),
         (sigma_cf*sigma_tf/(SF*(sigma_cf -
sigma_tf)))^2)))

If I type "print(Re(r[1]), digits = 14)", I get what
Octave gets for r(3), but the imaginary part is small
but nonzero, -5.457521e-31.

Is this normal or is this a sign that something is 
subtly off?

The Octave calcs were done before I migrated to
Mac-intel, and were done on a PPC eMac. The Matlab
calcs were done thru Rosetta, and the R calcs were
Intel-native.



More information about the R-SIG-Mac mailing list