If you want to do it yourself instead of using a math library, then my immediate thought is tp write out and calculate the Taylor series of your function. sin(x) is basically x +x^3 + x^5 +... with appropriate constants (look them up on wikipedia) so then sin(x)/x is the same thing but you divide all the parts by x so you're gonna have c + x^2 + x^4 + ... Now just add more parts in a while loop until the error term is small enough or you have spent some maximal number of allowed iterations and you're good.
People are being kind of rude, sorry about that.
I also think they aren't understanding your problem. You have a function f(w,t) = sin(wt)/w which is well defined everywhere (in the sense of limits at w=0 ), but for which the naive implementation (compute sin(wt), then divide by w) gives the "wrong" output for w=0 (an error instead of t).
Note that the function sin(x)/x has a name, sinc(x). Using this to rewrite your function gives f(w,t) = sin(wt)/w = tsin(wt)/(wt) = tsinc(wt).
Now you just need to find a quality implementation of sinc from a math library.
this seems like a standard problem. did you discuss it with your colleagues? alternatively, did you already ask chatgpt? where are you struggling?
Hello. I am a school student making an open source robot car.
I did not ask my teammate, will do.
Btw there is our repository: (Currently there is no proper README.md, docs). https://github.com/XLNC-APEX/WRO_FE_2026_NATIONAL
You can see images and some steering, radius related experiment at my mastodon post. https://mas.to/@soupborsh/117011244080971088
I prefer to not interact with AI, that is why I am writing here to humans.
yeah and i prefer not to interact with people who seek help who apparently didn't put any work into trying to solve the problem themselves first
Then don't comment.
So... you want to define division by zero?
I thought maybe with some clever algebra or calculus the function can be transformed into function that has outputs equal to current's:
lim~w->a~f(w,t)
Since the limit (AFAIK) is defined everywhere.
Also maybe(idk) dividing really small number by other really small number is numerically unstable? I use f32(32 bit float) on microcontroller.
Ahh yeah, I misunderstood what you were going for, sorry! Yeah, check out Buildout's suggestion!
math
General community for all things mathematics on @lemmy.world
Submit link and text posts about anything at all related to mathematics.
Questions about mathematical topics are allowed, but NO HOMEWORK HELP. Communities for general math and homework help should be firmly delineated just as they were on reddit.