Wondering Why I Might Be Getting Differently-Shaped Graphs For the Same Input Between Desmos and VPython

Hello all, I'm hoping someone can help me with this issue I've been having for a few days:

I have this function in Desmos: https://www.desmos.com/calculator/h2owg1no4t

If you parse through the inputs, you'll see that the graph that is showing when you open that page is the graph "m", which is the sum of "g's", which are in turn sums of single frequency "f" waves. In total the graph "m" is made up of six different cosine plane waves and one constant term.

I'm trying to accomplish something slightly different in Glowscript/VPython but am essentially trying to replicate this same function. Here is the Glowscript code: https://www.glowscript.org/?fbclid=IwAR0YeqIyK22vJ2LwYfczH-qUe7xEWWBa1Th9hbCAyM9qUvobx29TNFk8jd0#/user/cody825/folder/MyPrograms/program/SeniorProjectSecondAttempt

Again, if you look in the Glowscript code and took the time to go through the arithmetic, you would see that the input for the Glowscript graph is the exact same six cosine plane waves as in the Desmos graph with the only exception being I'm not bothering with the constant term. And you'll see that the two graphs look VERY similar. But the Desmos graph is superoscillating in the regions where the graph goes toward zero (as it should be), whereas the superoscillations are being washed out in the VPython graph.

You can't even see this difference on the scale provided in those links, but if you refer to this link: https://www.desmos.com/calculator/dz5i4ymkzz which is the same function in Desmos just zoomed into a different scale where you can see the fine details, you'll see what I mean about the superoscillations.

If you do the same zooming on the VPython graph, you don't see the correct fine details. At first I thought that it was a matter of Glowscript not having enough decimal precision, but then I tried a slightly different approach: https://www.glowscript.org/?fbclid=IwAR0YeqIyK22vJ2LwYfczH-qUe7xEWWBa1Th9hbCAyM9qUvobx29TNFk8jd0#/user/cody825/folder/MyPrograms/program/Cosines

This is, again, the same exact function except instead of being expressed as a sum of Fourier components, it is simply the explicit binomial expansion of the function which is: f(t) = Re([cos(t/12) + 13i*sin(t/12)]^12)

And this final graph DOES have the correct (superoscillatory) fine details. I'm having a hard time discerning the issue here.

Can anyone take a look and help me? Thanks in advance!

  • I resolved this issue. It came down to a really simple mistake on my part where I was putting in a number that was wrong by the placement of one decimal point.

  • Erdos Erdos
    0

    You should also pay attention to different scaling in x and y directions. Desmos has uniform scaling in x and y direction, but Vpython does not. This is another reason the graphs may seem different.

Join Matchmaticians Affiliate Marketing Program to earn up to 50% commission on every question your affiliated users ask or answer.