Cody

Problem 46968. Electric Potential Energy

Solution 3291633

Submitted on 20 Oct 2020 by Dyuman Joshi
  • Size: 22
  • This is the leading solution.
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
q = [1e-5 1e-5]; c = [1 1; 4 5]; assert(abs(ESF(q,c)-0.18)<1e-6);

ans = 0.1800

2   Pass
q = [1e-7 1e-6]; c = [0 0; -6 -8]; assert(abs(ESF(q,c)-9e-5)<1e-6);

ans = 9.0000e-05

3   Pass
q = [1e-2 -1e-3]; c = [0.5 0.75; -2.5 -2.25]/sqrt(2); assert(abs(ESF(q,c)+3e4)<1e-6);

ans = -3.0000e+04

4   Pass
q = [-1 -1]; c = [-3 -4;-3 -1]; assert(abs(ESF(q,c)-3e9)<1e-6);

ans = 3.0000e+09

5   Pass
q = [1e5 1e-15]; c = [-0 +0; -200 990]; assert(abs(ESF(q,c)-8.911e-4)<1e-6);

ans = 8.9109e-04

6   Pass
q = [-1e-7 1e-13]; c = [-27 100; 92 -220]; assert(abs(ESF(q,c)+2.6361e-13)<1e-6);

ans = -2.6361e-13

7   Pass
q = [1e30 1e-30]; c = [-exp(1) pi; -exp(1) pi+1]; assert(abs(ESF(q,c)-9e9)<1e-6);

ans = 9.0000e+09

Suggested Problems

More from this Author1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!