Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Complex numbers in excel
I do a call to a sub akoef in the code beneath. It works fine in the
non-complex case that I have coded: first, the call in main program: ''''''''''''''''''''''''''''''' Call AKOEF(OM, DELT, NAX, G, AKD, a, B) '''''''''''''''''''''''''''''' here is the called sub - the complex suggestions are in comments: Sub AKOEF(OM, DELT, NAX, G, AKD, a, B) i = 1 ' should be -1 for complex i = Sqr(i) ' should be imsqrt for complex sa = 0 AKD(NAX) = sa ARG = Sqr(1 / a) * (-i * OM - 0.5 * OM * (B / a)) * DELT * NAX s1 = G(NAX) * Exp(ARG) ' exp should be imexp for complex NA = NAX - 1 For jj = 1 To NA j = NAX - jj AKs = AKD(j) * AKD(j) ARG = Sqr(1 / a) * (i * OM - 0.5 * OM * (B / a)) * DELT * j s2 = G(j) * Exp(ARG) * (1 - AKS) ' exp should be imexp for complex sa = 0.5 * (s1 + s2) * DELT + sa AKD(j) = Exp(-ARG) * sa 'exp should be imexp for complex s1 = s2 Next jj End Sub ----------------------------------------- in FORTRAN the complex case is very simple. I just declare the complex variables in akoef with a type command like this: TYPE COMPLEX AKD,AK,AKS,I,CEXP,CSQRT,ARG,S1,S2,SA I exchange the real function with complex functions. Complex fortran is a bit different from excel, but the idea is the same. and the call will return a complex variable AKD. ....so this is no problem.. .... there must be a way to do it simple also in excel. Anyone with experience? -- With regards Knut S |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Complex numbers in excel
Open VBA editor and type COMPLEX in the search box
Look at the method called Complex You should not try to use i=-1; i=SQR(i) best wishes -- Bernard V Liengme Microsoft Excel MVP www.stfx.ca/people/bliengme remove caps from email "knutso" wrote in message ... I do a call to a sub akoef in the code beneath. It works fine in the non-complex case that I have coded: first, the call in main program: ''''''''''''''''''''''''''''''' Call AKOEF(OM, DELT, NAX, G, AKD, a, B) '''''''''''''''''''''''''''''' here is the called sub - the complex suggestions are in comments: Sub AKOEF(OM, DELT, NAX, G, AKD, a, B) i = 1 ' should be -1 for complex i = Sqr(i) ' should be imsqrt for complex sa = 0 AKD(NAX) = sa ARG = Sqr(1 / a) * (-i * OM - 0.5 * OM * (B / a)) * DELT * NAX s1 = G(NAX) * Exp(ARG) ' exp should be imexp for complex NA = NAX - 1 For jj = 1 To NA j = NAX - jj AKs = AKD(j) * AKD(j) ARG = Sqr(1 / a) * (i * OM - 0.5 * OM * (B / a)) * DELT * j s2 = G(j) * Exp(ARG) * (1 - AKS) ' exp should be imexp for complex sa = 0.5 * (s1 + s2) * DELT + sa AKD(j) = Exp(-ARG) * sa 'exp should be imexp for complex s1 = s2 Next jj End Sub ----------------------------------------- in FORTRAN the complex case is very simple. I just declare the complex variables in akoef with a type command like this: TYPE COMPLEX AKD,AK,AKS,I,CEXP,CSQRT,ARG,S1,S2,SA I exchange the real function with complex functions. Complex fortran is a bit different from excel, but the idea is the same. and the call will return a complex variable AKD. ...so this is no problem.. ... there must be a way to do it simple also in excel. Anyone with experience? -- With regards Knut S |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how can i write complex numbers inside excel cels? | Excel Discussion (Misc queries) | |||
import complex numbers to excel | Excel Worksheet Functions | |||
How do I set up Excel to handle complex (& imaginary) numbers? | Excel Worksheet Functions | |||
Complex Numbers in Excel? | Excel Programming | |||
Complex numbers in VBA (Excel( | Excel Programming |