[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting complex numbers results instead of expected real numbers
From: |
CdeMills |
Subject: |
Re: Getting complex numbers results instead of expected real numbers |
Date: |
Sun, 12 Feb 2012 10:52:04 -0800 (PST) |
Yes and no. In the construct:
info_vec = [info_vec; c0 xstar];
you concatenate a line to info_vec whose one element is complex, so the
whole thing is promoted to complex.
Once again, the solutions is quite easy; in your function ClosureTrigger,
just replace
y1 =
l2m*(r-mu)*(l1p-l1m)*(phistar*k0+(gama+delta*k0)/r-c0/r*(xtau/c0)^l2p)-((l2m-1)*(l1p-l1m)-l1m*(1+l1p-l2m)*(xtau/c0)^l1p)*xtau;
by
y1
=real(l2m*(r-mu)*(l1p-l1m)*(phistar*k0+(gama+delta*k0)/r-c0/r*(xtau/c0)^l2p)-((l2m-1)*(l1p-l1m)-l1m*(1+l1p-l2m)*(xtau/c0)^l1p)*xtau);
This way, you drop the complex part which is just roundoff error. The whole
call chain will then handle only real numbers; and the final results will be
real too.
Regards
Pascal
--
View this message in context:
http://octave.1599824.n4.nabble.com/Getting-complex-numbers-results-instead-of-expected-real-numbers-tp4381221p4381704.html
Sent from the Octave - General mailing list archive at Nabble.com.