Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Find function error: Undefined variable

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
01:40 PM

10-15-2014
01:40 PM

Hello all,

I'm trying to us the find fuction to solve an exponetal equation. I think my problem with the first Find(A.c) is that the value its solving for is around 10^-17 and it wants to say it's zero but can't becaure the value isn't zero. The second Find(T.f) I think is simular, I still get an error if I set a value for A.co. Ihave aslo tried to do this problem with out units and I get the same error.

If anyone has any sugestions that would be great.

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
02:25 PM

10-15-2014
02:25 PM

The "undefined variable" error is the only error a solve block will ever yield - no matter what the real cause for failing may be. If you right click the error and chose "Trace error" you (sometimes) see whats really going on - no solution was found because you are working at the limits of the tolerance settings.

In your case you are dealing with rather big and also some very small numbers and especially when you work with units this very often throws a solve block off the track.

I wonder why you would use a solve block anyway, given that you can solve those equations directly very easy by hand (and if not you can use the symbolics solve - see at the top).

You may also use the symbolic solver for your specific task.

See attchment.

18 REPLIES 18

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
02:25 PM

10-15-2014
02:25 PM

The "undefined variable" error is the only error a solve block will ever yield - no matter what the real cause for failing may be. If you right click the error and chose "Trace error" you (sometimes) see whats really going on - no solution was found because you are working at the limits of the tolerance settings.

In your case you are dealing with rather big and also some very small numbers and especially when you work with units this very often throws a solve block off the track.

I wonder why you would use a solve block anyway, given that you can solve those equations directly very easy by hand (and if not you can use the symbolics solve - see at the top).

You may also use the symbolic solver for your specific task.

See attchment.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
02:42 PM

10-15-2014
02:42 PM

Re: Find function error: Undefined variable

Thanks, for the help. I was using the solve block encase I needed to solve for a diferent variable in the equation later.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
02:45 PM

10-15-2014
02:45 PM

Re: Find function error: Undefined variable

Kendall Cotton wrote:

Have a look at the way I have set my sheets up. They may work for you.

You constructed your solve blocks in a way to solve for one variable only.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
03:19 PM

10-15-2014
03:19 PM

Re: Find function error: Undefined variable

Making a direct equation works. I've never tried solving symbolically, that's why I didn't try that. Now I just need to figure out how to plot multiple if statement, and I'll be all good

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
03:21 PM

10-15-2014
03:21 PM

Re: Find function error: Undefined variable

Kendall Cotton wrote:

I'm glad you have found your solution. If you feel the initial query to this thread has been answered, I would recommend creating a new thread with the new query.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
02:31 PM

10-15-2014
02:31 PM

Re: Find function error: Undefined variable

Try solving symbolically. I have stripped the units for ease of understanding.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
02:42 PM

10-15-2014
02:42 PM

Re: Find function error: Undefined variable

Similar approach but included units. I have used the symbolic Find function while Werner has used the Symbolic Solve function.

At least you variation .

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
02:48 PM

10-15-2014
02:48 PM

Re: Find function error: Undefined variable

Mike Armstrong wrote:

Similar approach but included units. I have used the symbolic Find function while Werner has used the Symbolic Solve function.

At least you variation .

Best to solve this kind of equations without any "Find" or "solve" but using direct assigments - the equations are easy enough. And with real tough, complicated equations, Mathcad's symbolics unfortunately ever so often tends to fail

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
02:52 PM

10-15-2014
02:52 PM

Re: Find function error: Undefined variable

Werner Exinger wrote:

Mike Armstrong wrote:

Similar approach but included units. I have used the symbolic Find function while Werner has used the Symbolic Solve function.

At least you variation .

Best to solve this kind of equations without any "Find" or "solve" but using direct assigments - the equations are easy enough.And with real tough, complicated equations, Mathcad's symbolics unfortunately ever so often tends to fail

Fully agreed on.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
02:46 PM

10-15-2014
02:46 PM

Re: Find function error: Undefined variable

Mike Armstrong wrote:

Try solving symbolically. I have stripped the units for ease of understanding.

Without units the first solve block gets a solution numerically, too, without any modification whatsoever.

To make the second solve block work numerically, you have to provide a decent guess value and set CTOL way up to 10 (from the default 10^-3)!!

Adding units will increase the problem, though.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
02:52 PM

10-15-2014
02:52 PM

Re: Find function error: Undefined variable

Werner Exinger wrote:

Mike Armstrong wrote:

Try solving symbolically. I have stripped the units for ease of understanding.

Without units the first solve block gets a solution numerically, too, without any modification whatsoever.

To make the second solve block work numerically, you have to provide a decent guess value and set CTOL way up to 10 (from the default 10^-3)!!

Adding units will increase the problem, though.

Are you sure? Mine does not find a solution and I think you are missing T.i from first equation.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
03:00 PM

10-15-2014
03:00 PM

Re: Find function error: Undefined variable

Mike Armstrong wrote:

Werner Exinger wrote:

Mike Armstrong wrote:

Try solving symbolically. I have stripped the units for ease of understanding.

Without units the first solve block gets a solution numerically, too, without any modification whatsoever.

To make the second solve block work numerically, you have to provide a decent guess value and set CTOL way up to 10 (from the default 10^-3)!!

Adding units will increase the problem, though.

Are you sure? Mine does not find a solution and I think you are missing T.i from first equation.

You are right! T.i is missing because I used the sheet you posted and the variable is already missing there

With T.i in place we would have to set CTOL up to 10^2 to get a numerical solution.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
03:02 PM

10-15-2014
03:02 PM

Re: Find function error: Undefined variable

Werner Exinger wrote:

You are right! T.i is missing because I used the sheet you posted and the variable is already missing there

With T.i in place we would have to set CTOL up to 10^2 to get a numerical solution.

Oops. I must have deleted it by mistake in my first sheet. At least my second sheet is correct.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
03:04 PM

10-15-2014
03:04 PM

Re: Find function error: Undefined variable

Werner Exinger wrote:

With T.i in place we would have to set CTOL up to 10^2 to get a numerical solution.

I don't see the logic with having to change CTOL locally in the worksheet. Would it not be a better solution to have the numerically processor non-dependant, as with the symbolic processor?

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
03:21 PM

10-15-2014
03:21 PM

Re: Find function error: Undefined variable

Mike Armstrong wrote:

Werner Exinger wrote:

With T.i in place we would have to set CTOL up to 10^2 to get a numerical solution.

I don't see the logic with having to change CTOL locally in the worksheet. Would it not be a better solution to have the numerically processor non-dependant, as with the symbolic processor?

Guess thats a more subtle problem. The algorithms used by the symbolics may fail while the numeric approximation algorithms still yield a result. The problem here is the absolute tolerance value used while a relative tolerance value would be more preferable (but probably may lead to other problems).

A standard way out here is to use MinErr instead of Find. Don't know why I didn't thought of it in the first place - probably because my first thought was "why a solve block at all?".

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
03:24 PM

10-15-2014
03:24 PM

Re: Find function error: Undefined variable

Werner Exinger wrote:

Mike Armstrong wrote:

Werner Exinger wrote:

With T.i in place we would have to set CTOL up to 10^2 to get a numerical solution.

I don't see the logic with having to change CTOL locally in the worksheet. Would it not be a better solution to have the numerically processor non-dependant, as with the symbolic processor?

Guess thats a more subtle problem. The algorithms used by the symbolics may fail while the numeric approximation algorithms still yield a result. The problem here is the absolute tolerance value used while a relative tolerance value would be more preferable (but probably may lead to other problems).

Right I get you. So it is good practice you try and solve numerically before trying symbolically?

Werner Exinger wrote:

A standard way out here is to use MinErr instead of Find. Don't know why I didn't thought of it in the first place - probably because my first thought was "why a solve block at all?".

I also attempt this route first, but seem to shy away from it when I get a result. Is it safe to rely on Minerr?

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
03:40 PM

10-15-2014
03:40 PM

Re: Find function error: Undefined variable

Right I get you. So it is good practice you try and solve numerically before trying symbolically?

Why not the other way round? If the symbolics yield a result I would trust it the most (at least thats as it should be). But we know there are cases where the symbolics fails and the numerics gives us a result. And we also have it the other way round like in this example.

I also attempt this route first, but seem to shy away from it when I get a result. Is it safe to rely on Minerr?

Within Mathcad's usual numeric precision and tolerance I would say, yes. At least we get the best result Mathcad is able to find, no matter if the difference to the last but one value in the iteration is smaller than CTOL or not. Double checking the result it it fits the problem is a must anyway.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

10-15-2014
03:51 PM

10-15-2014
03:51 PM

Re: Find function error: Undefined variable

Werner Exinger wrote:

Right I get you. So it is good practice you try and solve numerically before trying symbolically?

Why not the other way round? If the symbolics yield a result I would trust it the most (at least thats as it should be). But we know there are cases where the symbolics fails and the numerics gives us a result. And we also have it the other way round like in this example.

I also attempt this route first, but seem to shy away from it when I get a result. Is it safe to rely on Minerr?

Within Mathcad's usual numeric precision and tolerance I would say, yes. At least we get the best result Mathcad is able to find, no matter if the difference to the last but one value in the iteration is smaller than CTOL or not. Double checking the result it it fits the problem is a must anyway.

In this instance it has worked, but I have seen results in the past which are incorrect. As you said, double checking is a must.