How to Write a C Program for Derivative Calculation?

Click For Summary

Discussion Overview

The discussion revolves around writing a C program to read a mathematical expression, compute its derivative, and print the result. Participants explore the challenges of parsing expressions and handling mathematical functions within the program.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes their goal of creating a program that can read an expression like (X^2-1)*tan-ln^2/X and output its derivative.
  • Another participant requests to see the progress made so far in the implementation.
  • A different participant points out that the input expression is problematic, noting that functions like tan and ln should not be treated as numbers in the output.
  • One participant asks for clarification on the scope of the functions to be included in the program, suggesting that the complexity of the implementation may vary based on the types of functions desired.
  • There is a suggestion to consider how to parse the expression into atomic tokens for further processing.

Areas of Agreement / Disagreement

Participants express differing views on the validity of the input expression and the approach to parsing it. There is no consensus on how to proceed with the implementation or the specific requirements for the program.

Contextual Notes

Participants have not fully defined the types of functions to be included or the specific requirements for parsing expressions, which may affect the complexity of the implementation.

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..
 
Technology 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.
 

Similar threads

  • · Replies 15 ·
Replies
15
Views
5K
Replies
2
Views
1K
Replies
12
Views
3K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 10 ·
Replies
10
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 29 ·
Replies
29
Views
4K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K