Should computer programming take priority over math in the high school curriculum?

If we take a look at the world as we know it today, we can easily spot that technology has taken over our lives. It is so deeply intertwined with everything we do that it would be difficult and challenging to give up using it at all.

This, along with the popularity of some of the richest people on the planet, has created a collective wish: to try to be like them or even better. More and more children want to be computer scientists, to invent the next Facebook or Microsoft. And a legit question has appeared.

Should computer programming take priority over the math in the high school curriculum? If students want to learn more about computer science, should we make it a priority over other subjects? Should the high school math curriculum be changed? Let’s find out the answer to these questions.

Should computer science be made a priority over math?

The direct and clear answer to this question is no. Even though many students in high school would love to learn more about computer science, coding, and programming, this does not mean that it should be a priority over math.

Math anxiety is a real thing that is more and more present in our schools. And both students and their parents are trying to find solutions to cope with it easily. In this case, learning computer science might seem more attractive. It seems that it can help you build a nice future career, especially as there are a lot of resources you can access. But these subjects complement each other nicely.

Concepts you study in math will be useful in computer science too. Learning computer science without math will make it more difficult to evolve and build a solid knowledge base. Many high school math questions shed more light on some challenging computer science concepts, such as algorithms. No matter if you do online high school math, or you go to classes, what you learn during these hours will be of tremendous help.

However, learning computer science is just as important as learning mathematics. Let’s see why.

Having an Advantage

Considering the fact that technology is so deeply intertwined with our lifestyles, knowing how to use it is always a plus. But anyone knows how to use a smartphone or smartwatch as they are user-friendly. But what happens if you want to go beyond the traditional user interface? What happens if a nice idea strikes you, and you want to try it and see how it works?

Well, for this you need computer science knowledge. Which can be developed and improved during high school, with an equal emphasis on math too. Having at least the basic knowledge to get started in computer science or build your custom app can prove to be an advantage.

Computer Science Can Be Used to Teach Math

The best math apps for high school have a few modules that help you practice the easiest and most difficult math concepts equally. But sometimes, learning math can feel like a burden. As mentioned above, math anxiety is something common, and it can be triggered by a lot of factors. But what is important is that math just builds upon the previous year.

So, if you haven’t understood the math concepts taught earlier, it would be difficult to advance. Well, this is the case for many students. And computer science can be used to teach math. High school students are more attracted by new technologies, platforms, and apps to use and discover. And because computer science relies on math concepts, it can be used to teach math to students too.

Like this, students can understand the connection of math with real life too. A lot of them think that what they learn during math classes will not be useful later in life. Some even ask themselves how integrals, derivatives, or matrices help them. But if you understand that all these complex concepts are present in computer science in one way or another, learning them might be easier.

Final Words

Many students and people fail to understand that math is present in our everyday life. And as computer science is a much more appealing subject, many think about it taking priority over the math in the high school curriculum. Even though this might sound nice, these two subjects complement each other, and they should be given equal priority.

How do I do math operations using Spring EL?

As we know that the simplest value that can be expressed in the Spring EL is a literal value such as number. Furthermore, we can also do math operations using the Spring EL. The spring configuration below show you how can do math operations using the Spring Expression Language. These operations include:

  • Add operation (+)
  • Subtract operation (-)
  • Multiply operation (*)
  • Divide operations (/)
  • Modulo operation (%)
  • Power operation (^)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="" xmlns:xsi=""

    <bean id="myBean" class="org.kodejava.spring.core.el.MyBean">
        <property name="total" value="#{50 + 50}" />
        <property name="length" value="#{100 - 10}" />
        <property name="size" value="#{10 * 10}" />
        <property name="reminder" value="#{10 % 3}" />
        <property name="distance" value="#{1000 / 10}" />
        <property name="power" value="#{2 ^ 10}" />


The configuration above requires a bean / pojo called MyBean. It’s a simple class with some fields and getters and setters. Followed later by a simple class called SpELMathOperationDemo that demonstrate the Spring EL math operations.

package org.kodejava.spring.core.el;

public class MyBean {
    private int total;
    private int length;
    private int size;
    private float distance;
    private int reminder;
    private int power;

    public int getTotal() {
        return total;

    public void setTotal(int total) { = total;

    public int getLength() {
        return length;

    public void setLength(int length) {
        this.length = length;

    public int getSize() {
        return size;

    public void setSize(int size) {
        this.size = size;

    public float getDistance() {
        return distance;

    public void setDistance(float distance) {
        this.distance = distance;

    public int getReminder() {
        return reminder;

    public void setReminder(int reminder) {
        this.reminder = reminder;

    public int getPower() {
        return power;

    public void setPower(int power) {
        this.power = power;
package org.kodejava.spring.core.el;

import org.springframework.context.ApplicationContext;

public class SpELMathOperationDemo {
    public static void main(String[] args) {
        ApplicationContext context =
                new ClassPathXmlApplicationContext("spel-math-operation.xml");

        MyBean bean = (MyBean) context.getBean("myBean");
        System.out.println("bean.getTotal()    = " + bean.getTotal());
        System.out.println("bean.getLength()   = " + bean.getLength());
        System.out.println("bean.getSize()     = " + bean.getSize());
        System.out.println("bean.getReminder() = " + bean.getReminder());
        System.out.println("bean.getDistance() = " + bean.getDistance());
        System.out.println("bean.getPower()    = " + bean.getPower());

And these are the output printed out by the code snippet:

bean.getTotal()    = 100
bean.getLength()   = 90
bean.getSize()     = 100
bean.getReminder() = 1
bean.getDistance() = 100.0
bean.getPower()    = 1024

Maven Dependencies

    <!-- -->
    <!-- -->
    <!-- -->

Maven Central Maven Central Maven Central

How do I calculate the length of hypotenuse?

Hypot is a mathematical function defined to calculate the length of the hypotenuse of a right-angle triangle. It was designed to avoid errors arising due to limited-precision calculations performed on computers.

From: Wikipedia

The Math.hypot(double x, double y) return the sqrt(x2+ y2) without intermediate overflow or underflow. The result will be same with this calculation Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)).

package org.kodejava.math;

public class HypotExample {
    public static void main(String[] args) {
        double number1 = 3.0d;
        double number2 = 5.0d;

        // calculate square root of total value of
        // number1 ^ 2 + number2 ^ 2
        double sqr = Math.hypot(number1, number2);

        System.out.println("Total value = " +
                (Math.pow(number1, 2) + Math.pow(number2, 2)));
        System.out.println("Square root = " + sqr);

How do I calculate exponential function?

In mathematics, the exponential function is the function ex, where e is the number (approximately 2.718281828) such that the function ex equals its own derivative. The function f(x) = ex at the point x = 0 is equal to 1.

package org.kodejava.math;

public class ExponentExample {

    public static void main(String[] args) {
        double x = 0.0d;

        // calculates e raised to the power of x (e^x)
        double fx = Math.exp(x);

        // calculates e raised to the power of x minus 1 (e^x - 1)
        double fxm1 = Math.expm1(x);

        System.out.println("fx   = " + fx);
        System.out.println("fxm1 = " + fxm1);

How do I get the exponent of exponential function?

The exponential function is f(x) = ex. The Math.getExponent() method is used to get the x value of the given parameter, in which the parameter is a result of exponential function calculation.

package org.kodejava.math;

public class GetExponent {
    public static void main(String[] args) {
        double fx = 1.0d;
        float fx1 = 1.0f;

        int x = Math.getExponent(fx);
        System.out.println("Exponent  = " + x);

        // argument in float
        int xf = Math.getExponent(fx1);
        System.out.println("Exponent1 = " + xf);

How do I get signum function of a number?

The code below show you how to get the signum function of a number using the Math.signum() static method call. This method extracts the sign of a real number. If you have a number of x, the signum function of x is -1 if x < 0; 0 if x = 0 and 1 if x > 0.

package org.kodejava.math;

public class SignumExample {

    public static void main(String[] args) {
        Double zero = 0.0D;
        Double negative = -25.0D;
        Double positive = 15.0D;

        // Get the signum function of value of a number.
        // It returns:
        // * 0 if the value is zero.
        // * 1.0 if value is greater than zero.
        // * -1.0 if value is less than zero.
        double sign1 = Math.signum(zero);
        double sign2 = Math.signum(negative);
        double sign3 = Math.signum(positive);

        // For floating-point value
        float sign4 = Math.signum(zero.floatValue());
        float sign5 = Math.signum(negative.floatValue());
        float sign6 = Math.signum(positive.floatValue());

        System.out.println("In double:");
        System.out.println("Signum of " + zero + " is " + sign1);
        System.out.println("Signum of " + negative + " is " + sign2);
        System.out.println("Signum of " + positive + " is " + sign3);

        System.out.println("In float:");
        System.out.println("Signum of " + zero + " is " + sign4);
        System.out.println("Signum of " + negative + " is " + sign5);
        System.out.println("Signum of " + positive + " is " + sign6);

Here is the output of the program:

In double:
Signum of 0.0 is 0.0
Signum of -25.0 is -1.0
Signum of 15.0 is 1.0
In float:
Signum of 0.0 is 0.0
Signum of -25.0 is -1.0
Signum of 15.0 is 1.0

How do I raised a number to the power of n?

The static method Math.pow(double a, double b) can be used to raise the value specified in the a, the first argument, (the base), to the power of the value specified in b, the second argument, (the exponent). The exponent tells us how many times the base should be multiplied by itself. So, if I have the number of 5, and I want to raise it to the 3rd power, it means that I have to multiply 5 by itself for 3 times.

There are some special cases for the Math.pow() method, as you can read in the Javadocs, here four of them taken from the Javadocs:

  • If the second argument is positive or negative zero, then the result is 1.0.
  • If the second argument is 1.0, then the result is the same as the first argument.
  • If the second argument is NaN, then the result is NaN.
  • If the first argument is NaN and the second argument is nonzero, then the result is NaN.

You can read more detail about the Math.pow() method on the following Javadocs, Math.pow().

Let’s see a code snippet as an example:

package org.kodejava.math;

public class PowerExample {

    public static void main(String[] args) {
        double cubeRoot = 5d;

        // Get the cubed number of cube root
        // x cubed = x^3 (multiplication three times)
        double cubed = Math.pow(cubeRoot, 3);
        System.out.println(cubeRoot + " cubed is " + cubed);

        // Raised to zero
        System.out.println("Math.pow(2, 0): " + Math.pow(2, 0));

        // Raised to one
        System.out.println("Math.pow(2, 1): " + Math.pow(2, 1));

        // Raised to NaN
        System.out.println("Math.pow(2, Double.NaN): " + Math.pow(2, Double.NaN));

        // NaN raised to the nonzero exponent
        System.out.println("Math.pow(Double.NaN, 2): " + Math.pow(Double.NaN, 2));

Our program print the following output:

5.0 cubed is 125.0
Math.pow(2, 0): 1.0
Math.pow(2, 1): 2.0
Math.pow(2, Double.NaN): NaN
Math.pow(Double.NaN, 2): NaN

How do I calculate logarithm?

We can calculate logarithm using the Math.log10() and the Math.log() static method call.

package org.kodejava.math;

public class LogarithmExample {

    public static void main(String[] args) {
        double number1 = 1000.0d;

        // Get common logarithm
        double log10 = Math.log10(number1);
        System.out.println("Common logarithm of " + number1 + " = " + log10);

        // Get natural logarithm
        double loge = Math.log(number1);
        System.out.println("Natural logarithm of " + number1 + " = " + loge);

The output of the program is:

Common logarithm of 1000.0 = 3.0
Natural logarithm of 1000.0 = 6.907755278982137

How do I round a number?

The example below show you some methods of the Math class that can be used to round the value of a number. These methods are Math.ceil(), Math.floor() and Math.round().

package org.kodejava.math;

public class GetRoundedValueExample {

    public static void main(String[] args) {
        Double number = 1.5D;

        // Get the smallest value that is greater than or equal to the
        // argument and is equal to a mathematical integer
        double roundUp = Math.ceil(number);
        System.out.println("Result of rounding up of " + number + " = " + roundUp);

        // Get the largest value that is less than or equal to the
        // argument and is equal to a mathematical integer
        double roundDown = Math.floor(number);
        System.out.println("Result of rounding down of " + number + " = " + roundDown);

        // Get the closest long value to the argument
        long round1 = Math.round(number);
        System.out.println("Rounding result of " + number + " (in long) = " + round1);

        // Get the closest int value to the argument
        int round2 = Math.round(number.floatValue());
        System.out.println("Rounding result of " + number + " (in int) = " + round2);

Here are the result of the program:

Result of rounding up of 1.5 = 2.0
Result of rounding down of 1.5 = 1.0
Rounding result of 1.5 (in long) = 2
Rounding result of 1.5 (in int) = 2

How do I calculate cube root and square root of a number?

To calculate the cube root and the square root of a double value we can use the Math.cbrt(double a) and Math.sqrt(double a) static method call.

package org.kodejava.math;

public class CubeSquareRootExample {

    public static void main(String[] args) {
        double cube = 125.0d;
        double square = 100.0d;

        // Get the cube root of double value
        double cubeRoot = Math.cbrt(cube);
        System.out.println("Cube root of " + cube + " is " + cubeRoot);

        // Get the square root of double value
        double squareRoot = Math.sqrt(square);
        System.out.println("Square root of " + square + " is " + squareRoot);

This snippet will print the following output:

Cube root of 125.0 is 5.0
Square root of 100.0 is 10.0