写文章 分享兴趣、传播快乐、增长见闻、留下美好,大家好,这里是LearningYard学苑,今天小编为大家带来文章:用mathematica求不定积分与mathematica函数作图教程。 Shareyourinterests,spreadhappiness,increaseyourknowledge,andstaygood。Hello,everyone。ThisisLearningYardAcademy。Today,theeditorbringsyouanarticle:Usingmathematicatofindindefiniteintegralsandmathematicafunctionmappingtutorial主题一:用mathematica求不定积分Topic1:Usingmathematicatofindindefiniteintegral 方法一:使用命令:Integrate〔f,x〕(其中为积分变量) Method1:Usethecommand:Integrate〔f,x〕(whereistheintegralvariable) 方法二:直接用工具栏输入不定积分 Method2:Usethetoolbartoinputtheindefiniteintegraldirectly 案例展示Caseshow: 计算不定积分Calculateindefiniteintegral 答案Answer: 或者 小贴士: Integrate命令在处理积分运算时会做两个假设。第一个假设即Mathematica假设除了积分变量之外其它符号都被作为常数处理。 第二个假设是Mathematica求得的积分结果是一个通式(genericform),积分结果可能在某些点不成立,这时Mathematica会告诉你 的标准结果,并且假设这一结果在哪些点不成立,如 假设n1。 积分变量不一定是单个的符号变量,也可以是一个函数如sinx 如果无法积分,Mathematica会保留积分的原式,若原式中含有常数系数,Mathematica会把常数系数提到积分之外,保留积不出来的表达式,如 Tips: TheIntegratecommandmakestwoassumptionswhenprocessingintegraloperations。ThefirstassumptionisthatMathematicaassumesthatallsymbolsexcepttheintegralvariablearetreatedasconstants。 ThesecondhypothesisisthattheintegralresultobtainedbyMathematicaisagenericform,andtheintegralresultmaynotbevalidatsomepoints。Atthistime,Mathematicawilltellyouthestandardresultandassumethattheresultisnotvalidatwhichpoints。 Theintegralvariableisnotnecessarilyasinglesymbolicvariable,butcanalsobeafunctionsuchassinx。 Ifintegrationisnotpossible,Mathematicawillretaintheoriginalintegralformula。Iftheoriginalformulacontainsconstantcoefficients,Mathematicawilladdtheconstantcoefficientsoutsidetheintegralandretaintheexpressionsthatcannotbeintegrated。主题二:用Mathematica作函数图Topic2:UseMathematicatomakefunctiongraphs二维作图原理Principleoftwodimensionaldrawing 计算机在画函数图形时所用的基本方法类似于描点法。机器首先对所给的区间里的一定数量的点(通常取区间的均分点)计算函数值,并画出这些点(x,f(x)),然后依x的大小从小到大所对应的点用直线段连接成一条直线(实际上是一条折线),就把它作为函数在观察区内的图形 Thebasicmethodusedbythecomputertodrawfunctiongraphsissimilartothedotmethod。Themachinefirstcalculatesthevalueofthefunctionforacertainnumberofpointsinthegiveninterval(usuallytheaveragepointoftheinterval),anddrawsthesepoints(x,f(x)),andthencorrespondstothesizeofxfromsmalltolargeUsestraightlinesegmentstoconnectthepointsintoastraightline(actuallyapolyline),anduseitasafunctionofthegraphintheobservationarea。基本绘图命令PlotBasicdrawingcommandsPlot Plot命令表达式中的可选项是对画图的细节提出的各种要求和设置,每个选项都有一个确定的名字和选项值以选项名选项值的形式放在Plot命令的最后位置,一次可设置多个选项,以逗号相隔依次排列。 TheoptionsinthePlotcommandexpressionarevariousrequirementsandsettingsforthedetailsofdrawing。EachoptionhasacertainnameandoptionvalueintheformofoptionnameoptionvalueinthelastpositionofthePlotcommand。Multipleoptionscanbesetatonetime,arrangedinorderwithcommasseparated。 可选项 说明 PlotRange 指定作图范围。默认值是Automatic。可用{y1,y2}的形式要求绘出坐标在〔y1,y2〕内的图形。 SpectRation 图形的高度与宽度的比例,默认值是黄金分割值0。618。如果要图形按实际情况显示,则需要设置为Automatic。 Axes 是否画出坐标轴以及设置坐标轴的原点位置。默认值是True。表示画出坐标轴;如果设置AxesNone,表示不画坐标轴;如果设置Axes{x0,y0}则设置坐标原点为〔x0,y0〕。 AxesLabel 设置坐标轴上的标记符号,默认值为None。表示不作标记。用AxesLabel字符串,字符串的形式定义轴的纵坐标和横坐标标记。 Ticks 设置坐标轴上刻度的位置,默认值是Automatic,表示由系统自动定位。用TicksNone表示不标坐标刻度;Ticks{xi,yi}规定x轴和y轴的刻度值;Ticks{t1,t2,}表示要在一个轴上按t1,t2,设置刻度。 PlotPoints 设置采样函数的点数,默认值是15。对于函数值变化剧烈的表达式,应设定较大的点数。 PlotStyle 指定曲线的样式,默认值为Automatic,取默认值时,图形为黑实线。可通过可选项改变曲线的样式。 DisplayFunction 用什么机制显示图形。默认值是DisplayFunction,可用Identity表示只生成图形,但是现在不显示。 案例展示Caseshow: 将函数 和ysinx的图像展示在一张纸上Displaytheimageofthefunctionandysinxonapieceofpaper。 答案Answer: Out〔3〕Graphics 小贴士: 如果用Plot函数画两个或多个函数的图形,可以用PlotStyle为每条曲线设定一个不同方式,这时必须把描述一条曲线的项放在一个表里作为PlotStyle值的一个子表。 Tips: IfyouusethePlotfunctiontodrawgraphsoftwoormorefunctions,youcanusePlotStyletosetadifferentmethodforeachcurve。Atthistime,youmustputtheitemdescribingacurveinatableasasubtableofthePlotStylevalue。 案例展示Caseshow: 分别用红、绿、蓝三种颜色画出 的图形Graphicsdrawninthreecolorsofred,greenandblue。 In〔7〕:Plot〔{Sin〔x〕,Sin〔2x〕,Sin〔3x〕},{x,0,2Pi},PlotStyle{RGBColor〔1,0,0〕, RGBColor〔0,1,0〕,RGBColor〔0,0,1〕}〕 Out〔7〕Graphics 二维参数图Twodimensionalparameterdiagram 在二维平面内,有时无法将隐函数f(x,y)0化成yf(x)显函数的形式,所以无法使用Plot命令直接绘图。但是在某些情况下,可以把平面上的曲线f(x,y)0化成:xx(t),yy(t)的形式,其中变量t为方程式的参数(Parameter),而这个方程式则被称为参数方程(Parametricequation)。随着t的变化,我们可以在x,y平面上描绘出曲线的轨迹,所得的曲线称为参数图。Mathematica用ParametricPlot命令绘制二维参数图。它的使用形式有两种: (1)ParametricPlot〔{x(t),y(t)},{t,下限,上限},可选项〕绘制二维参数图; (2)ParametricPlot〔{{x1(t),y1(t)},{x2(t),y2(t)},},{t,下限,上限}〕同时绘制多个参数图。 ParametricPlot接受与Plot一样的可选项,其作用也一样,但是PlotPoints选项的默认值为25。 Inthetwodimensionalplane,sometimesitisimpossibletoconverttheimplicitfunctionf(x,y)0intotheformofyf(x)explicitfunction,sothePlotcommandcannotbeusedtodrawdirectly。However,insomecases,thecurvef(x,y)0ontheplanecanbetransformedintotheform:xx(t),yy(t),wherethevariabletistheparameteroftheequation,Andthisequationiscalledaparametricequation(Parametricequation)。Withthechangeoft,wecandrawthetrajectoryofthecurveonthexandyplanes,andtheresultingcurveiscalledaparametricdiagram。MathematicausestheParametricPlotcommandtodrawatwodimensionalparametermap。Itcanbeusedintwoforms: (1)ParametricPlot〔{x(t),y(t)},{t,lowerlimit,upperlimit},optional〕 (2)ParametricPlot〔{{x1(t),y1(t)},{x2(t),y2(t)},},{t,lowerlimit,upperlimit}〕Drawmultipleparametergraphsatthesametime。 ParametricPlotacceptsthesameoptionsasPlot,anditseffectisthesame,butthedefaultvalueofthePlotPointsoptionis25。 案例展示Caseshow: 利用ParametricPlot命令画单位圆 (0t2pi)的图形 UsetheParametricPlotcommandtodrawthegraphoftheunitcircle(0t2pi) 答案Answer: In〔1〕:ParametricPlot〔{Sin〔t〕,Cos〔t〕},{t,0,2Pi},AspectRatioAutomatic〕 Out〔1〕Graphics 极坐标作图Polarcoordinatemapping Mathematica没有直接提供极坐标的绘图命令,我们只要把ParametricPlot稍做修改,就可以定义成极坐标的绘图命令。极坐标方程式可以写成 的形式,而极坐标上的点在xy直角坐标系统上的坐标,根据几何关系可以写成 因此,如果把ParametricPlot〔{x,y},{t,下限,上限}〕命令中的x和y改成 则参数方程式的图形即为极坐标方程式的图形。现在我们定义PolarPlot极坐标绘图命令: (1)PolarPlot〔r,{t,下限,上限},可选项〕 (2)ParametricPlot〔{rCos〔t〕,rSin〔t〕},{t,下限,上限},可选项〕 Mathematicadoesnotdirectlyprovidepolarcoordinatedrawingcommands。WeonlyneedtomodifyParametricPlottodefineitaspolarcoordinatedrawingcommands。Thepolarcoordinateequationcanbewrittenintheform: ,andthecoordinatesofthepointonthepolarcoordinateinthexyrectangularcoordinatesystemcanbewrittenas Therefore,ifyouchangethexandyas intheParametricPlot〔{x,y},{t,lowerlimit,upperlimit}〕command,thegraphoftheparametricequationisthegraphofthepolarcoordinateequation。 NowwedefinePolarPlotpolarcoordinatedrawingcommand: (1)PolarPlot〔r,{t,lowerlimit,upperlimit},optional〕 (2)ParametricPlot〔{rCos〔t〕,rSin〔t〕},{t,lowerlimit,upperlimit},optional〕平面数据作图Planedatamapping Mathematica可以根据一组数据作出图形,使用的函数形式是ListPlot〔数据,可选项〕 Mathematicacanmakegraphsbasedonasetofdata,andthefunctionformusedis ListPlot〔data,optional〕 可选项 说明 PlotJoined 是否用直线连接各点。默认值为False,可用True表示得到连接这些点的折线。 PlotStyle 所画的点或直线的类型,默认值为Automatic。 案例展示Caseshow:: 画数列 的前100项的散点图 Drawascatterplotofthefirst100itemsof 答案Answer:In〔2〕:tTable〔(11n)n,{n,1,100}〕;ListPlot〔t〕 Out〔2〕Graphics 图形的重新显示、组合和输出Redisplay,combinationandoutputofgraphics 案例展示:将yx2和yx的图形重新组合显示在图上 Caseshow:recombiningthegraphsofyx2andyxtodisplayonthegraph 答案Answer:In〔3〕:f1Plot〔x2,{x,2,2}〕; f2Plot〔x,{x,2,2}〕; Show〔f1,f2,PlotRange{2,2},AspectRatioAutomatic,AxesLabel{x,y}〕 Out〔3〕Graphics 参考资料:网络 翻译:Google翻译 本文由LearninglYard学苑整理发出,部分资料来自网络,若有侵权请联系! 如果您对今天的文章有独特的想法,欢迎给我们留言,让我们相约明天,祝您今天过得开心快乐!