Hi,
Please could I have a simple program written in C++ to perform the
following:
Calculates the complex ratio, Vout/Vin, for given values of R1, R2,
C1, C2, and a range of frequencies, w.
The program should take the values of R1, R2, C1, C2, and the details
of the frequency range from a text file.
Complex numbers should be represented by a structure.
Separate functions should be written for all necessary complex
arithmetic operations, e.g. a function that performs complex addition,
a function that performs complex multiplication, etc.
The results should be written to a text file.
The basic calculations are:
R1 / ( jwC1R1 + 1 ) -(1)
R2 / ( jwC2R2 + 1 ) -(2)
(R2 + jwR1R2C1) / { (R1 + R2) + jwR1R2 (C1 + C2) } (R2 + jwR1R2C1) / {
(R1 + R2) + jwR1R2 (C1 + C2) } -(3)
in all above instances, 'j' is the imaginary number 'square root of
(-1)'.
Additional information which may be of some benefit to understanding
what I wish to do here is that the program is in relevence to the
following circuit:
http://answers.google.com/answers/main?cmd=threadview&id=156343
Thanks! |
Clarification of Question by
noggywoggy-ga
on
04 Feb 2003 15:12 PST
If researchers feel that the list price is too low for this question,
please post a clarification and suggest a more appropriate price for
the work.
|
Request for Question Clarification by
mathtalk-ga
on
04 Feb 2003 19:35 PST
Hi, noggywoggy-ga:
I'm not sure how other researchers feel about the pricing. I think it
is low for most programming requests, but yours seems to be an
especially simple one. Let's clarify what precisely is needed,
please, before I start coding (to minimize any rework that might be
required).
In the subject you ask for a "C program", but in the body of the
question for "a simple program written in C++". Without knowing the
larger design of what this code might be used in, I can't make a
strong recommendation one way or the other. However if simplicity is
desired, in representing the formula Vout/Vin, I think a simple
"console" program will be easiest, using an implementation of complex
arithmetic.
Now more to the details of what the program is supposed to do. You
say the program should take the input values R1, R2, C1, C2, and w
from a text file. It would be helpful if you were to specify exactly
how the text file will be formatted, including a discussion of units
so that any unit conversions required before applying the formulas can
be anticipated.
Finally it appears that your (3) above contains the formula:
(R2 + jwR1R2C1) / { (R1 + R2) + jwR1R2 (C1 + C2) }
previously derived for you by shivreddy-ga (a brilliant researcher)
twice. It would therefore be my assumption that your main requirement
is for the corresponding values of Vout/Vin to be written once for
each desired input frequency w. Here I am reading into your request
that the resistances and capacitances remained fixed during each run
of the program, but the "range" of frequencies amounts to a sequence
of varied frequency values for w. Please say if this is your
expectation, and whether writing the output ratios Vout/Vin to the
console is acceptable.
I look forward to helping with this project, but I'm leaving the
question unlocked in case another researcher feels confident in
tackling the work without the clarifications above.
regards, mathtalk-ga
|
Clarification of Question by
noggywoggy-ga
on
05 Feb 2003 05:09 PST
Hi mathtalk-ga!
Thanks for asking for a clarification, after having this locked for
nearly 24hours with no answers or clarifications from prospective
researchers I was beginning to wonder what was wrong with the
question! With regards to your comments, here's my response...
As I'm a novice to this subject with relatively little experience I
didn't realise that C and C++ were much different, I've been recently
told otherwise however and the program should simply be written in C
(just I'll be using MS Visual C++ to code/debug it, but I'll be
running it from a unix console) so yes, a console program would be
desirable.
I have no experience with input files at all, I presume they are just
a list of comma separated values or carriage return separated values?
Units will simply be the standard for each component (ohms for r,
farads for c, Hz for w) units shouldn't need to be converted I don't
think. All values of R and C are fixed, only the frequency is varied
over, let's say, the range 20Hz to 120Hz in 10Hz steps. I therefore
require an output file that contains the ratio Vin/Vout at each
frequency only, and the r's and c's are fixed in each run as you
mentioned. I don't think writing these values to the console is
necessary only output to a .txt file, before terminating the program.
Finally, with regards to equation (3), yes it was a typo! The equation
you posted is what is required, I simply copied and pasted twice by
mistake sorry.
Thanks once again!
noggywoggy-ga
|
Request for Question Clarification by
mathtalk-ga
on
05 Feb 2003 09:44 PST
Thanks for the nicely worded clarification of the program
requirements. I believe I have enough information to write the
program you want. However I would suggest that you reconsider the
list price at this time, which can be changed at any time before the
question is answered or expires.
I believe the main guideline is to choose a list price based on how
much the question's answer is worth to you. For some additional
guidelines given by Google Answers, see here:
https://answers.google.com/answers/pricing.html
In general my opinion is that working program code is tantamount to a
multipart question, and I would prefer requests for tested software to
be priced at least at the $50 level. Obviously there are many
questions about software or programming that can be satisfied with a
lesser effort, perhaps by locating some sample code already presented
elsewhere on the Web. However that does not appear to be likely in
this case.
I am interested in answering your question, and if you change the list
price and post a clarification here, I will be notified and respond
quickly to your request.
regards, mathtalk-ga
|
Clarification of Question by
noggywoggy-ga
on
05 Feb 2003 10:24 PST
Hi mathtalk-ga,
I was wondering whether the question could be fully answered for the
list price, unfortunately my budget doesn't stretch that far - being a
student and all. I was going to apply a tip for the finished code for
yourself, but I couldn't stretch myself to $50 in any case, I'm
afraid. Perhaps just for the price as it currently stands you could
just shortly (you know how much work is appropriate at this price
better than me), explain what a structure is, outline what a basic
input file should look like and how to call values from it, and
perhaps explain how on earth a complex number can be defined in C. I
hope this isn't asking too much still, if it is please clarify and
I'll slim this down further.
I think I'll be able to manage the rest of the code myself.
Thanks,
noggywoggy-ga
|