| Author |
Topic  |
|
|
modimh
India
4 Posts |
Posted - 07/01/2002 : 03:19:07 AM
|
I have written a programme using OriginC. I need to calculate exponential value of complex numbers. The exponential function available in complex.h file didnot give me correct value of my complex numbers. for example my OriginC function contains following:
complex a,b; a=1+2i; b=exp(a); printf("%e",cabs(b));
here irrespective of value 'a' the output remains same. Please help me |
|
|
easwar
USA
1965 Posts |
Posted - 07/01/2002 : 09:43:02 AM
|
Hi,
For the sequence of operations you are doing, the result should depend only on the real part of a.
a=p+iq b=exp(p+iq) = exp(p)* exp(iq) conjgate of b, b* = exp(p) * exp(-iq) cabs(b) = sqrt(b x b*) = sqrt(exp(2p)) = exp(p)
Easwar OriginLab.
Edited by - easwar on 07/01/2002 09:48:17 |
 |
|
|
modimh
India
4 Posts |
Posted - 07/04/2002 : 04:20:47 AM
|
Hi Dr. Easwar Thank you very much for reply. I have analysed the problen in my programme. Actually when i was multiplying complex defined array with double defined array and inputting this to exponential function than the output was remainning same=(1+0i) irrespective of input values. I have used following scheme to solve the problem
vector M(10), N(10); vector d(10);
N[j]=exp(M[j]*d[j]); //this way the result was remainning same irrespective of input parameters values. So I have defined another temperary variable and stored d[j] in that i.e.
double temp; temp=d[j]; now N[j]=exp(M[j]*temp);
This way the value of N[j] is changing as input values changing. If there is another better way to do it please suggest. My OriginC function is working well. I want to include it in non-linear fitting functions list. Can I do it Please suggest. Regards M.H.Modi
quote:
Hi,
For the sequence of operations you are doing, the result should depend only on the real part of a.
a=p+iq b=exp(p+iq) = exp(p)* exp(iq) conjgate of b, b* = exp(p) * exp(-iq) cabs(b) = sqrt(b x b*) = sqrt(exp(2p)) = exp(p)
Easwar OriginLab.
Edited by - easwar on 07/01/2002 09:48:17
|
 |
|
|
modimh
India
4 Posts |
Posted - 07/04/2002 : 08:50:13 AM
|
The two vector defined M[j], N[j] is of type complex. And other d[j] is of type double. I had typed but surprisingly it is not being shown on screen
vector M(10), N(10);//complex type vector d(10);// double type
M.H.Modi
|
 |
|
|
easwar
USA
1965 Posts |
Posted - 07/04/2002 : 2:21:20 PM
|
quote:
...If there is another better way to do it please suggest. ...My OriginC function is working well. I want to include it in non-linear fitting functions list.
Hello,
We need to fix the problem with product of complex and real vectors. The workaround you are using is good.
As for using your Origin C function to perform fitting, you can look at the sample project: ..\Sample Projects\Programming\NLSF User-defined Function\AsymGauss.opj to see how you can define and add a new fitting function that uses an Origin C function.
You can also type the Origin C code right inside the function. Please review the following sample project for an example: ..\Sample Projects\Data Analysis\Curve Fitting\NLSF User Def Func.opj
Easwar OriginLab.
|
 |
|
| |
Topic  |
|