最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

mathematica軟件的常用操作1——注釋、運(yùn)行代碼、解方程、解不等式、畫圖

2023-06-25 22:14 作者:木修于淋  | 我要投稿

本篇文章基于12.0版本進(jìn)行介紹。mathematica是一款很好用的數(shù)學(xué)計(jì)算軟件,它有很強(qiáng)大的符號(hào)計(jì)算能力,我常常用它來進(jìn)行復(fù)雜的符號(hào)表達(dá)式運(yùn)算,其中用到的主要操作如下。

注釋/取消注釋:

選中要注釋的內(nèi)容,然后alt+/。注釋完之后如下所示:(*fjlaskgj*)。

運(yùn)行代碼:

輸入代碼后點(diǎn)擊shift+enter即可運(yùn)行剛寫的代碼,重新計(jì)算整個(gè)文檔可以點(diǎn)上面的"計(jì)算"選項(xiàng),里面有"結(jié)束內(nèi)核",點(diǎn)擊就可以了,然后再點(diǎn)“計(jì)算”里面的"計(jì)算筆記本",即可重新計(jì)算整個(gè)文檔。

Solve解方程:

解一元方程:

Solve[a x^2 + b x + c == 0, x] // Simplify。//Simplify是化簡用的,運(yùn)行后的結(jié)果如下:

Solve[a x^2 + b x + c == 0, x] // Simplify

Solve[Sin[x] == Cos[x], x],計(jì)算結(jié)果如下:

Solve[Sin[x] == Cos[x], x]

Solve[x^2 + 3 x + 2 == 0, x],計(jì)算結(jié)果為:{{x -> -2}, {x -> -1}}。

解方程組:

Solve[a x + b y == c && a1 x + b1 y == d, {x, y}] // FullSimplify,//FullSimplify是完全化簡用的,和Simplify的效果差不多,使用的時(shí)候可以都試試,運(yùn)行后的結(jié)果如下:

Solve[a x + b y == c && a1 x + b1 y == d, {x, y}] // FullSimplify

此時(shí)x、y并沒有值,可以通過下法拿到上面的值并賦值給某個(gè)變量,也可以用%表示上一步得到的結(jié)果,但是用它容易混亂,可以直接復(fù)制使用上面的結(jié)果。

拿到上面結(jié)果的值

Reduce解不等式:

Reduce[2 x + y >= 1 && 4 x - y <= 2, {x, y}] // FullSimplify,運(yùn)行結(jié)果如下:

(2 x <= 1 && 2 x + y >= 1) || (2 x > 1 && 2 + y >= 4 x)

Reduce[0 < 1/2 (1 - Sqrt[1 - p0]) < 1, p0] // Simplify,運(yùn)行結(jié)果為0 < p0 <= 1。

Plot和Plot3D畫圖:

下面生成的圖片可以另存為多種格式,也可以在畫圖時(shí)添加一些命令改變圖片的樣式,以便在論文中使用。

畫曲線:

Plot[{1 - 2 x, 4 x - 2}, {x, -5, 5}, PlotLegends -> "Expressions",? AxesLabel -> {"x1", "y1"},?LabelStyle ->?Directive[15, FontFamily -> "Times New Roman", FontColor -> Blue],?ImageSize -> {200}]。其中{1 - 2 x, 4 x - 2}表示要畫的兩個(gè)函數(shù),{x, -5, 5}表示自變量的范圍,PlotLegends -> "Expressions"表示圖例用所畫曲線的表達(dá)式表示,?AxesLabel -> {"x1", "y1"}表示x軸和y軸對(duì)應(yīng)的名稱分別命名為“x1”、“y1”,LabelStyle ->?Directive[15, FontFamily -> "Times New Roman", FontColor -> Blue]表示對(duì)圖中的字體樣式進(jìn)行設(shè)置,字體大小為15,字體格式為"Times New Roman",字體顏色為藍(lán)色,ImageSize -> {200}表示設(shè)置圖片大小為200。如果想更深入了解某個(gè)關(guān)鍵詞的用法可以去幫助文檔里面搜索,會(huì)出來很多示例。最終的運(yùn)行結(jié)果如下:

Plot[{1 - 2 x, 4 x - 2}, {x, -5, 5}, PlotLegends -> "Expressions", ?AxesLabel -> {"x1", "y1"}, LabelStyle -> Directive[15, FontFamily -> "Times New Roman", FontColor -> Blue], ImageSize -> {200}]

畫三維曲面:

Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}],其中x^2 + 2 y^2表示三維曲面的函數(shù),{x, -5, 5}, {y, -5, 5}表示兩個(gè)變量的范圍,運(yùn)行結(jié)果如下:

Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}]

加入坐標(biāo)圖例,并更改字體格式和大?。?/strong>

Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}, AxesLabel -> {x, y, z},LabelStyle->Directive[20, FontFamily -> "Times New Roman", FontColor -> Blue]],其中AxesLabel -> {x, y, z}表示為三個(gè)坐標(biāo)軸命名,最終運(yùn)行結(jié)果如下:

Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}, AxesLabel -> {x, y, z}, ?LabelStyle ->Directive[20, FontFamily -> "Times New Roman", FontColor -> Blue]]

為圖形加入邊框:

Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}, AxesLabel -> {x, y, z},? LabelStyle ->Directive[20, FontFamily -> "Times New Roman", FontColor -> Black],?BoundaryStyle -> Directive[Blue, Thick]],其中BoundaryStyle -> Directive[Blue, Thick]表示為圖片添加邊框,顏色為藍(lán)色,粗的,效果如下:

Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}, AxesLabel -> {x, y, z}, ?LabelStyle ->Directive[20, FontFamily -> "Times New Roman", FontColor -> Black], BoundaryStyle -> Directive[Blue, Thick]]

改變圖形樣式:

Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}, AxesLabel -> {x, y, z},?LabelStyle ->Directive[20, FontFamily -> "Times New Roman", FontColor -> Black],?BoundaryStyle -> Directive[Blue, Thick],?PlotStyle -> ColorData["Rainbow"]],其中PlotStyle -> ColorData["Rainbow"]改變圖片的背景顏色,有很多顏色可以選,我這里只是隨便選了一種,效果如下:

Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}, AxesLabel -> {x, y, z}, LabelStyle ->Directive[20, FontFamily -> "Times New Roman", FontColor -> Black], BoundaryStyle -> Directive[Blue, Thick], PlotStyle -> ColorData["Rainbow"]]

還可以去除圖形顏色:

Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}, AxesLabel -> {x, y, z},?LabelStyle ->Directive[20, FontFamily -> "Times New Roman", FontColor -> Black],?BoundaryStyle -> Directive[Blue, Thick], PlotStyle -> None],其中?PlotStyle -> None為去除背景顏色,只剩下網(wǎng)格了,效果如下:

Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}, AxesLabel -> {x, y, z}, LabelStyle ->Directive[20, FontFamily -> "Times New Roman", FontColor -> Black], BoundaryStyle -> Directive[Blue, Thick], PlotStyle -> None]

也可以同時(shí)繪制多幅圖:

Plot3D[{x^2 + 2 y^2, 60}, {x, -5, 5}, {y, -5, 5},AxesLabel -> {x, y, z},LabelStyle ->?Directive[20, FontFamily -> "Times New Roman", FontColor -> Black],? BoundaryStyle -> Directive[Blue, Thick], PlotStyle -> None],其中{x^2 + 2 y^2, 60}表示要繪制的兩個(gè)平面:

Plot3D[{x^2 + 2 y^2, 60}, {x, -5, 5}, {y, -5, 5},AxesLabel -> {x, y, z},LabelStyle -> Directive[20, FontFamily -> "Times New Roman", FontColor -> Black], ?BoundaryStyle -> Directive[Blue, Thick], PlotStyle -> None]

還可以用含有x的變量來約束范圍:

Plot3D[60, {x, -5, 5}, {y, x, 5}, AxesLabel -> {x, y, z},?LabelStyle -> Directive[20, FontFamily -> "Times New Roman", FontColor -> Black],? BoundaryStyle -> Directive[Blue, Thick], PlotStyle -> None],其中{y, x, 5}表示用變量x來約束y的范圍,輸出效果如下:

Plot3D[60, {x, -5, 5}, {y, x, 5}, AxesLabel -> {x, y, z}, LabelStyle -> Directive[20, FontFamily -> "Times New Roman", FontColor -> Black], ?BoundaryStyle -> Directive[Blue, Thick], PlotStyle -> None]

將多幅不同樣式的圖放在一起:

Show[Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5},? ?AxesLabel -> {x, y, z},? ?LabelStyle ->? ? Directive[20, FontFamily -> "Times New Roman", FontColor -> Black],?BoundaryStyle -> Directive[Blue, Thick], PlotStyle -> None],?Plot3D[60, {x, -5, 5}, {y, -5, 5}, AxesLabel -> {x, y, z},?LabelStyle ->?Directive[20, FontFamily -> "Times New Roman", FontColor -> Black],? BoundaryStyle -> Directive[Red, Thickness[0.01]], Mesh -> None,?PlotStyle -> None]],里面包含了兩個(gè)Plot3D函數(shù),利用Show語句將兩個(gè)圖合并到一張圖上展示,其中BoundaryStyle -> Directive[Red, Thickness[0.01]]設(shè)置邊框?yàn)榧t色,粗細(xì)為0.01,Mesh -> None表示去除內(nèi)部網(wǎng)格,?PlotStyle -> None表示去除圖片顏色。輸出結(jié)果如下:

Show[Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5}, ? AxesLabel -> {x, y, z}, ? LabelStyle -> ? ?Directive[20, FontFamily -> "Times New Roman", FontColor -> Black], BoundaryStyle -> Directive[Blue, Thick], PlotStyle -> None], Plot3D[60, {x, -5, 5}, {y, -5, 5}, AxesLabel -> {x, y, z}, LabelStyle -> Directive[20, FontFamily -> "Times New Roman", FontColor -> Black], ?BoundaryStyle -> Directive[Red, Thickness[0.01]], Mesh -> None, PlotStyle -> None]]

上面也可以通過賦值來實(shí)現(xiàn):

p1 = Plot3D[x^2 + 2 y^2, {x, -5, 5}, {y, -5, 5},?AxesLabel -> {x, y, z},?LabelStyle ->?? Directive[20, FontFamily -> "Times New Roman", FontColor -> Black],BoundaryStyle -> Directive[Blue, Thick], PlotStyle -> None];

p2 = Plot3D[60, {x, -5, 5}, {y, -5, 5}, AxesLabel->{x, y, z},LabelStyle->?Directive[20, FontFamily -> "Times New Roman", FontColor -> Black], BoundaryStyle -> Directive[Red, Thickness[0.01]], Mesh ->None,?PlotStyle -> None];

Show[p1, p2],輸出結(jié)果如下:

Show[p1, p2]

未完待續(xù)。。。。。。

大家感覺有幫助的話不妨動(dòng)動(dòng)小手點(diǎn)個(gè)贊吧。

mathematica軟件的常用操作1——注釋、運(yùn)行代碼、解方程、解不等式、畫圖的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
望江县| 博乐市| 宣恩县| 长沙县| 新乐市| 泾源县| 昌宁县| 峨边| 米林县| 天水市| 双柏县| 巴青县| 灵山县| 湄潭县| 蕲春县| 崇州市| 吉安县| 玉林市| 牙克石市| 客服| 平果县| 会泽县| 福清市| 驻马店市| 新疆| 青冈县| 特克斯县| 江西省| 娄底市| 新晃| 浑源县| 高淳县| 裕民县| 玉龙| 松原市| 金溪县| 齐齐哈尔市| 闵行区| 临颍县| 新宁县| 廉江市|