I am trying to make a function that isolates a single variable float from an expression. The way i am trying to do this is by using newtons method to aproximate this variable. I have mananged to make a somewhat functional differentiation function but it might be too difficult to make it work on all mathematical functions at my current level. i either need a way to apply the lim function or use a library. The attatched image shows my current method
Does anyone know how to make this work or if there is a library that i can use or take inspiration from?
This really does not look like a godot question. You might have better luck on some math forum I think. Translating the algorithm once you have it into whatever language shouldn’t be too hard.
If you get a C# version of Godot you might be able to use one of its libraries. I imagine the choice there is wider than it is with GDScript.
Then, is this even possible for an arbitrary function?
On all mathematical functions? You’re assuming all mathematical functions are even differentiable. And that all the given functions are real-valued.
I’d take a step back and ask why you need to do this and what you’re trying to achieve with it; as someone with a BS in Physics (aka all the BS needed for a BS in Math, too) and looking up the formula, Newton’s Method isn’t a generic “solve everything” problem. It requires you to have an idea of how close you want to get to a desired solution and a lot of general “feels about right” rather than “mathematically precise and solved” stuff; i.e., you need knowledge around the equation and solution you’re going for, rather than arbitrarily throwing stuff into it.
Are you trying to make a program that does actual math itself, or is this trying to solve something specific? Depending on your answer, you may get help here, or you may be doing something way over most peoples heads.