4444#
4545
4646# @assert isequal(differentiate("sin(x) + cos(x)^2"), :(+(cos(x),*(2,cos(x)))))
47- @assert isequal (differentiate (" x + exp(-x) + sin(exp(x))" , :x ), :(+ (1 , * ( exp (- (x)), - 1 ), * ( cos ( exp (x)), exp (x)))))
47+ @assert isequal (differentiate (" x + exp(-x) + sin(exp(x))" , :x ), :(+ (1 ,* ( - 1 , exp (- (x))), * ( exp (x), cos ( exp (x) )))))
4848
4949# TODO : Make these work
5050# differentiate(:(sin(x)), :x)(0.0)
@@ -60,42 +60,14 @@ y = BasicVariable(:y)
6060
6161@assert isequal (@sexpr (x + y), :($ x + $ y))
6262@assert isequal (differentiate (@sexpr (3 * x), x), 3 )
63- @assert isequal (differentiate (:(sin (sin (x))), :x ), :(* (cos (sin (x)) ,cos (x ))))
64- @assert isequal (differentiate (@sexpr (sin (sin (x))), x), :(* (cos (sin ( $ x)) ,cos ($ x ))))
63+ @assert isequal (differentiate (:(sin (sin (x))), :x ), :(* (cos (x) ,cos (sin (x) ))))
64+ @assert isequal (differentiate (@sexpr (sin (sin (x))), x), :(* (cos ($ x),cos (sin ( $ x) ))))
6565
6666function testfun (x)
6767 z = BasicVariable (:z )
6868 differentiate (@sexpr (3 * x + x^ 2 * z), z)
6969end
7070
71- @assert isequal (testfun (x), :(* (1 ,^ ($ (x),2 ))))
72- @assert isequal (testfun (3 ), :(* (1 ,^ (3 ,2 ))))
73- @assert isequal (testfun (@sexpr (x+ y)), :(* (1 ,^ (+ ($ (x),$ (y)),2 ))))
74-
75- differentiate (:(2 ), :x )
76- differentiate (:(x), :x )
77- differentiate (:(x + x), :x )
78- differentiate (:(x - x), :x )
79- differentiate (:(2 * x), :x )
80- differentiate (:(x * 2 ), :x )
81- differentiate (:(a * x), :x )
82- differentiate (:(x * a), :x )
83- differentiate (:(x ^ 2 ), :x )
84- differentiate (:(a * x ^ 2 ), :x )
85- differentiate (:(2 ^ x), :x )
86- differentiate (:(sin (x)), :x )
87- differentiate (:(cos (x)), :x )
88- differentiate (:(tan (x)), :x )
89- differentiate (:(exp (x)), :x )
90- differentiate (:(log (x)), :x )
91- differentiate (:(sin (x) + sin (x)), :x )
92- differentiate (:(sin (x) - cos (x)), :x )
93- differentiate (:(x * sin (x)), :x )
94- differentiate (:(x / sin (x)), :x )
95- differentiate (:(sin (sin (x))), :x )
96- differentiate (:(sin (cos (x) + sin (x))), :x )
97- differentiate (:(exp (- x)), :x )
98- differentiate (:(log (x^ 2 )), :x )
99- differentiate (:(x^ n), :x )
100- differentiate (:(n^ x), :x )
101- differentiate (:(n^ n), :x )
71+ @assert isequal (testfun (x), :(^ ($ (x),2 )))
72+ @assert isequal (testfun (3 ), 9 )
73+ @assert isequal (testfun (@sexpr (x+ y)), :(^ (+ ($ x,$ y),2 )))
0 commit comments