Plot has attribute HoldAll and tries to evaluate the function Normal[Series[…]] only after assigning specific numerical values to x. As you have shown in the resolution, in this case we need to force the symbolic evaluation of Series[Sin[x],{x,0,someInteger}] to obtain the power series expansion for Sin[x] before trying to substitute numeric values for x.
This is why the following is unable to plot:
From time to time I consider equations like “f(x) = some right-hand side”. To investigate this kind of equations, I want to transform them by a rule like \xi = x/some factor, say \xi = x/a. (Typically, x and a have the same dimension and thus \xi is dimensionless.) Therefore, I want Mathematica to find and collect all quotients of x/a and replace them with \xi.
Replacing “(1 + x)^6 /. x -> 3 - a” is quite simple and standard. But the reverse way doesn’t seem to work, does it? Unfortunately I didn’t find any hints in the reference.
Example 2: In the example above I have already helped Mathematica, of course it would be nice if the task could also be solved when one is one step further away - i.e. if this equation had to be substituted:
So you could summarize that I would like to have a) an automatism (or a workaround or a strategy) that collects the terms as desired (see Example 2) and b) also considers powers of the variable (see Example 1).
Hi Ulf,
A good rule of thumb is to use Evaluate when you want to ensure all symbolic processing of the expression has been completed before Plot (which has HoldAll attribute) tries to substitute numerical values for x in the function.
In this particular example, using Evaluate to first replace f with the InterpolatingFunction from the NDSolve solution is ideally the right way to proceed. However, if we substitute x with a numeric value and then replace f with another function, it still works fine (replacement of f is not affected by the numeric value of x).
The order in which evaluation proceeds is more important in the example quoted a few comments back in this thread:
Here you absolutely want to finish the symbolic evaluation of Normal[Series[Sin[x], {x, 0, 10}]]] before numeric values of x are passed to it. So you need to force the evaluation using Evaluate.
Ah, I see what you mean. That is indeed a difficult general problem to solve, and I’ve run into it myself in the past. After some searching, I’ve found something that seems to work… it still needs a bit of simplification (with Simplify or FullSimplify), but it ought to do what you want, and thee discussion surrounding it provides some insight as to why this is a nontrivial problem:
I was doing some exploring recently. And tried to use a web-camera image as a good source of data. I am using Mathematica 12.1 on my Raspberry Pi 4 with an USB webcam attached.
What I don’t understand is, when I try to grab an image, I get an error. I did the documentation digging and found out, that there were special variables $ImagingDevice and $ImagingDevices, that select and represent the devices, the image is grabbed from. I checked, what device was used, and without chaning anything the image grab started working as expected. I reproduced this behaviour several times and made a screenshot.
Reminding our Study Group participants that the New in Version 12.2 webinar starts in less than 1 hour, at noon CST. Today’s topics include the latest enhancements in visualization, the new area of bio-sequence computation, and new functionality for Wolfram Notebooks and working with code.
Hi Fedor, Unfortunately I do not have a better explanation other than a guess that the code behind $ImagingDevices (or FindDevices[] or other similar functions) triggered an initial handshake with the device or camera. Seems like initially DeviceOpen or DeviceRead was failing under the hood behind CurrentImage. Once the camera device was recognized, CurrentImage started working.
Executing the packed array timing example I didn’t get the order of magnitude faster execution. Attached file shows the timing I got. Anyone have an idea why the timing stayed the same? Thanks in advance.
Information for AI agents: this site’s guide is at /llms.txt. Search results are available as JSON from /search.json?q=…; the /search page returns no results to automated clients.