Handmade Hero » Forums » Code » Day 365 - math solving software
mmozeiko
Mārtiņš Možeiko
1281 posts
1 project
#10948 Day 365 - math solving software
2 months, 1 week ago Edited by Mārtiņš Možeiko on Feb. 20, 2017, 7:54 p.m.

I watching this episode now and want to address Casey's complaints about math solving software. I can recommend using SageMath open-source software for that. No need to pay hundreds of dollars for expensive math packages if all you want is to solve simple equations. You can download it for using offline, but note that it is pretty big, because it is built on top of other open-source software. Another option is to use its online version which might be slow, because they offer it for free.

In my previous job our researchers did a lot of work with SageMath mostly focused on number theory for crypto stuff.

As for our ray intersection solution, you can enter following program and press "Run" button to execute it:
1
2
3
4
5
6
var('pax,pay,rax,ray,pbx,pby,rbx,rby,ta,tb')

eq1 = pax + ta*rax == pbx + tb*rbx
eq2 = pay + ta*ray == pby + tb*rby

solve([eq1,eq2],[ta,tb])

Pretty simple. And this is how the result will look like: https://cloud.sagemath.com/projec...b7/files/2017-02-19-214708.sagews
1
2
[[ta == -((pay - pby)*rbx - pax*rby + pbx*rby)/(ray*rbx - rax*rby),
  tb == -((pay - pby)*rax - pax*ray + pbx*ray)/(ray*rbx - rax*rby)]]

I believe SageMath uses Maxima software for solving this, so you might be able to install only Maxima, instead of whole SageMath if you care about installing something smaller.
people
39 posts
#10949 Day 365 - math solving software
2 months, 1 week ago Edited by people on Feb. 20, 2017, 8:28 a.m. Reason: program name fixup

Can confirm that maxima works for this, even though it's lispy it was the lightest weight program I could find that actually worked for symbolic equation transformation. I used xmaxima so that I could use the arrow keys to move around and retrieve past commands with the up arrow, for some reason the commandline version doesn't support this.
cmuratori
Casey Muratori
799 posts
1 project

Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.

#10989 Day 365 - math solving software
2 months ago

This is really interesting Martins... I will check it out! Maybe we can use it on stream...

Thanks,
- Casey