How to Write a C Program for Derivative Calculation?

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
rambo3131
Messages
18
Reaction score
0
Hi,i ve problem about C.i should write a program that read expression from standart input take derivative and print.
For example: input: (X^2-1)*tan-ln^2/X
output: (((X*2)*tan+(tan^2+1)*(X^2-1))-(1/X*ln*2*X-ln^2)/X^2)

I converted expression to postfix form by shuting yard algorithm ,but then i couldn't continue..please help me ...This is so important..
 
Physics news on Phys.org
rambo3131 said:
Hi,i ve problem about C.i should write a program that read expression from standart input take derivative and print.
For example: input: (X^2-1)*tan-ln^2/X
output: (((X*2)*tan+(tan^2+1)*(X^2-1))-(1/X*ln*2*X-ln^2)/X^2)

I converted expression to postfix form by shuting yard algorithm ,but then i couldn't continue..please help me ...This is so important..

Please show us what you have so far.
 
rambo3131 said:
Hi,i ve problem about C.i should write a program that read expression from standart input take derivative and print.
For example: input: (X^2-1)*tan-ln^2/X
output: (((X*2)*tan+(tan^2+1)*(X^2-1))-(1/X*ln*2*X-ln^2)/X^2)
Your input expression is meaningless. tan and ln are not numbers, as you seem to show in the output expression. These are functions, each of which takes an argument.


rambo3131 said:
I converted expression to postfix form by shuting yard algorithm ,but then i couldn't continue..please help me ...This is so important..
 
rambo3131 said:
Hi,i ve problem about C.i should write a program that read expression from standart input take derivative and print.
For example: input: (X^2-1)*tan-ln^2/X
output: (((X*2)*tan+(tan^2+1)*(X^2-1))-(1/X*ln*2*X-ln^2)/X^2)

I converted expression to postfix form by shuting yard algorithm ,but then i couldn't continue..please help me ...This is so important..

How general do you want to go? How many types of functions do you want to use?

The first thing you should do is answer the above, and then think about you are going to parse the expression to get tokens that are atomic and that you can work with.

Depending on what restrictions you want, the implementation could be very complicated.

So I guess my question is, what exactly do you want to do? What possible expressions can you have? Your explanation is not specific enough to give you any pointers.