Mathematica-My polynomial's graph is different in two plots ?

  • Mathematica
  • Thread starter nalkapo
  • Start date
  • Tags
    Graph Plots
In summary, the individual is experiencing a difference in the polynomial's graph when plotted in two different places in Mathematica. This is due to the automatic scaling of the graph, which can be adjusted with a PlotRange command. Additionally, the individual was able to use the Manipulate command to plot an interactive manipulation of a function and polynomial with changeable n values.
  • #1
nalkapo
28
0
Mathematica-My polynomial's graph is different in two plots!?

Please help...
In mathematica I used the same polynomial and plotted two times in different place.
but in these graphs, my polynomial looks different.
Is there anyone who knows the problem?

--> mathematica notebook file is attached...
 

Attachments

  • Untitled-2.nb
    21.1 KB · Views: 522
Physics news on Phys.org
  • #2


It's just the scale that's different. Unless you tell it otherwise, Mathematica will adjust the scale so that the plot fills the graph. It needed a different scale the second time to fit both functions. If you want the same scale for both, just add a PlotRange command, as follows. If you do this for both plots, they will look the same.
Code:
Plot[{Piecewise[{{x, 0 <= x <= 1/2}, {1 - x, 1/2 <= x <= 1}}], p}, {x,
   0, 1}, PlotStyle -> {Orange, Thick}, PlotRange -> {0, 1}]
 
  • #3


Thanks phyzguy,
also i sent an email to mathematica support and they corrected my commands.
they just added: AxesOrigin->{0,0} and it worked.
 
  • #4


do you think it is possible that for different values of n, i can use 'Manipulate' command and plot an interactive manipulation? for example; n from 0 to 30...
i tried but it didnt work...
Is there anyone who can help, please?

i have a function and a polynomial;

f[x]=Piecewise[{{x, 0<=x<=1/2},{1-x, 1/2<=x<=1}}]
Q[x]=(1-(t-x)^2)^n
P[x]= Integrate[f[t]*Q[x],{t,0,1}]

I want to manipulate P[x] and f[x] in the same plot with changeable n values from 0 to 30. so n will affect on the shape of P[x].
 
Last edited:
  • #5


Works for me… What's your code ?
Here is what works for me :

Manipulate[
f[x_] = Piecewise[{{x, 0 <= x <= 1/2}, {1 - x, 1/2 <= x <= 1}}];
Q[x_] = (1 - (t - x)^2)^n;
P[x_] = Integrate[f[t]*Q[x], {t, 0, 1}];
Plot[{f[x], Q[x], P[x]}, {x, 0, 1}]
, {n, 0, 30, 1}]
 

1. Why is the polynomial's graph different in two plots?

The polynomial's graph may appear different in two plots due to variations in the plot range, plot options, or the data points used to create the plot.

2. Can Mathematica accurately graph polynomials?

Yes, Mathematica can accurately graph polynomials as long as the correct syntax and data points are used. It also offers various plot options to customize the appearance of the graph.

3. How can I adjust the plot range to better display the polynomial's graph?

To adjust the plot range in Mathematica, you can use the PlotRange option or the PlotRangePadding option. The PlotRange option allows you to specify the exact range of values for the x and y axes, while the PlotRangePadding option adds padding to the automatically determined plot range.

4. What are some common errors that may cause discrepancies in the polynomial's graph?

Some common errors that may cause discrepancies in the polynomial's graph include using incorrect syntax, incorrect data points, or forgetting to include necessary plot options. It is also important to check for any typos or mistakes in the input.

5. Can I overlay multiple polynomial graphs in one plot using Mathematica?

Yes, it is possible to overlay multiple polynomial graphs in one plot using the Show function in Mathematica. This allows you to compare and analyze different polynomials on the same graph.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
892
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
Back
Top