前提・実現したいこと
python 初心者です.
ある関数を原点周りにθだけ回転させた関数を描きたいです.
宜しくお願い致します.
発生している問題
インターネットなどでやり方を探しているのですが,初心者ということもあり,いまいち理解できていません.
詳細・プログラム
z =c*x**2/(1+(1-(1+k)*c**2*x**2)**(1/2))
上記した関数zを原点周りに90°だけ回転させた関数を出力させたいです.
自分で以下のようなプログラムを書きましたがエラーが出ました.
Python
1 2import numpy as np 3import matplotlib.pyplot as plt 4import math 5 6# 描画範囲の指定 7# x = np.arange(x軸の最小値, x軸の最大値, 刻み) 8x = np.arange(0, 6.28, 0.1) 9 10plt.grid(True) 11plt.xlabel('$x$', fontsize=16) 12plt.ylabel('$z(x)$', fontsize=16) 13plt.title('upper die') 14 15R=-19.41053 16k=-59.85017 17c=1/R 18sinθ = math.sin(math.radians(90)) 19cosθ = math.cos(math.radians(90)) 20 21# 計算式 22z =c*x**2/(1+(1-(1+k)*c**2*x**2)**(1/2)) 23 24 25# 横軸の変数。縦軸の変数。 26plt.plot(x*cosθ-z*sinθ, x*sinθ+z*cosθ) 27 28# 描画実行 29plt.show() 30
エラーメッセージ
上記のプログラムを描いた結果出てきた,エラーです
>>> c=1/R >>> sinθ = math.sin(math.radians(90)) File "<stdin>", line 1 sinθ = math.sin(math.radians(90)) ^ SyntaxError: invalid syntax >>> cosθ = math.cos(math.radians(90)) File "<stdin>", line 1 cosθ = math.cos(math.radians(90)) ^ SyntaxError: invalid syntax >>> >>> # 計算式 ... z =c*x**2/(1+(1-(1+k)*c**2*x**2)**(1/2))+A*x**2+B*x**4+C*x**6+D*x**8+E*x**10+F*x**12 >>> >>> >>> # 横軸の変数。縦軸の変数。 ... plt.plot(x*cosθ-z*sinθ, x*sinθ+z*cosθ) File "<stdin>", line 2 plt.plot(x*cosθ-z*sinθ, x*sinθ+z*cosθ) ^ SyntaxError: invalid syntax >>> >>> # 描画実行 ... plt.show()
補足情報(FW/ツールのバージョンなど)
python3.6を使用しています.
知識のあるかたご享受お願い致します.
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/17 01:24