Euler改进版

import matplotlib.pyplot as plt
import numpy as np

y = 1
x = 0
fx =np.zeros(100)
fy = np.zeros(100)

for i in range(1,100):

    y1 = 1.1*y - (0.2 * x / y)
    y = y + 0.1*0.5*(y-2*x/y+y1-2*(x+0.1)/y1)
    x=x+0.1
    fx[i]=x
    fy[i] = y
    print(x , y)



plt.plot(fx, fy, ls='-', lw=2, label='cosine', color='purple')
plt.legend()
plt.xlabel('independent variable')
plt.ylabel('dependent variable')
plt.show()


0.1 1.105
0.2 1.2027188239305164
0.30000000000000004 1.2952053219196042
0.4 1.3839589485795254
0.5 1.4701696376540312
0.6 1.554851395854456
0.7 1.6389243850090953
0.7999999999999999 1.7232700048845917
0.8999999999999999 1.8087710088382984
0.9999999999999999 1.8963429719737364
1.0999999999999999 1.9869605827587593
1.2 2.0816806982266156
1.3 2.181663224781239
1.4000000000000001 2.2881903583807692
1.5000000000000002 2.40268439809909
1.6000000000000003 2.5267241707960104
1.7000000000000004 2.6620600431821155
1.8000000000000005 2.8106275368070084
1.9000000000000006 2.974559688350774
2.0000000000000004 3.156198491601665
2.1000000000000005 3.3581059872213244
2.2000000000000006 3.5830757912070768
2.3000000000000007 3.8341460299682493
2.400000000000001 4.114614744020186
2.500000000000001 4.428058815662833
2.600000000000001 4.778357373352464
2.700000000000001 5.169720452519645
2.800000000000001 5.6067234883854775
2.9000000000000012 6.094348022360558
3.0000000000000013 6.638028853695297
3.1000000000000014 7.243707782194986
3.2000000000000015 7.917894071080438
3.3000000000000016 8.667731804517246
3.4000000000000017 9.501074407975022
3.5000000000000018 10.426566725405085
3.600000000000002 11.453735190923377
3.700000000000002 12.59308678363269
3.800000000000002 13.856217605997317
3.900000000000002 15.255932076113023
4.000000000000002 16.806373872429432
4.100000000000001 18.523169917946845
4.200000000000001 20.423588842598978
4.300000000000001 22.526715520839574
4.4 24.8536434498266
4.5 27.427686915376846
4.6 30.27461509121015
4.699999999999999 33.422910434933655
4.799999999999999 36.90405398466657
4.899999999999999 40.75284042610424
4.999999999999998 45.00772609417307
5.099999999999998 49.71121339939304
5.1999999999999975 54.9102755300241
5.299999999999997 60.65682568069231
5.399999999999997 67.00823550048321
5.4999999999999964 74.02790794286497
5.599999999999996 81.78591024112828
5.699999999999996 90.35967333168207
5.799999999999995 99.8347647094698
5.899999999999995 110.30574243154827
5.999999999999995 121.87709879377728
6.099999999999994 134.66430309965028
6.199999999999994 148.79495392845746
6.299999999999994 164.41005240205277
6.399999999999993 181.6654091563802
6.499999999999993 200.73319905762912
6.5999999999999925 221.8036791767322
6.699999999999992 245.08708716458972
6.799999999999992 270.81573897014147
6.8999999999999915 299.24634683216647
6.999999999999991 330.6625806733071
7.099999999999991 365.37789845321066
7.19999999999999 403.73867372108566
7.29999999999999 446.1276515731507
7.39999999999999 492.9677674969956
7.499999999999989 544.726367205465
7.599999999999989 601.9198695634373
7.699999999999989 665.1189191317249
7.799999999999988 734.9540797373667
7.899999999999988 812.1221258775678
7.999999999999988 897.3929947293138
8.099999999999987 991.6174681277665
8.199999999999987 1095.7356611596895
8.299999999999986 1210.7864020660293
8.399999999999986 1337.9175970406773
8.499999999999986 1478.3976833390982
8.599999999999985 1633.6282849689683
8.699999999999985 1805.1581972335575
8.799999999999985 1994.6988396570453
8.899999999999984 2204.1413314715337
8.999999999999984 2435.5753600344274
9.099999999999984 2691.3100304335685
9.199999999999983 2973.8969043045654
9.299999999999983 3286.1554577273346
9.399999999999983 3631.201212204929
9.499999999999982 4012.476819398064
9.599999999999982 4433.786409759476
9.699999999999982 4899.333547777395
9.799999999999981 5413.763172521911
9.89999999999998 5982.207941950846

在这里插入图片描述

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UWVTLqM1-1632444602094)(output_0_1.png)]


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值