Difference between revisions of "Creation of Sets/Array in z^3"

From ZCubes Wiki
Jump to navigation Jump to search
Line 42: Line 42:
 
  '''x = [0.8 1 1.2000000000000002 1.4000000000000001 1.6 1.8 2 2.2]'''
 
  '''x = [0.8 1 1.2000000000000002 1.4000000000000001 1.6 1.8 2 2.2]'''
  
*To remove the digits after one decimal, use round function.
 
x = round((xmin-dx),1)..round((xmax+dx),1)..(dx);
 
'''x = [1 1.2 1.4 1.6 1.8 2]'''
 
  
 
*To get the inverse of a matrix, add ~ to the array.
 
*To get the inverse of a matrix, add ~ to the array.
  x = (round((xmin-dx),1)..round((xmax+dx),1)..(dx))~
+
  x = ((xmin-dx)..(xmax+dx)..(dx))
  '''x = 1'''
+
n = x~
     '''1.2'''
+
  '''n = 0.8'''
     '''1.4'''
+
    '''1'''
 +
     '''1.2000000000000002'''
 +
     '''1.4000000000000001'''
 
     '''1.6'''
 
     '''1.6'''
 
     '''1.8'''
 
     '''1.8'''
 
     '''2'''
 
     '''2'''
 +
    '''2.2'''
  
  
Line 63: Line 63:
 
  xmax = 2
 
  xmax = 2
 
  dx = 0.2
 
  dx = 0.2
  x = [(xmin-dx)..(xmax+dx)..(dx)];
+
  x = (xmin-dx)..(xmax+dx)..(dx);
 
  u0 = EXP(-2<*>(x|-|0.25)<^>2);
 
  u0 = EXP(-2<*>(x|-|0.25)<^>2);
  '''u0 = [0.32465246735834974 0.16447445657715493 0.07100535373963703 0.026121409853918226 0.008188701014374078 0.002187491118182886]'''
+
  '''u0 = [0.5460744266397094 0.32465246735834974 0.16447445657715493 0.07100535373963703 0.026121409853918226 0.008188701014374078 0.002187491118182886 0.0004979554215032733]'''
  
  
Line 75: Line 75:
 
  xmax = 2
 
  xmax = 2
 
  dx = 0.2
 
  dx = 0.2
  x = round((xmin-dx),1)..round((xmax+dx),1)..(dx);
+
  x = (xmin-dx)..(xmax+dx)..(dx);
 
  u0 = EXP(-2<*>(x<->0.25)<^>2);
 
  u0 = EXP(-2<*>(x<->0.25)<^>2);
  m = (x).mergerows(u0~).graphin()
+
  '''m = (x).mergerows(u0~).graphin()'''
  
 
'''The graph looks as shown below.'''
 
'''The graph looks as shown below.'''
  
 
[[File:Capture.JPG]]
 
[[File:Capture.JPG]]

Revision as of 07:57, 14 November 2016

Tricks and Shortcuts


Description

*Creating an Array

  • Comma(,) has to be used to separate the elements(especially when negative numbers are in an array). This removes the ambiguity.
For example:(without comma)
a = [1 2 3; -4*5 -4 6; 7 8 10]
This gives the answer as:
a =  1 2  3
   -24 6
     7 8 10
with comma:
a = [1 2 3; -4*5, -4 6; 7 8 10]
a =  1  2 3
   -20 -4 6
     7  8 10


*Notations

  • The unit operators work for simple or matrix parameters on both sides. This makes |-| be available for non-unit based subtraction. This is possibly a better notation.
  • To do unit based subtractions, do
A=[1m 2m];
B=[4m 5m];
c=A<->B
c = [-3m -3m]
  • Matrix subtraction, without units.
A=[1m 2m];
B=[4m 5m];
c=A|-|B
c = [-3 -3]


*Creating an Array within an interval

  • An array can be created within a given interval using this notation. Brackets() are important.
var x = [];
xmin = 1
xmax = 2
dx = 0.2
x = (xmin-dx)..(xmax+dx)..(dx);
x = [0.8 1 1.2000000000000002 1.4000000000000001 1.6 1.8 2 2.2]


  • To get the inverse of a matrix, add ~ to the array.
x = ((xmin-dx)..(xmax+dx)..(dx))
n = x~
n = 0.8
    1
    1.2000000000000002
    1.4000000000000001
    1.6
    1.8
    2
    2.2


*Evaluating a Function

  • Calculating the value of function "u0" with corresponding values of x.
var x = [];
var u0 = [];
xmin = 1
xmax = 2
dx = 0.2
x = (xmin-dx)..(xmax+dx)..(dx);
u0 = EXP(-2<*>(x|-|0.25)<^>2);
u0 = [0.5460744266397094 0.32465246735834974 0.16447445657715493 0.07100535373963703 0.026121409853918226 0.008188701014374078 0.002187491118182886 0.0004979554215032733]


*PLOT

  • Graph of x vs u0: Merge x and u0~ arrays using "mergerows" and include .graphin() to plot.
var x =[];
var u0 = [];
xmin = 1
xmax = 2
dx = 0.2
x = (xmin-dx)..(xmax+dx)..(dx);
u0 = EXP(-2<*>(x<->0.25)<^>2);
m = (x).mergerows(u0~).graphin()

The graph looks as shown below.

Error creating thumbnail: Unable to save thumbnail to destination