This content has been marked as final. Show 9 replies
See the attached.
You need to be aware that Mathcad has two internal processors: the numeric and the symbolic. They are more-or-less independent of each other, and do not behave the same way. The symbolic processor works with expressions. It takes an input expression, does something with it, and returns a new expression. That new expression make be as simple as a number, but it's still an expression. It does not know about units, and does not care about unassigned variables (even if an expression is flagged in red, the symbolic processor ignores that). The numeric processor deals with numbers and functions, and all variables must be either defined or included in the arguments to the function definition. Although the two processors are essentially independent, you can take the result of a symbolic evaluation and numerically assign it to a variable or function.
further to Richard's cooments, it also has its own 'equals' ( -> vs := ).
This means you could see the function assignment as a concatenation, e.g.
f(x) := (SolveMyExpn, solve -> 3*x^2 + 2*x + 1 )
I deliberately added the brackets so you can see that the symbolic solution is performed first and just returns an expression. This expression is then passed to the (numerical processor) function assignment which matches up the parameter names in the function with those in the expression. Very powerful, sometimes intimidating, ...
You can also play with having a 'variable' carrying the solvable expression (which can include boolean == etc.)
SolveMyExpn := (2x+1)^2 - (x+1)^2 + 1
Have a look at the many posts by Tom G who is rather adept at using this capability.
Thanks to all three of you. There are still some issues.
The first two ideas with the dummy and the local definition did not work on my version Mathcad 14.0 M010. I attached the two screenshots.
Richard's way worked. I used the same definition in my first row with Fun(x), but I did not know that Mathcad needed the symbolic evaluation right afterwards. I thought this only gives insight to the user.
There is another problem, however, since I also have to evaluate the 2nd-, 3rd-, and 4th-order polylogarithms. But my Mathcad cannot evaluate these symbolically like with the 1st-order polylogarithm. I think there is no closed form, only the infinite series.
Any idea how to handle them?
More about the background:
My antiderivate of interest (see attached picture) belongs to Planck's radiation law. It shall be integrated vs. the wavelength (finite integration limits - my infrared-camera has a specified spectral range). A substitution already took place, where x~1/wavelength. I want to use the antiderivative to calculate upper limit minus lower limit.
Or do you think I should integrate numerically from the beginning without using the antiderivative, because the polylogarithms are infinite series anyway? The solution of the integration will still be dependent on the temperature, so I'd prefer a symbolic solution.
On 9/22/2009 11:30:59 AM, McHale wrote:
>Thanks to all three of you.
>There are still some issues.
>The first two ideas with the
>dummy and the local definition
>did not work on my version
>Mathcad 14.0 M010. I attached
>the two screenshots.
The way the two processors interact has changed somewhat over the years. Just use what I showed.
>Richard's way worked. I used
>the same definition in my
>first row with Fun(x), but I
>did not know that Mathcad
>needed the symbolic evaluation
>right afterwards. I thought
>this only gives insight to
In general, you don't. I assumed you had done this deliberately, because the polylog function is not defined for the numeric processor. You can make it work by having the symbolic processor evaluate it and pass the numeric result to the numeric processor.
There are other reasons to construct expressions like this to, but in general it's not needed.
>There is another problem,
>however, since I also have to
>evaluate the 2nd-, 3rd-, and
>4th-order polylogarithms. But
>my Mathcad cannot evaluate
>these symbolically like with
>the 1st-order polylogarithm. I
>think there is no closed form,
>only the infinite series.
>Any idea how to handle them?
You would have to define your own function. See:
>More about the background:
>My antiderivate of interest
>(see attached picture) belongs
>to Planck's radiation law. It
>shall be integrated vs. the
>wavelength (finite integration
>limits - my infrared-camera
>has a specified spectral
Why not just integrate it numerically?
> A substitution
>already took place, where
Are you trying to convert from wavelength to wavenumber? If you are, it's not quite that simple because the spectral radiance is not just specified at a particular wavelength or wavenumber, but also per unit wavelength or wavenumber. I have a handy worksheet with various forms of the law defined so that I don't have to figure them out every time. See the attached.
>I want to use
>the antiderivative to
>calculate upper limit minus
You've lost me there. Why do you need the derivative to find the integral limits?
>Or do you think I should
>integrate numerically from the
>beginning without using the
>, because the
>polylogarithms are infinite
>series anyway? The solution of
>the integration will still be
>dependent on the temperature,
That's not a problem for the numeric processor.
The technique you show here, using a symbolic evaluation within a numerically evaluated function works in MC11 and earler, but was broken in MC12, probably a side effect of SUC. But even when it works, it is extremely slow, often to the point or being impractical.
I would suggest just using numerical integration. Unless the integrand is unusually complicated (multiple integrals, solutions based on solve blocks, etc.) numerical integration is usually quite fast. You can define functions based on the integrals, with things like the termperature as arguments, so you lose nothing there.
� � � � Tom Gutman
Assignment of symbolic reasults is done the same way as the assignment of numeric results, using the :=. As Richard points out, the numeric and symbolic processors are quite distinct. While both use the := for assignment/definition, they each interpret the expressions independently, and don't always agree.
Your key problem here is polylog. That is one of the (relatively few) functions that are known to the symbolic processor (and so can be evaluated symbolically) but not implemented in the numeric processor. If you want to be able to use the polylog function numerically you will have to find or write an implementation of the polylog function, either as a Mathcad function or iin a user DLL.
Now for a more detailed analysis and explanation of some items in your worksheet.
Polylog is known to the symbolic processor, but not the numeric processor. Hence the assignment to Fun Fun having a usable symbolic definition, but being undefined numerically.
The assignment to x is unexceptional, and results in both the numeric and symbolic processors seeing the value of x as 3 (although they use very different internal representations of 3).
The next assignment to y is quite different for the numeric and symbolic processor. The sysmbolic processor sees a perfectly good definition of Num, and evaluates it for the value of x (3). Th result is an expression, not a number. The actual number is transcendental and not reprsentable as a number. You can use the float keyword to have the symbolic processor produce a number which approximates the correct result. The numeric processor simply sees Num as undefined, and so leaves y as undefined.
Plotting is numeric only. x has the value of three, so only one x value is plotted, at three. y is undefined. Since there is exactly one undefined variable in the plot, quickplot is activated. That implicitly varies the undefined variable (y) from -10 to +10. Hence the vertical line at x=3 with y ranging from -10 to +10.
Your next definition for x defines x as a range (not area) variable. The numeric and symbolic processors both know about range variables, so that definition works for both.
Your symbolic evaluation of Fun(x) now works. The symbolic processor has a definition for Fun and can evaluate it for each x value. Note that while the result is displayed as though it were a vector, it is not a vector but a list. A list can be displayed, but is not a value and cannot be assigned as such.
Your subsequent definition for y fails a basic rule governing the use of range variables in assignments -- if a range variable appears in the right hand side of an assignment, it must also appear in the left hand side. This restriction is enforced by both the numeric and symbolic processors. The numeric assignment fails before even getting that far, due to Num being undefined. The sysmbolic assignment fails due to the misuse of the range variable. Here you get to notice how while error messages in general are very bad, those for symbolic errors are even worse. Thus you get no clue as to the source of the problem, just the bland statement that you had an error somewhere.
In your section using a vector x you have left i undefined. That sort of works with the evaluation of Fun (symbolically), as the symbolic processor can leave i as a free variable in the resulting expression. But even the symbolic processor cannot do an assignement to an element of an array with undefined subscripts. Define i as the range 0..3 and you can get a symbolic result for y.
� � � � Tom Gutman
On 9/22/2009 7:21:58 AM, McHale wrote:
>I have a fundamental problem
>plotting the values of a
>symbolic function, because I
>cannot assign these values to
>How can I do it?
This should get you started.
On 9/22/2009 9:02:59 AM, schneidrax wrote:
>On 9/22/2009 7:21:58 AM, McHale wrote:
>>I have a fundamental problem
>>plotting the values of a
>>symbolic function, because I
>>cannot assign these values to
>>How can I do it?
>This should get you started.
I do understand that the Mathcad 2001i approach using the dummy and the local definition did not work on your version Mathcad 14.0 M010.
However, I did want to point out in the event you found some way to use the polylog function that the Mathematica expression represents a solution to the indefinite integral only and that integration limits still need to be accounted for. This may not prove so simple as the example below illustrates: