Effacer les filtres
Effacer les filtres

陰関数を一度に解く方法

3 vues (au cours des 30 derniers jours)
高木 範明
高木 範明 le 22 Déc 2023
Commenté : 高木 範明 le 26 Déc 2023
陰関数をfor/endを使わずに、配列で一度に解く為に、つぎのコードを書きました。
しかし、x_values=[3,4,5]に対して、yが[0,0,0]になっており、算出できていません。
間違っているところのご教示をよろしくお願いします。
% 陰関数の定義
f = @(xy) xy(1)^2 + xy(2)^2 - 25;
% xの値をベクトルで指定
x_values = [3, 4, 5];
% 初期推定値をベクトル化
initialGuess = zeros(length(x_values), 2);
initialGuess(:, 1) = x_values;
% fsolveを使用して方程式を解く
options = optimoptions('fsolve', 'Algorithm', 'levenberg-marquardt');
solutions = fsolve(f, initialGuess, options);
% 結果の表示
disp('各xに対する算出されたyの値:');
% disp(solutions(:, 2));
disp(solutions);
-----------------------
出力結果は次の通りです。
方程式は初期点で解かれました。
初期点における関数値のベクトルがゼロに近く
(関数の許容誤差値による測定)
問題が正則として現れる (勾配による測定) ため、fsolve は完了しました。
<停止条件の詳細>
xに対する算出されたyの値:
3 0
4 0
5 0
  4 commentaires
高木 範明
高木 範明 le 25 Déc 2023
In the implicit function of two variables, f(x,y), if we put a certain value in x, we want to calculate the value of y. Then, we want the given x to be an array, and we also want the obtained y to be an array. This is the objective.
高木 範明
高木 範明 le 25 Déc 2023
The actual implicit function to be calculated is a monotonically increasing expression, unlike x^2+y^2=25, and there is never more than one y for x.

Connectez-vous pour commenter.

Réponse acceptée

Atsushi Ueno
Atsushi Ueno le 23 Déc 2023
> (fsolve 関数の説明)「 x (解) のサイズは、x0 (初期条件) のサイズと同じです」
  1. 「2次元配列の1列目に初期条件を与えると2列目に解が出力される」訳ではありません。
  2. 初期条件([3;4;0]は既に解になっています。fsolve 関数は何もせずそのまま解として出力しています
  3. 初期条件のサイズは2行1列で十分です(おそらく最初は25でなくxy(3)としていたと想定します)
  4. 解は[3;4]以外にもたくさん存在します。狙いの値に定めるには制約条件の設定が必要です
options = optimoptions('fsolve','Algorithm','levenberg-marquardt','Display','iter');
f = @(xy) xy(1)^2 + xy(2)^2 - 25;
initialGuess = rand(3,1);
[solutions,fval] = fsolve(f, initialGuess, options)
First-order Norm of Iteration Func-count ||f(x)||^2 optimality Lambda step 0 4 576.243 38.4 0.01 1 11 29.5594 38.6 10 3.42556 2 15 0.101804 2.54 1 0.544966 3 19 4.79125e-06 0.0176 0.1 0.0317904 4 23 4.57568e-12 1.72e-05 0.01 0.00021868 5 27 4.57403e-20 1.72e-09 0.001 2.13887e-07 Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
solutions = 3×1
2.9841 4.0119 0.6230
fval = -2.1387e-10
initialGuess = [3 4]; % 初期条件が既に解なので、イタレーションが1度しか回らずに済む
[solutions,fval] = fsolve(f, initialGuess, options)
First-order Norm of Iteration Func-count ||f(x)||^2 optimality Lambda step 0 3 0 0 0.01 Equation solved at initial point. fsolve completed because the vector of function values at the initial point is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
solutions = 1×2
3 4
fval = 0
  2 commentaires
高木 範明
高木 範明 le 25 Déc 2023
詳細なご説明をありがとうございます。
私自身、少し勘違いをしているようです。
まずは、ご説明の理解をさせていただきます。
高木 範明
高木 範明 le 26 Déc 2023
ご説明の内容を理解しました。
また、2変数(X1,X2)の陰関数において、複数の初期/入力条件(X1_1、X1_2、、、)に対して、答え(X2_1、X2_2、、、)が一気に算出する機能がないことも理解いたしました。
どうもありがとうございました。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 数学 dans Help Center et File Exchange

Tags

Produits


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!