R语言求导数和积分

  • Post author:
  • Post category:其他


R语言求导数和积分



求导数


例一:






sin

(

tan

x

)

的导数

\text{求}\sin \left( \tan x \right) \text{的导数}













sin





(


tan




x


)






的导数






f <- quote(sin(tan(x)))
D(f,"x")

在这里插入图片描述

求的结果为:



cos

(

tan

x

)

(

1

/

cos

2

(

x

)

)

=

cos

(

tan

x

)

sec

2

x

\cos \left( \tan x \right) \ast \left( 1/\cos ^2\left( x \right) \right) =\frac{\cos \left( \tan x \right)}{\sec ^2x}






cos





(


tan




x


)
















(



1


/





cos










2












(


x


)




)






=





















sec










2











x
















cos




(



tan




x



)




























例二:






sin

x

cos

(

x

y

)

x

的导数

\text{求}\sin x\cos \left( xy \right) \text{对}x\text{的导数}













sin




x




cos





(


x


y


)










x



的导数






f <- quote(sin(x)*cos(x*y))
D(f,"x")

在这里插入图片描述

即结果为:



cos

x

cos

(

x

y

)

sin

x

sin

(

x

y

)

y

\cos x\cos \left( xy \right) -\sin x\sin \left( xy \right) y






cos




x




cos





(


x


y


)














sin




x




sin





(


x


y


)





y







给定条件下的导数值:


  • 以例二为例,求出当x等于1,y=2时的导数值
f <- quote(sin(x)*cos(x*y))
z <- D(f,"x")
eval(z,list(x=1,y=2))

在这里插入图片描述



积分





0

π

2

sin

x

d

x

\int_0^{\frac{\pi}{2}}{\sin xdx}


















0





















2
















π









































sin




x


d


x






f <- function(x) sin(x)
integrate(f,0,pi/2)

在这里插入图片描述


结果是1



版权声明:本文为qq_54423921原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。