0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

二次関数の曲線距離を求めたい

Posted at

二次関数の曲線距離を求めたい

二次関数の曲線距離を求めたくなったときのためのものです。

コード

初期値a,目標値b,増加分lamとして二次関数の距離を求めてみます。

import math
import numpy as np

def F(x):
    return x**2

def pytha(x1, y1, x2, y2):
  return np.sqrt((x2 - x1)**2 + (y2 - y1)**2)

a = 0
b = 1
lam = 0.01

total_sum = 0  # 和の初期値

x1 = a
y1 = F(x1)

while x1 <= b:
    x2 = x1 + lam
    y2 = F(x2)
    distance = pytha(x1, y1, x2, y2)
    total_sum += distance  # F(x) の和
    print(f"{x1:.10f}, {y1:.10f}, {x2:.10f}, {y2:.10f}, {distance:.10f}")
    x1 = x2
    y1 = y2

print(f"F(x) の和: {total_sum:.10f}")

方程式

曲線の距離には方程式があります。

L = \int_{a}^{b}\sqrt{1+f'(x)^2}dx
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?