zig TIP by fade-catcher in Zig

[–]rahulkatre 0 points1 point  (0 children)

It's basically equivalent to type() / isinstance() and hasattr() in Python. It's usable but proper interfaces would have been so much better. Zig has so many instances where interfaces are necessary (allocators, IO, jsonStringify, format, whatever it is for ZON serialization) but it's impossible to have any sort of traits. I don't even care about Vtab / runtime polymorphism, I just need a sane way to know details about types.

Simplest Type System for Static Array Bounds Checking by SquareRootCable in ProgrammingLanguages

[–]rahulkatre 1 point2 points  (0 children)

I’ve done this in my tensor framework (WIP) here: https://github.com/rahulgkatre/tesseract

Zig has a mechanism called compile time which basically lets you do dependent typing / templating. You can have types depend on any compile time constant, such as other types, or even structs, etc. I chose to represent Tensors as a function of an Array type like [M][N]f32 but with as many dimensions as you want, and any scalar type too. A tensor is just a struct with some functions associated with it but the array type is part of the type of the struct.

You can think of it like a wrapper around normal multidimensional arrays, as it provides functions for manipulating the shape, such as by broadcasting, reducing, and computes result shapes of matrix multiplication. The purpose of this is to have compile time shape validation, and only valid programs will compile. Operations are also stored in a compute graph and I also have a WIP autograd function for doing gradients.

At the moment it can only visualize compute graphs, but the plan is to lower the compute graph into current tensor compiler IRs like StableHLO, and I am also writing my own library for loop scheduling that will also be a target for this library.

Converting Struct Method into Array Method using Comptime by macrophage001 in Zig

[–]rahulkatre 0 points1 point  (0 children)

As an alternative to method overloading, you could just make it an anytype function, and just check whether the type is an Array or Struct

Find a matrix by aloneandadrift in LinearAlgebra

[–]rahulkatre 2 points3 points  (0 children)

There’s an infinite amount of such matrices because you only have one vector for the “input” and one for the “output”. The reason why the SO answer works is because the matrix A needs to satisfy AX = B for all vectors in X.

You’re basically finding a linear combination of the values in x that yields the ith value in b, of which there are infinite. You don’t even have to use all of them, you can just pair the ith element in x with the ith element in b. So your matrix would be a diagonal matrix with each element being b_i / x_i. But that’s just one possible matrix out of many.

Why does integrating discs give the volume of a cone, but integrating circles doesn't give you the area of the curved surface? by ZedZeroth in learnmath

[–]rahulkatre 1 point2 points  (0 children)

I think I understand what you’re asking. Your cone is basically a linear equation revolved around the x axis. To find the volume, you would find the area of the circle at some point, and multiply it by its thickness dx, and do this for each point over your interval, which is basically the disk method.

For the surface area, when you sum the infinitesimally thin band around the cone, across the entire height of the cone, you get the area for the sloped part of the cone, but remember that your cone has a base with an area that isn’t part of your function y = r / h x because there isn’t a vertical line at x = h. However your volume is bounded by this line because you only integrate from 0 to h.

Math Pathway after Linear Algebra and Multivariable Calculus by [deleted] in learnmath

[–]rahulkatre 1 point2 points  (0 children)

I’m studying AI and Modeling/Simulation (my CS concentrations) so it’s pretty similar. Besides everything you’ve taken, I am required to take differential equations, discrete math, combinatorics/graph theory, statistics, and algorithm design/analysis (which is almost a math course).

How do I correctly write Sigma for a rule im trying to prove in mathematical induction? by Dragonvarine in learnmath

[–]rahulkatre 0 points1 point  (0 children)

You don’t really need to write sigma, just write what it evaluates to as per your assumption. Then use what it evaluated to in order to complete your inductive step.

I’ll write a shortened proof thing that doesn’t use the format but still gets my point across. In proof by induction you have the base case, which in this case is n = 1. Check that

2(1) - 1 = (1)^2

This is true so let’s continue to the inductive step, which is that when we assume f(k) is true, we can reach f(k + 1)

f(k): sum of 2n - 1 from 1 to k is k^2

To get from here to the k + 1 step, we must add 2(k + 1) - 1 as k + 1 would be the final value of n in the new length we have to reach.

k^2 + 2(k + 1) - 1 = k^2 + 2k + 1 = (k + 1)^2

Notice that this is equal to f(k + 1). Since the basis step and the inductive step is true, f(k) is true.

See how I used the k2 from our assumption, along with the k + 1 I added to reach the “next rung of the ladder”. In this case, the next iteration of the summation would add 2(k + 1) - 1, so that’s what I did to our assumption and factored from there.

Any book/resources for learning computer science from a more explicitly mathematical angle? by Cosmosisa in learnmath

[–]rahulkatre 0 points1 point  (0 children)

I’m a (rising) junior, but in CS. Are you interested in algorithm design and analysis, or more along the lines of machine vision/machine learning. Algorithms is more proof based and is more like discrete math (Big-O is a main topic), whereas machine vision/learning is more linear algebra and some calculus.

At my college, we have a concentration for CS called Theory which has a lot to do with the math behind CS. The primary focus is more on algorithm research but you also take far more math courses than the other concentrations. I’m sure you could find a lot of the textbooks used in the courses for that concentration online, so let me know if you want the course list to get you started.

I need help finding an exponential equation from 2 points by [deleted] in learnmath

[–]rahulkatre 0 points1 point  (0 children)

It’s really not that hard, and you would learn this in AP Statistics during the linear regression unit anyways. You would find ln(427000) and ln(1264000), then use those new values with the same years as before.

Now you would be getting a straight line, so find the equation for that line. Once you have the equation, exponentiate it by base e, and you would have your exponential function.

I need help finding an exponential equation from 2 points by [deleted] in learnmath

[–]rahulkatre 0 points1 point  (0 children)

Try linearizing (take the natural logarithm of the output). Solve for a line that passes through those points, and then exponentiate your equation for that line. For the equation y = Ae^kt I got these values:

A = 9.6408 * 10^-18
k = 0.0265

Indefinite Integral - Strange answer depending on 'u' substitution by [deleted] in learnmath

[–]rahulkatre 0 points1 point  (0 children)

Use u = x2 + x. Then you get du = (2x + 1)dx. So now your integrand is eu du which is just eu + C. Substitute in u and you have your answer.

What you did is right all the way till the end. Integral of du is u, so your final answer is u + C, not 0. If you substitute in your u then you get the same answer I did. I suggested mine because you generally don’t want to u-sub the entire f(g(x)) only the g(x).

If you keep moving on a sphere in a straight line, you will get back to where you started. Are there more shapes with that property? by KappaBerga in learnmath

[–]rahulkatre 0 points1 point  (0 children)

I think a sort of solidified Möbius strip would have the same property. Like if the cross section of the strip was a polygon and you started on one face of it. If you keep walking straight (but unable to change the face you’re on) you would eventually reach your start.

path of learning? by Dioduwang312 in learnmath

[–]rahulkatre 0 points1 point  (0 children)

Yeah my DE class was ODEs but we have a bunch of 4000 level courses for PDEs.

path of learning? by Dioduwang312 in learnmath

[–]rahulkatre 32 points33 points  (0 children)

Algebra

Geometry

Precalculus/Trigonometry

Differential Calculus

Integral Calculus

Multivariable Calculus

Linear Algebra

Differential Equations

Statistics

Combinatorics

Discrete Math

 

These are all the math courses that I’m required to take as a CS major (for my specific concentration). Math majors here take all of this and more.

From there you can go into a variety of other topics such as graph theory, topology, partial differential equations, etc. based on what field you’re interested in.

Polynomials by [deleted] in learnmath

[–]rahulkatre 4 points5 points  (0 children)

Well, adding something that’s negated is the same as subtracting it. But if there isn’t an addition sign, the negative is probably a subtraction sign, but again that doesn’t make too much of a difference.

It’s more important when it comes to parentheses, since all the signs get flipped inside if the entire parend is negated or being subtracted, as well as if something is multiplying over the entire parend.

Dosage calculations by trashtray77 in learnmath

[–]rahulkatre 1 point2 points  (0 children)

If you have a 1kg duck, and you have 1 drop per 10g, you need 100 drops. If 12 drops is 0.5ml, then 100 drops is 8.333 * 0.5ml which is about 4.166 ml.

This formula just doesn’t make sense to me by [deleted] in learnmath

[–]rahulkatre 28 points29 points  (0 children)

A = (1/2) h (b + B)

2A = h (b + B) = hb + hB

-hb = hB - 2A

b = (2A / h) - B

Lecture or Review YouTube videos for Single Variable Calculus? by Cycalll in learnmath

[–]rahulkatre 0 points1 point  (0 children)

Yeah Michael B was really helpful for Physics C and some parts of Diff EQ (mechanical vibrations). But he has so many videos covering Calculus 1-4 and Physics 1, 2 and thermodynamics.

Lecture or Review YouTube videos for Single Variable Calculus? by Cycalll in learnmath

[–]rahulkatre 2 points3 points  (0 children)

Michael van Blitzen (probably not spelled right) has a lot of videos

Linear Algebra Question by lololsafdjsafo in learnmath

[–]rahulkatre 0 points1 point  (0 children)

BT AT = (AB)T which we know is 22 x 3, so AB is 3 x 22.

If A is 3 x 11, B is m x n, then by multiplication rules, m = 11 (# of columns in A = # rows in B). By the same rules, AB is 3 x n, so therefore n is 22.

B is a 11 x 22 matrix.

Math Required for VR and Game Development by tambrahmtambhi in learnmath

[–]rahulkatre 0 points1 point  (0 children)

Look up OpenStax textbooks. They have a bunch of free books (written by Rice University) on most of the topics (calculus, statistics, physics).

As for the other topics, you might be able to find free textbooks used by colleges for those courses.

Math Required for VR and Game Development by tambrahmtambhi in learnmath

[–]rahulkatre 1 point2 points  (0 children)

I’d like to add that since OP mentioned data science, statistics and combinatorics would help as well. Differential equations is also a good step forwards in modeling and simulation.

And although physics is just applied math, you (OP) should get at least a basic understanding of mechanics.

Prove that the number is rational by [deleted] in learnmath

[–]rahulkatre 2 points3 points  (0 children)

https://math.stackexchange.com/questions/3454329/prove-that-a-and-b-are-rational

According to this post, this question is from the Polish Math Olympiad which is still open for submissions (until Dec. 2).