New answers tagged code-review
1
Added sample data for performance testing -- see Update below.
The Manipulate controls for latitude and longitude allow the minimum values to be greater than the maximums. Is this the problem you want to fix in a more natural way?
I suggest a better method is to use latitude and longitude controls for the center of a region, and separate controls for the ...
4
Well, I give my first shot a "C-". Here is an updated self-corrected version, for posterity. Maybe some unlucky shmuck who is working with held expressions can make use of this someplace in the future.
Changes:
Change pattern guard to permit replacement rules which use nested lists of rules (an allowed syntax of regular Replace)
Use NonNegative ...
3
Evaluating the integrals used to produce the value shown in the inset will produce, as is pointed out in cvgnt's answer, a major improvement in your code's performance, but there are other improvements you can make. The following code shows how I would refactor your Manipulate, not only to improve performance, but also to improve the user experience.
kb = 1....
5
Actually, g[a,T] have analytic expression.
Integrate[f[v, T], {v, a, Infinity}, Assumptions -> T > 0]
$$1.\, -\frac{1. \sqrt{a^2} \text{erf}\left(0.0438624 \sqrt{\frac{a^2}{T}}\right)}{a}+\frac{0.0494935 a e^{-\frac{0.00192391
a^2}{T}}}{\sqrt{T}}$$
Integrate[f[v, T], {v, 0, Infinity}, Assumptions -> T > 0]
1
kb = 1.381*10^-23;
Nav = 6.022*...
Top 50 recent answers are included
Related Tags
code-review × 353performance-tuning × 62
list-manipulation × 41
code-request × 41
plotting × 33
function-construction × 27
equation-solving × 23
programming × 23
matrix × 19
differential-equations × 18
coding-style × 16
manipulate × 14
functional-style × 14
numerical-integration × 11
calculus-and-analysis × 9
functions × 8
numerics × 8
string-manipulation × 8
matlab × 8
broken-code × 8
graphics × 7
dynamic × 7
physics × 7
graphs-and-networks × 6
probability-or-statistics × 6