1
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?

More than 1 year has passed since last update.

高校化学の計算と線形近似

1
Last updated at Posted at 2025-04-21

# プログラム名: relative_error_calculation.py
# 内容: 2つの値 A, B の比率を用いて相対誤差・補正係数を計算し、
#      誤差補正後の表現(分数的/差分的)を評価する

# --- 値の設定 / Input values ---
A = 9.8
B = 9.8596

# --- A ÷ B の計算 / Division A by B ---
A_div_B = A / B

# --- 誤差量 C の計算 / Correction amount C ---
C = A * (1 / (A / B) - 1)

# --- 誤差を分母に加えた式 / 1 / (1 + C / A) ---
expr1 = 1 / (1 + C / A)

# --- 誤差を引いた形 / 1 - C / A ---
expr2 = 1 - C / A

# --- 結果表示 / Output results ---
print("A ÷ B =", A_div_B)
print("C =", C)
print("1 / (1 + C / A) =", expr1)
print("1 - C / A =", expr2)
# プログラム名: binomial_approx_xy.py
# 内容: (1 + x)(1 + y) ≒ 1 + x + y の近似検証
# Purpose: Verify the approximation (1 + x)(1 + y) ≈ 1 + x + y when x, y are small

# --- 小さい値を定義 / Define small x and y ---
x = 0.02
y = 0.03

# --- 正確な計算 / Exact multiplication ---
exact = (1 + x) * (1 + y)

# --- 近似式 / Approximate expansion ---
approx = 1 + x + y

# --- 誤差 / Difference between exact and approximate ---
error = exact - approx

# --- 出力 / Output results ---
print(f"x = {x}, y = {y}")
print(f"(1 + x)(1 + y) = {exact:.8f}")
print(f"1 + x + y ≈ {approx:.8f}")
print(f"差(誤差)= exact - approx = {error:.8e}")

# プログラム名: multiplicative_approximation_and_inverse.py
# 内容: (1 + A)(1 + B) や逆数近似などの計算と、A×B = X からの A, B の導出
# Purpose: Explore small approximations and solve A * B = X with B in (0.96, 1)

# --- 初期値定義 / Initial definitions ---
A = 0.013
B = 0.02

# --- 基本演算 / Basic operations ---
val_1_plus_A = 1 + A
val_1_minus_B = 1 - B
val_inv_1_minus_B = 1 / (1 - B)
val_1_plus_B = 1 + B
val_prod_1_plus_AB = (1 + A) * (1 + B)
val_1_plus_A_plus_B = 1 + A + B

# --- 出力 / Output results ---
print("[基本演算 / Basic Operations]")
print(f"A = {A}, B = {B}")
print(f"1 + A = {val_1_plus_A:.5f}")
print(f"1 - B = {val_1_minus_B:.5f}")
print(f"1 / (1 - B) = {val_inv_1_minus_B:.5f}")
print(f"1 + B = {val_1_plus_B:.5f}")
print(f"(1 + A)(1 + B) = {val_prod_1_plus_AB:.5f}")
print(f"1 + A + B = {val_1_plus_A_plus_B:.5f}")

# --- 6.02 × 4³ の計算 ---
X = 6.02 * 4**3  # = A × B

# Bの範囲: 0.96 < B < 1 より → 探索(仮に B = 0.97 とする)
B_est = 0.97
A_est = X / B_est

# --- 出力: 推定 B, A / Estimated B, A ---
print("\n[6.02 × 4³ = A × B より B∈(0.96,1) を仮定して A を計算]")
print(f"X = 6.02 × 4³ = {X:.5f}")
print(f"B (仮定) = {B_est}")
print(f"A = X / B = {A_est:.5f}")
# プログラム名: find_integer_A_within_B_range.py
# 内容: A×B = x×y を満たし、0.96 < B < 0.999 かつ A∈整数 となる A, B を求める
# Purpose: Solve for integer A such that A × B = x × y, with B in (0.96, 0.999)

# --- 初期定義 / Define x, y, product ---
x = 6.02
y = 4 ** 3  # = 64
product = x * y  # A × B = x × y

# --- Bの範囲でのAの最大・最小候補 / Range of A based on B bounds ---
B_min = 0.96
B_max = 0.999

A_min = int(product / B_max) + 1  # 切り上げ
A_max = int(product / B_min)      # 切り下げ

# --- 条件を満たすAの探索 / Search for valid A ---
valid_results = []
for A in range(A_min, A_max + 1):
    B = product / A
    if B_min < B < B_max:
        valid_results.append((A, B))

# --- xy / 0.96 と xy / 0.999 の境界値も計算 / Compute bounds ---
bound_low = product / B_max
bound_high = product / B_min

# --- 出力 / Print ---
print(f"x = {x}, y = {y}, x*y = {product:.5f}")
print(f"x*y / 0.999 = {bound_low:.3f}")
print(f"x*y / 0.96  = {bound_high:.3f}")
print(f"\nA × B = {product:.5f} かつ B ∈ (0.96, 0.999) のときの整数Aと対応するB:")

for A, B in valid_results:
    print(f"A = {A}, B = {B:.5f}")

# プログラム名: first_order_approximation_test.py
# 内容: 一次近似の式 (1+x)^a ≈ 1+ax, 1/(1±x) ≈ 1∓x を実際に検証し、誤差が x^2 に比例するか確認する

import numpy as np
import pandas as pd

# --- テストする x の値 ---
x_values = np.array([0.001, 0.01, 0.02, 0.03, 0.04, 0.05])

# --- 検証1: 1 / (1 - x) ≈ 1 + x ---
approx_1_minus_x = 1 + x_values
true_1_minus_x = 1 / (1 - x_values)
error_1_minus_x = true_1_minus_x - approx_1_minus_x
error_order_1 = x_values ** 2

# --- 検証2: 1 / (1 + x) ≈ 1 - x ---
approx_1_plus_x = 1 - x_values
true_1_plus_x = 1 / (1 + x_values)
error_1_plus_x = true_1_plus_x - approx_1_plus_x
error_order_2 = x_values ** 2

# --- データフレームにまとめて表示 ---
df = pd.DataFrame({
    "x": x_values,
    "1/(1-x)": true_1_minus_x,
    "Approx 1+x": approx_1_minus_x,
    "Error (1-x)": error_1_minus_x,
    "x^2 (ref)": error_order_1,
    "1/(1+x)": true_1_plus_x,
    "Approx 1-x": approx_1_plus_x,
    "Error (1+x)": error_1_plus_x,
    "x^2 (ref)": error_order_2,
})

# モジュール未使用で結果を表示(代替手段)

# 表を見やすく表示(小数点以下の桁数を揃える)
pd.set_option('display.float_format', lambda x: f"{x:.8f}")
df


# プログラム名: approximate_fraction_by_inverse.py
# Program Name: approximate_fraction_by_inverse.py
# 内容: ε近似を用いた (1/4) × (9.8 / 3.14²) の高速近似計算
# Purpose: Fast approximation of (1/4) × (9.8 / 3.14²) using inverse identity 1/(1+ε) ≈ 1-ε

# --- 初期値定義 / Initial constants ---
pi_approx = 3.14                             # π ≈ 3.14
numerator = 9.8                              # 分子 / Numerator
const_quarter = 1 / 4                        # 1/4

# --- 中間計算 / Intermediate calculations ---
square_pi = pi_approx ** 2                  # π² ≈ 9.8596
denominator = square_pi                     # 分母として使用

# 分数計算 / Fraction calculation: 9.8 / 9.8596
fraction = numerator / denominator

# ε の定義 / Define ε = (denominator - numerator) / numerator
epsilon = (denominator - numerator) / numerator

# 逆数の近似計算 / Approximate inverse: 1 / (1 + ε)
inv_approx = 1 / (1 + epsilon)              # 正確な逆数
inv_approx_linear = 1 - epsilon             # 1次近似 1 - ε

# (1/4) × 上記逆数 / Final approximations
result_exact = const_quarter * inv_approx                   # 精密な逆数を使った結果
result_linear = const_quarter * inv_approx_linear           # 1次近似を使った結果
result_distributive = const_quarter - const_quarter * epsilon  # 分配法則版

# 真の値の確認(精密) / True value
true_value = const_quarter * fraction

# --- 結果出力 / Output all variables with explanation ---
print(f"π の近似値 / Approximated pi: {pi_approx}")
print(f"π² ≈ {square_pi}")
print(f"定数 1/4 / Constant 1/4: {const_quarter}")
print(f"分子 / Numerator: {numerator}")
print(f"分母(π²) / Denominator: {denominator}")
print(f"分数 9.8 / 9.8596 = {fraction:.8f}")
print(f"ε = (π² - 9.8) / 9.8 = {epsilon:.8f}")
print(f"1 / (1 + ε) = {inv_approx:.8f}  ← 正確な逆数")
print(f"1 - ε ≈ {inv_approx_linear:.8f}  ← 1次近似")
print(f"(1/4) × (1 / (1 + ε)) = {result_exact:.8f}  ← 正確逆数")
print(f"(1/4) × (1 - ε) = {result_linear:.8f}  ← 近似")
print(f"(1/4) - (1/4) × ε = {result_distributive:.8f}  ← 分配法則使用")
print(f"真値(精密な分数) = {true_value:.8f}")

# プログラム名: significant_figures_two_digits.py
# Purpose: Solve 3 expressions with 2 significant figures using scientific notation.

import math

# --- (1) 式1: (1 / 0.76) × (1.013 / 9.8) × 10^5 ---
a1_num1 = 1
a1_den1 = 0.76
a1_num2 = 1.013
a1_den2 = 9.8
a1_exp = 1e5

a1_result = (a1_num1 / a1_den1) * (a1_num2 / a1_den2) * a1_exp
a1_result_sig2 = float(f"{a1_result:.2e}")  # 有効数字2桁に丸める / Round to 2 sig figs

# --- (2) 式2: (44 / 6.02e23) × (4 / (4×10⁻⁸×√2)^3) ---
a2_num1 = 44
a2_den1 = 6.02e23
a2_num2 = 4
a2_den2_base = 4 * 1e-8 * math.sqrt(2)
a2_den2 = a2_den2_base ** 3

a2_result = (a2_num1 / a2_den1) * (a2_num2 / a2_den2)
a2_result_sig2 = float(f"{a2_result:.2e}")

# --- (3) 式3: (94 × 54) / (29.4 × 1.5) ---
a3_num1 = 94
a3_num2 = 54
a3_den1 = 29.4
a3_den2 = 1.5

a3_result = (a3_num1 * a3_num2) / (a3_den1 * a3_den2)
a3_result_sig2 = round(a3_result, -int(math.floor(math.log10(abs(a3_result))) - 1))  # 有効数字2桁に四捨五入

# --- 結果表示 / Print results ---
print("【(1)】(1 / 0.76) × (1.013 / 9.8) × 10^5 =", a1_result_sig2)
print("【(2)】(44 / 6.02e23) × [4 / (4×10⁻⁸×√2)^3] =", a2_result_sig2)
print("【(3)】(94 × 54) / (29.4 × 1.5) =", a3_result_sig2)

# プログラム名: approximate_expression_steps.py
# Program name: approximate_expression_steps.py
# 内容: 入力された数式を順番に展開し、近似式の性質を確認
# Purpose: Step-by-step evaluation of algebraic approximations

# --- (1) 1 ÷ 0.76 ---
a1 = 1
b1 = 0.76
div1 = a1 / b1  # 正確な割り算 / Exact division

# --- (2) 1.013 = (1 + 0.013) ---
x = 1.013
delta_x = 0.013
x_approx = 1 + delta_x

# --- (3) 1.013 / (1 - 0.02) ---
numerator = 1.013
denom_eps = 1 - 0.02
div2 = numerator / denom_eps

# --- (4) 1.013 × (1 + 0.02) ---
mul1 = numerator * (1 + 0.02)

# --- (5) (1 + 0.013) × (1 + 0.02) ---
expr1 = (1 + 0.013) * (1 + 0.02)

# --- (6) (1 + 0.013) × (1 + 0.02) - 0.013 × 0.02 ---
correction = expr1 - (0.013 * 0.02)

# --- (7) 16 × 6.02 ÷ 100 の中間計算 ---
val1_raw = 16 * 6.02 / 100  # 中間値 / Intermediate result
inv_val1 = 1 / val1_raw     # 逆数 / Inverse of that value

# --- (8) 1 / (1 - 0.0368) ---
eps2 = 0.0368
div_eps2 = 1 / (1 - eps2)

# --- (9) (1 + 0.0368) ---
add_eps2 = 1 + eps2

# --- 結果の出力 / Output ---
print(f"(1) 1 ÷ 0.76 = {div1:.5f}")
print(f"(2) 1.013 = 1 + {delta_x}")
print(f"(3) 1.013 ÷ (1 - 0.02) = {div2:.5f}")
print(f"(4) 1.013 × (1 + 0.02) = {mul1:.5f}")
print(f"(5) (1 + 0.013) × (1 + 0.02) = {expr1:.5f}")
print(f"(6) (1 + 0.013)(1 + 0.02) - 0.013×0.02 = {correction:.5f}")
print(f"(7-1) 16 × 6.02 ÷ 100 = {val1_raw:.5f}")
print(f"(7-2) 1 / (16 × 6.02 ÷ 100) = {inv_val1:.5f}")
print(f"(8) 1 / (1 - 0.0368) = {div_eps2:.5f}")
print(f"(9) 1 + 0.0368 = {add_eps2:.5f}")


# プログラム名: reciprocal_approximation_x.py
# 内容: B/A = 1 + x の形に変形し、xの分数と小数・近似式を求める
# Purpose: Express B/A = 1 + x, then find x as fraction and decimal, and evaluate 1/(1+x) and 1-x

from fractions import Fraction

# --- 初期値の設定 / Set initial values ---
A = 282
B = 294

# --- 基本比率 / Basic ratios ---
A_div_B = A / B               # A ÷ B
B_div_A = B / A               # B ÷ A
inv_B_div_A = 1 / B_div_A     # 1 ÷ (B/A)

# --- B/A = 1 + x より、x の導出 / Solve for x: x = (B/A) - 1 ---
x_decimal = B_div_A - 1                      # 小数表現 / Decimal
x_fraction = Fraction(B, A) - 1              # 分数表現 / Fraction

# --- 近似式 / Approximations ---
inv_1_plus_x = 1 / (1 + x_decimal)           # 1 / (1 + x)
one_minus_x = 1 - x_decimal                  # 1 - x

# --- 結果の出力 / Output results ---
print(f"A = {A}, B = {B}")
print(f"(1) A ÷ B = {A_div_B:.8f}")
print(f"(2) 1 ÷ (B ÷ A) = {inv_B_div_A:.8f}")
print(f"(3) B ÷ A = {B_div_A:.8f} = 1 + x")
print(f"(4) x(小数)= {x_decimal:.8f}")
print(f"(5) x(分数)= {x_fraction}")
print(f"(6) 1 ÷ (1 + x) = {inv_1_plus_x:.8f}")
print(f"(7) 1 - x = {one_minus_x:.8f}")

化学の新研究

# プログラム名: lattice_packing_density_fe.py
# 内容: 鉄の体心立方格子(α鉄)と面心立方格子(γ鉄)の充填率と密度の計算
# Purpose: Compute packing efficiency and density for α-Fe (BCC) and γ-Fe (FCC)

import math

# --- 各定数・記号の初期化 / Initialize constants ---
pi = math.pi

# === α鉄: 体心立方格子 / α-Fe: Body-centered cubic (BCC) ===
r_alpha = 4 / math.sqrt(3)   # 対角線=4r → r = 4/√3
packing_alpha = (2 * (4/3) * pi * r_alpha**3) / (r_alpha**3 * (4/3)**3)  # = (2×(4/3)πr³) / a³ = (2×(4/3)πr³)/( (4r/√3)³ )

# 近似的な簡略式(画像の通り)で評価
a_alpha = 4 * r_alpha / math.sqrt(3)
volume_sphere_alpha = 2 * (4/3) * pi * r_alpha**3
volume_cube_alpha = a_alpha ** 3
packing_alpha_simple = volume_sphere_alpha / volume_cube_alpha

# --- γ鉄: 面心立方格子 / γ-Fe: Face-centered cubic (FCC) ---
r_gamma = 4 / math.sqrt(2)
a_gamma = 4 * r_gamma / math.sqrt(2)
volume_sphere_gamma = 4 * (4/3) * pi * r_gamma**3
volume_cube_gamma = a_gamma ** 3
packing_gamma = volume_sphere_gamma / volume_cube_gamma

# --- 密度比の計算 / Density ratio: ρ_gamma / ρ_alpha ---
density_alpha = 2 / (a_alpha ** 3)  # 単位格子あたり2原子
density_gamma = 4 / (a_gamma ** 3)  # 単位格子あたり4原子
density_ratio = density_gamma / density_alpha

# --- 出力 / Output ---
print(f"[α-Fe (BCC)]")
print(f"r (radius) = {r_alpha:.5f}")
print(f"Volume of 2 atoms = {volume_sphere_alpha:.5f}")
print(f"Cube volume = {volume_cube_alpha:.5f}")
print(f"Packing efficiency = {packing_alpha_simple:.4f}{packing_alpha_simple * 100:.1f}%")

print("\n[γ-Fe (FCC)]")
print(f"r (radius) = {r_gamma:.5f}")
print(f"Volume of 4 atoms = {volume_sphere_gamma:.5f}")
print(f"Cube volume = {volume_cube_gamma:.5f}")
print(f"Packing efficiency = {packing_gamma:.4f}{packing_gamma * 100:.1f}%")

print("\n[Density Ratio γ/α]")
print(f"Density α-Fe = {density_alpha:.5f}")
print(f"Density γ-Fe = {density_gamma:.5f}")
print(f"Density Ratio (γ / α) = {density_ratio:.3f}")

# プログラム名: nacl_density_radius_comparison.py
# 内容: NaClの密度・陽イオン半径・NaBrとの密度比の計算
# Purpose: Calculate density of NaCl, estimate Na+ ionic radius, compare NaBr/NaCl densities

# --- 定数定義 / Constants ---
mass_mol_NaCl = 58.5                # NaCl mol質量 [g/mol]
avogadro = 6.0e23                   # アボガドロ定数 [1/mol]
a_nacl = 5.6e-8                     # NaCl格子定数 [cm]
volume_unitcell_nacl = a_nacl ** 3 # 単位格子の体積 / Unit cell volume [cm^3]

# --- 単位格子あたりの粒子数: Na+4個, Cl-4個 / 4 NaCl units ---
mass_one_NaCl = mass_mol_NaCl / avogadro       # 1個のNaCl質量 [g]
mass_unitcell = mass_one_NaCl * 4              # 単位格子内4組

# --- 密度計算 / Density of NaCl ---
density_nacl = mass_unitcell / volume_unitcell_nacl

# --- 陽イオンの半径の計算 / Calculate radius r of Na+ ---
# 与えられた式: sqrt(2) * (r + 0.16) = 2 * 0.16
r_cl = 0.16
r_na = (2 * r_cl / (2**0.5)) - r_cl

# --- NaBr 密度比較 / NaBr density comparison ---
# NaBr: (0.12 + 0.18) × 2 = 0.60 [nm] = 6.0e-8 [cm]
a_nabr = 6.0e-8
volume_unitcell_nabr = a_nabr ** 3
mass_one_NaBr = 103 / avogadro
mass_unitcell_nabr = mass_one_NaBr * 4
density_nabr = mass_unitcell_nabr / volume_unitcell_nabr

# --- 密度比 / Density ratio ---
density_ratio = density_nabr / density_nacl

# --- 出力 / Output ---
print("[NaCl 密度計算 / Density of NaCl]")
print(f"1 NaCl 分子質量 = {mass_one_NaCl:.3e} g")
print(f"単位格子体積 = {volume_unitcell_nacl:.3e} cm³")
print(f"単位格子質量 = {mass_unitcell:.3e} g")
print(f"NaClの密度 = {density_nacl:.2f} g/cm³")

print("\n[Na+ の半径推定 / Na+ Ionic Radius Estimate]")
print(f"Na+ 半径 r = {r_na:.3f} nm")

print("\n[NaBr 密度計算 / Density of NaBr]")
print(f"NaBr 単位格子体積 = {volume_unitcell_nabr:.3e} cm³")
print(f"NaBr 単位格子質量 = {mass_unitcell_nabr:.3e} g")
print(f"NaBrの密度 = {density_nabr:.2f} g/cm³")

print("\n[NaBr / NaCl 密度比]")
print(f"密度比 = {density_ratio:.2f}")

# プログラム名: lattice_length_exponent_ops.py
# 内容: A = 5.6×10⁻⁸ に対する指数演算(A², A³, 1/A など)を実行
# Purpose: Perform exponential and reciprocal operations for lattice length A = 5.6e-8 cm

# --- 初期値設定 / Define base value ---
A = 5.6e-8  # 単位格子の1辺の長さ(cm) / Lattice constant [cm]

# --- べき乗 / Powers of A ---
A_squared = A ** 2       # A²
A_cubed = A ** 3         # A³

# --- 逆数 / Reciprocals ---
inv_A = 1 / A            # 1 / A
inv_A_squared = 1 / A_squared  # 1 / A²
inv_A_cubed = 1 / A_cubed      # 1 / A³

# --- 結果表示 / Output results ---
print(f"A = {A:.3e} [cm]")
print(f"A² = {A_squared:.3e} [cm²]")
print(f"A³ = {A_cubed:.3e} [cm³]")
print(f"1 / A = {inv_A:.3e} [1/cm]")
print(f"1 / A² = {inv_A_squared:.3e} [1/cm²]")
print(f"1 / A³ = {inv_A_cubed:.3e} [1/cm³]")

# プログラム名: density_fe3o4.py
# 内容: Fe₃O₄の密度をモル質量・アボガドロ数・単位格子体積から計算
# Purpose: Calculate the density of Fe₃O₄ using molar mass, Avogadro's number, and lattice constant

# --- 定数定義 / Constants ---
molar_mass_fe3o4 = 232              # モル質量 [g/mol] / Molar mass
avogadro = 6.0e23                   # アボガドロ定数 / Avogadro's number
num_atoms_per_cell = 8             # 単位格子あたりのFe₃O₄セット数
a_fe3o4 = 8.2e-8                    # 単位格子定数 [cm] / Lattice constant

# --- 計算 / Computation ---
mass_per_set = molar_mass_fe3o4 / avogadro             # Fe₃O₄ 1セットの質量 [g]
mass_per_cell = mass_per_set * num_atoms_per_cell      # 単位格子内の総質量 [g]
volume_cell = a_fe3o4 ** 3                              # 単位格子の体積 [cm³]
density_fe3o4 = mass_per_cell / volume_cell            # 密度 = 質量 / 体積 [g/cm³]

# --- 結果出力 / Output ---
print(f"[Fe₃O₄の密度計算 / Density of Fe₃O₄]")
print(f"モル質量 = {molar_mass_fe3o4} g/mol")
print(f"アボガドロ定数 = {avogadro:.1e} 1/mol")
print(f"単位格子の1セット質量 = {mass_per_set:.3e} g")
print(f"単位格子の総質量 = {mass_per_cell:.3e} g")
print(f"単位格子の体積 = {volume_cell:.3e} cm³")
print(f"Fe₃O₄の密度 = {density_fe3o4:.2f} g/cm³")

# プログラム名: osmotic_equilibrium_height_calc.py
# 内容: 浸透圧による圧力バランスと体積計算により、管の高さ h を求める
# Purpose: Solve for the height h of liquid column in osmotic equilibrium

# --- 初期条件の定義 / Initial conditions ---
P0 = 1.0e5            # 初期圧力 [Pa]
V_full = 3.14 * 20.0  # 完全に満たされた体積 [cm³]
n = 1.28e-3           # mol数 [mol]
R = 8.3e3             # 気体定数 [cm³⋅Pa/K⋅mol]
T = 300               # 温度 [K]

# --- 変数として高さ h を定義(記号的に扱う) ---
from sympy import symbols, solve, Eq, simplify

h = symbols('h', real=True)

# --- 圧力の式: P' = 2.00e6 / h ---
P_prime = 2.00e6 / h  # P' = 2.00×10⁶ / h

# --- P' - P0 = (1.0e5)(20.0 - h)/h の式から導く ---
lhs_pressure_diff = P_prime - P0
rhs_pressure_diff = (P0 * (20.0 - h)) / h
eq_pressure = Eq(lhs_pressure_diff, rhs_pressure_diff)

# --- 浸透圧式: ΠV = nRT より Π = ...
# Π = P0 * (20.0 - h) / h = nRT / V
V_solution = 3.14 * (20.0 - h)  # [cm³]
eq_osmotic = Eq((P0 * (20.0 - h) / h) * V_solution / 1000, n * R * T)

# --- 両式から得られる方程式(整理済み) ---
# 導かれる式: h² - 50h + 400 = 0
# 解く:
eq_final = Eq(h**2 - 50 * h + 400, 0)
solutions = solve(eq_final, h)

# --- 出力 / Output ---
print("[Step 1] 初期設定:")
print(f"P0 = {P0:.1e} [Pa]")
print(f"V_full = {V_full:.2f} [cm³]")
print(f"n = {n} mol, R = {R} cm³·Pa/K·mol, T = {T} K")

print("\n[Step 2] 圧力バランスの方程式:")
print("P' = 2.00×10⁶ / h")
print("P' - P0 = (1.0×10⁵)(20.0 - h) / h")

print("\n[Step 3] 浸透圧平衡式:")
print("Π = P0(20 - h)/h")
print("ΠV = nRT → 左辺 = Π × 3.14(20 - h) / 1000")

print("\n[Step 4] 方程式の整理と解:")
print("h² - 50h + 400 = 0")
print(f"解: h = {solutions[0]} [cm], h = {solutions[1]} [cm]")

# --- 条件に基づく選別 (0 ≤ h ≤ 20) ---
valid_h = [sol.evalf() for sol in solutions if 0 <= sol.evalf() <= 20]

print("\n[Step 5] 条件 0 ≤ h ≤ 20 を満たす解:")
for sol in valid_h:
    print(f"h = {sol:.2f} cm ✅")

# プログラム名: first_order_reaction_decay.py
# 内容: 一次反応 A → B における反応物 [A] の時間変化を計算
# Purpose: Compute concentration [A] over time for a first-order reaction A → B

import numpy as np

# --- 初期値の定義 / Initial values ---
A0 = 1.0       # 初期濃度 [A]₀ [mol/L]
k = 0.2        # 速度定数 k [1/time]
t = 10         # 時間 t [time unit]

# --- ログ式からの導出 / From integrated rate law ---
# log[A] = -kt + log[A0] ⇒ A = A0 * e^(-kt)
A_t = A0 * np.exp(-k * t)  # 濃度[A] at time t

# --- 出力 / Output ---
print("[一次反応 A → B / First-order Reaction]")
print(f"初期濃度 [A]₀ = {A0} mol/L")
print(f"速度定数 k = {k} [1/time]")
print(f"時間 t = {t} [time unit]")
print(f"[A](t) = A₀ × e^(-kt) = {A_t:.5f} mol/L")

# プログラム名: arrhenius_temperature_dependence.py
# 内容: アレニウスの式による反応速度定数kの温度依存性を計算
# Purpose: Compute temperature dependence of rate constant k using Arrhenius equation

import numpy as np

# --- 基本定義 / Base definitions ---
A = 1.0e13          # 指数因子 [1/s]
E = 80000           # 活性化エネルギー [J/mol]
R = 8.314           # 気体定数 [J/mol·K]

# --- 温度定義 / Temperature values ---
T1 = 300            # 温度1 [K]
T2 = 350            # 温度2 [K]

# --- アレニウスの式 / Arrhenius equation ---
def k_arrhenius(T):
    return A * np.exp(-E / (R * T))

# --- 常用対数形式 log₁₀k = -E/(2.3RT) + log₁₀A ---
def log10_k(T):
    return (-E / (2.303 * R * T)) + np.log10(A)

# --- 実行 / Evaluate ---
k1 = k_arrhenius(T1)
k2 = k_arrhenius(T2)
logk1 = log10_k(T1)
logk2 = log10_k(T2)

# --- 出力 / Output results ---
print("[アレニウス式による温度依存性 / Temperature Dependence of k]")
print(f"前因子 A = {A:.2e} [1/s]")
print(f"活性化エネルギー E = {E} J/mol")
print(f"気体定数 R = {R} J/mol·K")

print(f"\n[温度 T1 = {T1} K]")
print(f"k1 = {k1:.3e} [1/s]")
print(f"log₁₀(k1) = {logk1:.5f}")

print(f"\n[温度 T2 = {T2} K]")
print(f"k2 = {k2:.3e} [1/s]")
print(f"log₁₀(k2) = {logk2:.5f}")

# プログラム名: ester_equilibrium_concentration_solver.py
# 内容: 酢酸 + エタノールの平衡における K を用いて反応物質量 x を求める
# Purpose: Solve equilibrium concentration x using given K and initial conditions

import sympy as sp

# === 変数定義 / Define symbols ===
x = sp.Symbol('x', real=True)       # x [mol]:生成された酢酸エチルの物質量
V = 1.0                              # V [L]:体積は共通項として打ち消されるため 1.0 L とおく

# === 与えられた定数 / Given constants ===
K1 = 1.5                             # 平衡定数 for case (2)
acetic_init = 4.0                   # 初期酢酸量 [mol]
ethanol_init = 2.0                  # 初期エタノール量 [mol]

# --- 平衡時濃度の式(Vで割って濃度にする)---
# K = ([x]/V)^2 / ([acetic-x]/V × [ethanol-x]/V)
# → K = x^2 / [(acetic - x)(ethanol - x)]
eq1 = sp.Eq((x**2) / ((acetic_init - x) * (ethanol_init - x)), K1)

# --- 解を求める / Solve equation ---
sols1 = sp.solve(eq1, x)

print("[Case 1] 初期濃度 Acetic = 4.0 mol, Ethanol = 2.0 mol, K = 1.5")
for sol in sols1:
    if 0 < sol.evalf() < ethanol_init:
        print(f"✔️ 解: x = {sol.evalf():.3f} mol(有効範囲内)")
    else:
        print(f"✖️ 解: x = {sol.evalf():.3f} mol(無効)")

# === [Case 2] エステル: 1.0 mol、残り x mol 反応させたとする ===
x2 = sp.Symbol('x2', real=True)  # 初期投入量 [mol]
K2 = 2.0                         # 平衡定数

# エステル = 1.0 mol、反応した酢酸 = x2 - 2.0 mol
# K = ([1.0]/V)^2 / ((x - 2.0)^2 / V^2)
eq2 = sp.Eq((1.0 / V)**2 / ((x2 - 2.0)**2 / V**2), K2)
# 整理:1 = 2(x - 2)^2 → 2x^2 - 8x + 7 = 0
eq2_quadratic = sp.Eq(2 * x2**2 - 8 * x2 + 7, 0)
sols2 = sp.solve(eq2_quadratic, x2)

print("\n[Case 2] エステル 1.0 mol 生じたとき、初期投入 x mol を求める(K = 2.0)")
for sol in sols2:
    if sol.evalf() > 1.0:
        print(f"✔️ 解: x = {sol.evalf():.3f} mol(有効範囲)")
    else:
        print(f"✖️ 解: x = {sol.evalf():.3f} mol(不適)")

# プログラム名: decomposition_pressure_range_solver.py
# 内容: NaHCO₃ の分解における CO₂, H₂O の分圧と Kp を用いて圧力条件を求める
# Purpose: Solve pressure range of H2O vapor to prevent decomposition using equilibrium pressure equations

import sympy as sp

# --- 変数定義 / Define variables ---
P_H2O = sp.Symbol('P_H2O', real=True, positive=True)  # 水蒸気の分圧 [Pa]

# --- 定数定義 / Constants with units ---
P_CO2 = 1.0e5         # CO₂ の分圧 [Pa]
Kp = 2.4e9            # 平衡定数 Kp = P_CO2 × P_H2O [Pa²]

# === Step 1: 平衡条件より P_CO2 × P_H2O ≥ Kp を満たす必要がある ===
# このとき反応は右へ進まない(NaHCO₃ が分解しない)
# よって: (1.0×10⁵ - P_H2O) × P_H2O ≥ 2.4×10⁹
# ⇔ -P_H2O² + 1.0×10⁵×P_H2O - 2.4×10⁹ ≥ 0

# --- 2次不等式の解を求める / Solve quadratic inequality ---
lhs = -P_H2O**2 + 1.0e5 * P_H2O - 2.4e9
inequality = sp.solve(lhs >= 0, P_H2O)

# --- 2次方程式の判別式と解を表示 ---
# 解の公式: x = [b ± √(b² - 4ac)] / 2a
a = -1
b = 1.0e5
c = -2.4e9
discriminant = b**2 - 4*a*c  # = 1.0e10 - 9.6e9 = 4.0e8
root1 = (b + sp.sqrt(discriminant)) / (2*a)
root2 = (b - sp.sqrt(discriminant)) / (2*a)

# --- 出力 / Output ---
print("[Step 1] 条件式: (1.0×10⁵ - P_H2O) × P_H2O ≥ 2.4×10⁹")
print("⇔ -P_H2O² + 1.0×10⁵×P_H2O - 2.4×10⁹ ≥ 0")
print(f"\n[Step 2] 2次方程式の解:")
print(f"P_H2O₁ = {root1.evalf():.2e} Pa")
print(f"P_H2O₂ = {root2.evalf():.2e} Pa")

# --- 範囲表示 ---
min_val = min(root1.evalf(), root2.evalf())
max_val = max(root1.evalf(), root2.evalf())

print(f"\n[Step 3] NaHCO₃ が分解しない条件:")
print(f"{min_val:.2e} Pa ≤ P_H2O ≤ {max_val:.2e} Pa")

import numpy as np
import sympy as sp
# : total_H_plus_from_strong_and_water_dissociation.py

# ===============================
# (1) pH1とpH4の塩酸を100mLずつ混合
# ===============================

# 初期[H+]それぞれ [mol/L]
H1 = 10**-1
H4 = 10**-4

# 体積 [mL]
V1 = V2 = 100
V_total = V1 + V2

# 混合後の[H+]
H_mix = (H1 * V1 + H4 * V2) / V_total
pH_mix = -np.log10(H_mix)

print("[1] pH=1とpH=4の塩酸混合:")
print(f"[H+] 混合後 = {H_mix:.2e} mol/L")
print(f"pH = {pH_mix:.2f}")

# ===============================
# (2) 酢酸 CH₃COOH の電離度と pH
# ===============================

# 酢酸濃度 C [mol/L], 酢酸のKa
C = 0.20
Ka = 2.7e-5

# 電離度 α = sqrt(Ka/C)
alpha = np.sqrt(Ka / C)
H_conc = C * alpha
pH_acetic = -np.log10(H_conc)

print("\n[2] 酢酸 CH₃COOH の pH 計算:")
print(f"電離度 α = {alpha:.3f}")
print(f"[H⁺] = {H_conc:.2e} mol/L")
print(f"pH = {pH_acetic:.2f}")

# ===============================
# (3) pH=12.0 溶液にNaOHを加える量xを求める
# ===============================

# [OH⁻] = 1.0×10⁻² mol/L
target_OH = 1.0e-2
x = sp.Symbol('x', real=True, positive=True)

# 与えられた式:
# OH⁻ = (0.10 - 0.10x/1000) × (1000/(x+10)) = 1.0×10⁻²
expr = ((0.10 - 0.10 * x / 1000) * 1000 / (x + 10)) - target_OH
solution_x = sp.solve(expr, x)

# 条件に合う解のみ表示
valid_x = [sol.evalf() for sol in solution_x if sol.is_real and sol.evalf() > 0]

print("\n[3] NaOH加える体積 x [mL](pH=12.0に対応):")
for sol in valid_x:
    print(f"x = {sol:.2f} mL ✅")

#total_H_plus_from_strong_and_water_dissociation.py

import sympy as sp
import numpy as np

# === 変数定義 / Define variables ===
x = sp.Symbol('x', real=True, positive=True)  # 水の電離によって生じる [H⁺] = [OH⁻]

# === 定数 / Constants ===
Kw = 1.0e-14               # 水のイオン積 [mol²/L²]
H_from_HCl = 1.0e-7        # 強酸HClによって供給される [H⁺] mol/L

# === 全体の水素イオン濃度: H_total = H_from_HCl + x ===
# Kw = x * (H_from_HCl + x)
# x(H_from_HCl + x) = Kw → x² + H_from_HCl·x - Kw = 0

eq = sp.Eq(x * (H_from_HCl + x), Kw)
sols = sp.solve(eq, x)

# === 正の実数解のみ採用 ===
x_val = [sol.evalf() for sol in sols if sol.is_real and sol.evalf() > 0][0]
H_total = H_from_HCl + x_val

# === pH 計算 ===
pH = -np.log10(H_total)

# === 出力 / Output ===
print("[強酸 + 水の電離による [H⁺] 合算 pH計算]")
print(f"HCl由来の [H⁺] = {H_from_HCl:.1e} mol/L")
print(f"水の電離由来の [H⁺] = {x_val:.2e} mol/L")
print(f"全[H⁺] = {H_total:.2e} mol/L")
print(f"pH = {-np.log10(H_total):.2f}")
#carbonic_acid_dissociation_pH.py

import sympy as sp
import numpy as np

# === 定義 / Define symbols and constants ===
alpha = sp.Symbol('alpha', real=True, positive=True)  # 電離度 α
C = 1.0e-5       # 炭酸の濃度 C [mol/L]
K1 = 5.0e-7      # 第一段階の電離定数 K₁

# === 近似可能な場合(α << 1)の電離度 α ≈ √(K1/C) ===
alpha_approx = np.sqrt(K1 / C)

# === [H⁺] ≈ C × α(近似)===
H_approx = C * alpha_approx
pH_approx = -np.log10(H_approx)

# === 厳密な式 K1 = (Cα²)/(1-α) を二次方程式で解く ===
# 式変形: Cα² + K1α - K1 = 0
quadratic_eq = sp.Eq(C * alpha**2 + K1 * alpha - K1, 0)
alpha_exact_solutions = sp.solve(quadratic_eq, alpha)
alpha_exact = [sol.evalf() for sol in alpha_exact_solutions if 0 < sol.evalf() < 1][0]

# === 厳密に求めた [H⁺] と pH ===
H_exact = C * alpha_exact
pH_exact = -np.log10(H_exact)

# === 出力 / Output ===
print("[Case 1] α が小さいと仮定した近似解:")
print(f"α ≈ sqrt(K1 / C) = {alpha_approx:.3f}")
print(f"[H⁺] ≈ C × α = {H_approx:.2e} mol/L")
print(f"pH ≈ {-np.log10(H_approx):.2f}")

print("\n[Case 2] 厳密に2次方程式で求めた解:")
print(f"α = {alpha_exact:.3f}")
print(f"[H⁺] = {H_exact:.2e} mol/L")
print(f"pH = {pH_exact:.2f}")

# プログラム名: hypochlorite_hydrolysis_pH.py
# 内容: ClO⁻ の加水分解反応から [OH⁻] を求め、pOHとpHを計算
# Purpose: Calculate pH from hypochlorite ion hydrolysis

import numpy as np

# --- 定数定義 / Constants ---
Kw = 1.0e-14          # 水のイオン積 [mol²/L²]
Ka_HClO = 3.5e-8      # 次亜塩素酸 HClO の酸解離定数 Ka [mol/L]
C_ClO = 0.14          # ClO⁻ の初濃度 C [mol/L]

# --- 加水分解定数 Kh の導出: Kh = Kw / Ka ---
Kh = Kw / Ka_HClO  # [mol/L]
print("[1] 加水分解定数 Kh = Kw / Ka")
print(f"Kh = {Kh:.2e} mol/L")

# --- ClO⁻ + H₂O ⇌ HClO + OH⁻ の近似式: Kh = x² / C ⇒ x = sqrt(C * Kh) ---
OH_conc = np.sqrt(C_ClO * Kh)  # [OH⁻] [mol/L]
pOH = -np.log10(OH_conc)
pH = 14 - pOH

# --- 結果出力 / Output ---
print("\n[2] [OH⁻] = √(C × Kh)")
print(f"[OH⁻] = {OH_conc:.2e} mol/L")
print(f"pOH = {pOH:.2f}")
print(f"pH = {pH:.2f}")

# プログラム名: co2_dissolution_equilibrium_pressure.py
# 内容: 気相と液相のCO₂の平衡状態を計算し、溶解量と圧力を求める
# Purpose: Use ideal gas law and Henry's law to compute CO₂ solubility and pressure

# --- 定数定義 / Constants ---
R = 8.3e3                  # 気体定数 [Pa·L/mol·K]
V_gas = 2.24               # 気相の体積 [L]
T1 = 273                   # 温度 [K](0°C)
T2 = 293                   # 温度 [K](20°C)
CO2_total = 0.10           # 初期封入CO₂の物質量 [mol]
H1 = 1.7 / 1.0e5           # ヘンリー定数(0°C, 1.7L/1atm)[mol/(L·Pa)]
H2 = 0.88 / 1.0e5          # ヘンリー定数(20°C, 0.88L/1atm)[mol/(L·Pa)]
M_CO2 = 44.0               # CO₂のモル質量 [g/mol]

# === (1) 0°C における圧力・溶解量の計算 ===

# Pを未知数として定義
import sympy as sp
P = sp.Symbol('P', positive=True, real=True)

# n1: 気体中のCO₂ [mol]
n1 = P * V_gas / (R * T1)

# n2: 液体中のCO₂ [mol](ヘンリーの法則)
n2 = H1 * P

# n1 + n2 = 0.10 mol の保存式
eq1 = sp.Eq(n1 + n2, CO2_total)

# 解を求める
P_sol = sp.solve(eq1, P)[0].evalf()
n2_val = H1 * P_sol
mass_CO2 = n2_val * M_CO2

print("[1] 0°C における平衡時の圧力と溶解量")
print(f"→ 平衡圧 P = {P_sol:.2e} Pa")
print(f"→ 液体に溶けた CO₂ = {n2_val:.4e} mol")
print(f"→ CO₂ の質量 = {mass_CO2:.2f} g")

# === (2) 20°C における平衡時の圧力 ===

# n2 = H2 * P', n1 = P' * 2.24 / (R * 293), n1 + n2 = 0.10
P_prime = sp.Symbol('P_prime', positive=True)
n1_20 = P_prime * V_gas / (R * T2)
n2_20 = H2 * P_prime

eq2 = sp.Eq(n1_20 + n2_20, CO2_total)
P20_sol = sp.solve(eq2, P_prime)[0].evalf()

print("\n[2] 20°C における平衡圧力")
print(f"→ P' = {P20_sol:.2e} Pa")

# プログラム名: ethanol_formation_enthalpy.py
# 内容: 既知の燃焼熱からエタノールの生成熱を計算
# Purpose: Calculate standard enthalpy of formation of ethanol using Hess's law

# --- 与えられた熱化学反応式(ΔH 値) / Given Enthalpy Values [kJ/mol] ---
deltaH_C = -394    # C + O₂ → CO₂
deltaH_H = -286    # H₂ + ½O₂ → H₂O
deltaH_combustion_ethanol = -1370  # C₂H₅OH + 3O₂ → 2CO₂ + 3H₂O

# --- ステップ: 逆反応と係数調整 / Stepwise manipulation ---
# 2C + 3H₂ + ½O₂ → C₂H₅OH + ΔH_formation
# = 2×(C + O₂ → CO₂) → 2×(-394)
# + 3×(H₂ + ½O₂ → H₂O) → 3×(-286)
# - (C₂H₅OH + 3O₂ → 2CO₂ + 3H₂O) → -(-1370)

deltaH1 = 2 * deltaH_C
deltaH2 = 3 * deltaH_H
deltaH3 = -deltaH_combustion_ethanol

# --- 合計反応熱 / Sum using Hess's Law ---
deltaH_formation_ethanol = deltaH1 + deltaH2 + deltaH3

# --- 結果出力 / Output ---
print("[エタノールの生成熱計算 / Enthalpy of Formation of Ethanol]")
print(f"2C + 3H₂ + ½O₂ → C₂H₅OH")
print(f"ΔH = 2×{deltaH_C} + 3×{deltaH_H} - ({deltaH_combustion_ethanol})")
print(f"ΔH = {deltaH_formation_ethanol} kJ/mol ✅")

# プログラム名: arrhenius_plot_fit.py
# 内容: Arrheniusプロット(log(k) vs 1/T)から直線フィッティングしてEₐを求める
# Purpose: Plot and fit log(k) vs 1/T from temperature-dependent reaction rate data

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import linregress

# --- 入力データ(温度 T [K] と速度定数 k)---
T = np.array([833, 769, 714, 667, 625, 588])  # 温度 [K]
k = np.array([1.0e-1, 1.0e-2, 1.0e-3, 1.0e-4, 1.0e-5, 1.0e-6])  # 仮の k 値

# --- 変換: X = 1/T, Y = log₁₀(k) ---
X = 1 / T
Y = np.log10(k)

# --- 線形回帰 / Linear fit ---
slope, intercept, r_value, _, _ = linregress(X, Y)

# --- 活性化エネルギーの導出 ---
R = 8.314  # J/mol·K
Ea = -slope * 2.303 * R  # [J/mol]

# --- プロット ---
plt.figure(figsize=(6, 4))
plt.plot(X, Y, 'o', label='Data')
plt.plot(X, intercept + slope * X, 'r-', label=f'Fit: log₁₀k = {slope:.2f}·(1/T) + {intercept:.2f}')
plt.xlabel('1 / T [1/K]')
plt.ylabel('log₁₀ k')
plt.title('Arrhenius Plot')
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()

# --- 出力 ---
print("[アレニウス式のフィット結果]")
print(f"回帰式: log₁₀k = {slope:.3f}·(1/T) + {intercept:.3f}")
print(f"決定係数 R² = {r_value**2:.4f}")
print(f"活性化エネルギー Ea = {Ea/1000:.2f} kJ/mol")

# プログラム名: hi_equilibrium_model.py
# 内容: H₂ + I₂ ⇄ 2HI の反応に対する平衡計算
# Purpose: Simulate HI formation and reverse reaction to reach equilibrium

import numpy as np
from scipy.integrate import solve_ivp
import matplotlib.pyplot as plt

# --- 定数定義 / Rate constants ---
k1 = 1.0     # 正反応速度定数 [1/(mol·s)]
k2 = 0.5     # 逆反応速度定数 [1/(mol·s)]

# --- 初期濃度 [mol/L] ---
H2_0 = 1.0
I2_0 = 1.0
HI_0 = 0.0

# --- 微分方程式定義 ---
def reaction_rates(t, y):
    H2, I2, HI = y
    v1 = k1 * H2 * I2
    v2 = k2 * HI**2
    dH2_dt = -v1 + v2
    dI2_dt = -v1 + v2
    dHI_dt = 2 * v1 - 2 * v2
    return [dH2_dt, dI2_dt, dHI_dt]

# --- 数値解法による平衡到達までの時間発展 ---
t_span = (0, 50)
t_eval = np.linspace(*t_span, 500)
sol = solve_ivp(reaction_rates, t_span, [H2_0, I2_0, HI_0], t_eval=t_eval)

# --- プロット ---
plt.plot(t_eval, sol.y[0], label='[H₂]')
plt.plot(t_eval, sol.y[1], label='[I₂]')
plt.plot(t_eval, sol.y[2], label='[HI]')
plt.xlabel('Time [s]')
plt.ylabel('Concentration [mol/L]')
plt.title('HI Formation and Equilibrium')
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()

# プログラム名: chemical_equilibrium_HI.py
# 内容: H2 + I2 ⇄ 2HI における平衡定数とモル量を計算
# Purpose: Compute equilibrium constant K and final HI amount under different conditions

import sympy as sp

# === (1) 平衡定数 K の計算 ===

# 与えられた平衡時の値(体積 1.0 L と仮定)
HI_eq = 3.2  # mol
H2_eq = 0.40
I2_eq = 0.40

# 平衡定数 K の定義
K = (HI_eq**2) / (H2_eq * I2_eq)
print(f"[1] 平衡定数 K = [{HI_eq}]² / ({H2_eq}×{I2_eq}) = {K:.0f}")

# === (2) 新たにH2を1.0 mol加えたときの平衡計算 ===

# 反応前のモル数:
# H2: 3.0 mol, I2: 2.0 mol, HI: 0.0 mol
# 反応してy mol変化したとおく

y = sp.Symbol('y', real=True, positive=True)

# K = (2y)^2 / ((3 - y)(2 - y)) = 64
lhs = (2 * y)**2 / ((3 - y) * (2 - y))
eq = sp.Eq(lhs, 64)

sols = sp.solve(eq, y)

print("\n[2] H₂ を加えた場合の平衡計算:")
for sol in sols:
    if 0 < sol.evalf() < 2:
        y_val = sol.evalf()
        HI_final = 2 * y_val
        print(f"✔️ 有効な解: y = {y_val:.2f} mol → HI = 2y = {HI_final:.2f} mol")

# プログラム名: n2o4_dissociation_equilibrium.py
# 内容: N₂O₄ ⇄ 2NO₂ の平衡における解離度 α と平衡定数 K を求める
# Purpose: Calculate degree of dissociation α and equilibrium constant K

# --- 定数定義 / Constants ---
P = 1.0e5               # 圧力 [Pa]
V = 50 / 1000           # 容器の体積 [L]
T = 300                 # 温度 [K]
R = 8.3e3               # 気体定数 [Pa·L/(mol·K)]
M_N2O4 = 92.0           # N₂O₄ のモル質量 [g/mol]
mass = 0.156            # N₂O₄ の質量 [g]

# --- 初期モル数 C ---
C = mass / M_N2O4       # 初期モル数 [mol]

# === (1) 解離度 α を求める ===

# 圧力 = 全体のモル数 × R × T / V
# n_total = C (1 + α)
# P·V = C(1 + α)·R·T → α = (PV / CRT) - 1

alpha = (P * V) / (C * R * T) - 1
print(f"[1] 解離度 α = {(alpha * 100):.1f} %")

# === (2) 平衡定数 K の計算 ===

# K = [NO₂]² / [N₂O₄]
# 平衡濃度に置き換える:
# K = 4C²α² / (1 - α²)

K = (4 * C**2 * alpha**2) / (1 - alpha**2)
print(f"[2] 平衡定数 K = {K:.2e} mol/L")

# プログラム名: recrystallization_simulation.py
# Program Name: recrystallization_simulation.py
# 概要: 再結晶操作における析出量と飽和溶液量を計算し、温度変化に伴う析出量の変化を可視化する

import numpy as np
import matplotlib.pyplot as plt

# --- サンプルデータ(仮想の溶解度データ) / Sample solubility data ---
# 温度と対応する溶解度 [g/100g水]
temperature = np.array([80, 70, 60, 50, 40, 30, 20])   # 温度 [°C]
solubility = np.array([85, 75, 62, 50, 37, 28, 20])    # 溶解度 S1 or S2

# --- 初期温度と冷却後温度を選択(例: 80°C → 40°C) ---
S1 = solubility[0]   # 初期高温の溶解度
S2 = solubility[4]   # 冷却後の溶解度

# --- 析出量と飽和溶液量の計算 / Precipitate and saturated solution ---
precipitated = S1 - S2
saturated_solution = 100 + S1
precipitate_ratio = precipitated / saturated_solution

# --- 結果表示 / Print results ---
print(f"Initial solubility S1 = {S1} g")
print(f"Final solubility S2 = {S2} g")
print(f"Precipitated amount = {precipitated:.2f} g")
print(f"Saturated solution = {saturated_solution:.2f} g")
print(f"Precipitate ratio = {precipitate_ratio:.4f} (g/g)")

# --- 温度変化による析出量の変化を可視化 / Plot precipitation vs temperature drop ---
temp_drop = temperature[0] - temperature
precipitated_array = S1 - solubility  # それぞれの温度での析出量

plt.figure(figsize=(8, 5))
plt.plot(temp_drop, precipitated_array, marker='o')
plt.xlabel("Temperature Drop (°C)")
plt.ylabel("Precipitated Amount (g)")
plt.title("Precipitated Solute vs Temperature Drop")
plt.grid(True)
plt.tight_layout()
plt.show()

# プログラム名: mole_relationship_calculator.py
# Program Name: mole_relationship_calculator.py
# 概要: 質量・粒子数・体積とモルの関係を計算する(標準状態)

AVOGADRO = 6.022e23      # アボガドロ定数 [個/mol]
STANDARD_VOLUME = 22.4   # 標準状態での1 molの気体の体積 [L/mol]

def calculate_from_mass(mass_g, molar_mass_gmol):
    """ 質量からモル・粒子数・気体体積を計算 / Calculate from mass """
    n = mass_g / molar_mass_gmol
    particles = n * AVOGADRO
    volume = n * STANDARD_VOLUME
    return n, particles, volume

def calculate_from_particles(particles):
    """ 粒子数からモル・質量・体積を計算(質量はモル質量を別途入力)"""
    n = particles / AVOGADRO
    return n

def calculate_from_volume(volume_L):
    """ 標準状態の気体体積からモル数を計算 / Calculate from volume """
    n = volume_L / STANDARD_VOLUME
    return n

# --- 使用例 / Example ---
mass = 36.0             # [g]
molar_mass = 18.0       # [g/mol] → H2O
n, particles, volume = calculate_from_mass(mass, molar_mass)

# --- 結果表示 / Output ---
print("=== Mole Calculation from Mass ===")
print(f"Mass: {mass} g")
print(f"Molar Mass: {molar_mass} g/mol")
print(f"Mole: {n:.4f} mol")
print(f"Particles: {particles:.3e}")
print(f"Gas Volume (STP): {volume:.2f} L")

# プログラム名: ph_calculator.py
# 概要: 濃度・電離度からH+濃度とpHを求める

import numpy as np

def calculate_ph(concentration_mol_L, alpha):
    # H+濃度の計算 / Calculate H+ ion concentration
    h_concentration = concentration_mol_L * alpha

    # pHの計算 / Calculate pH
    ph = -np.log10(h_concentration)
    return h_concentration, ph

# --- 使用例 / Example ---
c = 0.010   # mol/L
alpha = 0.10  # 弱酸の電離度10%
H, pH = calculate_ph(c, alpha)

print(f"[H⁺] = {H:.2e} mol/L")
print(f"pH = {pH:.2f}")

# プログラム名: co2_volume_calculation.py
# CO2吸収量と体積を求めるプログラム

def calculate_co2_volume(
    baoh2_conc, baoh2_vol,
    hcl_conc, hcl_vol,
    molar_volume=22.4
):
    # Ba(OH)2の初期mol
    mol_baoh2_init = baoh2_conc * baoh2_vol / 1000

    # 滴定で使われたHClのmol
    mol_hcl_used = hcl_conc * hcl_vol / 1000

    # HCl:Ba(OH)2 = 2:1 より、残ったBa(OH)2
    mol_baoh2_remain = mol_hcl_used / 2

    # CO2と反応したBa(OH)2
    mol_baoh2_reacted = mol_baoh2_init - mol_baoh2_remain

    # CO2のmol = Ba(OH)2と1:1反応
    mol_co2 = mol_baoh2_reacted

    # 標準状態での体積 [mL]
    vol_co2_ml = mol_co2 * molar_volume * 1000
    return mol_co2, vol_co2_ml

# --- 実行例 / Example ---
baoh2_conc = 5.0e-3     # mol/L
baoh2_vol = 100         # mL
hcl_conc = 1.0e-2       # mol/L
hcl_vol = 7.4           # mL

mol_co2, vol_co2 = calculate_co2_volume(baoh2_conc, baoh2_vol, hcl_conc, hcl_vol)

print(f"吸収したCO2の物質量: {mol_co2:.2e} mol")
print(f"CO2の体積(標準状態): {vol_co2:.2f} mL")

# プログラム名: gas_laws_calculator.py
# 概要: 気体の法則と状態方程式による計算

R = 8.314  # [J/(mol·K)] = [Pa·m³/(mol·K)]

# 1. 気体の状態方程式:PV = nRT
def calculate_n(P_Pa, V_m3, T_K):
    """ 気体の状態方程式からmol数を計算 / Calculate moles """
    n = (P_Pa * V_m3) / (R * T_K)
    return n

# 2. 分子量の計算 M = wRT / PV
def calculate_molar_mass(w_g, P_Pa, V_m3, T_K):
    M = (w_g * R * T_K) / (P_Pa * V_m3)
    return M

# 3. 密度から分子量 M = dRT / P
def calculate_molar_mass_from_density(d_gL, T_K, P_Pa):
    M = (d_gL * R * T_K) / P_Pa
    return M

# --- 実行例 / Example ---
P = 101325       # [Pa]
V = 0.024        # [m³] = 24 L
T = 298          # [K]
w = 44           # g(例えばCO₂)
d = 1.96         # g/L

n = calculate_n(P, V, T)
M1 = calculate_molar_mass(w, P, V, T)
M2 = calculate_molar_mass_from_density(d, T, P)

print(f"モル数: {n:.4f} mol")
print(f"分子量 (質量から): {M1:.2f} g/mol")
print(f"分子量 (密度から): {M2:.2f} g/mol")

# プログラム名: bond_energy_calculator.py
# 概要: ヘスの法則を用いてCH4のC−H結合エネルギーを求める

def calculate_ch_bond_energy(deltaH_formation, deltaH_sublimation, hh_bond_energy):
    # 反応式の総エネルギー収支
    total_energy = deltaH_sublimation + 2 * hh_bond_energy - deltaH_formation

    # CH₄はC−H結合が4本 → 1本あたりのエネルギー
    ch_bond_energy = total_energy / 4
    return ch_bond_energy

# --- 与えられた値 / Given values ---
deltaH_formation = 75         # CH4の生成熱 [kJ/mol]
deltaH_sublimation = 721      # C(黒鉛) → C(気体) [kJ/mol]
hh_bond_energy = 436          # H-H 結合エネルギー [kJ/mol]

# --- 計算 / Calculate ---
ch_energy = calculate_ch_bond_energy(deltaH_formation, deltaH_sublimation, hh_bond_energy)
print(f"C−H結合エネルギー: {ch_energy:.0f} kJ/mol")

# プログラム名: buffer_solution_ph_calculator.py
# 概要: 緩衝液のpHを計算するプログラム

import math

def calculate_ph_acidic(K_a, c, c_prime, x):
    """酸性緩衝液のH+濃度を計算してpHを求める / Calculate H+ concentration and pH for acidic buffer solution"""
    H_concentration = (c_prime * x) / (c - x)
    ph = -math.log10(H_concentration)
    return ph

def calculate_ph_basic(K_b, c, c_prime, x):
    """塩基性緩衝液のOH-濃度を計算してpHを求める / Calculate OH- concentration and pH for basic buffer solution"""
    OH_concentration = (c_prime * x) / (c - x)
    pOH = -math.log10(OH_concentration)
    ph = 14 - pOH
    return ph

# --- 使用例 / Example ---
K_a = 1.8e-5     # 酸の解離定数 [mol/L]
K_b = 1.8e-5     # 塩基の解離定数 [mol/L]
c = 0.1          # 酸/塩基のモル濃度 [mol/L]
c_prime = 0.1     # 塩のモル濃度 [mol/L]
x = 1e-5          # 電離した分の濃度 [mol/L]

# 酸性の場合のpH計算
ph_acidic = calculate_ph_acidic(K_a, c, c_prime, x)

# 塩基性の場合のpH計算
ph_basic = calculate_ph_basic(K_b, c, c_prime, x)

print(f"酸性緩衝液のpH: {ph_acidic:.2f}")
print(f"塩基性緩衝液のpH: {ph_basic:.2f}")

# プログラム名: equilibrium_constant_calculator.py
# 概要: 反応の平衡定数を計算するプログラム

def calculate_equilibrium_constant(H2_initial, I2_initial, HI_generated, volume_L):
    # 平衡時の物質のモル数
    H2_at_equilibrium = H2_initial - (HI_generated / 2)
    I2_at_equilibrium = I2_initial - (HI_generated / 2)
    
    # 平衡定数の計算
    K = (HI_generated / volume_L) ** 2 / ((H2_at_equilibrium / volume_L) * (I2_at_equilibrium / volume_L))
    return K

# --- 使用例 / Example ---
H2_initial = 5.50   # H2の初期モル数 [mol]
I2_initial = 4.00   # I2の初期モル数 [mol]
HI_generated = 7.00 # 生成されたHIのモル数 [mol]
volume_L = 100      # 容器の体積 [L]

# 平衡定数Kの計算
K = calculate_equilibrium_constant(H2_initial, I2_initial, HI_generated, volume_L)

print(f"平衡定数K: {K:.2f}")

# プログラム名: equilibrium_calculator.py
# 概要: 平衡定数の計算と反応による生成物のモル数を求めるプログラム

def calculate_equilibrium_constant(H2_initial, I2_initial, HI_generated, volume_L):
    # 平衡時の物質のモル数
    H2_at_equilibrium = H2_initial - (HI_generated / 2)
    I2_at_equilibrium = I2_initial - (HI_generated / 2)
    
    # 平衡定数の計算
    K = (HI_generated / volume_L) ** 2 / ((H2_at_equilibrium / volume_L) * (I2_at_equilibrium / volume_L))
    return K

def calculate_generated_HI(c_H2, c_I2, volume_L, K):
    # 平衡定数を使って生成されるHIのモル数を計算する
    # x = 生成されるHIのモル数
    x = ((K * (c_H2 / volume_L) * (c_I2 / volume_L)) / (c_H2 / volume_L)) ** 0.5
    return x

# --- 使用例 / Example ---
H2_initial = 5.50   # H2の初期モル数 [mol]
I2_initial = 4.00   # I2の初期モル数 [mol]
HI_generated = 7.00 # 生成されたHIのモル数 [mol]
volume_L = 100      # 容器の体積 [L]

# 平衡定数Kの計算
K = calculate_equilibrium_constant(H2_initial, I2_initial, HI_generated, volume_L)

# 生成されるHIのモル数を計算(H2=5.00 mol, I2=5.00 molの場合)
c_H2 = 5.00        # 新しいH2のモル数
c_I2 = 5.00        # 新しいI2のモル数
generated_HI = calculate_generated_HI(c_H2, c_I2, volume_L, K)

print(f"平衡定数K: {K:.2f}")
print(f"生成されるHIのモル数: {generated_HI:.2f} mol")

# プログラム名: dissociation_degree_calculator.py
# 概要: 酸の電離度と水素イオン濃度を計算するプログラム

import math

def calculate_dissociation_degree(K_a, c):
    """ 電離定数と酸のモル濃度から電離度αを計算する """
    alpha = math.sqrt(K_a * c)
    return alpha

def calculate_hydrogen_ion_concentration(alpha, c):
    """ 電離度αと酸のモル濃度から水素イオン濃度[H+]を計算する """
    H_concentration = c * alpha
    return H_concentration

# --- 使用例 / Example ---
K_a = 2.7e-5   # 酸の電離定数 [mol/L]
c = 0.030      # 酸のモル濃度 [mol/L]

# 電離度αの計算
alpha = calculate_dissociation_degree(K_a, c)

# 水素イオン濃度[H+]の計算
H_concentration = calculate_hydrogen_ion_concentration(alpha, c)

print(f"電離度α: {alpha:.4f}")
print(f"水素イオン濃度[H+]: {H_concentration:.4e} mol/L")

# プログラム名: equilibrium_pressure_calculator.py
# 概要: 圧平衡定数Kpを求めるプログラム

import math

def calculate_Kp(P_initial, P_final, Kp_initial):
    # α(電離度)の計算
    alpha = (Kp_initial * (P_initial / P_final)) / (P_initial + Kp_initial)
    
    # 平衡定数Kpの計算
    Kp = (2 * alpha * P_initial)**2 / ((1 - alpha) * P_initial)
    
    return Kp

# --- 使用例 / Example ---
P_initial = 1.5e5  # 初期N2O4の分圧 [Pa]
P_final = 2.0e5    # 反応後の分圧 [Pa]
Kp_initial = 0.50  # 初期平衡定数

# 平衡定数Kpの計算
Kp = calculate_Kp(P_initial, P_final, Kp_initial)

print(f"平衡定数Kp: {Kp:.2f}")

# プログラム名: buffer_ph_calculator.py
# 概要: 緩衝液のpHを計算するプログラム

import math

def calculate_ph(K_a, c_acid, c_base):
    # 酢酸と酢酸ナトリウムのモル濃度からpHを計算
    # 酢酸の解離定数K_aとモル濃度を使ってpHを計算
    numerator = c_base * c_acid
    denominator = c_acid * (c_acid + c_base)
    H_concentration = math.sqrt(K_a * numerator / denominator)
    
    pH = -math.log10(H_concentration)
    return pH

# --- 使用例 / Example ---
K_a = 2.7e-5    # 酢酸の解離定数
c_acid = 0.10    # 酢酸のモル濃度 [mol/L]
c_base = 0.10    # 酢酸ナトリウムのモル濃度 [mol/L]

# pHの計算
ph = calculate_ph(K_a, c_acid, c_base)

print(f"緩衝液のpH: {ph:.2f}")

# プログラム名: solubility_calculator.py
# 概要: 温度による溶解度の計算(質量パーセント濃度)

def calculate_solubility(mass_solute, mass_solvent, total_mass):
    """質量パーセント濃度を計算する"""
    percent_concentration = (mass_solute / total_mass) * 100
    return percent_concentration

def calculate_mass_of_solute(solubility, mass_solvent):
    """溶解度から溶質の質量を計算する"""
    mass_solute = solubility * mass_solvent
    return mass_solute

# --- 使用例 / Example ---
mass_solvent_30 = 100  # 水の質量 [g] (30℃で)
solubility_30 = 0.45   # 30℃での溶解度 [g/mol]

# 溶質の質量計算(30℃)
mass_solute_30 = calculate_mass_of_solute(solubility_30, mass_solvent_30)

# 質量パーセント濃度の計算(30℃)
total_mass_30 = mass_solvent_30 + mass_solute_30
percent_concentration_30 = calculate_solubility(mass_solute_30, mass_solvent_30, total_mass_30)

print(f"30℃の溶質質量: {mass_solute_30:.2f} g")
print(f"30℃の質量パーセント濃度: {percent_concentration_30:.2f}%")

# プログラム名: unit_cell_density_calculator.py
# 概要: 単位格子の質量と密度を計算するプログラム

import math

def calculate_mass_of_unit_cell(molecular_weight, number_of_molecules, avogadro_constant):
    # 単位格子の質量を計算 / Calculate mass of unit cell
    mass = (molecular_weight * number_of_molecules) / avogadro_constant
    return mass

def calculate_density(mass, volume):
    # 密度を計算 / Calculate density
    density = mass / volume
    return density

# --- 使用例 / Example ---
molecular_weight = 18     # 水分子のモル質量 [g/mol]
number_of_molecules = 8  # 単位格子に含まれる水分子の数
avogadro_constant = 6.02e23 # アボガドロ定数 [個/mol]
volume_of_unit_cell = (2.76e-8)**3  # 単位格子の体積 [cm^3]

# 単位格子の質量を計算
mass_of_unit_cell = calculate_mass_of_unit_cell(molecular_weight, number_of_molecules, avogadro_constant)

# 密度を計算
density = calculate_density(mass_of_unit_cell, volume_of_unit_cell)

print(f"単位格子の質量: {mass_of_unit_cell:.2e} g")
print(f"単位格子の密度: {density:.3f} g/cm³")

import math

def calculate_h_concentration(c, alpha):
    """ 水素イオン濃度 [H+] の計算 """
    H_concentration = (1 + alpha) * c
    return H_concentration

def calculate_ph(H_concentration):
    """ pHの計算 """
    pH = -math.log10(H_concentration)
    return pH

def calculate_Kw_concentration(Kw, T):
    """ 温度による水のイオン積の変化とpHの計算 """
    H_concentration = math.sqrt(Kw)
    pH = -math.log10(H_concentration)
    return pH

# --- 使用例 / Example ---
c = 0.1  # 初期濃度 [mol/L]
alpha = 0.5  # 電離度
Kw = 6.91e-14  # 水のイオン積 (30℃)

# 水素イオン濃度の計算
H_concentration = calculate_h_concentration(c, alpha)

# pHの計算
ph = calculate_ph(H_concentration)

# pHの計算(30℃での水のイオン積を用いて)
ph_Kw = calculate_Kw_concentration(Kw, 30)

print(f"水素イオン濃度 [H+]: {H_concentration:.2e} mol/L")
print(f"pH: {ph:.2f}")
print(f"30℃でのpH (水のイオン積から): {ph_Kw:.2f}")

import math

def calculate_density(M_Na, M_Cl, N_A, l, num_atoms=4):
    """ 単位格子の密度を計算する関数 """
    # 質量計算
    mass = (M_Na + M_Cl) / N_A * num_atoms  # 単位格子の質量 [g]
    
    # 体積計算 (lは単位格子の一辺の長さ)
    volume = l ** 3  # 単位格子の体積 [cm³]
    
    # 密度計算
    density = mass / volume
    return density

# --- 使用例 / Example ---
M_Na = 23.0  # Naのモル質量 [g/mol]
M_Cl = 35.5  # Clのモル質量 [g/mol]
N_A = 6.02e23  # アボガドロ定数 [mol^-1]
l_NaCl = 5.63e-8  # NaCl単位格子の一辺 [cm]

# 塩化ナトリウム(NaCl)の結晶密度を計算
density_NaCl = calculate_density(M_Na, M_Cl, N_A, l_NaCl)

# 結果を表示
print(f"塩化ナトリウムの結晶密度: {density_NaCl:.3f} g/cm³")

# プログラム名: ideal_gas_calculator.py
# 概要: 気体の状態方程式 PV = nRT を使った計算

import math

def calculate_moles(P, V, T, R=8.3e3):
    """ モル数の計算 / Calculate moles (n) """
    n = (P * V) / (R * T)
    return n

def calculate_pressure(n, V, T, R=8.3e3):
    """ 圧力の計算 / Calculate pressure (P) """
    P = (n * R * T) / V
    return P

def calculate_molar_mass(mass, n):
    """ モル質量の計算 / Calculate molar mass (M) """
    M = mass / n
    return M

def calculate_volume(n, P, T, R=8.3e3):
    """ 体積の計算 / Calculate volume (V) """
    V = (n * R * T) / P
    return V

def calculate_mass(M, n):
    """ 質量の計算 / Calculate mass (M) """
    mass = M * n
    return mass

# --- 使用例 / Example ---
P = 3.0e5     # 圧力 [Pa]
V = 5.0       # 体積 [L]
T = 273 + 27  # 温度 [K]
mass = 0.6    # 質量 [g]

# モル数の計算
n = calculate_moles(P, V, T)

# 圧力の計算
P_calculated = calculate_pressure(n, V, T)

# 酸素のモル質量 (32 g/mol)
M_oxygen = 32

# 体積の計算
V_calculated = calculate_volume(n, P, T)

# 質量の計算
mass_calculated = calculate_mass(M_oxygen, n)

print(f"モル数 (n): {n:.2f} mol")
print(f"圧力 (P): {P_calculated:.2e} Pa")
print(f"体積 (V): {V_calculated:.2f} L")
print(f"質量 (M): {mass_calculated:.2f} g")

import math

def calculate_average_molecular_weight(masses, fractions):
    """ 平均分子量を計算する関数 """
    M = sum([mass * fraction for mass, fraction in zip(masses, fractions)]) / sum(fractions)
    return M

def calculate_pressure_using_ideal_gas(P, V, T, M, R=8.31e3):
    """ 気体の状態方程式を使用して圧力を計算する関数 """
    pressure = (P * R * T) / (M * V)
    return pressure

# --- 使用例 / Example ---
masses = [28, 32, 40]  # N2, O2, Arのモル質量 [g/mol]
fractions = [4, 1, 1]  # 各気体の体積分率(比例)N2 : O2 : Ar = 4 : 1 : 1

# 平均分子量の計算
M = calculate_average_molecular_weight(masses, fractions)

# 気体の圧力を求める
P = 1.72e5  # Pa
V = 5.0    # L
T = 273 + 27  # 30℃をKに変換

pressure = calculate_pressure_using_ideal_gas(P, V, T, M)

print(f"平均分子量: {M:.2f} g/mol")
print(f"計算した圧力: {pressure:.2e} Pa")

# プログラム名: heat_of_formation_calculator.py
# 概要: 生成熱と反応熱を計算するプログラム

def calculate_heat_of_formation(heat_1, heat_2, heat_3, heat_4):
    """ 生成熱を計算する関数 """
    Q = heat_1 + heat_2 + heat_3 - heat_4
    return Q

# --- 使用例 / Example ---
heat_1 = 394   # C + O2 -> CO2 の生成熱 [kJ/mol]
heat_2 = 286   # H2 + O2 -> H2O の生成熱 [kJ/mol]
heat_3 = 107   # C + 4H2 -> C3H8 の生成熱 [kJ/mol]
heat_4 = 2219  # C3H8 + O2 -> CO2 + H2O の生成熱 [kJ/mol]

# 生成熱の計算
Q = calculate_heat_of_formation(heat_1, heat_2, heat_3, heat_4)

print(f"生成熱: {Q} kJ/mol")

# プログラム名: electricity_calculator.py
# 概要: 電気量と電子の物質量を計算するプログラム

def calculate_electricity(i, t):
    """ 電気量を計算する関数 """
    Q = i * t  # クーロン [C]
    return Q

def calculate_moles_of_electrons(i, t, faraday_constant=9.65e4):
    """ 電子の物質量を計算する関数 """
    moles_of_electrons = (i * t) / faraday_constant  # mol
    return moles_of_electrons

# --- 使用例 / Example ---
i = 2.0  # 電流 [A]
t = 10.0  # 時間 [秒]

# 電気量の計算
Q = calculate_electricity(i, t)

# 電子の物質量の計算
moles_of_electrons = calculate_moles_of_electrons(i, t)

print(f"電気量: {Q:.2f} C")
print(f"電子の物質量: {moles_of_electrons:.4e} mol")

1
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
1
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?