|
|
|
differentiation in C++
|
|||
|---|---|---|---|
|
#18+
I need urgent help in following problem. Please give me atleast and idea as how to implement it thanks in advance for your time I need to write a program that will differentiate expressions in the variable X. The input to this program will be a series, each representing an infix expression to be differentiated. Each such expressions is to be viewed as a stream of tokens. Valid tokens are integers, the variable X, the binary operators (+, -, *, /, ^), and parentheses. To make scanning for tokens easy, you may assume that each token is followed by exactly one space, with the exception of the final token, which is followed by the end of line character. First the program will have to scan the infix expression, building up an appropriate binary tree representation of it. Once the binary expression tree is built, traverse it, building up an other binary expression tree, which represents the derivative of the original expression. The following differentiation rules should be used in this process: Suppose C is a constant, and S and T are expressions in X: Diff (C) = 0 Diff (X) = 1 Diff (S + T) = Diff (S) + Diff (T) Diff (S - T) = Diff (S) - Diff (T) Diff (S * T) = S * Diff (T) + T * Diff (S) Diff (S / T) = ((T * Diff (S)) - (S * Diff (T))) / (T ^ 2) Diff (S ^C) = (C * S ^ (C - 1)) * Diff (S) Finally, once the binary expression tree for the derivative has been built, print the expression. Print it in completely parenthesized infix notation to avoid ambiguity. Note that there are three distinct phases to this problem: 1) Parsing of the original infix expression into a binary tree representation 2) Building a binary tree representation of the derivative 3) Printing the derivative in completely parenthesized infix notation. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.12.2005, 19:49 |
|
||
|
differentiation in C++
|
|||
|---|---|---|---|
|
#18+
See first (maybe second also) edition "The art of computer programming" Donald E. Knuth volume 1 or 2. Problem was discussed in details. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 11.12.2005, 11:02 |
|
||
|
|

start [/forum/topic.php?fid=57&fpage=380&tid=2032316]: |
0ms |
get settings: |
10ms |
get forum list: |
19ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
28ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
55ms |
get tp. blocked users: |
2ms |
| others: | 256ms |
| total: | 391ms |

| 0 / 0 |
