+ 1
Does anyone have an idea how to write a code which differentiate any given equation?
for example: if we pass a string "2x^2 + 3x" the code should print 4x + 3
8 Réponses
+ 1
Understood. Thank you for the clarification. I am a person that when I code, I like to make sure I truly understand what is needing coded. :)
I personally don't have any code myself. However, here are a few articles that have some good explanations and details regarding what you are trying to do.
https://stackoverflow.com/questions/16702305/function-to-differentiate-a-polynomial-in-c&ved=0ahUKEwil0-_GtsTYAhUBq1MKHccuCnwQjjgILzAB&usg=AOvVaw17xuy4frAmnouil6RvvoUf
https://www.codeproject.com/Articles/15432/Fast-Automatic-Differentiation-in-C
I hope this helps you out and gets you your answer. :)
+ 2
You stay blessed as well. Good luck with your project and code. :)
+ 1
Thanks mate...i hope that will help. Stay blessed 😊
0
I'm a little concerned. How did you come about that answer? is that 2x and you are squaring both the 2 and the x or are you just squaring the x? Your math just seems very off to me. Thanks.
0
If he wanted to square both the 2 and x he would have written (2x)^2...
0
I understand. However, you cannot assume they meant that without verifying. It is better to verify than to assume and waste time trying to code something that was wrongly assumed.
0
@Ryan Wakefield
I understand that people in different places could have different ways of writing, but this "wrongly assumed" and "unverified" syntax of multiplication is widely used in my school. If somebody produces a code which works in the syntax as stated in the question, it will still make sense to me.
If your school uses a different style in multiplication, feel free to tell us the particular method. I would suggest those who provides the answer to specify his/her school or country, if there really exist another way of inputting multiplication syntax into digital device in somewhere else.
0
if the differentiation is 4x + 3 than one could have easily known that only x is squared, not 2.If still confused you can integrate 4x + 3 back and you will be happy 😊