Keyword: 誤差関数
概要
本サンプルは誤差関数を求めるC言語によるサンプルプログラムです。 本サンプルは引数xを読み込み、xの各値について以下に示される誤差関数を求めて出力します。
※本サンプルはnAG Cライブラリに含まれる関数 nag_erf() のExampleコードです。本サンプル及び関数の詳細情報は nag_erf のマニュアルページをご参照ください。
ご相談やお問い合わせはこちらまで
入力データ
(本関数の詳細はnag_erf のマニュアルページを参照)- 1行目はタイトル行で読み飛ばされます。
- 2~7行目に誤差関数の引数xの値を指定しています。
出力結果
(本関数の詳細はnag_erf のマニュアルページを参照)1 2 3 4 5 6 7 8
この出力例をダウンロード |
nag_erf (s15aec) Example Program Results x y -6.000e+00 -1.000e+00 -4.500e+00 -1.000e+00 -1.000e+00 -8.427e-01 1.000e+00 8.427e-01 4.500e+00 1.000e+00 6.000e+00 1.000e+00
- 3~8行目に引数xの値と誤差関数の値が出力されています。
ソースコード
(本関数の詳細はnag_erf のマニュアルページを参照)
※本サンプルソースコードはnAG数値計算ライブラリ(Windows, Linux, MAC等に対応)の関数を呼び出します。
サンプルのコンパイル及び実行方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
このソースコードをダウンロード |
/* nag_erf (s15aec) Example Program. * * CLL6I261D/CLL6I261DL Version. * * Copyright 2017 Numerical Algorithms Group. * * Mark 26.1, 2017. */ #include <nag.h> #include <stdio.h> #include <nag_stdlib.h> #include <nags.h> int main(void) { Integer exit_status = 0; double x, y; /* Skip heading in data file */ scanf("%*[^\n]"); printf("nag_erf (s15aec) Example Program Results\n"); printf(" x y\n"); while (scanf("%lf", &x) != EOF) { /* nag_erf (s15aec). * Error function erf(x) */ y = nag_erf(x); printf("%12.3e%12.3e\n", x, y); } return exit_status; }