| : | prepend item to list, or concatenate strings |
| @ | apply a function |
| /@ | apply a function to all entries in a list |
| .. | construct a list of consecutive integers |
| NFunction | make wrapper for numeric functions |
| Where | substitute result into expression |
| AddTo | add an equation to a set of equations or set of set of equations |
item : list string1 : string2 |
list -- a list
string1 -- a string
string2 -- a string
In> a:b:c:{}
Out> {a,b,c};
In> "This":"Is":"A":"String"
Out> "ThisIsAString";
|
fn @ arglist |
arglist -- single argument, or a list of arguments
In> "Sin" @ a
Out> Sin(a);
In> {{a},Sin(a)} @ a
Out> Sin(a);
In> "f" @ {a,b}
Out> f(a,b);
|
fn /@ list |
list -- list of arguments
In> "Sin" /@ {a,b}
Out> {Sin(a),Sin(b)};
In> {{a},Sin(a)*a} /@ {a,b}
Out> {Sin(a)*a,Sin(b)*b};
|
n .. m |
m -- integer, the last entry in the list
In> 1 .. 4
Out> {1,2,3,4};
|
NFunction("newname","funcname", {arglist})
|
"funcname" -- name of an existing function
arglist -- symbolic list of arguments
This can be useful when plotting functions defined through other Yacas routines that cannot return unevaluated.
If the numerical calculation does not return a number (for example, it might return the atom nan, "not a number", for some arguments), then the new function will return Undefined.
In> f(x) := N(Sin(x));
Out> True;
In> NFunction("f1", "f", {x});
Out> True;
In> f1(a);
Out> f1(a);
In> f1(0);
Out> 0;
|
In> t(x) := If(x<=0.5, 2*x, 2*(1-x)); Out> True; In> t(0.2); Out> 0.4; In> t(x); In function "If" : bad argument number 1 (counting from 1) CommandLine(1) : Invalid argument |
In> NFunction("t1", "t", {x})
Out> True;
In> t1(x);
Out> t1(x);
In> t1(0.2);
Out> 0.4;
|
In> Plot2D(t1(x), -0.1: 1.1) Out> True; |
expr Where x==v
expr Where x1==v1 And x2==v2 And ...
expr Where {x1==v1 And x2==v2,x1==v3
And x2==v4,...}
|
x - variable to set
v - value to substitute for variable
var1==val1 And var2==val2 And ... |
and fills in the corresponding values. Lists of value pairs are also possible, as:
{var1==val1 And var2==val2, var1==val3
And var2==val4}
|
These values might be obtained through Solve.
In> x^2+y^2 Where x==2
Out> y^2+4;
In> x^2+y^2 Where x==2 And y==3
Out> 13;
In> x^2+y^2 Where {x==2 And y==3}
Out> {13};
In> x^2+y^2 Where {x==2 And y==3,x==4 And y==5}
Out> {13,41};
|
eq1 AddTo eq2 |
A list a,b means that a is a solution, OR b is a solution. AddTo then acts as a AND operation:
(a or b) and (c or d) => (a or b) Addto (c or d) => (a and c) or (a and d) or (b and c) or (b and d) |
This function is useful for adding an identity to an already existing set of equations. Suppose a solve command returned a>=0 And x==a,a<0 And x== -a from an expression x==Abs(a), then a new identity a==2 could be added as follows:
In> a==2 AddTo {a>=0 And x==a,a<0 And x== -a}
Out> {a==2 And a>=0 And x==a,a==2 And a<0
And x== -a};
|
Passing this set of set of identities back to solve, solve should recognize that the second one is not a possibility any more, since a==2 And a<0 can never be true at the same time.
In> {A==2,c==d} AddTo {b==3 And d==2}
Out> {A==2 And b==3 And d==2,c==d
And b==3 And d==2};
In> {A==2,c==d} AddTo {b==3, d==2}
Out> {A==2 And b==3,A==2 And d==2,c==d
And b==3,c==d And d==2};
|