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

Function checkAntiderivative

test/compute-engine/calculus.test.ts:910–925  ·  view source on GitHub ↗
(
    integrand: any,
    points: Record<string, number>[]
  )

Source from the content-addressed store, hash-verified

908 ) {
909 const F = engine.expr(['Integrate', integrand, 'x']).evaluate();
910 expect(F.has('Integrate')).toBe(false);
911 const dF = engine.expr(['D', F.json as any, 'x']).evaluate();
912 const f = engine.expr(integrand);
913 for (const pt of points) {
914 const got = dF.subs(pt).N().re;
915 const want = f.subs(pt).N().re;
916 expect(Math.abs(got - want)).toBeLessThanOrEqual(
917 1e-7 * (1 + Math.abs(want))
918 );
919 }
920 }
921
922 test('∫(a + b·x⁴)/x⁶ does not drop the a-term', () =>
923 checkAntiderivative(
924 [
925 'Divide',
926 ['Add', 'a', ['Multiply', 'b', ['Power', 'x', 4]]],
927 ['Power', 'x', 6],
928 ],

Callers 1

calculus.test.tsFile · 0.85

Calls 6

evaluateMethod · 0.65
exprMethod · 0.65
hasMethod · 0.65
NMethod · 0.65
subsMethod · 0.65
absMethod · 0.65

Tested by

no test coverage detected