You are on page 1of 32

3 mar 2016 19:34:49 - CustomFunctions_examples.

sm

1 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

A 0 B 1 C 2

Clear A 1
A B 1 C 2
lastError "A - not defined."

Clear B , C 1
A B C

2 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

t 2 a b

a 1 0 0
A Z identity 3 0 1 0
b 0 0 1
1 π A B C
Unknowns B
e i t r s Unknowns Z 0
C
r x
Unknowns f x , y
s y

3 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

SettingsDirectory 0 "C:\Users\Davide Carpi\AppData\Roaming\SMath\"

4 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

π 2 12.7
7 π 4
e
5 14
Max 8 , , , 2 54.6
1 25 44 6 5 6
10 4 7
3 7

π 2 12.7
7 π 4
e
5 14
Min 8 , , , 2 10
1 25 44 6 5 6
10 4 7
3 7

5 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

1 4 7 i 1 8.06 Abs 4 7 i 8.06 4 7 i 8.06


Abs
4 7 i 2 8.06 2

1 4 7 i 1 8.06
1 1
Abs 4 7 i 2 8.06 2
4 7 i 2 8.06 2

6 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

OPTIMIZATION: NUMERIC OPTIMIZATION: SYMBOLIC

UoM 2 1 UoM 2 1
kN kN kg
UoM 2 1 m Pa UoM 2
m m 2
s
UoM 2 ft kip 1J 2
kg m
UoM 2 ft kip
N 2
UoM 2 1 Pa s
2
mm N kg
UoM 2
2 2
mm m s
UoM 2 cm 1m
UoM 2 cm m
kg m
1
2 kg m
3 kN s
UoM 2
4 kN kg m 3 kN s
1 UoM
2 4 kN kg m
s
2
s
kg m
1
2 kg m
3 kN s
UoM 2
4 kN kg m 3 kN s
1 UoM
2 4 kN kg m
s
2
s

7 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

OPTIMIZATION: NUMERIC OPTIMIZATION: SYMBOLIC

OoM 60 m 1 OoM 60 m 1
1
OoM 60 m 1 10 OoM 60 m 10
10 10
60 m
eOoM 60 m 2 ln
m
2 eOoM 60 m round ,0
eOoM 60 m 1 10 ln 10
10
60 m
ln
m
round ,0
ln 10
eOoM 60 m 10
10

y
4

0 x

-4
-6 -4 -2 0 2 4 6
x
OoM 10
x
eOoM 10

0 x
-16 -8 0 8 16
OoM x
10
eOoM x
10

8 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

Function name: Ceil(#)


Displayed:

Fast typing:

y 1 0 1 1 0 1
2 1.1 1 0.9 1 1 0
0.9 1.0 1.1 1 1 2
1

0 x
-1

-2 -2 -1 0 1 2
x

π π i ∞ 4 4 i ∞
π π i 4 4 i
2 "string" 2 "string"
2 "string" 2 "string"

9 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

Function name: Floor(#)


Displayed:

Fast typing:

y 1 0 1 1 0 1
2 1.1 1 0.9 2 1 1
0.9 1.0 1.1 0 1 1
1

0 x
-1

-2 -2 -1 0 1 2
x

π π i ∞ 3 3 i ∞
π π i 3 3 i
2 "string" 1 "string"
2 "string" 1 "string"

10 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

0
0 clone of built-in matrix(2,3)
Zeros 5 0
0 0 0
0 Zeros 2 , 3
0 0 0
0

11 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

1
1
1 1 1
Ones 5 1 Ones 2 , 3
1 1 1
1
1

12 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

clone of built-in diag()

1 2 3 1 0 0 1 2 3 1 0 0 1 1 0 0 0
Diag 4 5 6 0 5 0 4 5 6 0 5 0 2 0 2 0 0
Diag Diag
7 8 9 0 0 9 7 8 9 0 0 9 3 0 0 3 0
10 11 12 0 0 0 4 0 0 0 4

13 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

1 1 1 1
2 2 2 2
sys2mat sys2mat
3 3 3 3
4 4 4 4

0 0 0 0
1 1 1 1
sys2mat 2 2 sys2mat 2 2
1 1
3 3 3 3
4 4 4 4

14 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

OPTIMIZATION: NUMERIC OPTIMIZATION: SYMBOLIC

1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2
mat2sys mat2sys
3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4

1 1
2 2
1 3 1 3
3 4 3 4
mat2sys 2 4 mat2sys 2 4
5 6 7 5 5 6 7 5
6 6
7 7

1
2
1 3
3 4
mat2sys 2 4
1
5 6 7 5
6
7

15 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

"hello"
strjoin " " , "hello world!"
"world!"

"hello"
strjoin " " , "hello world!"
"world!"

"the"
strjoin " " , "fox" "the quick brown fox ..."
"quick" "brown"
"..."

"bread"
"milk"
strjoin ", " , "bread, milk, sugar, ..."
"sugar"
"..."

16 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

"the"
"QUICK"
strsplit "the QUICK bRoWn FoX...", " "
"bRoWn"
"FoX..."

"the QUICK bR"


strsplit "the QUICK bRoWn FoX...", "o" "Wn F"
"X..."

"the QUICK b"


strsplit "the QUICK bRoWn FoX...", "Ro"
"Wn FoX..."

17 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

strtolower "the QUICK bRoWn FoX..." "the quick brown fox..."

"the QUICK bRoWn FoX..." "the quick brown fox..."


strtolower 2 2
"another sTRINg" "another string"

18 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

strtoupper "the QUICK bRoWn FoX..." "THE QUICK BROWN FOX..."

"the QUICK bRoWn FoX..." "THE QUICK BROWN FOX..."


strtoupper 2 2
"another sTRINg" "ANOTHER STRING"

19 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

ucfirst "the QUICK bRoWn FoX..." "The QUICK bRoWn FoX..."

"The QUICK bRoWn FoX..." "The QUICK bRoWn FoX..."


ucfirst 2 2
"another sTRINg" "Another sTRINg"

20 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

ucwords "the QUICK bRoWn FoX..." "The QUICK BRoWn FoX..."

"The QUICK bRoWn FoX..." "The QUICK BRoWn FoX..."


ucwords 2 2
"another sTRINg" "Another STRINg"

21 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

11
GetType 12 "number" GetType 12.5 "number" GetType "number"
3

1
GetType "matrix" GetType 1 "matrix" GetType 1 "matrix"
2

1
GetType "system" GetType 2 "system" GetType 2 "system"
2

GetType "a string" "string" GetType "something" "string"

GetType ∞ "number" GetType π "number" GetType i "number"

GetType x "unknown" GetType 1 x "unknown" GetType sin x "unknown"

22 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

var2str 12 "12" var2str 123.456789 "123.456789"

var2str 12 m "12 m" var2str 123.456789m "123.456789 m"

var2str 12 mm "0.012 m" var2str 123.456789mm "0.123456789 m"

3 3
var2str "0.75" var2str "-0.75" var2str "something" "something"
4 4

var2str 1234.567 , 2 "1234.57"


var2str 1234.567 m , 2 "1234.57 m"
var2str 1234.567 mm , 2 "1.23 m"
var2str 1234.567 , "0.0000" "1234.5670" see also:
var2str 1234.567 , "0.####" "1234.567" - Standard Numeric Format Strings
- Custom Numeric Format Strings
var2str 1234.567 , "000000.0000" "001234.5670" CTRL+CLICK
var2str 1234.567 , "E2" "1.23E+003"
var2str 1234.567 , "F2" "1234.57"
var2str 1234.567 , "N2" "1,234.57"
π
var2str π i, 2 "3.14+0.79i"
4

y y
6 6
5 [ 123.46 , 1.41 ] 5 { 123.46
4
[ 3.14 , 2.72 ] 4
{ 3.14
3 3
2 2
1 1
0 x 0 x
-1 0 4 8 12 16 20 24 28 -1 0 4 8 12 16 20 24
123.456 2 123.456
5 5 var2str , 2 12 "darkblue" 5 5 var2str , 2 12 "darkblue"
π e π

23 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

2D LINEAR INTERPOLATION

XX 20 50 100 150 200 250 300 350 400 450 500 550 600

15 4 9 17 25 35 45 56 68 81 94 109 124 140


20 4 10 19 28 39 50 62 75 89 103 119 135 152
25 5 11 20 31 42 54 67 81 95 111 128 145 163
40 5 12 23 35 47 60 75 90 106 123 142 161 181
50 6 14 26 38 51 66 81 98 115 133 153 173 195
65 7 16 29 43 58 74 90 108 127 147 169 191 214
80 8 17 31 46 62 78 96 115 135 156 179 202 226
100 9 19 34 50 67 85 104 124 146 168 192 217 243
125 10 21 38 55 74 93 114 136 159 183 208 235 263
150 11 23 42 61 80 101 132 156 182 209 238 267 298
200 14 28 50 72 95 119 154 182 212 242 274 308 343
YY 250 MM 16 33 57 82 107 133 173 204 236 270 305 342 380
300 18 39 67 95 124 153 191 224 259 296 333 373 414
350 22 45 77 108 140 173 208 244 281 320 361 403 446
400 25 49 84 117 152 187 223 262 301 343 385 430 476
450 27 54 91 127 163 200 239 280 322 365 410 457 505
500 30 58 98 136 175 215 256 299 343 389 436 486 537
600 34 67 112 154 197 241 286 333 382 432 484 537 593
700 38 75 124 170 217 264 313 364 416 470 526 583 642
800 43 83 137 188 238 290 343 397 453 511 571 633 696
900 47 91 150 205 259 315 372 430 490 552 616 681 749
1000 52 100 163 222 281 340 400 463 527 592 660 729 801
1400 70 133 215 291 364 439 514 591 670 750 833 918 1098

xx 20 yy 215

InterpBilinear XX , YY , MM , xx , yy 14.6

XX XX mm xx xx mm YY YY mm yy yy mm MM MM K

InterpBilinear XX , YY , MM , xx , yy 14.6 K

24 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

Function name: Conjugate(#)


Displayed:

Fast typing: or

i θ i θ 1 4 7 i 1 4 7 i
ρ e ρ e
4 7 i 2 4 7 i 2
5 3 i 5 3 i
1 4 7 i 1 4 7 i
1 1
5 3 i 5 3 i 4 7 i 2 4 7 i 2
4 7 i 2 4 7 i 2

25 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

function name

lele 3 a x b a x x b - acronyms of the symbols involved


- names like HTML entities syntax: le, lt, ge, gt
lelt 3 a x b a x x b 'l' is for 'less'
'g' is for 'greater'
't' is for 'than'
ltle 3 a x b a x x b
'e' is for 'equal to'

ltlt 3 a x b a x x b all functions are font-scalable:


* minor issues with font-size less than 10pt;
gege 3 a x b a x x b * thickness scaling not available.

gegt 3 a x b a x x b

gtge 3 a x b a x x b

gtgt 3 a x b a x x b

26 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

Function name: cases(2n+1) n>0


if
Displayed: otherwise

Fast typing:

a if x 0 3 if x 0
b otherwise 2 if 1 x 0.5
f x
1 if x 2
a if x 0 1 otherwise
b if x 0
c otherwise

4 y
3

0 x
-1
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5
-2
f x

symbolic optimization (mainly useful to use with integrals)


* any not null condition is like a 'true' (by design)

a if x 0
b if x 0 x 0 0 a x 0 0 x 0 0 b x 0 0 c
c otherwise

optimization numeric: nested if/else test it: change f(x) optimization

a if x 0 5
b if x 0 f x dx
c otherwise 3

optimization none: no function calls


a if x 0 a if x 0
b if x 0 b if x 0
c otherwise c otherwise

27 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

Function name: Kronecker(#,#)


Displayed: δ

Fast typing:

1 if i j show cases() δ 1
δ 33
ij 0 otherwise on 'none'
optimization δ 0
34

28 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

Function name: perc(#) SMath Studio ≥ 0.97.5890 supports % and ‰ units


Displayed: %

Fast typing:

N
N%
100

29 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

Function name: permil(#) SMath Studio ≥ 0.97.5890 supports % and ‰ units


Displayed: ‰

Fast typing:

N
N‰
1000

30 / 32
3 mar 2016 19:34:49 - CustomFunctions_examples.sm

at(2)
d
f z
dz
x
at(3) b
d
f x
dx
a

x
1
sin x sin x sin x sin x sin x
x 0 x 1 0
0 0

y y
2 2
0 x 0 x
-2
-8 -4 0 4 8 -2
-8 -4 0 4 8
x π
sin z sin x
x 2 π x

f a, b 2 a b

f x, y y 2 x

implicit equivalence:
- any unknown needs a value;
- values are set sorting unknowns in alphabetical order.

f a, b y 2 x f a, b y 2 x
x x y
y
f a, b y 2 x
x
y

f a, b y 2 a "a" untouched
a y

f a, b a 2 b swap unknowns
b a

explicit equivalence:
- allowed total or partial replacement;
- random sorting allowed;

f a, b y 2 x f a, b y 2 x
a x a x b y
b y
f a, b y 2 x
a x
b y

f a, b y 2 x
b y a x random sorting

f a, b b 2 x partial replacement
a x

f a, b y 2 a partial replacement
b y
31 / 32
y 3 mar 2016 19:34:49 - CustomFunctions_examples.sm

f a, b b 2 a absent unknown to replace


z x

d 3 d 3 2 2
f z z 3 z 3 5 75
dz dz

f 75 priorities & parameters


5

5
z!
f x z x f 4 235.4
1 z
z= 1

f x 235.4
4

4 k n k dk 12 n k dk
3 k 3

32 / 32

You might also like