1
$\begingroup$

I use Mathematica to do a bunch of symbolic calculations (integrals, ...). This is good because I found that sometimes, if I plug in numeric values, Mathematica takes much longer.

However, sometimes I am interested in the numeric result. And sometimes I just want to plot something.

Currently I perform the symbolic calculations and then use pattern substitution with numeric values when I want to plot something or get the numeric result.

Very simple example:

ymodcst = 
 Integrate[
  u*InverseLaplaceTransform[Kint/(s - pint), s, t] /. 
   t -> t - \[Tau], {\[Tau], 0, t}]

At some point, when I need to plot or want numeric values:

ymodcst/.Kint -> 100*^6*2*\[Pi] /. pint -> -1*^6/3*2*\[Pi]/.t -> 1*^-6/.u->1

or

Plot[ymodcst/.Kint -> 100*^6*2*\[Pi] /. pint -> -1*^6/3*2*\[Pi]/.u->1,{t,0,1*^-6}]

However, usually the symbolic expressions contain tons of variables and substituting them every time is cumbersome and error-prone.

When I define the variables first globally, e.g.

Kint = 100*^6*2*\[Pi]
pint = -1*^6/3*2*\[Pi]

I am back at the original problem.

So what I would look for is something like a toggle between "fill in the numeric values" and "do everything symbolically". Or better: A function "apply_numeric_values"

I hope my setup is clear.

$\endgroup$

closed as off-topic by user9660, m_goldberg, MarcoB, dr.blochwave, Jens May 11 '16 at 16:33

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Community, m_goldberg, MarcoB, dr.blochwave, Jens
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ I do not see what the problem actually. Can you not write something like params={a->100,b->200}; then do the symbolic calculations, and end write symbolicStuff/.params. I also find I found that sometimes, if I plug in numeric values, Mathematica takes much longer. interesting. One would expect the other way around, i.e. normally symbolic takes longer (but I guess it depends) $\endgroup$ – Nasser Nov 6 '14 at 2:04
  • $\begingroup$ First: This was exactly I was looking for! You may create an answer with that. Second: I am not saying that numerical integration is slower than symbolic, I am saying that symbolic integration with (some) symbols replaced with their numerical values is slower than doing everything without replacing the symbols and replace the symbols just in the end. $\endgroup$ – divB Nov 6 '14 at 3:44