Skip to content

Instantly share code, notes, and snippets.

@dillmo
Last active August 29, 2015 13:56

Revisions

  1. dillmo revised this gist Feb 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion random_function_generator.cpp
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    /* Copyright(c) 2014 dillmo
    * Licensed under the MIT License (http://opensource.org/licenses/MIT)
    *
    * A program I made for algebra class. Running this program outputs several
    * A program I made for algebra class. Running this program outputs several
    * functions with their respective parent functions. To take advantage of this
    * program for studying, it is recommended you run it, then graph the output
    * for whichever type of function you are studying.
  2. dillmo revised this gist Feb 7, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion random_function_generator.cpp
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    /* Copyright(c) dillmo 2014
    /* Copyright(c) 2014 dillmo
    * Licensed under the MIT License (http://opensource.org/licenses/MIT)
    *
    * A program I made for algebra class. Running this program outputs several
  3. dillmo revised this gist Feb 7, 2014. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions random_function_generator.cpp
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,12 @@
    /* Copyright(c) dillmo 2014
    * Licensed under the MIT License (http://opensource.org/licenses/MIT)
    *
    * A program I made for algebra class. Running this program outputs several
    * functions with their respective parent functions. To take advantage of this
    * program for studying, it is recommended you run it, then graph the output
    * for whichever type of function you are studying.
    */

    #include <iostream>
    #include <cstdlib>
    #include <ctime>
  4. dillmo revised this gist Feb 7, 2014. 1 changed file with 0 additions and 116 deletions.
    116 changes: 0 additions & 116 deletions gistfile1.cpp
    Original file line number Diff line number Diff line change
    @@ -1,116 +0,0 @@
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    using namespace std;

    int main() {
    int a, h, k, b, c, d;

    srand (time(NULL));

    cout << "Parent function: y = a" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    a = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << '\n';
    }

    cout << '\n' << "Parent function: y = x" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);

    cout << "Trans " << i << ": y = " << a << "x" << '\n';
    }

    cout << '\n' << "Parent function: y = |x|" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "|x + (" << -h << ")| + (" << k
    << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^2" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "(x + (" << -h << "))^2 + (" << k
    << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = sqrt(x)" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << " * sqrt(x + (" << h << ")) + ("
    << k << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^3" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    b = rand() % 20 - 10;
    c = rand() % 20 - 10;
    d = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "x^3 + (" << b << ")x^2 + (" << c
    << ")x + (" << d << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^(1/3)" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "(x + (" << -h << "))^(1/3) + ("
    << k << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^x" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while((a == 0) || (a == 1));
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "^(x + (" << -h << ")) + (" << k
    << ")" << '\n';
    }

    return 0;
    }
  5. dillmo revised this gist Feb 7, 2014. 1 changed file with 124 additions and 0 deletions.
    124 changes: 124 additions & 0 deletions random_function_generator.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,124 @@
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    using namespace std;

    int main() {
    int a, h, k, b, c, d;

    srand (time(NULL));

    // Constant function
    cout << "Parent function: y = a" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    a = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << '\n';
    }

    // Linear function
    cout << '\n' << "Parent function: y = x" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);

    cout << "Trans " << i << ": y = " << a << "x" << '\n';
    }

    // Absolute value function
    cout << '\n' << "Parent function: y = |x|" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "|x + (" << -h << ")| + (" << k
    << ")" << '\n';
    }

    // Quadratic function
    cout << '\n' << "Parent function: y = x^2" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "(x + (" << -h << "))^2 + (" << k
    << ")" << '\n';
    }

    // Square root function
    cout << '\n' << "Parent function: y = sqrt(x)" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << " * sqrt(x + (" << h << ")) + ("
    << k << ")" << '\n';
    }

    // Cubic function
    cout << '\n' << "Parent function: y = x^3" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    b = rand() % 20 - 10;
    c = rand() % 20 - 10;
    d = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "x^3 + (" << b << ")x^2 + (" << c
    << ")x + (" << d << ")" << '\n';
    }

    // Cube root function
    cout << '\n' << "Parent function: y = x^(1/3)" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "(x + (" << -h << "))^(1/3) + ("
    << k << ")" << '\n';
    }

    // Exponential function
    cout << '\n' << "Parent function: y = a^x" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while((a == 0) || (a == 1));
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "^(x + (" << -h << ")) + (" << k
    << ")" << '\n';
    }

    return 0;
    }
  6. dillmo revised this gist Feb 7, 2014. 1 changed file with 13 additions and 7 deletions.
    20 changes: 13 additions & 7 deletions gistfile1.cpp
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,8 @@ int main() {
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "|x + (" << -h << ")| + (" << k << ")" << '\n';
    cout << "Trans " << i << ": y = " << a << "|x + (" << -h << ")| + (" << k
    << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^2" << '\n';
    @@ -50,7 +51,8 @@ int main() {
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "(x + (" << -h << "))^2 + (" << k << ")" << '\n';
    cout << "Trans " << i << ": y = " << a << "(x + (" << -h << "))^2 + (" << k
    << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = sqrt(x)" << '\n';
    @@ -63,7 +65,8 @@ int main() {
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << " * sqrt(x + (" << h << ")) + (" << k << ")" << '\n';
    cout << "Trans " << i << ": y = " << a << " * sqrt(x + (" << h << ")) + ("
    << k << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^3" << '\n';
    @@ -77,7 +80,8 @@ int main() {
    c = rand() % 20 - 10;
    d = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "x^3 + (" << b << ")x^2 + (" << c << ")x + (" << d << ")" << '\n';
    cout << "Trans " << i << ": y = " << a << "x^3 + (" << b << ")x^2 + (" << c
    << ")x + (" << d << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^(1/3)" << '\n';
    @@ -90,7 +94,8 @@ int main() {
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "(x + (" << -h << "))^(1/3) + (" << k << ")" << '\n';
    cout << "Trans " << i << ": y = " << a << "(x + (" << -h << "))^(1/3) + ("
    << k << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^x" << '\n';
    @@ -103,8 +108,9 @@ int main() {
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "^(x + (" << -h << ")) + (" << k << ")" << '\n';
    cout << "Trans " << i << ": y = " << a << "^(x + (" << -h << ")) + (" << k
    << ")" << '\n';
    }

    return 0;
    }
    }
  7. dillmo revised this gist Feb 6, 2014. 1 changed file with 20 additions and 1 deletion.
    21 changes: 20 additions & 1 deletion gistfile1.cpp
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,26 @@ int main() {

    srand (time(NULL));

    cout << "Parent function: y = |x|" << '\n';
    cout << "Parent function: y = a" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    a = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << '\n';
    }

    cout << '\n' << "Parent function: y = x" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);

    cout << "Trans " << i << ": y = " << a << "x" << '\n';
    }

    cout << '\n' << "Parent function: y = |x|" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
  8. dillmo revised this gist Feb 6, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.cpp
    Original file line number Diff line number Diff line change
    @@ -80,7 +80,7 @@ int main() {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    } while((a == 0) || (a == 1));
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

  9. dillmo created this gist Feb 6, 2014.
    91 changes: 91 additions & 0 deletions gistfile1.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,91 @@
    #include <iostream>
    #include <cstdlib>
    #include <ctime>
    using namespace std;

    int main() {
    int a, h, k, b, c, d;

    srand (time(NULL));

    cout << "Parent function: y = |x|" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "|x + (" << -h << ")| + (" << k << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^2" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "(x + (" << -h << "))^2 + (" << k << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = sqrt(x)" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << " * sqrt(x + (" << h << ")) + (" << k << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^3" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    b = rand() % 20 - 10;
    c = rand() % 20 - 10;
    d = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "x^3 + (" << b << ")x^2 + (" << c << ")x + (" << d << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^(1/3)" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "(x + (" << -h << "))^(1/3) + (" << k << ")" << '\n';
    }

    cout << '\n' << "Parent function: y = x^x" << '\n';
    for(int i = 1; i <= 2; i++)
    {
    do
    {
    a = rand() % 20 - 10;
    } while(a == 0);
    h = rand() % 20 - 10;
    k = rand() % 20 - 10;

    cout << "Trans " << i << ": y = " << a << "^(x + (" << -h << ")) + (" << k << ")" << '\n';
    }

    return 0;
    }