Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6214923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:57:43+00:00 2026-05-24T06:57:43+00:00

I’m a self taught developer (about 3 years now), and I want to improve

  • 0

I’m a self taught developer (about 3 years now), and I want to improve my development skills by learning how to write math equations into code.

It’s something that continues to bother me, I see many books and articles accompanied by glowing math equations, which genuinely look really interesting. I can read parts of them (multiplication, division, decimals, sigma, variables) but I have troubles when going off to implement them in code.

For example, how would one go about getting started to understand these kind of equations: http://en.wikipedia.org/wiki/Manhattan_distance and going off to write them in code?

Any recommendations of places to get started? Is it not the code issue, but lack of fundamental math understanding? I’m willing to listen and read, since I feel this ability is really important for a developer to have.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:57:44+00:00Added an answer on May 24, 2026 at 6:57 am
    I can read parts of them (multiplication, division, decimals, sigma, variables)
    but I have troubles when going off to implement them in code.
    

    Well, the crucial thing I guess is that you need to be able to break down the formula you’re interested into its component pieces, and if you can understand how to code those pieces individually, you are in a position to then glue them back together in the form of code.

    Let us take as an example the Manhattan distance between two points in two-dimensional space with a fixed (x, y) coordinate system. You want to write a function that will take two points and give you the Manhattan distance between those points. Let’s forgo the use of object-oriented concepts here and just assume that you have four input variables:

    x1, the x-coordinate of the first point
    y1, the y-coordinate of the first point
    x2, the x-coordinate of the second point
    y2, the y-coordinate of the second point
    

    So our function will be like

    function mdistance (x1, y1, x2, y2) {
        ???
    }
    

    What should the insides of the function (the function body) look like? Now we inspect the mathematical formula that we want to rewrite as code. Wikipedia’s version (under “Formal description”) treats the case of arbitrary dimensions – we can do this too, but for now we’re considering the 2-dimensional case only. So their n is 2 as far as we are concerned, and we want to compute |x1 - x2| + |y1 - y2|. That is the result of losing the sigma notation in favour of an expression describing a sum with two summands. But we still haven’t worked out how |a - b| can be expressed in computer code.

    So now the function could look like

    function mdistance (x1, y1, x2, y2) {
        return bars(x1, x2) + bars(y1, y2);
    }
    

    And that, as far as it goes, is fine, because we’ve isolated the thing we don’t yet know how to do as another function, called bars(). Once we define bars(), the function mdistance() will work just fine, assuming of course that our definition for bars() is sensible. So the problem is just to define bars(). By breaking the problem into its component parts, we’ve made our job easier, because we just have to make each part work – which is simpler than making everything work at once.

    So how should bars() be defined? Well, |a - b| just expresses the idea “the absolute value of a - b“. PHP has a built-in function for the absolute value of a real number; it is abs(). So we define bars() like this:

    function bars (a, b) {
        return abs(a - b);
    }
    

    Now our function mdistance() will work just the way we want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.