Errors when plotting but not when evaluating

In summary, the conversation discusses an issue with plotting at line 21 and the possible reasons for it, including evaluating a numerical value for a variable. The conversation also suggests a potential solution, but it may take a long time to run. The individual also expresses uncertainty about the correct order for Mathematica to execute tasks.
  • #1
member 428835
Hi PF!

Attached is a screenshot of my code:
Screen Shot 2018-03-13 at 1.07.00 PM.png

The issue I'm facing is not being able to plot at line 21. It's weird because when I evaluate ##\alpha[1/4]## on it's own line I instantly receive a 5X1 vector. When I evaluate the Table[##\phi##] statement also shown in line 21 on it's own line I receive instantly a 5X1 vector too. Then when I copy-paste these results and dot them into each other I instantly get a good answer. So why can I not do this on the same line?

On line 21, I've tried changing the ##x## variable in ##\phi## to a ##z## and plotting in ##z##, but it takes so long to run this way. I've also tried evaluating ##\alpha## since this seems to be the issue, but again no luck.

Any help would be awesome!
 

Attachments

  • Screen Shot 2018-03-13 at 1.07.00 PM.png
    Screen Shot 2018-03-13 at 1.07.00 PM.png
    25.2 KB · Views: 908
Physics news on Phys.org
  • #2
I'm not sure, but it could be because it is trying to evaluate ##\phi## using a numerical value for ##x##. Try and see if the following helps:
Code:
Plot[\[Alpha][1/4].Table[\[Phi][xx, k, 1/4], {k, 1, 1/1/4 + 1}] /.
  xx -> x, {x, 0, 1}]
 
  • #3
DrClaude said:
I'm not sure, but it could be because it is trying to evaluate ##\phi## using a numerical value for ##x##. Try and see if the following helps:
Code:
Plot[\[Alpha][1/4].Table[\[Phi][xx, k, 1/4], {k, 1, 1/1/4 + 1}] /.
  xx -> x, {x, 0, 1}]
Yea I tried this but it takes a ridiculous amount of time. Much longer than if I compute manually and then take the dot product. I'm glad I tried this first though! Makes me think I am doing something right!
 
  • #4
It's hard sometimes to know in which order Mathematica is doing things.
 

What causes errors when plotting?

Errors when plotting can be caused by a variety of factors, such as incorrect data formatting, missing data, or a bug in the plotting software. It is important to carefully check the data and the code used for plotting to identify the specific cause of the error.

Why do errors occur during plotting but not during evaluation?

Errors that occur during plotting but not during evaluation are typically due to differences in the data or code used for plotting compared to the data or code used for evaluation. For example, the plotting software may require a specific data format that is different from what is used for evaluation, resulting in an error.

How can I troubleshoot errors when plotting?

To troubleshoot errors when plotting, it is important to carefully review the code used for plotting and the data being plotted. Check for any inconsistencies or formatting issues in the data, and also review the code for any potential bugs or errors. Additionally, consulting documentation or seeking help from others can also be helpful in troubleshooting errors.

What are common sources of errors when plotting?

Some common sources of errors when plotting include incorrect data formatting, missing data, coding errors, and software compatibility issues. It is important to carefully review all of these factors when troubleshooting errors in plotting.

How can I prevent errors when plotting in the future?

To prevent errors when plotting in the future, it is important to thoroughly check and test the data and code before attempting to plot. Additionally, regularly updating software and checking for compatibility issues can also help prevent errors. It can also be helpful to have a colleague or peer review the code and data to catch any potential issues before plotting.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • Introductory Physics Homework Help
Replies
11
Views
562
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • Beyond the Standard Models
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Programming and Computer Science
Replies
2
Views
926
Back
Top