[Mathematica] Simple Problem with the plot functionby PEZenfuego Tags: function, mathematica, plot, simple 

#1
May813, 07:57 PM

P: 48

I have a formula for the fibonacci sequence (with 1 being the first) and I noticed that the 12th fibonacci number was 144. I thought that was a neat coincidence, so I I headed over to mathematica to see if this (and 1) were the only numbers that had this property. I was almost certain that it was. So I plotted the two graphs, but only the x^2 graphed showed up. Here was my input. My question is about what I did wrong.
phi := (1 + Sqrt[5])/2 phih := (1  Sqrt[5])/2 f:={(phi^n)(phih^n)}/{Sqrt[5]} y:=n^2 Plot[{f, y}, {n, 20, 20}] Now, this works when I remove the phih term, which works well enough that I can clearly see that only 1 and 12 are solutions. On the other hand, this is not plotting something that it should be plotting... Anyway, thank you in advance for the help. 



#2
May813, 08:46 PM

P: 178

The problem is that plot tries to make a continuous plot. It then runs into the problem that phih^x is not a realvalued function for noninteger x, and refuses to plot it altogether. To just plot the values at integer values of x, you can use DiscretePlot:
DiscretePlot[{f, y}, {n, 20, 20, 1}] 



#3
May813, 09:12 PM

P: 48





#4
May813, 09:48 PM

P: 178

[Mathematica] Simple Problem with the plot functionPlot[(1 + I*HeavisideTheta[x  5]*HeavisideTheta[6  x]), {x, 0, 10}] (I would prefer it to give an error message or a warning, but it doesn't seem to do that.) Your function is a bit worse though as it is only realvalued on integer values of x. The proof just uses the general definition of the power of a number a (negative, complex etc.), which makes use of the complex logarithm: [itex]a^b=e^{b log a}[/itex]. If a is real and negative, then this simplifies to [itex]a^b=e^{bLog(a)+ib\pi}=a^b e^{ib\pi}[/itex], which is only real for integer values of b. 


Register to reply 
Related Discussions  
Implicit function plot in Mathematica  Math & Science Software  2  
Mathematica  2D plot for function of 2 vars?  Math & Science Software  3  
Plot Gamma Function with Mathematica  Math & Science Software  1  
Plot inverse function Mathematica  Math & Science Software  5  
how do i plot a function of two variables in mathematica?  Math & Science Software  3 