0
$\begingroup$

I have a Piecewise and Nintegrate both defined with NumericQ. The NIntegrate part of the Piecewise operates when first inserted into a working program, but not when called from inside a table. Their column entries inside the Table results are surronded by {} brackets and do not plot. What do the brackets mean and can they be over-ridden?

If the whole notebook is re-evaluated, they don't work period. Unfortunately there is a bit too much to cut and paste. It is a big program that has ground to a halt over this substitution of a reformulation of the numerical integral for less oscillatory result. Sample first two rows, See 5th,7th,8th,9th entries are bracketed and will not plot

{{0.0001,0.968874,0.696658,0.000049905,{0.000195849},0.0314159,{0.960548},{0.00013444},{-0.412487}}, {0.025,0.968874,0.696658,0.00831408,{0.0473654},0.0303378,{0.956449},{0.0357167},{0.0495755}},

$\endgroup$
  • $\begingroup$ It's not clear to me what the problem is exactly. Can you explain through a simple example? $\endgroup$ – Szabolcs Mar 13 at 17:22
  • $\begingroup$ Please share some code. If yours is too long, generate a smaller example. It shouldn't be difficulty, since the problem is obviously in the refactored part of your code, which was otherwise working previously. Make sure that you include all necessary definitions to run your code, or even better, a simpler sample snippet that reproduces your issue. See also: Minimal Working Example and guidelines for asking questions. $\endgroup$ – MarcoB Mar 13 at 17:38
  • $\begingroup$ To alleviate the symptom, you can Flatten[yourOutput]. That will remove extra lists ({}). However, you should still find a "cure" for your code, but we cannot help you until you show some code. $\endgroup$ – MarcoB Mar 13 at 17:39
  • $\begingroup$ Flatten removes all internal bracketing and destroys the matrix structure altogether, so then it won't plot either. The brackets around matrix entries probably are a flag that Nintegrate is struggling and not confident in the number it is giving. $\endgroup$ – simon Mar 13 at 19:44
0
$\begingroup$

Ok found elsewhere on exchange that proper Flatten command is Flatten /@ list removes these presumably warning brackets around list members generated by NIntegrate

Plotting these formerly bracketted values shows good smoothness and match to asymptotes so Mathematica's caution about its Nintegrate output should have come with an explanatory message including this how to over-ride.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.