Difference between revisions of "Creation of Sets/Array in z^3"
Jump to navigation
Jump to search
| Line 16: | Line 16: | ||
'''-20 -4 6''' | '''-20 -4 6''' | ||
'''7 8 10''' | '''7 8 10''' | ||
| + | |||
'''*Notations''' | '''*Notations''' | ||
| Line 34: | Line 35: | ||
'''*Creating an Array with an interval''' | '''*Creating an Array with an interval''' | ||
*An array can be created within a given interval using this notation. Brackets() are important. | *An array can be created within a given interval using this notation. Brackets() are important. | ||
| + | var x = []; | ||
xmin = 1 | xmin = 1 | ||
xmax = 2 | xmax = 2 | ||
dx = 0.2 | dx = 0.2 | ||
| − | x = | + | x = (xmin-dx)..(xmax+dx)..(dx); |
'''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. | *To remove the digits after one decimal, use round function. | ||
| − | x = | + | x = round((xmin-dx),1)..round((xmax+dx),1)..(dx); |
'''x = [1 1.2 1.4 1.6 1.8 2]''' | '''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 = | + | x = (round((xmin-dx),1)..round((xmax+dx),1)..(dx))~ |
'''x = 1''' | '''x = 1''' | ||
'''1.2''' | '''1.2''' | ||
| Line 52: | Line 54: | ||
'''1.8''' | '''1.8''' | ||
'''2''' | '''2''' | ||
| + | |||
'''*Evaluating a Function''' | '''*Evaluating a Function''' | ||
*Calculating the value of function "u0" with corresponding values of x. | *Calculating the value of function "u0" with corresponding values of x. | ||
| + | var x = []; | ||
| + | var u0 = []; | ||
xmin = 1 | xmin = 1 | ||
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 = [0.32465246735834974 0.16447445657715493 0.07100535373963703 0.026121409853918226 0.008188701014374078 0.002187491118182886]''' | ||
| + | |||
| + | |||
| + | '''*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 = round((xmin-dx),1)..round((xmax+dx),1)..(dx); | ||
u0 = EXP(-2<*>(x<->0.25)<^>2); | u0 = EXP(-2<*>(x<->0.25)<^>2); | ||
| − | + | m = (x).mergerows(u0~).graphin() | |
Revision as of 07:17, 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 with 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 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.
x = (round((xmin-dx),1)..round((xmax+dx),1)..(dx))~
x = 1
1.2
1.4
1.6
1.8
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.32465246735834974 0.16447445657715493 0.07100535373963703 0.026121409853918226 0.008188701014374078 0.002187491118182886]
*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 = round((xmin-dx),1)..round((xmax+dx),1)..(dx); u0 = EXP(-2<*>(x<->0.25)<^>2); m = (x).mergerows(u0~).graphin()