![]() |
|
#1
|
|||
|
|||
finding the value and derivative of a math functionhi
what should we do if we take a math function from input like "sin(2x+1)/tan(x^2) " and we want to find the derivative of the functionand the value of the function for a special x (ex. x=2) .... (we might have sin,cos,tan,cotn,exp,ln,log in the input .and we only have one variable) i have no idea for solving this problem. |
|
#2
|
|||
|
|||
Re: finding the value and derivative of a math functionQuote:
What kind of class is this assignment for? What are the prerequisites? The C language (C++ too) has no features or functions that convert user input to identifiers (functions or variables). So, for example, you couldn't just enter "sin(x)" and have the compiler or any of its standard library functions convert that to a function call. What you are looking for is something like an "arithmetic expression parser." There are numerous examples on the web, and there are several commonly used ways to convert user input to a function call that evaluates the expression. First step is (usually) to break the input into "tokens" and classify them as "identifiers," operators," etc. Compiler writers define a set of rules (sometimes called "productions") that define what kinds of tokens can be combined in such a way that implies something semantically significant, like calling a library functions to get the value sin(x) and cos(x) and then add their numerical results. Symbolically manipulating expressions consisting of various combinations of the various standard library functions to apply rules for differentiating and integrating them analytically is another level entirely. So: Where would you like to start? We have no way of knowing what you know and/or what you have done. We have no way of knowing exactly what you are required to produce. (Integrating polynomials is a lot easier than, say, integrating some other kinds of functions.) Give us some specific information, and ask specific questions. I mean, what kind of help could you possibly expect by just giving a vague problem description and saying that you have no idea??? Regards, Dave |
|
#3
|
|||
|
|||
Re: finding the value and derivative of a math functionthanks for your guidance.
since i'm a begginer i don't exactly know what i need !!! i should read about the keys that you have given and think about it. if i couldn't solve the problem i would try to ask my question specificly. |
|
#4
|
|||
|
|||
Re: finding the value and derivative of a math functionQuote:
I meant no disrespect. Believe it or not, some of us actually remember being in a position like that. (In my case, it was about 10 minutes ago.) My problem with your problem is: It's not exactly a beginner subject in any context that I can imagine. That's why I asked about the subject of the course and its prerequisites. I mean, if you were an experienced programmer in certain other languages (like Maple, for example) and wanted help with C or C++ that would be one thing. (But I don't think you would have said that you don't have any idea. And it still wouldn't exactly be a beginner topic.) If you have no programming experience and are given a problem in what amounts to symbolic logic and symbol manipulation as well as arithmetic expression parsing, I would really like to know what course it is. Regards, Dave Footnote: "No one was born knowing this stuff, you know." ---davekw7x |
|
#5
|
|||
|
|||
Re: finding the value and derivative of a math functionThis is the project of a 3 credit course of c++ programming.and we should give it as our final project.and uo to now i have solved simple basic problems like calculating n! and....!!!!
anyhow i should solve it... i'm trying to write the program just using the basic things.if i could solve it i'll let you know. |
Recent GIDBlog
Developing GUIs with wxPython (Part 4) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The