問題タブ [math.sqrt]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - Math.sqrt() のより高速な代替手段
Math.sqrt()
未知の値の平方根を取得するために使用する代替手段はありますか?
例えば:
を使用して数値の平方根を取得するのは非常に遅い操作だと聞いたことMath.sqrt()
があります。乱数の平方根を取得できるより高速な方法があるかどうか疑問に思っています。これについての助けをいただければ幸いです。
math - Java で double が完全な正方形かどうかを検出する
6.25 のような double が完全な正方形であるかどうかを検出したいと思います。
平方根が整数である数値の完全な二乗を検出するには、次のようにします。
ただし、これは 6.25 のような数値では機能しません。これは実際には完全平方です。
python - Python プロット - プロット図のデータを倍増
テキストファイルからデータを読み取っていますが、その場合、プロット関数で3*sqrt(col1)
=のようにこの値を複数にする必要があります。x1.append(3*math.sqrt(float(p[1])))
プロットする前に複数の列番号データを取得するにはどうすればよいですか? たとえば、col3 データを 3*sqrt(col3) で乗算してから、そのデータをプロットします。
go - go の二乗負の数
goで負の数を2乗するのに問題があります...
(2*(1-0.5)-4)/((4*(4-2))/(2-1))^(1/2) = -1.06066017
しかし、行くと私は得るNaN
または、次のように使用する場合math.Abs
:
私は戻ってきました:0.6123724356957
それは正しくありません、正しい結果は次のとおりです:-1.06066017
これを回避する方法はありますか?
java - forループでprintlnが1回だけ間違った値を印刷するのはなぜですか?
ポリゴン名とその頂点座標を指定して、周囲を出力するコードを作成する必要があります。入力値を変更しても、常に 5.0 が出力されます。私は何を間違っていますか?
for ループを使用して、三角形のすべての辺の長さを出力しようとしましたが、結果はまだ 5.0 で、一度だけ出力されます。今、すべてのステップで再帰的な合計を出力しようとしましたが、結果はありません
(Punto はポイントを意味します) 正解は 12 ですが、常に 5 と 1 回だけ出力されます。
javascript - Difference in performance between Math.sqrt and Math.pow against Math.abs in JavaScript?
I was doing a programming task in JavaScript when I found out that a formula that involves an absolute value between substractions and a sum (Manhattan distance) is less efficient in execution time than a formula that involves the square root of the sums of two powered expressions (Euclidian distance). Am I doing something wrong here or is it normal? I thought the absolute value would not be very difficult to execute.
#xA;I am using console.time("Execution time")
to test the performance, and I see that Eucl_dist is usually few microseconds lower than Man_dist:
I posted the code I am using for benchmarking as per @Bergi suggestion
java - 論理平方法
論理平方根法がわかりません
コードの操作方法は理解していますが、このコードの背後にあるロジックは理解できません