Scilab Program - eulers formula - IProgramX

Program

  function[]=eu(x0,y0,xn,h,f)
      y(1)=y0;
      j=(xn-x0)/h;
      for i=1:j
          y(i+1)=y(i)+h*f(x0,y(i))
          x0=x0+h;
          printf('\ny(%g)=%g\n',x0,y(i+1));
   
  end
  endfunction

Output:

  deff('y=f(x,y)','y=2+sqrt(x*y)')

  eu(1,1,1.6,0.1,f)

y(1.1)=1.3

y(1.2)=1.61958

y(1.3)=1.95899

y(1.4)=2.31858

y(1.5)=2.69874

y(1.6)=3.09994

Post a Comment

1 Comments

  1. @Slip – 1



    Q. 1) Write a PHP script to keep track of number of times the web page has been accessed (Use Session
    Tracking).
    Ans:









    Q. 2)Create ‘Position_Salaries’ Data set. Build a linear regression model by identifying independent and
    Target variable. Split the variables into training and testing sets. Then divide the training and testing sets
    Into a 7:3 ratio, respectively and print them. Build a simple linear regression model.
    Ans:



    Import numpy as np
    Import pandas as pd
    From sklearn.model_selection import train_test_split
    From sklearn.linear_model import LinearRegression
    # Create the Position_Salaries dataset
    Data = {‘Position’: [‘CEO’, ‘charman’, ‘director’, ‘Senior Manager’, ‘Junior Manager’, ‘Intern’],
    ‘Level’: [1, 2, 3, 4, 5, 6],
    ‘Salary’: [50000, 80000, 110000, 150000, 200000, 250000]}
    Df = pd.DataFrame(data)
    # Identify the independent and target variables
    X = df.iloc[:, 1:2].values
    Y = df.iloc[:, 2].values
    # Split the variables into training and testing sets with a 7:3 ratio
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)
    # Print the training and testing sets
    Print(“X_train:\n”, X_train)
    Print(“y_train:\n”, y_train)
    Print(“X_test:\n”, X_test)
    Print(“y_test:\n”, y_test)
    # Build a simple linear regression model
    Regressor = LinearRegression()
    Regressor.fit(X_train, y_train)
    # Print the coefficients and intercept
    Print(“Coefficients:”, regressor.coef_)
    Print(“Intercept:”, regressor.intercept_)

    ReplyDelete