Challenge 5 :- Differential count | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Challenge 5 :- Differential count

Write a program to count , in how many tries the differentiation of a given expression becomes equal to the right hand side . For example :- If a user enters :- x^3 + 12x^2 + 5x = 2x^2 + 7x + 10 I suggest you to use differentiation of a simple expression like the above , but if you wish you can even make it more complex* . So if we differentiate the above expression on both sides till L.H.S = R.H.S then :- 1) 3x^2 + 24x + 5 = 4x + 7 + 0 2) 6x + 24 + 0 = 4 3) 6 + 0 = 0 4) 0 = 0 Output should be 4.

5th Sep 2017, 11:46 AM
RZK 022
RZK 022 - avatar
3 Answers
5th Sep 2017, 3:03 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 2
My attempt in Ruby below. I like the methods of Krishna and Sayan. However, I wanted to output the equation at each step of the differentiation to demonstrate the process. https://code.sololearn.com/c6nBo5Xbij10/?ref=app This program takes equations input by the user, or will default to the example from the original challenge if no input is given. It does need more error catching in case of improper input formatting, and only takes "simple" equations, but seems to work well.
6th Sep 2017, 6:31 PM
André
André - avatar
5th Sep 2017, 3:54 PM
sayan chandra
sayan chandra - avatar