Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse derivatives instead of just relying on tree #887

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/Parser/Differentiation.pm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ sub Parser::D {
return (0 * $self)->reduce('0*x' => 1) unless defined $self->{variables}{$x};
$f = $f->D($x);
}
return $self->new($f);
my $deriv = $self->new($f);
$deriv->{string} = $deriv->{tree}->string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line means that any constants are clipped to 6 significant digits (the default number format), so the result may have different from the original.

You may also want to add a new reduction rule that controls doing this doing this, so it can be turned off, if desired.

$deriv->tokenize;
$deriv->parse;
return $deriv;
}

#
Expand Down