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 8964327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:33:46+00:00 2026-06-15T16:33:46+00:00

According to the SciPy documentation , it is possible to minimize functions with multiple

  • 0

According to the SciPy documentation, it is possible to minimize functions with multiple variables, yet it doesn’t say how to optimize such functions.

from scipy.optimize import minimize
from math import *

def f(c):
  return sqrt((sin(pi/2) + sin(0) + sin(c) - 2)**2 + (cos(pi/2) + cos(0) + cos(c) - 1)**2)

print(minimize(f, 3.14/2 + 3.14/7))

The above code try to minimize the function f, but for my task I need to minimize with respect to three variables.

Simply introducing a second argument and adjusting minimize accordingly yields an error:

TypeError: f() takes exactly 2 arguments (1 given)

How does minimize work when minimizing with multiple variables?

  • 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-15T16:33:47+00:00Added an answer on June 15, 2026 at 4:33 pm

    Pack the multiple variables into a single array:

    import scipy.optimize as optimize
    
    def f(params):
        # print(params)  # <-- you'll see that params is a NumPy array
        a, b, c = params # <-- for readability you may wish to assign names to the component variables
        return a**2 + b**2 + c**2
    
    initial_guess = [1, 1, 1]
    result = optimize.minimize(f, initial_guess)
    if result.success:
        fitted_params = result.x
        print(fitted_params)
    else:
        raise ValueError(result.message)
    

    yields

    [ -1.66705302e-08  -1.66705302e-08  -1.66705302e-08]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

according to netbeans documentation to check out from svn: Checking out Files from a
According to this question and the documentation of attr_readonly the following should be possible:
According to Hibernate documentation : After observing that arrays cannot be lazy , you
Given the following Markov Matrix: import numpy, scipy.linalg A = numpy.array([[0.9, 0.1],[0.15, 0.85]]) The
According to the Quartz 2's documentation RequestsRecovery - if a job requests recovery, and
According to everything I've read, Firefox 3.5+ supports localStorage. And yet I'm seeing the
According to the Ruby Set class's documentation, == Returns true if two sets are
How do I raise a scipy.sparse matrix to a power, element-wise? numpy.power should, according
According to the official documentation , the KeyDown event on a Windows Forms control
According to this article from Herb Sutter, one should always pick Class Specializing over

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.