[2D plot] Plot of points in piecewise functions

[2D plot] Plot of points in piecewise functions - Сообщения

#1 Опубликовано: 20.11.2018 06:45:41
Michał Janowski

Michał Janowski

1 сообщений из 7 понравились пользователям.

Группа: User

Hello!

I have a problem with simple equation. In case of my function, f(10) is equal to 5 but there is no "dot" of such value on the graph.
Please tell me how it should look like.

Where is the dot.sm (3 КиБ) скачан 43 раз(а).

Where is the dot.jpg

Best regards.
Mroczak
#2 Опубликовано: 20.11.2018 10:30:13
Fridel Selitsky

Fridel Selitsky

520 сообщений из 451 понравились пользователям.

Группа: User

Just point x=10 must be drawn
#3 Опубликовано: 20.11.2018 13:23:46
Michał Janowski

Michał Janowski

1 сообщений из 7 понравились пользователям.

Группа: User

I think, that it is not proper solution. That "point" is already included in definition of the function, so why I should draw it manually. What in case, if the function is more complex and I don't know that there is such orphaned value in the middle of continous parts of function just from looking on the function definition. Your solution is correct in situation if we exactly know that there is such thing. It should be drawn on the graph somehow automatically, but it's not.

Best regards,
Mroczak
#4 Опубликовано: 20.11.2018 13:41:01
Arie

Arie

93 сообщений из 285 понравились пользователям.

Группа: User

I think the issue is the auto-generated range does not include the point x=10 exactly and therefore never reaches the point where f(x) = 5. Simply allowing for some error as I've done in the attached solves the problem for me. Where is the dot (1).sm (3 КиБ) скачан 33 раз(а).

Another option, defining the range discretely.

Where is the dot discrete.sm (5 КиБ) скачан 38 раз(а).
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#5 Опубликовано: 20.11.2018 14:12:09
Michał Janowski

Michał Janowski

1 сообщений из 7 понравились пользователям.

Группа: User

From your example it follows, that there is a problem on the level of logical operators - you had to manually insert error what should be done by choosing 'lower' and 'higher' instead of 'lower or equal' and 'higher or eqal'. It looks like, that in such function there is no difference between operators 'lower' and 'higher' vs 'lower or equal' and 'higher or equal'. For me, it should't work this way and it seems to be some kind of 'bug'. At least your idea works as problem workaround, but unfortunately it is still only workaround. Thank you for your answer!

Best regards,
Mroczak
#6 Опубликовано: 20.11.2018 15:09:48
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Wrote

think the issue is the auto-generated range does not include the point x=10 exactly and therefore never reaches the point where f(x) = 5



That's part of "the point". The function has to be drawn on the canvas, thus it is calculated for each pixel, and each pixel correspond to a value that depends on the range (first and last values visible), and even on the number of pixels (the width of the canvas).

You can figure it easily placing a breakpoint in the plot placeholder and looking at the values of x.

2018-11-20 19_07_51-SMath Studio - [Where%20is%20the%20dot.sm_].png

You must be very lucky to hit exactly 10.000000000000000 (15 digits)
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#7 Опубликовано: 20.11.2018 15:10:32
frapuano

frapuano

13 сообщений из 115 понравились пользователям.

Группа: User

Peter,

the issue -in my modest opinion - is only on the plot side; your definition of the function and its discontinuity works fine and the value f(10) is evaluated correctly ..but plotting a function with discontinuity requires a discontinuity analyzer i.e. you need ( I mean the developer of the 2d Plot that I guess is Andrey ) to develop a module that find the discontinuities , analyze them and behaves accordingly ( these are at least of 3 different types for functions of one variable ) and this is not so easy to handle.
This remembers me 40 years ago when on a Sperry Univac I had to develop in fortran by myself something to plot correctly the angular patter of the radiation scattered when a laser beam is sent in a spray of fuel droplets, this produces at some particular angles rainmbows so discontinuities in the pattern that created many troubles to the offline plotter I were using at the time, took me a lot of effort ( and euristics ) to analyze and try to solve this issue.

Best regards

Franco
#8 Опубликовано: 20.11.2018 16:14:02
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

I have a problem with simple equation. In case of my function, f(10) is equal to 5 but there is no "dot" of such value on the graph.
Please tell me how it should look like.


Your setup is not correct. Once in a while, undefined condition(s) do not reflect.
In very rare instances, it's the other way around, i.e: one of the condition must
be undefined wrt the algorithmic suite [typical => De Boor spline point].

Where is the dot discrete.sm (6 КиБ) скачан 48 раз(а).

if_otherwise.PNG

#9 Опубликовано: 20.11.2018 18:46:02
Arie

Arie

93 сообщений из 285 понравились пользователям.

Группа: User

Wrote


the issue -in my modest opinion - is only on the plot side



Yes and no. You cannot really expect the program to know to evaluate/plot at a specific point for any arbitrary function. Additionally as shown in the figure below one can produce "incorrect" results by exploiting the fact that we're performing calculations on a discrete system.

It may seem like the plot "should" be able to detect an infinitesimal point at x=10, but what if we redefined it for x=pi or any arbitrary number. It becomes very difficult to find that single point discontinuity in the function.

I think in an instance like this, the user needs to either add some "fudge-factor" to the function or define the range manually to include the point(s) in question.
Untitled.png
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#10 Опубликовано: 20.11.2018 19:56:45
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote

Wrote


the issue -in my modest opinion - is only on the plot side



Yes and no. You cannot really expect the program to know to evaluate/plot at a specific point for any arbitrary function.



Hi. Yes, you can. With the normal issues for symbolic or numeric manipulations. And as frapuano talk, in some moment we need to implement some code for handle singularities. As an example, maybe too much specific, but about finite jumps, you can see
https://en.smath.info/forum/yaf_postst14910_Round.aspx and the implementation of discontinuous plots in round.sm (69 КиБ) скачан 99 раз(а).

Maple have following functions, but need readlib for the following two:

Clipboard03.gif

Clipboard01.gif

Also can use this option for plots:

Clipboard06.gif

Best regards.
Alvaro.
#11 Опубликовано: 21.11.2018 01:29:12
Arie

Arie

93 сообщений из 285 понравились пользователям.

Группа: User

Wrote



Maple have following functions, but need readlib for the following two:


Alvaro.



I see your point. I found a piecewise plotting example with removable discontinuity in maple here (need to scroll down).

A couple points to note. Generally, I don't think something like fdiscont would work for piecewise functions with single point discontinuities or perhaps even jump continuities. It mentions issues with these in the description.

I notice that both Maple and Matlab have "piecewise" functions. I assume that in those environments the "piecewise" functions may be an indicator to the "plot" function that specific conditions exist for which the function needs to be evaluated. Therefore the plot function will evaluate the boundary conditions.

Perhaps in SMath something similar could be implemented s.t. when a function is passed into the plot and it is specified as a piecewise function, it will evaluate any conditions specified within the range that aren't part of the auto-generated range.

I'm not certain if it's necessary to indicate that a function is intended to be piecewise continous within SMath or if SMath is smart enough to determine intent by the structure of the function itself. I do not think, generally, any function with conditionals can be considered piecewise, but I'm not sure if that's true.
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
#12 Опубликовано: 21.11.2018 01:37:40
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

Please tell me how it should look like.


Answer @ post # 8. Conditions are either true/false... Not maybe YES/maybe NO.

AdAbsurdum.PNG

#13 Опубликовано: 21.11.2018 05:13:04
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote



I'm not certain if it's necessary to indicate that a function is intended to be piecewise continous within SMath or if SMath is smart enough to determine intent by the structure of the function itself. I do not think, generally, any function with conditionals can be considered piecewise, but I'm not sure if that's true.



Hi. The only "true" piecewise function is Dirac's delta ... and it's a distribution, not a function. In maple you can convert from if's or some other to piecewise or step functions with 'convert', and in matlab (mupad, actually) with 'coerce'. Numeric or symbolic procedures for handling discontinuous plots have a lot of issues, and only works for "normal" functions, if not, think about how to implement procedures for plot x/sin(1/x) near zero.

But answering your question, my guess is not: assume that you implement an amazing routine for say that a number is rational or not (and then irrational: mathematica have something like that, or at least Wolfram think this). And then construct this function, and see this unusual, for say something, property

Clipboard08.gif

Best regards.
Alvaro
#14 Опубликовано: 21.11.2018 13:04:22
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

I'm not certain if it's necessary to indicate that a function is intended to be piecewise continous within SMath or if SMath is smart enough to determine intent by the structure of the function itself. I do not think, generally, any function with conditionals can be considered piecewise, but I'm not sure if that's true.


Mon ami, your point is SO fundamental
Those things appeared ad-nauseum in Mathsoft Collaboratory.
Mathcad up to 11, was a bit more understanding, but wrong by principle
because confusing because not telling the truth. A piece-wise function
MUST be specified completely. On that, Smath is absolutely correct.

There are other things under the hood related to this discussion:
Integration of erf(x), and Gamma(x), the integrand must be vectorized.
Indirectly, it kind of depends upon of discontinuous approximation
of these two functions, the only two I have detected.

Most/most important about discontinuous is the major difference between
if/else and if/otherwise. Generally, they do the same but they aren't.
EXPLAIN: if/else is not scalar and it will not integrate a completely
specified if/else function. On the other hand, if/otherwise is scalar
thus will integrate. They both plot the same to add to the confusion.
Demonstrated => Integrate Discontinuous [Nuance].
Demonstrated => Where is the Dot Discrete.
It may even be more important if the path of integration is discontinuous.

Jean

Where is the dot discrete.sm (19 КиБ) скачан 40 раз(а).
Integrate Discontinuous [Nuance].sm (24 КиБ) скачан 41 раз(а).

#15 Опубликовано: 22.11.2018 12:56:46
Oscar Campo

Oscar Campo

124 сообщений из 298 понравились пользователям.

Группа: Moderator

Wrote

Hello!

I have a problem with simple equation. In case of my function, f(10) is equal to 5 but there is no "dot" of such value on the graph....



In a more compact form you can view no discontinuities

Captura de pantalla 2018-11-22 a la(s) 10.54.01 a. m..png
1 пользователям понравился этот пост
frapuano 22.11.2018 15:28:00
#16 Опубликовано: 22.11.2018 15:34:31
frapuano

frapuano

13 сообщений из 115 понравились пользователям.

Группа: User

...It would be interesting to know why it works this way , just for sake of understanding; looks to me that the merging of several OR operations should be linked to this different (... and positive )behaviour.

Best regards

Franco
#17 Опубликовано: 22.11.2018 15:54:18
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

Wrote

...It would be interesting to know why it works this way , just for sake of understanding; looks to me that the merging of several OR operations should be linked to this different (... and positive )behaviour.

Best regards

Franco



They behave the same way; in the first post the plot was made with "Graph by points" enabled.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#18 Опубликовано: 22.11.2018 17:29:35
frapuano

frapuano

13 сообщений из 115 понравились пользователям.

Группа: User

Strange I had the idea that the graph in the first post was not with "Graph by points" enabled, I am starting to have more issues with my eyes than it was supposed to be.

Best regards

Franco
#19 Опубликовано: 23.11.2018 01:32:02
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

The same plot in Mathcad will shows no apparent break @ 5.
Mathcad plots on ½ pica thus plots straight lines, thus not fine/pleasant look.
Smath plots on pixel thus the discontinuous were there is no ½ pixel.
A scalar function is a function that runs on a vanishing iterator 'x' .
Smath does not calculate ln(,), exp(,) ... it fetches from Windows.
Most if not all functions are approximations of 21 decimals.
i.e: Normalized Padé Rational Fractions.
Result may be only 18 Decimals. Thus, by convention results are
truncated to 15 decimals. Symbolic Engines is another story.
High accuracy Main-Frames may run Chebyshev of very high numerical
stability 25 decimals [typical Clenshaw ...]
Normalized Rational Fraction approximates on various best range wrt
to minimal arithmetic operations. Each function has its own specific range
generally very small. More numerical maths kind of scale the base range
to accommodate the 'x' of greater value than the base approximation,
naturally up to the max of the result < 10^307.
Before the event of rational approximations the first IBM used
continued fraction for the principal ln(x), exp(x), sqrt(x) ...

Can't help more about unknown math suite/use of the proposal.

scalarNOTscalar.PNG
#20 Опубликовано: 23.11.2018 01:42:43
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

math suite ...


...in the if/otherwise '5' has no meaning.
Backspace to delete 5, type ".

  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений