[100] 061 HighSchool-scilab, [100] 061 re-interpreted by www.msharpmath.com revised on 2012.10.28 cemmath The Simple is the Best HighSchool-scilab, re-interpreted by msharpmath The following website posts a pdf file for HighSchool education. http://www.scilab.org/support/documentation/tutorials Scilab for high schools Presentation Booklet 2010 edition – only available in French This booklet, realized with the support of INRIA and co-written by the Scilab Consortium and teachers is a practical introduction to Scilab with examples based on French high school mathematics programs. We downloaded the above file and re-interpret some parts in terms of Msharpmath. The orginal commands in Scilab can be found in the booklet in the above website. Later, we will handle those examples unsolved below. ■ Plot graphs. double f(x) = (x^2+2*x)*exp(-x); double g(x) = sin(x/2); x = (-2,5).span(50); plot (x, f++(x)); plot+(x, g++(x)); 1 [100] 061 HighSchool-scilab, re-interpreted by www.msharpmath.com Another way is using Umbrella ‘plot’ in Msharpmath as follows. #> plot .x[50](-2,5) ( (x^2+2*x)*exp(-x) , sin(x/2) ); #> plot.x[100](-1,1).y[200](-2,2) ( 2*x^2 + y^2 ); #> plot.@t[100](0,4*pi) ( cos(t),sin(t),t ); 2 [100] 061 HighSchool-scilab, re-interpreted by www.msharpmath.com ■ arithmatic #> 75 % 4 ; // remainder 75 = 4 * 18 + 3 ans = #> -75 % 4 ; 3 // remainder -75 = -4 * 19 + 1 ans = #> 75.factor; 1 // factorization ans = [ #> U = 3 5 5] 1:10 ;; #> U.sum1; ans = 55 #> U.prod1; ans = 3628800 #> v = [ 2, 6, 9, 6, -4, 0, 2 ]; v= [ 2 6 9 6 3 -4 0 2] [100] 061 HighSchool-scilab, #> ++v; // unique(v) in Scilab ans = [ 2 6 #>w = [ 1,5,3,8,14,7,3,2,12,6 ]; w= re-interpreted by www.msharpmath.com [ 1 5 3 9 -4 (w < 5).true; 8 14 7 ans = [ 1] [ 3] [ 7] [ 8] Chapter 3 Example 3 #> a=3; b=4; c=sqrt(a^2 + b^2); a= 3 b= 4 c= 5 #> double hypotenuse(a,b)=sqrt(a^2+b^2); #> hypotenuse(4,5); ans = 0] 6.4031242 Example 5 #> double u[100]; #> u[0] = 1; 4 3 2 12 6] [100] 061 HighSchool-scilab, re-interpreted by www.msharpmath.com #> for(n = 0; n < 30; n++) u[n+1] = u[n]+2*n+1; #> u[30]; ans = 961 Example 7 S = 5000; N = 2009; while( S < 7000 ) { S *= 1.027; N += 1; } #> [ N, S ]; ans = [ 2022 7069.45 ] Example 8 a = b = .zeros(1,40);; a(1) = 20; b(1) = 60; for(n = 1; n <= 40; n++) { a(n+1) = (2*a(n)+b(n))/4;; b(n+1) = (a(n)+2*b(n))/4;; [ n, a(n), b(n) ]; } u = a+b; v = b-a; 5 [100] 061 HighSchool-scilab, re-interpreted by www.msharpmath.com Example 11 double logic11(a,b) { if( a >= b ) return a-b; else return b-a; } #> logic11(3,-5); ans = 8 Example 14 double f(x) = x^2-x-1; a=1; b=2; while( b-a > 10^(-4) ) { c = (a+b)/2; if( f(a)*f(b) > 0 ) a = c; else // bisection method to find a root b = c; } Example 18 plot.x[100](0,2) ( 0 ); plot+.x[100](2,4) ( x-2 ); plot+.x[100](4,7) ( 2*x-6 ); 6 [100] 061 HighSchool-scilab, re-interpreted by www.msharpmath.com Example 19 #> plot.x[100](-10,10).y[100](-5,5) ( (4*x*y^2+x+3*y)/100 ); Example 25 matrix diveucl(double a,b) { q = 0; while( a >= b ) { a -= b; // a = a-b q += 1; } return [ q, a ]; } 7 [100] 061 HighSchool-scilab, re-interpreted by www.msharpmath.com #> diveucl(1224,15); ans = [ 81 9] //---------------------------------------------------------------------// end of file //---------------------------------------------------------------------- 8