コメント一覧
まえへ つぎへ89 投稿者:
名無しさん 2020/01/14 12:09:40
/* laplace */
#include <stdio.h>
#include <math.h>
#define N 5
float f(int i,int j);
int main (void)
{
int i, j, m;
float u[N + 1][N + 1], U, er, d, h;
d = 1.0 ;
h = d / N;
for (i = 0; i <= N; i++)
for (j = 0; j <= N; j++)
u[i][j] = 0.0;
for (i = 0; i <= N; i++)
{
u[i][N] = sin(M_PI*h*i);
}
m = 0;
do
{
er = 0.0;
for (i = 1; i < N; i++)
{
for (j = 1; j < N; j++)
{
U = (u[i - 1][j] + u[i][j - 1]
+ u[i + 1][j] + u[i][j + 1]- h * h * f(i,j)) / 4.0;
er += fabs (U - u[i][j]);
u[i][j] = U;
}
}
m++;
}
while (er > 1.0e-4);
printf ("%d\n", m);
for (j = N; j >= 0; j--)
{
for (i = 0; i <= N; i++)
printf ("%7.3f", u[i][j]);
printf ("\n");
}
}
float f(int i,int j) {
if(i==j) {
return (-2.135e-10/8.854e-12);
}else {
return 0;
}
}
/*
[e142122@ei1-pc15 ~/0114]$ 2
26
0.000 0.588 0.951 0.951 0.588 -0.000
0.000 0.415 0.708 0.804 0.704 0.000
0.000 0.363 0.661 0.854 0.459 0.000
0.000 0.376 0.719 0.526 0.279 0.000
0.000 0.422 0.348 0.252 0.133 0.000
0.000 0.000 0.000 0.000 0.000 0.000
*/
90 投稿者:
名無しさん 2020/01/15 15:47:48
https://twitter.com/oauth/authorize?oauth_consumer_key=sUKqnlGM88igrfq922BCg&oauth_nonce=48oDF_0MsUE2nH_y27LhvjtUGFlz2g&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1579033170&oauth_token=N2KapAAAAAAAQBNbAAABb6fz6tc&oauth_version=1.0&oauth_signature=OxL%2BE4ifmjseeESbMKr7uI9LYyw%3D
91 投稿者:
名無しさん 2020/01/16 13:07:50
-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v2.1.3
Comment: https://keybase.io/crypto
wcFMA9MRkNUWGNGuARAAtxmMIeXHZgBUpHxXsNCtLoZOFeX/29qZYhMLRULUTVQo
qL6t24HH5zWwC0WVin8lVOVKWO6YVd0p1efMLnNJU6OHYTwipFhLu9u37lIR0dDa
PCmN4aXDh02iGvwoMeXVIJJL3wFHuC9vpm/PDtlr1kmvQffn1GkmOCi613gEu8su
EwPRSnWka29FHELdYfdd1CkuhM3QoYK5e8XnzFZtNcDcir32NW9NVaVYhouruSmJ
TkA3wgsb92qRfDN7NgrneQ1bMMzk1YsobSz3bRGXjFGAfaibuP+fWZXVOusxpnP3
CVto7l0T9bAAgiqp5d8IZ0xF/T0Zgu5y/bUNkMQbiWrE40ZdxgD5Za8lALPwna7S
QqH3uR5aOajnKA1crRAWsNtxTcB4kFtSu9owfmcSGqcQ0m9A8MNlEQNr4Wa6r70K
qEKEXn4GVSgQa0RjhDdpU7sK/2ZT+y5R5MizOA06Rhb2uwI1C6fj4Pk1vP5xkUMv
P40ErnifNnD+hPQILkwk75aEoq0CywvSlcOXvecsHFfzo23QQFTJqPzykTwHB5op
tn/RdUPqr3f3URS+IcKY4crEzfFRM+BsvzPm2dEAh+A/aaxAIlQjU79C9g3wXSPq
zWYmNRnbOWGzXEahEz22hV31mbzXt1lQA9V9Y3hG4B+X69/T5Uk4Xtetwb8NA9zS
XQFR3sfWKGBp05qznX0IIJO92vkEKc7ObCHDVvtVExfXrSz+3QhEgbrUOiYDqGrQ
xpSoNZIjyNmRTfPOayXKJjioZFYgcsmht7GIT4/XwrusF5IrFCkzEYDSCV8XzA==
=vhfT
-----END PGP MESSAGE-----
92 投稿者:
名無しさん 2020/01/17 11:29:18
------------BEGIN PGP SIGNATURE---------------
srfnisbrOmankofjieosfaFRrgjgqargwuigbr59g
GERg5iwoghiowhtiowbgh4iowtqq34htQTq3hqtq3
H54Wy5w%WgQ%gh5QhqwHY%WhthejejywshWHW54wH
------------END PGP SIGNATURE-----------------
93 投稿者:
名無しさん 2020/01/20 09:24:47
-----BEGIN PGP MESSAGE-----
hQIMAysOPFaclZ0ZAQ/+J5K/WWVpM7YhYj2UjV1MAjLRpjVokZHEf72JmfKNMymS
dbBgI0goz8NuQwJnzh6uniDhxjEYkEqMfqjQMp4vee8vjTyLR/yr+nTZhBXH9SZw
0YBlNJuSwEMZMil18FLgYt+iWY4jVHnkAO7EfJDXvjt4z4a2PjiDdTKOxrBqnyCz
N1Ncss/cApJuFMTfE4YOjlFLGyxi+jGun96ORK4pnn0BOM/1pv5dEF9Dy1/pOv9r
/IVehevUWm7RJGDpZ1wnSRHAnHevmcDsujiasxGyv/pdEW/R8KJL98uhqOiaiBZf
dzs9Z16de4iPCihAHhoj+F9sVA78ofddbevl7H34QUwFvupqtXP2AHyMwACtLjxP
tRK/1mGYTJ4SZigqAE/KIx4CY/ScW4wTPRyzIZzXLOJ92z2GgIHY1x/tJQkW15FF
jhxOzpZZU+Sod6ustM36GHM6hg+x+QagCFmW17bloqQZQTkz97FOhpxtjXPpNMi8
b1idC7soAOsw07BwlOzoBysz2e/mdOzfPujhYAe3zqEm5TsDle2FtVo5jJaLIhrD
ejsAqNxQFhqVFLlKCm1rFZ8Wcyz0WaKc++vzqn4UvVi8LckRYTRK43n5bh+ck9PV
5tuYSiUb4ey0dLFlD6lIay+mVnM0qWb6EgW7qOH1GtnDpJMjehwIgbVZ6ljkKE3S
VgEV0VDAN337eeDshKewtrcBef3zgGlTDrSaJnL67n4OzThWF0ZT5hMFE81Zp80V
/5FyDwnYIlYEzH0cD6U3FOJld8W3UfOUXrM+nNYC1rDxO2Rv/ugg
=tph2
-----END PGP MESSAGE-----
94 投稿者:
名無しさん 2020/01/20 09:43:03
-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v2.1.3
Comment: https://keybase.io/crypto
wcFMAysOPFaclZ0ZAQ//eIcyeq+wEtcWHW6Z3RcVTZhagrKic2P3AvGyXO+vGYqo
IXY2CQ6wkhA0TldznaJRfV4xxBRGEQJfcXMuQatNYj8ZiVMhgEWNroq+CkD1LgLA
OmlLDKLMS60sxkwNZ6fgBJ26urhaH71VkvNGn1FwS67F5eprkppX8CJP/0aYBvTm
JK3t6PElo7Lzp/ZeTtBahUhS9H1ftgib4GteRh3wj/UCRnbTe2uI6Uy4+AQzOezD
Gb+tmXV5LRZA+ZQ6zsGbPzGB2xrGWXRuoXNq4iDim1RwR32wN3VgA+k7hIVVGZZo
iwEsaY+T1PnfnsC2AbY2tq8yV2vxV1yjnhrRxsYq0pt/3yQfOwh9O+rq3Sm/DhHn
7ET3ALwXL5rVitwhZJkJci2EKkxwWN28iq0rsIH/K4kc7YCMqeYc5Rg/eGvpxJYa
achge7wviIyX131Gc44Dhc6kS7fkZmGZm3fpcq4fKAwWjILGc6jI0pkcAy5BkxUF
fsA8RCeXmQ5GIeoO1S2G21Snjsaei5oDKB3a2V4UKdP3Xf61WC5n2Zd+CvsSCtOu
Ntw742lwwArpD+EvBwZ5ozSZkmN72hjT1eI7sQGFfiWUPG8cV/0EwywhzPczNejQ
YxJbitpOovsKixgDtUn1I9OeyEervEt/OaR5MLx3xxbr6ZgIlcjDQTuymtXYaePS
SwFuz+3R17sep6CbXxGVEH0v8n1aRFznsnFvXA1h0ETPbUYhItU7nJqNoC+0sU0L
FW49E8W4FP4GV2+DqJ5XnDluyTTKxOpfelPsqw==
=ZVci
-----END PGP MESSAGE-----
95 投稿者:
to mimoex 2020/01/20 09:43:36
-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v2.1.3
Comment: https://keybase.io/crypto
wcFMA9MRkNUWGNGuAQ//Z3rFuw0C2gX3y0/ESEWY61SEuMOXu45/prrwcXkl96zk
rGOaGjsWA5bl3pja5k1qnW0hDAThqB3W4V1mlkXGe6Z+9ea1Pfndtyno2ThjW6NT
0gcrGkLsQMJWFr3oCQdap6Iiqk/4meBmaLUPkuFixZIWXJQCHSTbb/UkckZ9eBFd
JGMGoqLJS6CtANZInh5w2K8CwhIbmeQbIzYh8R2ubf7wUsx2Z4RnTqkdVH0prpKy
OW1Wgud6g0oKhgazxsfhY67HIlXM17slMeejl/doZL+7i8KzvZjiA5jFxQA/13qV
eNyQp+xKlWxWCTwJHo8oZ7QWCB0hWjWyr50NeaxEFwzEgnnCNi3XYTFS4h466DX2
s3DqNPHqZ0CAyLv7zBS9xIitqOxbUqZyrDjn0bR/RNzTS15wvgcPsJ51aAUxoQ+V
G2lz5YATpuh0pvC2k9XLdXPg73CvbiOmXAJFOGwCFO1Z4vNhFINjkCPP6npwXIi+
YMAdqSl6Df+gOilqFUxa5KtuP5fe7M3QnfbEzdcViuZhMSNQDByt4078yyl/vjjP
8U2IVUfKOFIBbR1kptsQaEbTTSpq+K6TK8PdUyFS76sLwCRQc1QUvzWDSj+5/Wc/
IrQPoS8wevERSRaY7IMMYkFZy2bce33M5OYg3WUI0pAFGNTc+jOY6zIScUgePfTS
SwFKP1rnEzWO53+w7X23OcEZ0BjhblAmGC/S0ZDcVd1xsa0n5ZgoKqKSwAzevgc7
NO8ejzZaK6iI59webdn8jjcbabOfv+09UT/MtA==
=If5Q
-----END PGP MESSAGE-----
96 投稿者:
名無しさん 2020/01/20 16:33:28
97 投稿者:
名無しさん 2020/01/20 16:33:32
98 投稿者:
名無しさん 2020/01/21 12:19:27
#include <stdio.h>
#include <math.h>
#define M 10
#define N 100
// c*c 熱伝導係数=1
// r = k / h / h = c * c * k / h / h
//
// ( r <= 1 / 2 )
// r -> 1 のときうまくいかない
// h=0.2 -> k でrの条件を満たすべき
//iがx方向
//jが時間t
//jが0なおかつI->...
int main(void) {
int i, j, m, n;
float u[M + 1][N + 1], r, k, h, er, x, t;
printf("interval of position(h)= : ");
scanf("%f", &h);
printf("interval of time(k)= : ");
scanf("%f", &k);
r = k / h / h;
printf("r=%f\n", r);
m = (int)(1.0 / h + 0.5);
n = (int)(1.0 / k + 0.5);
printf("m=%d n=%d\n", m, n);
for (j = 0; j <= n; j++) {
for (i = 0; i <= m; i++) {
x = i * h;
if ((x == 0 || x == 1) && j >= 0)
u[i][j] = 0.0;
else if (x >= 0 && x <= 0.5 && j == 0)
u[i][j] = 2.0 * x;
else if (x >= 0.5 && x <= 1 && j == 0)
u[i][j] = 2.0 * (1.0 - x);
else
u[i][j] = 0.0;
}
}
for (j = 0; j < n; j++) {
for (i = 1; i < m; i++) {
u[i][j + 1] = (1.0 - 2.0 * r) * u[i][j]
+ r * (u[i + 1][j] + u[i - 1][j]);
}
}
for (j = 0; j <= n; j++) {
printf("%7.3f", k * j);
for (i = 0; i <= m; i++)
printf("%7.3f", u[i][j]);
printf("\n");
}
}
/*
shion@PC-9821Air ~ % sh comp.sh m
interval of position(h)= : 0.2
interval of time(k)= : 0.02
r=0.500000
m=5 n=50
0.000 0.000 0.400 0.800 0.800 0.400 0.000
0.020 0.000 0.400 0.600 0.600 0.400 0.000
0.040 0.000 0.300 0.500 0.500 0.300 0.000
0.060 0.000 0.250 0.400 0.400 0.250 0.000
0.080 0.000 0.200 0.325 0.325 0.200 0.000
0.100 0.000 0.162 0.262 0.262 0.162 0.000
0.120 0.000 0.131 0.212 0.212 0.131 0.000
0.140 0.000 0.106 0.172 0.172 0.106 0.000
0.160 0.000 0.086 0.139 0.139 0.086 0.000
0.180 0.000 0.070 0.112 0.112 0.070 0.000
0.200 0.000 0.056 0.091 0.091 0.056 0.000
0.220 0.000 0.046 0.074 0.074 0.046 0.000
0.240 0.000 0.037 0.060 0.060 0.037 0.000
0.260 0.000 0.030 0.048 0.048 0.030 0.000
0.280 0.000 0.024 0.039 0.039 0.024 0.000
0.300 0.000 0.019 0.032 0.032 0.019 0.000
0.320 0.000 0.016 0.026 0.026 0.016 0.000
0.340 0.000 0.013 0.021 0.021 0.013 0.000
0.360 0.000 0.010 0.017 0.017 0.010 0.000
0.380 0.000 0.008 0.014 0.014 0.008 0.000
0.400 0.000 0.007 0.011 0.011 0.007 0.000
0.420 0.000 0.005 0.009 0.009 0.005 0.000
0.440 0.000 0.004 0.007 0.007 0.004 0.000
0.460 0.000 0.004 0.006 0.006 0.004 0.000
0.480 0.000 0.003 0.005 0.005 0.003 0.000
0.500 0.000 0.002 0.004 0.004 0.002 0.000
0.520 0.000 0.002 0.003 0.003 0.002 0.000
0.540 0.000 0.002 0.002 0.002 0.002 0.000
0.560 0.000 0.001 0.002 0.002 0.001 0.000
0.580 0.000 0.001 0.002 0.002 0.001 0.000
0.600 0.000 0.001 0.001 0.001 0.001 0.000
0.620 0.000 0.001 0.001 0.001 0.001 0.000
0.640 0.000 0.001 0.001 0.001 0.001 0.000
0.660 0.000 0.000 0.001 0.001 0.000 0.000
0.680 0.000 0.000 0.001 0.001 0.000 0.000
0.700 0.000 0.000 0.000 0.000 0.000 0.000
0.720 0.000 0.000 0.000 0.000 0.000 0.000
0.740 0.000 0.000 0.000 0.000 0.000 0.000
0.760 0.000 0.000 0.000 0.000 0.000 0.000
0.780 0.000 0.000 0.000 0.000 0.000 0.000
0.800 0.000 0.000 0.000 0.000 0.000 0.000
0.820 0.000 0.000 0.000 0.000 0.000 0.000
0.840 0.000 0.000 0.000 0.000 0.000 0.000
0.860 0.000 0.000 0.000 0.000 0.000 0.000
0.880 0.000 0.000 0.000 0.000 0.000 0.000
0.900 0.000 0.000 0.000 0.000 0.000 0.000
0.920 0.000 0.000 0.000 0.000 0.000 0.000
0.940 0.000 0.000 0.000 0.000 0.000 0.000
0.960 0.000 0.000 0.000 0.000 0.000 0.000
0.980 0.000 0.000 0.000 0.000 0.000 0.000
1.000 0.000 0.000 0.000 0.000 0.000 0.000
*/