Cody

Problem 1197. Numerical Integration

Solution 1583364

Submitted on 14 Jul 2018 by bainhome
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x0 = 1; I_correct = 2.6405789412796; fprintf('Relative difference to reference solution: %e\n',norm(coshint(x0)-I_correct)/I_correct) assert(norm(coshint(x0)-I_correct)/I_correct <= 1e-10)

Relative difference to reference solution: 2.806903e-13

2   Pass
x0 = 2; I_correct = 3.9464053536380; fprintf('Relative difference to reference solution: %e\n',norm(coshint(x0)-I_correct)/I_correct) assert(norm(coshint(x0)-I_correct)/I_correct <= 1e-10)

Relative difference to reference solution: 1.197320e-13

3   Pass
x0 = 13; I_correct = 9.4065231838369e+02; fprintf('Relative difference to reference solution: %e\n',norm(coshint(x0)-I_correct)/I_correct) assert(norm(coshint(x0)-I_correct)/I_correct <= 1e-10)

Relative difference to reference solution: 7.976732e-15

4   Pass
% cosh(x) ~ 1 + x^2/2 + ... % and up to x0=1e-5 Integrating (analytically) the approximation is % accurate enough for l=1:5 x0 = 1e-6 * (1+rand); I_correct = pi*(4+x0^2)/4/sqrt(2); fprintf('Relative difference to reference solution: %e\n',norm(coshint(x0)-I_correct)/I_correct) assert(norm(coshint(x0)-I_correct)/I_correct <= 1e-10) end

[Warning: Infinite or Not-a-Number value encountered.] [> In integralCalc/iterateScalarValued (line 349) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In coshint (line 5) In ScoringEngineTestPoint4 (line 7) In solutionTest (line 9)] Relative difference to reference solution: 0.000000e+00 [Warning: Infinite or Not-a-Number value encountered.] [> In integralCalc/iterateScalarValued (line 349) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In coshint (line 5) In ScoringEngineTestPoint4 (line 8) In solutionTest (line 9)] [Warning: Infinite or Not-a-Number value encountered.] [> In integralCalc/iterateScalarValued (line 349) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In coshint (line 5) In ScoringEngineTestPoint4 (line 7) In solutionTest (line 9)] Relative difference to reference solution: 0.000000e+00 [Warning: Infinite or Not-a-Number value encountered.] [> In integralCalc/iterateScalarValued (line 349) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In coshint (line 5) In ScoringEngineTestPoint4 (line 8) In solutionTest (line 9)] [Warning: Infinite or Not-a-Number value encountered.] [> In integralCalc/iterateScalarValued (line 349) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In coshint (line 5) In ScoringEngineTestPoint4 (line 7) In solutionTest (line 9)] Relative difference to reference solution: 0.000000e+00 [Warning: Infinite or Not-a-Number value encountered.] [> In integralCalc/iterateScalarValued (line 349) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In coshint (line 5) In ScoringEngineTestPoint4 (line 8) In solutionTest (line 9)] [Warning: Infinite or Not-a-Number value encountered.] [> In integralCalc/iterateScalarValued (line 349) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In coshint (line 5) In ScoringEngineTestPoint4 (line 7) In solutionTest (line 9)] Relative difference to reference solution: 0.000000e+00 [Warning: Infinite or Not-a-Number value encountered.] [> In integralCalc/iterateScalarValued (line 349) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In coshint (line 5) In ScoringEngineTestPoint4 (line 8) In solutionTest (line 9)] [Warning: Infinite or Not-a-Number value encountered.] [> In integralCalc/iterateScalarValued (line 349) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In coshint (line 5) In ScoringEngineTestPoint4 (line 7) In solutionTest (line 9)] Relative difference to reference solution: 0.000000e+00 [Warning: Infinite or Not-a-Number value encountered.] [> In integralCalc/iterateScalarValued (line 349) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In coshint (line 5) In ScoringEngineTestPoint4 (line 8) In solutionTest (line 9)]