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

  • SEARCH
  • Home
  • 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 9226277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:47:26+00:00 2026-06-18T04:47:26+00:00

I am looking for a way to add together multiple mathematical functions before assigning

  • 0

I am looking for a way to add together multiple mathematical functions before assigning the numerical values for the variables in the equations.
I am doing it this way because I need to optimize my code, and I want to assign different values to the variables each time. An example of what I am trying to do:

  1. f(x, y) = x + 2y

  2. g(x, y) = 3x - y

  3. adds f(x, y) + g(x, y) to get h(x, y), so f(x, y) + g(x, y) = h(x, y) = 4x + y

  4. Now that I have h(x, y), I need multiple values from h(x, y)

x = 4; y = 3, h(x, y) = 19
x = 1, y = 0, h(x, y) = 4

etc.

Is this possible? I was trying to create them as strings, add the strings, then remove the quotes to evaluate the sum but this did not work. I am trying to do my method this way because I want to optimize my code. It would help very much if I am able to create my final function before evaluating it (it would be h(x, y) in this case).

EDIT: I’m doing additions of (e ** (x + y)), so linear solutions using matrices don’t work :/

  • 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-06-18T04:47:28+00:00Added an answer on June 18, 2026 at 4:47 am

    SymPy can do this:

    import sympy as sym
    
    x, y = sym.symbols('xy')
    f = x + 2*y
    g = 3*x - y
    h = f + g
    

    This shows that SymPy has simplified the expression:

    print(h)
    # y + 4*x
    

    And this shows how you can evaluate h as a function of x and y:

    print(h.subs(dict(x=4, y=3)))
    # 19
    print(h.subs(dict(x=1, y=0)))
    # 4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for a way to add a couple of Simple XML objects together. The
I was looking for a way to add new elements to an an existing
I'm looking for a way to add an EventListener which will automatically removes itself
I'm looking for a way to add a value to price of configurable product
All, I am looking for a way to add an OCS presence icon the
I looking for a way to dynamicly add a filter to my statment without
Looking for a way to programatically, or otherwise, add a new instance of SQL
I'm looking for an easy way in Obj.C to do add a space between
I'm looking for a good way to add arbitrary properties to the objects in
I am looking for a script or a fast way of putting together a

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.