After inserting it into Answers using the sigma button on the toolstrip:
Honestly, I wouldn't enter this as one term. As you called out, there's a decent amount of risk in missing a term or typing it in incorrectly. I'd enter it in one term or one part of a term at a time.
function result = W11(t, v)
k = 2;
sv = sqrt(v);
sv3 = sv.^3;
st = sqrt(t);
st3 = st.^3;
term(1) = -(t.^(-2*k).*(v^k))/3 * (sv3-1./sv3)./(st3-1./st3) * (sv-1./sv)./(st-1./st);
term(2) = ...
result = sum(term);
end
This way if there's a problem with one of the terms its individual piece can be debugged more easily. You could even compute more of the common subexpressions once like I did with sv, sv3, etc. The expression (sv-1./sv)./(st-1./st) looks like it occurs frequently so it may be a good candidate.
0 Comments
Sign in to comment.