Message Font: Serif | Sans-Serif
 
UnThreaded | Threaded | Whole Thread (17) | Ignore Thread Prev | Next
Author: rmhj Big gold star, 5000 posts Old School Fool Add to my Favorite Fools Ignore this person (you won't see their posts anymore) Number: of 5858  
Subject: Re: A (complex) puzzle Date: 9/23/2011 3:06 PM
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Recommendations: 0
LorenCobb: Not in Gnu Fortran, I believe. The Fortran call log(x), where x is complex, generates a complex answer (the principal value of the complex logarithm). These doc files

http://gcc.gnu.org/onlinedocs/gfortran/LOG.html

say as much, though they do not specify what would happen if the log function is called on a negative constant.


That is what I'd expect, FORTRAN having had COMPLEX data types since day IV (if not earlier). However, the argument is a REAL (or integer?), and I've long since forgotten FORTRAN's type conversion and promotion rules (and I don't know what they say about evaluation of constants at compile time). Unlike C, they're probably quite strict (ISTR that parentheses are inviolate in FORTRAN).

If you're angling to do all this in complex arithmetic, then the result probably comes out very weird if you apply Euler's identity, e^(i(theta)) = cos(theta) = i*sin(theta) after doing the original exponent rearrangement. If you do, then you get the ln(-4) ~= 1.386... + pi*i. Multiply by 3/2 (2.07944... + 4.7123...i) and exponentiate, and the result is -8i.

But I think most of us would understand any of these answers (domain error, 8, -8i).

rj
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Print the post  
UnThreaded | Threaded | Whole Thread (17) | Ignore Thread Prev | Next

Announcements

Managing Your Wealth
Our own TMFHockeypop from Rule Your Retirement fame on the TV show Managing Your Wealth.
When Life Gives You Lemons
We all have had hardships and made poor decisions. The important thing is how we respond and grow. Read the story of a Fool who started from nothing, and looks to gain everything.
Post of the Day:
Apple

Apple and Ninety Years Ago
What was Your Dumbest Investment?
Share it with us -- and learn from others' stories of flubs.
Community Home
Speak Your Mind, Start Your Blog, Rate Your Stocks

Community Team Fools - who are those TMF's?
Contact Us
Contact Customer Service and other Fool departments here.
Work for Fools?
Winner of the Washingtonian great places to work, and "#1 Media Company to Work For" (BusinessInsider 2011)! Have access to all of TMF's online and email products for FREE, and be paid for your contributions to TMF! Click the link and start your Fool career.
Advertisement