Mathematica 教學 微積分基本應用
由 戴忠淵 於 2010年7月11日星期日
上午8:04 發表
用Mathematica如何畫Weierstrass function?
他跟我說極限不存在,無法畫
http://en.wikipedia.org/wiki/Nowhere_differentiable
只能用FindRoot
findtan[start_?NumericQ,end_?NumericQ]:=Block[{a=start,b=end}, Select[x/.FindRoot[Tan[x]==x,{x,#*Pi+0.01}]&/@Range[Floor[(start+Pi/2)/Pi],Floor[(end+Pi/2)/Pi]],
a<=#<=b&]]
findtan[10,30]
Plot[{x,Tan[x]==x},{x,10,30},Epilog->{PointSize[0.0125],Point[{#,Tan[#]}&/@findtan[10,30]]}]
n不需要那麼大~~
Weierstrass[a_?NumberQ, b_Integer?OddQ, start_, end_] :=
Block[{aa = a, bb = b, cc = start, dd = end},
If[aa <= 0 || aa >= 1 || aa*bb <= 1 + 3 Pi/2, Print["xxxxxx"],
Plot[Evaluate@Sum[aa^n *Cos[bb^n Pi x], {n, 250}], {x, cc, dd}]]]
eierstrass[0.5, 21, -1, 1]
我剛剛用Mathematica跑了一下,第一題給的答案從10.9041開始
但是我用Wolfram alpha算的結果:比0大的答案中,還有4.4934,7.7253比10.9041小
要如何修正?
findtan[10,30]這個是傳回 10<=x<=30間的解阿
你要找0~10的就用findtan[0,10]
如果是要找x>=0的前三個解必定在0~5Pi/2間
findtan[0, 5 Pi/2]就ok
fc[x_ /; 1 <= x <= 3] := 0
Plot[{x^-2, fc[x]}, {x, 0, 4}, Filling -> 1 -> {2},
FillingStyle -> Automatic]
這樣咖方便~
Plot[{f[z], If[-5 < z < 1.96, 0]}, {z, -5, 5}, Filling -> {1 -> {2}}]
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~
讀者回應 ( 8 意見 )
訂閱發佈留言 (Atom)
問一下,tanx=x 要如何求x>=0最小的三個解?
以及指定範圍內的解?
是只能用FindRoot嗎?