MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / TR2

Function TR2

src/compute-engine/symbolic/fu-transforms.ts:120–139  ·  view source on GitHub ↗
(expr: Expression)

Source from the content-addressed store, hash-verified

118// ============================================================================
119
120export function TR2(expr: Expression): Expression | undefined {
121 const ce = expr.engine;
122 const op = expr.operator;
123 if (!isFunction(expr)) return undefined;
124 const arg = expr.op1;
125
126 if (!arg) return undefined;
127
128 if (op === 'Tan') {
129 // tan(x) -> sin(x)/cos(x)
130 return ce._fn('Sin', [arg]).div(ce._fn('Cos', [arg]));
131 }
132
133 if (op === 'Cot') {
134 // cot(x) -> cos(x)/sin(x)
135 return ce._fn('Cos', [arg]).div(ce._fn('Sin', [arg]));
136 }
137
138 return undefined;
139}
140
141/**
142 * Apply TR2 to all subexpressions

Callers 1

fu.test.tsFile · 0.90

Calls 3

isFunctionFunction · 0.90
divMethod · 0.65
_fnMethod · 0.65

Tested by

no test coverage detected