THanks for your comments, I've already done this in csharp. Simultaenous equations are very very complicated in computing and I believe beyond the capacity of mIRC scripting language. I have a multiple solution simultaneous equation solver if you're interested. This script also does quadratics and gives all solutions to them. Factorisation is possible but unfortunately don't have time to implement them into mIRC though have done all these things in csharp. You're welcome to edit the script how you wish though :)
Ahh right the backslashes :)
Thanks mate, all fixed. All done.
I\'ve updated the code one last time again :P
Thanks a bunch for all your help, good luck with perl. I moved from mIRC to C# because I never used mIRC for chatting or whatever, just for scripting. What made you choose to learn perl out of all the languages out there?
Also cheers for the links, I\'ll check them out. There\'s one more thing I would like to add to the $trans code which is to do ) --> )* but I\'m going to try to do that myself following your links ;) It\'s a really simple one I know :P
Merry Christmas
Dude thankyou so much! Updated n done. It\'s pretty much finished now :)(unless there are any more unwanted requests :P). No but seriously I don\'t know what else to add to it now, it works exactly as it should.
Btw, where did you learn your regsubex stuff really well? I would love to learn it, it\'s incredibily useful.
TropNul, I have found another bug in the parser, and remembered the pain reason I used stript in the first place, it was to calculate what was in the bracket before the function.
Eg if you try to solve for sin(2x) = 1, it won\'t work. stript would take sin(2*45) = 1 or whatever x was and calculate that to be 90. Is there anyway to incorporate that into your current parser (as well as supporting negatives)? Sorry for all the trouble!
Hey TropNul I\'m extremely grateful for all your help! You\'re code works well, except you\'re right, theres a bug. But I don\'t think it\'s because of what you said, I spent an hour or so trying to figure out what it was because it was very confusing. I would try to solve sin(x)=90 (which should return $false) and it would always return -2. It would return false under the old parser and even through all the checks to make sure the answer was legit it still always returned -2. It turned out that the parser couldn\'t support negative numbers with the functions, so sin(-2) wouldn\'t work. I\'m not quite sure but all I need to add is a -? somewhere in the regsubex line? I\'ve also given them different names so that shouldn\'t be a problem.
@Korvin, thanks for the feedback :) However it\'s impossible to add another variable such as Y, this is because you can only solve 1 variable per equation. eg if you consider y + x = 1. This has infinite number of solutions. This primarily solves any single equation. To solve simultaneous equations its infinitely more complicated. I have done it in C# but I think it\'s pretty much close to impossible in mIRC.
You could still solve for any variable in y=mx + c. If you know any 3 values and you are left with a fourth variable.
Wow thanks a lot! I added the code (under the trans alias) and you in the credits :)
Updated it guys.
Unfortunately I found another bug, if you have more than one function in the code, the solver doesn\'t work. So if you try to solve (sinx)(cosx)=0.2 no luck. I rooted the problem to be the with parser, after it sorts out the first function, it doesn\'t continue to the next one, it just stops.
The parser does this: $parser(sin(30)-3.4) returns 0.5-3.4 and then you can put that into $calc. However if you do (sin(30)+sin(30)-3.4), it returns 0.5+0-3.4. I really have no idea how to solve it. the stript function doesn\'t need any editing, it\'s just the regsubex of the parser, but I have no idea how to do it, I know next to nothing about regex now.
alias parser return $regsubex($regsubex($1,/(?<=sin|asin|acos|atan|cos|tan|log|sqrt)(\\\\d+)/g,(\\\\t)),/((?:sin|asin|acos|atan|cos|tan|log|sqrt).+?\\\\051)/g,$($ $+ $stript(\\\\t,1) $+ $chr(40) $+ $stript(\\\\t) $+ $chr(41) $+ .deg,2)).
It\'s not that important anyway, but just would be nice to have a complete solver. Thanks a lot for before though TropNul :)
Thanks for feedback guys :)
However I need some help with a regsubex expression, I coded this over 6 months ago and only learnt regex over the weekend especially for this. I have forgotton it all...
I need it so that if there is a letter before an x, the x gets replaced to (x). Eg, sinx becomes sin(x) and cosx becomes cos(x) etc. I\'m not sure if this is possible but if xx could be (x)(x) as well?
Could anyone help me with this at all? I want to just do $solve(sinx = 0.23) without having to do sin(x). Cheers
Really? I get 4x = 20 returns 5. Ok I\'ve replaced the code with the one I have exactly. I then deleted my code and pasted the one on here and it still gave me 5. So the one uploaded is definitely the right one now. Sorry about the mix up :)
ty for testing it though
TropNul I have added comments to my code to how it works. If you need anything else clearing up just let me know.
Haha yeah, I uploaded a dodgy version, sorry guys, updated and fixed :)
TropNul I\'ll try to add comments later on today or by tomorrow if I get time.
However I need some help with a regsubex expression, I coded this over 6 months ago and only learnt regex over the weekend especially for this. I have forgotton it all...
I need it so that if there is a letter before an x, the x gets replaced to (x). Eg, sinx becomes sin(x) and cosx becomes cos(x) etc. I\'m not sure if this is possible but if xx could be (x)(x) as well?
Note: the log function in mIRC seems to be bugged. Rather than being the standard base 10, it works at base 2.718281306 which is really weird. Anyone know how to get base 10 in mIRC? For this reason the log solve function is acting very strangely. It was base 10 in previous versions of mIRC..
Thanks for the feedback guys, Rebellious, I\'ve tested all the examples and all the 4x\'s and they all work. Not sure why they don\'t with yours. Would be greatful if anyone else can test it? Thanks
$solve(4x*2=20) returns 2.5. I\'ve made the parser include things like 4x. Maybe I uploaded a dodgy version version I\'ll check.
thanks a lot,
I would just like to point out that it\'s different from all other solvers that it finds all the solutions for all quadratics and cubics and up to whatever, including trig functions as well. Thanks mountaindew, this is my first snippet I\'ve submitted so I would really like constructive criticism if you have any. :)
Yes it can do algebra, it solve much more complicated equations than this. x is currently the only variable, I was going to add $solve(,) and then it would solve for that variable, but it seemed a bit pointless. If you think it would be a lot better than I\'ll do it.
I would like to know how I can increase the score of 6, what is there to improve? Would really appreciate any tips you all have. Thanks