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

  • Thread starter Thread starter nalkapo
  • Start date Start date
  • Tags Tags
    Graph Plots
AI Thread Summary
In Mathematica, users encountered an issue where the same polynomial appeared differently in two plots due to varying scales. The automatic scaling by Mathematica adjusts the plot to fill the graph area, leading to discrepancies. To ensure consistent appearance, adding a PlotRange command can standardize the scale across plots. Additionally, users discussed using the Manipulate command to create interactive plots that adjust the parameter 'n' from 0 to 30, affecting the shape of the polynomial. A working code snippet was provided, demonstrating how to integrate the functions and visualize them interactively. The discussion emphasized the importance of setting axes origins and maintaining consistent plot ranges for clarity in graphical representations.
nalkapo
Messages
28
Reaction score
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

Physics news on Phys.org


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}]
 


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


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:


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}]
 

Similar threads

Back
Top