/usr/share/yacas/simplify.rep/code.ys is in yacas 1.3.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 10 # Simplify(expr_IsList) <-- MapSingle("Simplify",expr);
15 # Simplify(Complex(_r,_i)) <-- Complex(Simplify(r),Simplify(i));
20 # Simplify((_xex) == (_yex)) <-- (Simplify(xex-yex) == 0);
20 # Simplify((_xex) > (_yex)) <-- (Simplify(xex-yex) > 0);
20 # Simplify((_xex) < (_yex)) <-- (Simplify(xex-yex) < 0);
20 # Simplify((_xex) >= (_yex)) <-- (Simplify(xex-yex) >= 0);
20 # Simplify((_xex) <= (_yex)) <-- (Simplify(xex-yex) <= 0);
20 # Simplify((_xex) !== (_yex)) <-- (Simplify(xex-yex) !== 0);
// conditionals
25 # Simplify(if (_a) _b) <-- "if" @ {Simplify(a), Simplify(b)};
25 # Simplify(_a else _b) <-- "else" @ {Simplify(a), Simplify(b)};
50 # Simplify(_expr) <-- MultiSimp(Eval(expr));
Eliminate(_var,_replace,_function) <-- Simplify(Subst(var,replace)function);
//ExpandBrackets(_xx) <-- SimpExpand(SimpImplode(SimpFlatten(xx)));
ExpandBrackets(x) := NormalForm(MM(x));
Function("Flatten",{body,flattenoper})
[
DoFlatten(body);
];
RuleBase("DoFlatten",{doflattenx});
UnFence("DoFlatten",1);
10 # DoFlatten(_doflattenx)_(Type(doflattenx)=flattenoper) <--
Apply("Concat",MapSingle("DoFlatten",Tail(Listify(doflattenx))));
20 # DoFlatten(_doflattenx) <-- { doflattenx };
10 # UnFlatten({},_op,_identity) <-- identity;
20 # UnFlatten(list_IsList,_op,_identity) <--
Apply(op,{Head(list),UnFlatten(Tail(list),op,identity)});
RuleBase("SimpAdd",{x,y});
RuleBase("SimpMul",{x,y});
RuleBase("SimpDiv",{x,y});
10 # SimpFlatten((_x)+(_y)) <-- SimpAdd(SimpFlatten(x),SimpFlatten(y));
10 # SimpFlatten((_x)-(_y)) <-- SimpAdd(SimpFlatten(x),SimpMul(-1,SimpFlatten(y)));
10 # SimpFlatten( -(_y)) <-- SimpMul(-1,SimpFlatten(y));
10 # SimpFlatten((_x)*(_y)) <-- SimpMul(SimpFlatten(x),SimpFlatten(y));
10 # SimpFlatten((_x)/(_y)) <-- SimpDiv(SimpFlatten(x),SimpFlatten(y));
10 # SimpFlatten((_x)^(n_IsPositiveInteger)) <--
SimpMul(SimpFlatten(x),SimpFlatten(x^(n-1)));
100 # SimpFlatten(_x) <--
[
x;
];
10 # SimpExpand(SimpAdd(_x,_y)) <-- SimpExpand(x) + SimpExpand(y);
10 # SimpExpand(SimpMul(_x,_y)) <-- SimpExpand(x) * SimpExpand(y);
10 # SimpExpand(SimpDiv(_x,_y)) <-- SimpExpand(x) / SimpExpand(y);
20 # SimpExpand(_x) <-- x;
/* Distributed multiplication rule */
10 # SimpImplode(SimpMul(SimpAdd(_x,_y),_z)) <--
SimpImplode(SimpAdd(SimpImplode(SimpMul(x,z)),
SimpImplode(SimpMul(y,z))));
10 # SimpImplode(SimpMul(_z,SimpAdd(_x,_y))) <--
SimpImplode(SimpAdd(SimpImplode(SimpMul(z,x)),
SimpImplode(SimpMul(z,y))));
/* Distributed division rule */
10 # SimpImplode(SimpDiv(SimpAdd(_x,_y),_z)) <--
SimpImplode(SimpAdd(SimpImplode(SimpDiv(x,z)),
SimpImplode(SimpDiv(y,z))));
20 # SimpImplode(SimpAdd(_x,_y)) <--
SimpAdd(SimpImplode(x),SimpImplode(y));
20 # SimpImplode(SimpMul(_x,_y)) <--
SimpMul(SimpImplode(x),SimpImplode(y));
20 # SimpImplode(SimpDiv(_x,_y)) <--
SimpDiv(SimpImplode(x),SimpImplode(y));
30 # SimpImplode(_x) <-- x;
//////////////////////////////////////////////////
/// ExpandFrac --- normalize rational functions (no simplification)
//////////////////////////////////////////////////
5 # ExpandFrac(expr_IsList) <-- MapSingle("ExpandFrac", expr);
// expression does not contain fractions
10 # ExpandFrac(_expr)_Not(HasFuncSome(expr, "/", {Atom("+"), Atom("-"), *, /, ^})) <-- expr;
15 # ExpandFrac(a_IsRationalOrNumber) <-- a;
20 # ExpandFrac(_expr) <-- ExpandFrac'combine(GetNumerDenom(expr));
ExpandFrac'combine({_a, _b}) <-- a/b;
/// GetNumerDenom(x) returns a pair of expressions representing normalized numerator and denominator; GetNumerDenom(x, a) multiplies the numerator by the number a
GetNumerDenom(_expr, _a) <-- GetNumerDenom(expr)*{a,1};
// on expressions that are not fractions, we return unit denominator
10 # GetNumerDenom(_expr)_Not(HasFuncSome(expr, "/", {Atom("+"), Atom("-"), *, /, ^})) <-- {expr, 1};
// rational numbers are not simplified
15 # GetNumerDenom(a_IsRationalOrNumber) <-- {a, 1};
// arithmetic
20 # GetNumerDenom(_a + _b) <-- ExpandFrac'add(GetNumerDenom(a), GetNumerDenom(b));
20 # GetNumerDenom(_a - _b) <-- ExpandFrac'add(GetNumerDenom(a), GetNumerDenom(b, -1));
20 # GetNumerDenom(- _a) <-- GetNumerDenom(a, -1);
20 # GetNumerDenom(+ _a) <-- GetNumerDenom(a);
20 # GetNumerDenom(_a * _b) <-- ExpandFrac'multiply(GetNumerDenom(a), GetNumerDenom(b));
20 # GetNumerDenom(_a / _b) <-- ExpandFrac'divide(GetNumerDenom(a), GetNumerDenom(b));
// integer powers
20 # GetNumerDenom(_a ^ b_IsInteger)_(b > 1) <-- ExpandFrac'multiply(GetNumerDenom(a), GetNumerDenom(a^(b-1)));
20 # GetNumerDenom(_a ^ b_IsInteger)_(b < -1) <-- ExpandFrac'divide(GetNumerDenom(1), GetNumerDenom(a^(-b)));
20 # GetNumerDenom(_a ^ b_IsInteger)_(b = -1) <-- ExpandFrac'divide(GetNumerDenom(1), GetNumerDenom(a));
// non-integer powers are not considered to be rational functions
25 # GetNumerDenom(_a ^ _b) <-- {a^b, 1};
// arithmetic on fractions; not doing any simplification here, whereas we might want to
ExpandFrac'add({_a, _b}, {_c, _d}) <-- {a*d+b*c, b*d};
ExpandFrac'multiply({_a, _b}, {_c, _d}) <-- {a*c, b*d};
ExpandFrac'divide({_a, _b}, {_c, _d}) <-- {a*d, b*c};
|