2018年12月28日 星期五

EX2-2 利用Python 改寫

EX2-2 利用Python 改寫

from math import *

#===========================================================
#power:         primary ["**" u_expr]
#define   f(x) =  (0.0000115*pow(x,2)+0.000014*pow(x,1.5)-0.01962)
#===========================================================
def f_cal(x) :
    temp=   (0.0000115*pow(x,2)+0.000014*pow(x,1.5)-0.01962)
    return temp


a=0.0
b=51.0
x=a
i=1
print(" i     x          f(x)\n")

while x<=b:
    s = "{%5d} {%2.2f} {%2.5f}" %(i,x,f_cal(x))
    print(s)
    i+=1
    x=x+1

a=37.0
b=38.0
x=a
i=1
print(" i     x          f(x)\n")

while x<=b:
    s = "{%5d} {%2.2f} {%2.5f}" %(i,x,f_cal(x))
    print(s)
    i+=1
    x=x+0.01




Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
====== RESTART: H:/2018-09勤益科大數值分析/數值分析/PYTHON/EX2-2-1.py ============
 i     x          f(x)

{    1} {0.00} {-0.01962}
{    2} {1.00} {-0.01959}
{    3} {2.00} {-0.01953}
{    4} {3.00} {-0.01944}
{    5} {4.00} {-0.01932}
{    6} {5.00} {-0.01918}
{    7} {6.00} {-0.01900}
{    8} {7.00} {-0.01880}
{    9} {8.00} {-0.01857}
{   10} {9.00} {-0.01831}
{   11} {10.00} {-0.01803}
{   12} {11.00} {-0.01772}
{   13} {12.00} {-0.01738}
{   14} {13.00} {-0.01702}
{   15} {14.00} {-0.01663}
{   16} {15.00} {-0.01622}
{   17} {16.00} {-0.01578}
{   18} {17.00} {-0.01532}
{   19} {18.00} {-0.01482}
{   20} {19.00} {-0.01431}
{   21} {20.00} {-0.01377}
{   22} {21.00} {-0.01320}
{   23} {22.00} {-0.01261}
{   24} {23.00} {-0.01199}
{   25} {24.00} {-0.01135}
{   26} {25.00} {-0.01068}
{   27} {26.00} {-0.00999}
{   28} {27.00} {-0.00927}
{   29} {28.00} {-0.00853}
{   30} {29.00} {-0.00776}
{   31} {30.00} {-0.00697}
{   32} {31.00} {-0.00615}
{   33} {32.00} {-0.00531}
{   34} {33.00} {-0.00444}
{   35} {34.00} {-0.00355}
{   36} {35.00} {-0.00263}
{   37} {36.00} {-0.00169}
{   38} {37.00} {-0.00073}
{   39} {38.00} {0.00027}
{   40} {39.00} {0.00128}
{   41} {40.00} {0.00232}
{   42} {41.00} {0.00339}
{   43} {42.00} {0.00448}
{   44} {43.00} {0.00559}
{   45} {44.00} {0.00673}
{   46} {45.00} {0.00789}
{   47} {46.00} {0.00908}
{   48} {47.00} {0.01029}
{   49} {48.00} {0.01153}
{   50} {49.00} {0.01279}
{   51} {50.00} {0.01408}
{   52} {51.00} {0.01539}
 i     x          f(x)

{    1} {37.00} {-0.00073}
{    2} {37.01} {-0.00072}
{    3} {37.02} {-0.00071}
{    4} {37.03} {-0.00070}
{    5} {37.04} {-0.00069}
{    6} {37.05} {-0.00068}
{    7} {37.06} {-0.00067}
{    8} {37.07} {-0.00066}
{    9} {37.08} {-0.00065}
{   10} {37.09} {-0.00064}
{   11} {37.10} {-0.00063}
{   12} {37.11} {-0.00062}
{   13} {37.12} {-0.00061}
{   14} {37.13} {-0.00060}
{   15} {37.14} {-0.00059}
{   16} {37.15} {-0.00058}
{   17} {37.16} {-0.00057}
{   18} {37.17} {-0.00056}
{   19} {37.18} {-0.00055}
{   20} {37.19} {-0.00054}
{   21} {37.20} {-0.00053}
{   22} {37.21} {-0.00052}
{   23} {37.22} {-0.00051}
{   24} {37.23} {-0.00050}
{   25} {37.24} {-0.00049}
{   26} {37.25} {-0.00048}
{   27} {37.26} {-0.00047}
{   28} {37.27} {-0.00046}
{   29} {37.28} {-0.00045}
{   30} {37.29} {-0.00044}
{   31} {37.30} {-0.00043}
{   32} {37.31} {-0.00042}
{   33} {37.32} {-0.00041}
{   34} {37.33} {-0.00040}
{   35} {37.34} {-0.00039}
{   36} {37.35} {-0.00038}
{   37} {37.36} {-0.00037}
{   38} {37.37} {-0.00036}
{   39} {37.38} {-0.00035}
{   40} {37.39} {-0.00034}
{   41} {37.40} {-0.00033}
{   42} {37.41} {-0.00032}
{   43} {37.42} {-0.00031}
{   44} {37.43} {-0.00030}
{   45} {37.44} {-0.00029}
{   46} {37.45} {-0.00028}
{   47} {37.46} {-0.00027}
{   48} {37.47} {-0.00026}
{   49} {37.48} {-0.00025}
{   50} {37.49} {-0.00024}
{   51} {37.50} {-0.00023}
{   52} {37.51} {-0.00022}
{   53} {37.52} {-0.00021}
{   54} {37.53} {-0.00020}
{   55} {37.54} {-0.00019}
{   56} {37.55} {-0.00018}
{   57} {37.56} {-0.00017}
{   58} {37.57} {-0.00016}
{   59} {37.58} {-0.00015}
{   60} {37.59} {-0.00014}
{   61} {37.60} {-0.00013}
{   62} {37.61} {-0.00012}
{   63} {37.62} {-0.00011}
{   64} {37.63} {-0.00010}
{   65} {37.64} {-0.00009}
{   66} {37.65} {-0.00008}
{   67} {37.66} {-0.00007}
{   68} {37.67} {-0.00006}
{   69} {37.68} {-0.00005}
{   70} {37.69} {-0.00004}
{   71} {37.70} {-0.00003}
{   72} {37.71} {-0.00002}
{   73} {37.72} {-0.00001}
{   74} {37.73} {-0.00000}
{   75} {37.74} {0.00001}
{   76} {37.75} {0.00002}
{   77} {37.76} {0.00003}
{   78} {37.77} {0.00004}
{   79} {37.78} {0.00005}
{   80} {37.79} {0.00006}
{   81} {37.80} {0.00007}
{   82} {37.81} {0.00008}
{   83} {37.82} {0.00009}
{   84} {37.83} {0.00010}
{   85} {37.84} {0.00011}
{   86} {37.85} {0.00012}
{   87} {37.86} {0.00013}
{   88} {37.87} {0.00014}
{   89} {37.88} {0.00015}
{   90} {37.89} {0.00016}
{   91} {37.90} {0.00017}
{   92} {37.91} {0.00018}
{   93} {37.92} {0.00019}
{   94} {37.93} {0.00020}
{   95} {37.94} {0.00021}
{   96} {37.95} {0.00022}
{   97} {37.96} {0.00023}
{   98} {37.97} {0.00024}
{   99} {37.98} {0.00025}
{  100} {37.99} {0.00026}
{  101} {38.00} {0.00027}
>>>


沒有留言:

張貼留言

Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3

  Node-Red Dashboard UI Template + AngularJS 參考 AngularJS教學 --3 AngularJS 實例 <!DOCTYPE html> <html> <head> <meta charse...