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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:00:38+00:00 2026-06-03T13:00:38+00:00

I seem to be getting an error when I use the root-finder in scipy.

  • 0

I seem to be getting an error when I use the root-finder in scipy. I was wondering if anyone could point out what I’m doing wrong.
The function I’m finding the root of is just an easy example, and not particularly important.

If I run this code with scipy 0.9.0:

import numpy as np
from scipy.optimize import fsolve

tmpFunc = lambda xIn: (xIn[0]-4)**2 + (xIn[1]-5)**2 + (xIn[2]-7)**3

x0 = [3,4,5]
xFinal = fsolve(tmpFunc, x0 )

print xFinal

I get the following error message:

Traceback (most recent call last):
  File "tmpStack.py", line 7, in <module>
    xFinal = fsolve(tmpFunc, x0 )
  File "/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py", line 115, in fsolve
    _check_func('fsolve', 'func', func, x0, args, n, (n,))
  File "/usr/lib/python2.7/dist-packages/scipy/optimize/minpack.py", line 26, in _check_func
    raise TypeError(msg)
TypeError: fsolve: there is a mismatch between the input and output shape of the 'func' argument '<lambda>'.
  • 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-03T13:00:39+00:00Added an answer on June 3, 2026 at 1:00 pm

    Well it looks like I was trying to use this routine incorrectly. This routine requires the same number of equations and variables vs. the one equation with three variables I gave it. So if the input to the function to be minimized is a 3-D array the output should be a 3-D array. This code works:

    import numpy as np
    from scipy.optimize import fsolve
    
    tmpFunc = lambda xIn: np.array( [(xIn[0]-4)**2 + xIn[1], (xIn[1]-5)**2 - xIn[2]) \
    , (xIn[2]-7)**3 + xIn[0] ] )
    
    x0 = [3,4,5]
    xFinal = fsolve(tmpFunc, x0 )
    
    print xFinal
    

    Which represents solving three equations simultaneously.

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

Sidebar

Related Questions

I'm getting the following error message and I can't seem to figure out the
I cannot seem to figure out I am getting the following error in IE
Seem to be getting an error but can't figure out how to drill down
Does anyone know why I keep getting this error below? I can't seem to
I seem to be getting the above error when trying to make a callable
This may seem like a simple question but i am getting an error when
This might seem ridiculously simple, but I've been getting all kinds of error depending
I am getting this error: The type or namespace name 'AutoMapper' could not be
I'm new to PHP and I seem to be doing something wrong. On one
I'm trying to use the Seq.generate_using function but unfortunately, I don't seem to be

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.