I printed this out in Microsoft Word but am running the program in the IDE Dr Racket using the programming language racket. I have finished the differentiation function and have implemented the sum rule, difference rule, product rule, quotient rule and power rule. It works correctly. My goal is to simplify the output (so its easier to read) using the simplify function. I have a good start on this function but need help completing it to satisfy the requirements of 2a and 2b in the third pic. Please only attempt if you are confident in your solution. I am reposting this in hopes that it is easier to read. Thanks for your hard work and I will give a correct solution a big thumbs up.
rlang racket (require racket/trace) (define (diff x expr) differentiation function that produces the derivative of a given function with respect to a given variable (if (not (list? expr)) (if (equal? x expr) 1 0) ;d/dx(x) - 1, d/dx(c)-o (let ( (operation (car expr) expr is (operation u v) (u (cadr expr)) (v (caddr expr))) (case operation ((+) (list'+ (diff xu) (diff x v))) ; d/dx (u+v)-du/dx + dv/dx sum rule (-) (list'-(diff x u) (diff x v));d/dx (u-v) - du/dx-dv/dx difference rule (list u (diff x v) (list v (diff xu))) product rule (U) (list'/ (list '- (list v(diff x u) (list u (diff x v)) (list* v v) quotient rule ((A) (list v (list* (list 'A u (-v 1)) (diff x u))) power rule (trace diff) (diff x 'Vx 2)) ;to test the derivative of x/2 which is 1/2...this is working correctly (diff 'x"U (+3 (. 7 x))(-(* x 2) 1)) to test code on the derivative of (7x+3)/(x^2-1) this is working correctly ;(diff "x"(^ ( test not written yet but will test my ability to differentiate power functions, must find the derivative of 3xAS which is 15xA4 the simplify function is used to simplify the results of the differentiation function in order to make them more readable (define(simplify exp) (if (not list? expr)) expr (let ((operation (car expr)) else part of our if (a (simplify (cadr expr)l) ;recursive call (b (simplity (caddr expr)) recursive call rlang racket (require racket/trace) (define (diff x expr) differentiation function that produces the derivative of a given function with respect to a given variable (if (not (list? expr)) (if (equal? x expr) 1 0) ;d/dx(x) - 1, d/dx(c)-o (let ( (operation (car expr) expr is (operation u v) (u (cadr expr)) (v (caddr expr))) (case operation ((+) (list'+ (diff xu) (diff x v))) ; d/dx (u+v)-du/dx + dv/dx sum rule (-) (list'-(diff x u) (diff x v));d/dx (u-v) - du/dx-dv/dx difference rule (list u (diff x v) (list v (diff xu))) product rule (U) (list'/ (list '- (list v(diff x u) (list u (diff x v)) (list* v v) quotient rule ((A) (list v (list* (list 'A u (-v 1)) (diff x u))) power rule (trace diff) (diff x 'Vx 2)) ;to test the derivative of x/2 which is 1/2...this is working correctly (diff 'x"U (+3 (. 7 x))(-(* x 2) 1)) to test code on the derivative of (7x+3)/(x^2-1) this is working correctly ;(diff "x"(^ ( test not written yet but will test my ability to differentiate power functions, must find the derivative of 3xAS which is 15xA4 the simplify function is used to simplify the results of the differentiation function in order to make them more readable (define(simplify exp) (if (not list? expr)) expr (let ((operation (car expr)) else part of our if (a (simplify (cadr expr)l) ;recursive call (b (simplity (caddr expr)) recursive call