Why do graphing calculators plot this function wrong? Wolfram Mathematica example.

401 Views Asked by At

Wrong graph of the function f(x)=-1^x

The function in question is $f(x)=-1^x$ and the plot example is from Wolfram Mathematica. The graph is supposed to show a zig-zag otherwise known as the triangle waveform. This problem happened on Microsoft Mathematics, Desmos online graphing calculator, another graphing calculator online, everywhere except Microsoft Excel so far.

Wolfram Language code for the graph linked is simply: Plot[-1^x, {x, -100, 100}]

2

There are 2 best solutions below

0
On

What you wrote according to order of operations is $-1^x=-1$. You meant $(-1)^x$ probably. See:

http://m.wolframalpha.com/input/?i=%28-1%29%5Ex&x=0&y=0

1
On

The problem I encountered was twofold:

1) $f(x)=-1^x$, won't show oscillatory motion

because

$=-1^x=-(1^x)-(1)=-1$

2) $f(x)=(-1)^x$, won't plot

because

if $\{x|x \in \mathbb R\} \land x=a/2b$ where $b \in \mathbb N$

"$x$ is in the domain of all real numbers and $x=a/$some even number"

where

$a \neq 2b \lor a \notin \mathbb Q \lor a=2n+1$ where $n \in \mathbb N$

"the numerator $a$ is not equal to the divisor or is irrational or odd"

then

$ (-1)^x \in \mathbb C \land (-1)^x=i=\sqrt[2n]{-1}, n\in \mathbb N$

"$(-1)^x$ is in the domain of all complex numbers and equal to the even root of -1."

In layman terms, when $-(1)$ is elevated to a power other than an integer then the imaginary number $i$ (which is not plottable over a range of real numbers) tend to appear over the range of $(-1)^x$.

The solution:

$f(x)=(-1)^x$, will plot if $\{x|x\in \mathbb Z\}$

"$x$ is in the domain of all integers"

Sample MATLAB code:

x=-100:1:100; %Domain in increments of 1 plots the set of all integers

y=(-1)^.x;

plot(x,y)

The result is the graph of a triangle waveform or "zig-zag."

A new problem arised in Wolfram Mathematica for me. The plot function Plot[] is in the format Plot[expression,{var,varmin,varmax}] with no option for setting the increment of the domain to any desired value. In the case of $(-1)^x$ to 1. Any help with this?