Computer Science Canada Math Equation Fun |
Author: | Nick [ Tue Apr 29, 2008 4:58 pm ] |
Post subject: | RE:Math Equation Fun |
do you know what the arc does? it makes it use the Quenent identity of the function which basacally means 1/sin or 1/cos or 1/tan why this causes an error? what's 1 divided by 0? |
Author: | Sean [ Tue Apr 29, 2008 5:00 pm ] |
Post subject: | Re: RE:Math Equation Fun |
nick @ Tue Apr 29, 2008 4:58 pm wrote: do you know what the arc does?
it makes it use the Quenent identity of the function which basacally means 1/sin or 1/cos or 1/tan why this causes an error? what's 1 divided by 0? What error are you speaking of? You mean of arccos and arcsin? |
Author: | Nick [ Tue Apr 29, 2008 5:01 pm ] |
Post subject: | RE:Math Equation Fun |
that I am |
Author: | Sean [ Tue Apr 29, 2008 5:03 pm ] |
Post subject: | RE:Math Equation Fun |
Arccos finds the arc cosine of a value and displays it in radiants. I don't believe I would be able to minipulate it into what I have done. However arctan is usable. It's just something I quickly came up with. Not that serious of a project. |
Author: | Nick [ Tue Apr 29, 2008 5:08 pm ] |
Post subject: | RE:Math Equation Fun |
I'm saying that 1/0 is undoable and since arc creates a recipocal, there is division, so if your cos/sin/tan value results in a 0 you get an error |
Author: | Saad [ Tue Apr 29, 2008 5:10 pm ] | ||||||||||||||
Post subject: | Re: Math Equation Fun | ||||||||||||||
Sean wrote: However, if you try to use arcsin and arccos, you have a Quit #100 error. No idea what that is. arccos, and arcsin of x has the restrictions that -1 >= x <= 1. This is by definition what the trig ratios give. Furthermore I hope you realise that trig functions are not just trippy things. Sean wrote:
This program is quite boring and the quote can be improved. First of all, why is c global and why is randint being used. You should be using Rand.Int which returns a random integer
Now for a little more advanced stuff. Looking at the code we can easily say that that code requires us to change quite a bit if we want to use the function. So what should we do? The answer is passing functions as parameters. This allows us to make a function that graphs any given function. But before I go there you should have knowledge on functions (Tutorial here). So without much delay some code.
Woah , thats weird code so let me explain it part by part.
In this procedure declaration we are defining a function to take 2 parameters. One is a function to graph and one is the color. However lets take a closer look at the following
Note that this is really similar to just regular parameters passed into procedures/functions but more specifically we declare myFunctionToGraph as a function that takes 1 real number and returns a real number. The _ in the thing is that Turing requires a name after a function for some reason. Now since myFunctionToGraph is a function, that means we can use it to give us our Y-Values
The last part is the call to DrawGraphForFunction. We just pass it as a regular parameter.
Now this may have been a bit much but This covers up what I just talked about which is passing functions. |
Author: | Nick [ Tue Apr 29, 2008 5:17 pm ] |
Post subject: | RE:Math Equation Fun |
oh and that part about -1 < x < 1 is a probable cause for that error as well also, Saad's method is much better (I even changed my sine wave program to almost the same thing too, just never submitted it) |
Author: | Sean [ Tue Apr 29, 2008 7:16 pm ] |
Post subject: | RE:Math Equation Fun |
I really could careless if it is boring, or not. I made this program in five minutes, and it was just playing around with cos, tan, sin, and arctan. There is no need to go and point out that you don't like it or not like that. And plus, don't speak to me as if I am some person who can't understand coding. |
Author: | zylum [ Tue Apr 29, 2008 7:30 pm ] |
Post subject: | RE:Math Equation Fun |
Sean, there is no need to get defensive. No one said your program is boring or that they don't like it. nick suggested a reason as to why arcsin and arccos give you an error and Saad gave you some ways to improve your program as well as give a brief intro to functional programming which might inspire you to make more interesting programs. |
Author: | Sean [ Tue Apr 29, 2008 7:38 pm ] |
Post subject: | Re: Math Equation Fun |
Saad @ Tue Apr 29, 2008 5:10 pm wrote: arccos, and arcsin of x has the restrictions that -1 >= x <= 1. This is by definition what the trig ratios give. Furthermore I hope you realise that trig functions are not just trippy things. This program is quite boring and the quote can be improved. Never once did I want this to be trippy. I don't do drugs, neither will I ever. Furthermore, I was doing graphic styles using trig formulas. Nothing More, Nothing Less. Oh, and there is the boring section. |
Author: | Saad [ Tue Apr 29, 2008 7:43 pm ] |
Post subject: | Re: Math Equation Fun |
Sean @ Tue Apr 29, 2008 7:38 pm wrote: Saad @ Tue Apr 29, 2008 5:10 pm wrote: arccos, and arcsin of x has the restrictions that -1 >= x <= 1. This is by definition what the trig ratios give. Furthermore I hope you realise that trig functions are not just trippy things. This program is quite boring and the quote can be improved. Never once did I want this to be trippy. I don't do drugs, neither will I ever. Furthermore, I was doing graphic styles using trig formulas. Nothing More, Nothing Less. Oh, and there is the boring section. Sorry for some misunderstanding. It seemed like your program was one of your trippy programs that I've seen. My diction was probably a poor choice and sorry for that too. As for the "boring section", I just tried to give some constructive criticism and a small introduction into some functional programming. If you find it boring then I'm sorry about the long post. |
Author: | Sean [ Tue Apr 29, 2008 7:46 pm ] |
Post subject: | Re: Math Equation Fun |
Please link me to a trippy post of mine. Never created one. And your introduction was appreciated, however, would of been better not to include the boring part, as that tends to rally people against you. |
Author: | Saad [ Tue Apr 29, 2008 7:47 pm ] |
Post subject: | Re: Math Equation Fun |
Sean @ Tue Apr 29, 2008 7:46 pm wrote: Please link me to a trippy post of mine. Never created one.
I never said your trippy flashes. I was referring to trippy flashes that have been already posted (not by you) Sean @ Tue Apr 29, 2008 7:46 pm wrote: And your introduction was appreciated, however, would of been better not to include the boring part, as that tends to rally people against you.
Again I'm sorry for my choice of words. |
Author: | Tony [ Tue Apr 29, 2008 8:38 pm ] |
Post subject: | RE:Math Equation Fun |
It was all misunderstanding, lets leave it at that. |